00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "param.h"
00041 #include "route_init.h"
00042 #include "route_eval.h"
00043
00044 #include "order_xover.h"
00045 #include "edge_xover.h"
00046 #include "partial_mapped_xover.h"
00047 #include "city_swap.h"
00048 #include "part_route_eval.h"
00049 #include "merge_route_eval.h"
00050 #include "two_opt_init.h"
00051 #include "two_opt_next.h"
00052 #include "two_opt_incr_eval.h"
00053
00054 #include <peo>
00055
00056 #define POP_SIZE 10
00057 #define NUM_GEN 10
00058 #define CROSS_RATE 1.0
00059 #define MUT_RATE 0.01
00060
00061
00062 int main (int __argc, char * * __argv) {
00063
00064 peo :: init (__argc, __argv);
00065
00066
00067 loadParameters (__argc, __argv);
00068
00069
00070 RouteInit route_init;
00071 RouteEval full_eval;
00072
00073
00074 OrderXover order_cross;
00075 PartialMappedXover pm_cross;
00076 EdgeXover edge_cross;
00077 CitySwap city_swap_mut;
00078
00079
00081 TwoOptInit pmx_two_opt_init;
00082 TwoOptNext pmx_two_opt_next;
00083 TwoOptIncrEval pmx_two_opt_incr_eval;
00084 moBestImprSelect <TwoOpt> pmx_two_opt_move_select;
00085 moHC <TwoOpt> hc (pmx_two_opt_init, pmx_two_opt_next, pmx_two_opt_incr_eval, pmx_two_opt_move_select, full_eval);
00086
00088 eoPop <Route> ox_pop (POP_SIZE, route_init);
00089
00090 eoGenContinue <Route> ox_cont (NUM_GEN);
00091 eoCheckPoint <Route> ox_checkpoint (ox_cont);
00092 peoSeqPopEval <Route> ox_pop_eval (full_eval);
00093 eoStochTournamentSelect <Route> ox_select_one;
00094 eoSelectNumber <Route> ox_select (ox_select_one, POP_SIZE);
00095 eoSGATransform <Route> ox_transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
00096 peoSeqTransform <Route> ox_para_transform (ox_transform);
00097 eoEPReplacement <Route> ox_replace (2);
00098
00099 peoEA <Route> ox_ea (ox_checkpoint, ox_pop_eval, ox_select, ox_para_transform, ox_replace);
00100
00101 ox_ea (ox_pop);
00102
00103
00104 peo :: run ();
00105 peo :: finalize ();
00106
00107
00108 std :: cout << ox_pop[ 0 ].fitness();
00109 hc( ox_pop[ 0 ] );
00110 std :: cout << " -> " << ox_pop[ 0 ].fitness() << std :: endl;
00111
00112
00113 return 0;
00114 }