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 #include <iostream>
00028 #include <eo>
00029 #include <ga/make_ga.h>
00030 #include "binary_value.h"
00031 #include <apply.h>
00032 #include <ga/eoPBILDistrib.h>
00033 #include <ga/eoPBILOrg.h>
00034 #include <ga/eoPBILAdditive.h>
00035 #include <eoSimpleEDA.h>
00036
00037 using namespace std;
00038
00039 typedef eoBit<double> Indi;
00040
00041
00042 #include "ga/make_PBILdistrib.h"
00043 eoPBILDistrib<Indi> & make_PBILdistrib(eoParser& _parser, eoState&_state, Indi _eo)
00044 {
00045 return do_make_PBILdistrib(_parser, _state, _eo);
00046 }
00047
00048
00049 #include "ga/make_PBILupdate.h"
00050 eoDistribUpdater<Indi> & make_PBILupdate(eoParser& _parser, eoState&_state, Indi _eo)
00051 {
00052 return do_make_PBILupdate(_parser, _state, _eo);
00053 }
00054
00055
00056 int main(int argc, char* argv[])
00057 {
00058
00059 try
00060 {
00061 eoParser parser(argc, argv);
00062
00063 eoState state;
00064
00067
00068
00069 eoEvalFuncPtr<Indi, double> mainEval( binary_value<Indi>);
00070 eoEvalFuncCounter<Indi> eval(mainEval);
00071
00072
00073 eoPBILDistrib<Indi> & distrib = make_PBILdistrib(parser, state, Indi());
00074
00075 eoDistribUpdater<Indi> & update = make_PBILupdate(parser, state, Indi());
00076
00079
00080
00081 eoContinue<Indi> & term = make_continue(parser, state, eval);
00082
00083 eoCheckPoint<Indi> & checkpoint = make_checkpoint(parser, state, eval, term);
00084
00085
00086
00087
00088
00089 eoParam* ptParam = parser.getParamWithLongName(string("resDir"));
00090 eoValueParam<string>* ptDirNameParam = dynamic_cast<eoValueParam<string>*>(ptParam);
00091 if (!ptDirNameParam)
00092 throw runtime_error("Parameter resDir not found where it was supposed to be");
00093
00094
00095 eoValueParam<bool>& plotDistribParam = parser.getORcreateParam(false, "plotDistrib",
00096 "Plot Distribution", '\0',
00097 "Output - Graphical");
00098 if (plotDistribParam.value())
00099 {
00100 unsigned frequency=1;
00101 eoGnuplot1DSnapshot *distribSnapshot = new eoGnuplot1DSnapshot(ptDirNameParam->value(),
00102 frequency, "distrib");
00103 state.storeFunctor(distribSnapshot);
00104
00105 distribSnapshot->add(distrib);
00106
00107 checkpoint.add(*distribSnapshot);
00108 }
00109
00110
00111
00112 unsigned popSize = parser.getORcreateParam(unsigned(100), "popSize",
00113 "Population Size", 'P', "Algorithm").value();
00114 eoSimpleEDA<Indi> eda(update, eval, popSize, checkpoint);
00115
00118
00119 make_help(parser);
00120
00123
00124 eda(distrib);
00125
00126 std::cout << "Final Distribution\n";
00127 distrib.printOn(std::cout);
00128 std::cout << std::endl;
00129
00130
00131 if (plotDistribParam.value())
00132 {
00133 string foo;
00134 cin >> foo;
00135 }
00136 }
00137 catch(std::exception& e)
00138 {
00139 std::cout << e.what() << std::endl;
00140 }
00141 }