-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: automatizando captura de entrada para o furaaf
- Loading branch information
1 parent
791a41a
commit 1bbad66
Showing
10 changed files
with
156 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** | ||
* @brief Este algoritmo de ilha seleciona os algoritmos que irão compor o conjunto de ilha com base na proporção de cada um, que é passada por parâmetro. Os parâmetros são: | ||
* -Q: proporção do PSO | ||
* -G: proporção do GA | ||
* -D: proporção do DE | ||
* -O: proporção do ACO | ||
* -L: proporção do CLONALG | ||
* O tamanho do conjunto de ilhas é passado por parâmetro com a flag -N. | ||
* | ||
* Exemplo de execução: ./evol -N 10 -Q 30 -G 0 -D 68 -O 0 -L 49 -K 2 | ||
* | ||
* @author @gustavo1902 | ||
* @author @ViniciusBastoss | ||
* @author @caioreius | ||
* @author @GuilhermeAGouveia | ||
* Orientador: Prof. Dr. @iagoac | ||
* @date 2023-08-31 | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "algorithms/genetic.h" | ||
#include "algorithms/pso.h" | ||
#include "algorithms/clonalg.h" | ||
#include "algorithms/aco.h" | ||
#include "algorithms/diferencial.h" | ||
#include "algorithms/parameters.h" | ||
#include "algorithms/commom.h" | ||
#include "libs/utils.h" | ||
#include <math.h> | ||
|
||
#define DEBUG(x) | ||
|
||
void get_algoritms(int *result){ | ||
|
||
double soma_proporcoes = parameters.num_pso + parameters.num_aco + parameters.num_clonal + parameters.num_diferencial + parameters.num_genetico; | ||
int cont = 0, total_islands = 0; | ||
double total_islands_double; | ||
proporcao_alg proporcoes[5]; | ||
|
||
proporcoes[0].proporcao = parameters.num_pso; | ||
proporcoes[1].proporcao = parameters.num_diferencial; | ||
proporcoes[2].proporcao = parameters.num_aco; | ||
proporcoes[3].proporcao = parameters.num_clonal; | ||
proporcoes[4].proporcao = parameters.num_genetico; | ||
|
||
for(int i = 0; i < 5; i++){ | ||
total_islands_double = parameters.num_algorithms * (proporcoes[i].proporcao/soma_proporcoes); | ||
proporcoes[i].alg = i; | ||
if((total_islands_double - (int)total_islands_double) < 0.5) | ||
proporcoes[i].total_islands = (int)total_islands_double; | ||
else | ||
proporcoes[i].total_islands = 1 + (int)total_islands_double; | ||
total_islands += proporcoes[i].total_islands; | ||
} | ||
|
||
qsort(&proporcoes, 5, sizeof(proporcao_alg), comparador_proporcoes_alg); | ||
|
||
//for(int i = 0; i < 5; i++){ | ||
// printf("proporção:%d\n",proporcoes[i].proporcao); | ||
// } | ||
|
||
//adiciona ilhas aos algoritmos até que total == num_algoritmos | ||
while(total_islands < parameters.num_algorithms){ | ||
for(int i = 0; total_islands < parameters.num_algorithms && i < 5; i++){ | ||
proporcoes[i].total_islands += 1; | ||
total_islands += 1; | ||
} | ||
} | ||
|
||
while(total_islands > parameters.num_algorithms){ | ||
for(int i = 5; total_islands > parameters.num_algorithms && i > 0; i--){ | ||
proporcoes[i].total_islands -= 1; | ||
total_islands -= 1; | ||
} | ||
} | ||
|
||
//cria o vetor de algoritmos [0,0,0,1,1...] | ||
for(int i = 0; i < 5; i++){ | ||
for(int j = 0; j < proporcoes[i].total_islands; j++, cont++){ | ||
result[cont] = proporcoes[i].alg; | ||
} | ||
} | ||
|
||
} | ||
|
||
void print_arr_int(int *arr, int size){ | ||
for(int i = 0; i < size; i++){ | ||
if (i == size - 1) | ||
printf("%d", arr[i]); | ||
else | ||
printf("%d,", arr[i]); | ||
} | ||
printf("\n"); | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
// ./evol -t 1 -K 2 -k 3 -Q 30 -G 0 -D 68 -O 0 -L 49 -A 10 | ||
set_parameters(argc, argv); // Lê os parâmetros da linha de comando e repassa para as variáveis globais | ||
int *algoritmos = calloc(parameters.num_algorithms, sizeof(int *));; | ||
get_algoritms(algoritmos); | ||
print_arr_int(algoritmos, parameters.num_algorithms); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
1,0 | ||
0,0,1 | ||
0,0,1,1 | ||
1,3,2,0,4 | ||
0,0,3,2,1,4 | ||
1,1,3,3,4,2,0 | ||
0,0,0,0,1,1,3,4 | ||
0,0,0,0,1,1,1,3,4 | ||
3,3,3,2,2,2,0,0,4,1 | ||
3,3,3,3,3,2,2,0,0,4,1 | ||
0,0,0,0,0,3,3,3,1,1,1,2 | ||
2,2,2,2,4,4,4,4,3,3,0,0,1 | ||
0,0,0,0,0,0,4,4,4,4,4,1,1,3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
echo "Coletando as informações de entrada para o furaaf.sh" | ||
echo "Executando o make" | ||
|
||
export COD_NAME="getInputForFuraaf" | ||
make | ||
|
||
echo "Limpando ilhas.txt" | ||
rm -rf ilhas.txt | ||
|
||
for i in $(cat irace/results/results-island-model/results/results-evol-1-25.txt | grep "./" | cut -d'l' -f2 | sed "s/ /_/g"); do | ||
params=$(echo $i | sed "s/_/ /g" | sed "s/A/N/g"); | ||
./evol $params >> ilhas.txt; | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Resultado para função 1: Minimo: 126.547534 Maximo: 8386.436448 Média: 4649.74566240000000000000 Desvio padrão: 2464.07017994474973408365 |