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

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

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

Generated on Fri Jul 5 2013 09:34:23 for ECF by  doxygen 1.7.1