4 # include <gsl/gsl_rng.h>
5 # include <gsl/gsl_randist.h>
11 # include <tpl_dynArray.H>
12 # include <tpl_graph_utils.H>
13 # include <tpl_agent_graph.H>
18 using namespace Aleph;
23 extern double initial_life;
25 extern double feromone_importance;
27 extern double distance_importance;
29 extern double food_importance;
31 extern double & alpha;
43 extern double min_dist;
44 extern double max_dist;
59 : food(__food), num(-1)
67 : food(p->food), num(p->num)
76 double feromone_level;
80 Ant_Arc() : feromone_level(0), distance(0) { }
104 virtual bool select_path(
void * ,
108 EXIT(
"ERROR: must not be called");
117 EXIT(
"ERROR: must not be called");
126 typedef Ant_Graph::Node Node;
128 typedef Ant_Graph::Arc Arc;
130 pthread_mutex_t bit_mutex;
134 Ant_Graph(
const size_t & num_threads = 1)
137 init_mutex(bit_mutex);
142 destroy_mutex(bit_mutex);
154 void operator () (ofstream & output,
Ant_Graph &, Ant_Graph::Node * p)
156 output << p->food <<
" " << p->num << endl;
165 void operator () (ifstream & input,
Ant_Graph &, Ant_Graph::Node * p)
167 input >> p->food >> p->num;
170 cout << p->food <<
" " << p->num;
176 void operator () (ofstream & output,
Ant_Graph &, Ant_Graph::Arc * a)
178 output << a->feromone_level <<
" " << a->distance << endl;
181 cout << a->feromone_level <<
" " << a->distance;
187 void operator () (ifstream & input,
Ant_Graph &, Ant_Graph::Arc * a)
189 input >> a->feromone_level >> a->distance;
192 cout << a->feromone_level <<
" " << a->distance;
202 static long born_count;
203 static long died_count;
226 virtual bool select_path(Ant_Graph::Node * src_node,
227 Ant_Graph::Node *& tgt_node,
228 Ant_Graph::Arc *& ant_arc);
232 Ant_Graph::Node * tgt_node,
233 Ant_Graph::Arc * ant_arc);
237 void save(
Ant_Graph & g, ofstream & output);
239 void load(
Ant_Graph & g, ifstream & input);
Definition: tpl_agent_graph.H:335
Definition: tpl_ant.H:163
Definition: bitArray.H:96
virtual bool walk(Ant_Graph *g, Ant_Graph::Node *tgt_node, Ant_Graph::Arc *ant_arc)
ejecuta la transición
Definition: tpl_ant.H:174
Definition: tpl_ant.H:124
Definition: tpl_agent_graph.H:313
Definition: tpl_ant.H:185
Definition: tpl_ant.H:198
Definition: tpl_agent_graph.H:422
Definition: tpl_ant.H:152
virtual bool select_path(Ant_Graph::Node *src_node, Ant_Graph::Node *&tgt_node, Ant_Graph::Arc *&ant_arc)
Selecciona el próximo camino.
Definition: tpl_agent_graph.H:74