1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
class grasp{
public:
dados d;
string nomeLOG;
int round;
int numClusterHead;
double min_cost;
vector<int> ch_index; //variavel que guarda quem é o ch de cada no
vector<int> ch_list; //variável que guarda quem são os clusters head no round atual
vector<int> ch_list_lvl_2; //variável que guarda quem são os clusters head no round atual
vector<double> cost_solution;
vector<int> ch_routing; //vetor que guarda pra qual nó cada cluster head vai transmitir. Montado no algoritmo de Dijkstra
vector<double> energia_gasta_round;
vector< vector<int> > pool_PR;
vector<double> cost_pool_PR;
vector<int> dif_pool_PR;
int PATHRELINK;
int LVL2CLUSTER;
int POOL_SIZE;
double M_CON;
double M_BL;
double M_PR;
int best_sol_it;
double porcent_local_search;
int exec;
public:
grasp(string instancia, int pr, int lvl2, double param_ls, int index_exec);
void copy(vector<int> orig, vector<int> &dest);
double find_min_dist(vector<int> ch_list_aux, vector<int> &ch_index_aux);
void map_new_ch(int new_ch_coord_X[], int new_ch_coord_Y[], vector<int> &new_ch_list, int elegible[], vector<int> ch_list_it);
double geraPerturbacao();
int is_ClusterHead(int node);
void imprime_ch_list(int round);
void imprime_iter_results(int iter, double constr, double BL, double PR, double TC, double TLS, double TPR, double TG);
int valid_ch_list(vector<int> ch_list_param);
void setup();
int start();
double grasp_();
void sample_greedy(int elegible[], vector<int> &ch_list_it, vector<int> &ch_index_it);
void random(int elegible[], vector<int> &ch_list_it, vector<int> &ch_index_it);
double find_cost(vector<int> temp_ch_list, vector<int> temp_ch_index);
//double find_cost_to_sink(vector<int> temp_ch_list,vector<int> ch_routing);
int getNumNodes();
double soma_energia();
int swap_ch(vector<int> &ch_list_aux, vector<int> &ch_list_index, int elegible[]);
void coord_perturb(vector<int> ch_list_it, vector<int> &new_ch_list, int elegible[]);
//double insertClusterHead(vector<int> &ch_list_aux, vector<int> &ch_index_param_aux, int elegible[]);
double dijkstra(vector<int> ch_list_param, vector<int> &ch_index_param);
int remove_Cluster_Head(int node, vector<int> &ch_list_aux, vector<int> &ch_index_aux);
int find_closest_ch(int node,vector<int> &ch_list_aux, vector<int> &ch_index_aux);
int insert_Cluster_Head(int new_ch, vector<int> &ch_index_param_aux);
void choose_ch_from_cluster(int dead_ch, vector<int> &ch_list_param, vector<int> &ch_index_param);
//path relinking
bool solucao_igual(vector<int> solucao1, vector<int> solucao2);
double forward_path_relinking(vector<int> &solucao_1, double cost_1, vector<int> &solucao_2, double cost_2);
double backward_path_relinking(vector<int> &solucao_1, double cost_1, vector<int> &solucao_2, double cost_2);
int add_sol_to_pool(vector<int> solution, double cost);
int add_sol_to_pool_dif(vector<int> solution, double cost);
int solution_in_pool(vector<int> solution);
void atualiza_difference_pool();
//second lvl clustering
void random_2(vector<int> &ch_list_it, vector<int> &ch_index_it, vector<int> new_cluster);
void sample_greedy_lvl2(vector<int> &ch_list_2, vector<int> &ch_index_2, vector<int> new_cluster, int new_sink);
void grasp_lvl2(vector<int> new_cluster, int new_sink, vector<int> &ch_list_param, vector<int> &ch_index_param);
void level2Clustering(vector<int> ch_list_param, vector<int> &ch_index_param, vector<int> &cluster_lvl_2);
double find_cost_2(vector<int> ch_list_2, vector<int> &ch_index_2, vector<int> new_cluster, int new_sink);
void gera_logs(int round);
};
|