00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00027 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030
00031 #include <iostream>
00032 #include <eo>
00033 #include <ga/make_ga.h>
00034 #include "binary_value.h"
00035 #include <apply.h>
00036 #include <ga/eoPBILDistrib.h>
00037 #include <ga/eoPBILOrg.h>
00038 #include <ga/eoPBILAdditive.h>
00039 #include <eoSimpleEDA.h>
00040
00041
00042 using namespace std;
00043
00044 typedef eoBit<double> Indi;
00045
00046
00047 #include "ga/make_PBILdistrib.h"
00048 eoPBILDistrib<Indi> & make_PBILdistrib(eoParser& _parser, eoState&_state, Indi _eo)
00049 {
00050 return do_make_PBILdistrib(_parser, _state, _eo);
00051 }
00052
00053
00054 #include "ga/make_PBILupdate.h"
00055 eoDistribUpdater<Indi> & make_PBILupdate(eoParser& _parser, eoState&_state, Indi _eo)
00056 {
00057 return do_make_PBILupdate(_parser, _state, _eo);
00058 }
00059
00060
00061 int main(int argc, char* argv[])
00062 {
00063
00064 try
00065 {
00066 eoParser parser(argc, argv);
00067
00068 eoState state;
00069
00072
00073
00074 eoEvalFuncPtr<Indi, double> mainEval( binary_value<Indi>);
00075 eoEvalFuncCounter<Indi> eval(mainEval);
00076
00077
00078 eoPBILDistrib<Indi> & distrib = make_PBILdistrib(parser, state, Indi());
00079
00080 eoDistribUpdater<Indi> & update = make_PBILupdate(parser, state, Indi());
00081
00084
00085
00086 eoContinue<Indi> & term = make_continue(parser, state, eval);
00087
00088 eoCheckPoint<Indi> & checkpoint = make_checkpoint(parser, state, eval, term);
00089
00090
00091
00092
00093
00094 eoParam* ptParam = parser.getParamWithLongName(string("resDir"));
00095 eoValueParam<string>* ptDirNameParam = dynamic_cast<eoValueParam<string>*>(ptParam);
00096 if (!ptDirNameParam)
00097 throw runtime_error("Parameter resDir not found where it was supposed to be");
00098
00099
00100 eoValueParam<bool>& plotDistribParam = parser.getORcreateParam(false, "plotDistrib",
00101 "Plot Distribution", '\0',
00102 "Output - Graphical");
00103 if (plotDistribParam.value())
00104 {
00105 #ifdef HAVE_GNUPLOT
00106 unsigned frequency=1;
00107 eoGnuplot1DSnapshot *distribSnapshot = new eoGnuplot1DSnapshot(ptDirNameParam->value(),
00108 frequency, "distrib");
00109 state.storeFunctor(distribSnapshot);
00110
00111 distribSnapshot->add(distrib);
00112
00113 checkpoint.add(*distribSnapshot);
00114 #endif
00115 }
00116
00117
00118
00119 unsigned popSize = parser.getORcreateParam(unsigned(100), "popSize",
00120 "Population Size", 'P', "Algorithm").value();
00121 eoSimpleEDA<Indi> eda(update, eval, popSize, checkpoint);
00122
00125
00126 make_help(parser);
00127
00130
00131 eda(distrib);
00132
00133 std::cout << "Final Distribution\n";
00134 distrib.printOn(std::cout);
00135 std::cout << std::endl;
00136
00137
00138 if (plotDistribParam.value())
00139 {
00140 string foo;
00141 cin >> foo;
00142 }
00143 }
00144 catch(std::exception& e)
00145 {
00146 std::cout << e.what() << std::endl;
00147 }
00148 }