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 <= 24; function++) { 00034 00035 // read XML config 00036 std::ifstream fin(argv[1]); 00037 if (!fin) { 00038 std::cerr << "Error opening config file! (" << argv[1] << ")\n"; 00039 return 1; 00040 } 00041 00042 std::string xmlFile, temp; 00043 while (!fin.eof()) { 00044 getline(fin, temp); 00045 xmlFile += "\n" + temp; 00046 } 00047 fin.close(); 00048 00049 // set log and stats parameters 00050 std::string funcName = uint2str(function); 00051 std::string logName = "log", statsName = "stats"; 00052 if(function < 10) { 00053 logName += "0"; 00054 statsName += "0"; 00055 } 00056 logName += uint2str(function) + ".txt"; 00057 statsName += uint2str(function) + ".txt"; 00058 00059 // update in XML 00060 XMLResults results; 00061 XMLNode xConfig = XMLNode::parseString(xmlFile.c_str(), "ECF", &results); 00062 XMLNode registry = xConfig.getChildNode("Registry"); 00063 00064 XMLNode func = registry.getChildNodeWithAttribute("Entry", "key", "coco.function"); 00065 func.updateText(funcName.c_str()); 00066 XMLNode log = registry.getChildNodeWithAttribute("Entry", "key", "log.filename"); 00067 log.updateText(logName.c_str()); 00068 XMLNode stats = registry.getChildNodeWithAttribute("Entry", "key", "batch.statsfile"); 00069 stats.updateText(statsName.c_str()); 00070 00071 // write back 00072 std::ofstream fout(argv[1]); 00073 fout << xConfig.createXMLString(true); 00074 fout.close(); 00075 00076 00077 // finally, run ECF on a single function 00078 StateP state (new State); 00079 00080 // set the evaluation operator 00081 state->setEvalOp(new FunctionMinEvalOp); 00082 00083 state->initialize(argc, argv); 00084 state->run(); 00085 } 00086 00087 return 0; 00088 } 00089 */