//============================================================================ // Name : Trikitest.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ //#define HAVE_GNUPLOT #include using namespace std; #include #include //Representation and initializer #include #include #include /* // fitness function #include #include #include //Neighbors and Neighborhoods #include #include //Algorithm and its components #include #include //comparator #include //continuators #include #include #include #include #include */ //----------------------------------------------------------------------------- // Define types of the representation solution, different neighbors and neighborhoods //----------------------------------------------------------------------------- typedef eoInt Queen; //Permutation (Queen's problem representation) typedef moShiftNeighbor shiftNeighbor; //shift Neighbor typedef moRndWithReplNeighborhood rndShiftNeighborhood; //rnd shift Neighborhood (Indexed) int main() { //cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! //return 0; unsigned vecSize = 8; queenEval fullEval; /* ========================================================= * * Initilization of the solution * * ========================================================= */ eoInitPermutation init(vecSize); /* ========================================================= * * evaluation of a neighbor solution * * ========================================================= */ moFullEvalByCopy shiftEval(fullEval); /// by default /* ========================================================= * * the neighborhood of a solution * * ========================================================= */ rndShiftNeighborhood rndShiftNH((vecSize-1) * (vecSize-1)); /* ========================================================= * * the cooling schedule of the process * * ========================================================= */ /* ========================================================= * * the local search algorithm * * ========================================================= */ /* ========================================================= * * execute the local search from random solution * * ========================================================= */ Queen solution1; init(solution1); fullEval(solution1); moStdDevEstimator initTemp (500, rndShiftNH, fullEval); moTrueContinuator continuator; moCheckpoint checkpoint(continuator); moFitnessStat fitStat; checkpoint.add(fitStat); eoFileMonitor monitor("triki.out", ""); eoGnuplot1DMonitor monitor2("trikignu.out", true); moCounterMonitorSaver countMon(100, monitor); checkpoint.add(countMon); moCounterMonitorSaver gnuMon (1, monitor2); checkpoint.add(gnuMon); monitor.add(fitStat); monitor2.add(fitStat); //#ifdef HAVE_GNUPLOT moTrikiCoolingSchedule coolingSchedule(rndShiftNH, shiftEval, initTemp(solution1)); moSA localSearch1(rndShiftNH, fullEval, coolingSchedule, shiftEval, checkpoint); std::cout << "#########################################" << std::endl; std::cout << "initial solution1: " << solution1 << std::endl ; localSearch1(solution1); std::cout << "final solution1: " << solution1 << std::endl ; std::cout << "#########################################" << std::endl; }