//============================================================================ // Name : Trikitest.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ // FIXME proper header //#define HAVE_GNUPLOT #include using namespace std; #include #include //Representation and initializer #include #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 solution; init(solution); fullEval(solution); //moStdDevEstimator stdDevEst (500, rndShiftNH, fullEval); double stdDevEst = moStdDevEstimator(500, rndShiftNH, fullEval)(solution); 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 (10, monitor2); checkpoint.add(gnuMon); monitor.add(fitStat); monitor2.add(fitStat); //#ifdef HAVE_GNUPLOT //moTrikiCoolingSchedule coolingSchedule(rndShiftNH, shiftEval, initTemp(solution1)); //moTrikiCoolingSchedule coolingSchedule(initTemp(solution)); moTrikiCoolingSchedule coolingSchedule(stdDevEst, stdDevEst); moSA localSearch(rndShiftNH, fullEval, coolingSchedule, shiftEval, checkpoint); //moSA localSearch(rndShiftNH, fullEval, shiftEval); //moSA localSearch(rndShiftNH, fullEval, coolingSchedule); std::cout << "#########################################" << std::endl; std::cout << "initial solution: " << solution << std::endl ; localSearch(solution); std::cout << "final solution: " << solution << std::endl ; std::cout << "#########################################" << std::endl; }