• Main Page
  • Modules
  • Classes
  • Files
  • File List

D:/Projekt/ECF_trunk/examples/CEC/main.cpp

00001 #include <ecf/ECF.h>
00002 #include "FunctionMinEvalOp.h"
00003 #include <ecf/AlgGenHookeJeeves.h>
00004 
00005 
00006 //
00007 // this main() function optimizes a single CEC 2014 function (Id set in config file)
00008 // function Ids: 1-30
00009 //
00010 
00011 int main(int argc, char **argv)
00012 {
00013     StateP state (new State);
00014 
00015     // set the evaluation operator
00016     state->setEvalOp(new FunctionMinEvalOp);
00017 
00018     state->initialize(argc, argv);
00019     state->run();
00020 
00021     return 0;
00022 }
00023 
00024 
00025 
00026 //
00027 // this main() function iterates over multiple CEC 2014 functions and optimizes each one in turn
00028 // function Ids: 1-30
00029 //
00030 /*
00031 int main(int argc, char **argv)
00032 {
00033     // run for selected CEC functions
00034     for(uint function = 1; function <= 30; function++) {
00035 
00036         // read XML config
00037         std::ifstream fin(argv[1]);
00038         if (!fin) {
00039             std::cerr << "Error opening config file! (" << argv[1] << ")\n";
00040             return 1;
00041         }
00042 
00043         std::string xmlFile, temp;
00044         while (!fin.eof()) {
00045             getline(fin, temp);
00046             xmlFile += "\n" + temp;
00047         }
00048         fin.close();
00049 
00050         // set log and stats parameters
00051         std::string funcName = uint2str(function);
00052         std::string logName = "log", statsName = "stats";
00053         if(function < 10) {
00054             logName += "0";
00055             statsName += "0";
00056         }
00057         logName += uint2str(function) + ".txt";
00058         statsName += uint2str(function) + ".txt";
00059 
00060         // update in XML
00061         XMLResults results;
00062         XMLNode xConfig = XMLNode::parseString(xmlFile.c_str(), "ECF", &results);
00063         XMLNode registry = xConfig.getChildNode("Registry");
00064 
00065         XMLNode func = registry.getChildNodeWithAttribute("Entry", "key", "cec.function");
00066         func.updateText(funcName.c_str());
00067         XMLNode log = registry.getChildNodeWithAttribute("Entry", "key", "log.filename");
00068         log.updateText(logName.c_str());
00069         XMLNode stats = registry.getChildNodeWithAttribute("Entry", "key", "batch.statsfile");
00070         stats.updateText(statsName.c_str());
00071 
00072         // write back
00073         std::ofstream fout(argv[1]);
00074         fout << xConfig.createXMLString(true);
00075         fout.close();
00076 
00077 
00078         // finally, run ECF on single function
00079         StateP state (new State);
00080 
00081         // set the evaluation operator
00082         state->setEvalOp(new FunctionMinEvalOp);
00083 
00084         state->initialize(argc, argv);
00085         state->run();
00086     }
00087 
00088     return 0;
00089 }
00090 */

Generated on Tue Nov 4 2014 13:04:31 for ECF by  doxygen 1.7.1