From 3f22063e3c27a75656a7b615f5a6661bdf726640 Mon Sep 17 00:00:00 2001 From: boufaras Date: Thu, 12 Jan 2012 10:52:09 +0000 Subject: [PATCH] Clear and update srcs git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2648 331e1502-861f-0410-8da2-ba01fb791d7f --- trunk/paradiseo-mo/tutorial/CMakeLists.txt | 8 - .../tutorial/Lesson8/CMakeLists.txt | 11 - .../tutorial/Lesson8/moPopFitContinuator.h | 95 ----- .../tutorial/Lesson8/testPopLS.cpp | 385 ------------------ 4 files changed, 499 deletions(-) delete mode 100644 trunk/paradiseo-mo/tutorial/Lesson8/CMakeLists.txt delete mode 100644 trunk/paradiseo-mo/tutorial/Lesson8/moPopFitContinuator.h delete mode 100644 trunk/paradiseo-mo/tutorial/Lesson8/testPopLS.cpp diff --git a/trunk/paradiseo-mo/tutorial/CMakeLists.txt b/trunk/paradiseo-mo/tutorial/CMakeLists.txt index ea56e9b71..9abeb95b9 100644 --- a/trunk/paradiseo-mo/tutorial/CMakeLists.txt +++ b/trunk/paradiseo-mo/tutorial/CMakeLists.txt @@ -153,12 +153,6 @@ IF(ENABLE_CMAKE_EXAMPLE OR CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CM ) - EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${MO_SRC_DIR}/tutorial/Lesson10/testKswapNeighborhood.param - ${MO_BIN_DIR}/tutorial/Lesson10/testKswapNeighborhood.param - - ) ENDIF(ENABLE_CMAKE_EXAMPLE OR CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008" OR CMAKE_GENERATOR STREQUAL "Visual Studio 10") @@ -430,9 +424,7 @@ ADD_SUBDIRECTORY(Lesson4) ADD_SUBDIRECTORY(Lesson5) ADD_SUBDIRECTORY(Lesson6) ADD_SUBDIRECTORY(Lesson7) -ADD_SUBDIRECTORY(Lesson8) ADD_SUBDIRECTORY(Lesson9) -ADD_SUBDIRECTORY(Lesson10) IF(NOT CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" AND NOT CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008" OR CMAKE_GENERATOR STREQUAL "Visual Studio 10") ADD_COMMANDS_NEWMO() diff --git a/trunk/paradiseo-mo/tutorial/Lesson8/CMakeLists.txt b/trunk/paradiseo-mo/tutorial/Lesson8/CMakeLists.txt deleted file mode 100644 index a6230d822..000000000 --- a/trunk/paradiseo-mo/tutorial/Lesson8/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src - ${MO_SRC_DIR}/src - ${MOEO_SRC_DIR}/src - ${PROBLEMS_SRC_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../src) - -LINK_DIRECTORIES(${EO_BIN_DIR}/lib) - -ADD_EXECUTABLE(testPopLS testPopLS.cpp) - -TARGET_LINK_LIBRARIES(testPopLS eoutils ga eo) diff --git a/trunk/paradiseo-mo/tutorial/Lesson8/moPopFitContinuator.h b/trunk/paradiseo-mo/tutorial/Lesson8/moPopFitContinuator.h deleted file mode 100644 index 0e1874d7b..000000000 --- a/trunk/paradiseo-mo/tutorial/Lesson8/moPopFitContinuator.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 - -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -#ifndef _moPopFitContinuator_h -#define _moPopFitContinuator_h - -#include - -/** - * Termination condition until a running time is reached. - */ -template < class Neighbor > -class moPopFitContinuator: public moContinuator -{ -public: - - typedef typename Neighbor::EOT EOT; - typedef typename EOT::Fitness Fitness; - - /** - * Constructor - * @param _fit fitness to reach - * @param _verbose verbose mode true/false -> on/off - */ - moPopFitContinuator(Fitness _fit, bool _verbose=true): fit(_fit), verbose(_verbose) {} - - - /** - * Returns false when the running time is reached. - * @param _sol the current solution - */ - virtual bool operator() (EOT& _sol) - { - unsigned int i=0; - bool res=true; - while (res && i<_sol.size()){ - res= (_sol[i].fitness() < fit); - i++; - } - if (!res && verbose) - std::cout << "STOP in moPopFitContinuator: Reached maximum fitness [" << fit << "]" << std::endl; - return res; - } - - /** - * reset the start time - * @param _solution a solution - */ - virtual void init(EOT & _solution) {} - - - /** - * Class name - */ - virtual std::string className(void) const - { - return "moPopFitContinuator"; - } - - -private: - - Fitness fit; - /** verbose mode */ - bool verbose; - -}; - -#endif diff --git a/trunk/paradiseo-mo/tutorial/Lesson8/testPopLS.cpp b/trunk/paradiseo-mo/tutorial/Lesson8/testPopLS.cpp deleted file mode 100644 index b026f86c7..000000000 --- a/trunk/paradiseo-mo/tutorial/Lesson8/testPopLS.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 - -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau - -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr -*/ - -// standard includes -#define HAVE_SSTREAM - -#include // runtime_error -#include // cout -#include // ostrstream, istrstream -#include -#include - -// the general include for eo -#include -#include - -using namespace std; - -//----------------------------------------------------------------------------- -//Representation and initializer -#include -#include -#include -#include -#include - -// fitness function -#include -#include - -//Neighbors and Neighborhoods -#include -#include - -//Algorithm and its components -#include -#include - -//comparator -#include - -//continuators -#include -#include -#include -#include -#include - -#include "moPopFitContinuator.h" - -#include - - -//----------------------------------------------------------------------------- -// Define types of the representation solution, different neighbors and neighborhoods -//----------------------------------------------------------------------------- -typedef moPopSol > Solution; //Permutation (Queen's problem representation) - -typedef moPopBitNeighbor Neighbor; //shift Neighbor -typedef moRndWithReplNeighborhood Neighborhood; //rnd shift Neighborhood (Indexed) - - -class popInit: public eoInit{ - -public: - - popInit( eoInitFixedLength > & _rnd, unsigned int _popSize):rnd(_rnd), popSize(_popSize){} - - void operator()(Solution & _sol){ - - - - eoBit tmp; - - for(unsigned int i=0; i >& rnd; - unsigned int popSize; - -}; - -void main_function(int argc, char **argv) -{ - /* ========================================================= - * - * Parameters - * - * ========================================================= */ - - // First define a parser from the command-line arguments - eoParser parser(argc, argv); - - // For each parameter, define Parameter, read it through the parser, - // and assign the value to the variable - - eoValueParam seedParam(time(0), "seed", "Random number seed", 'S'); - parser.processParam( seedParam ); - unsigned seed = seedParam.value(); - - // the number of steps of the random walk - eoValueParam stepParam(100, "nbStep", "Number of steps of the random walk", 'n'); - parser.processParam( stepParam, "Representation" ); - unsigned nbStep = stepParam.value(); - - // description of genotype - eoValueParam vecSizeParam(8, "vecSize", "Genotype size", 'V'); - parser.processParam( vecSizeParam, "Representation" ); - unsigned vecSize = vecSizeParam.value(); - - // description of genotype - eoValueParam popSizeParam(10, "popSize", "population size", 'P'); - parser.processParam( popSizeParam, "Representation" ); - unsigned popSize = popSizeParam.value(); - - // the name of the "status" file where all actual parameter values will be saved - string str_status = parser.ProgramName() + ".status"; // default value - eoValueParam statusParam(str_status.c_str(), "status", "Status file"); - parser.processParam( statusParam, "Persistence" ); - - // the name of the output file - string str_out = "out.dat"; // default value - eoValueParam outParam(str_out.c_str(), "out", "Output file of the sampling", 'o'); - parser.processParam(outParam, "Persistence" ); - - // description of genotype - eoValueParam pparam(10, "p", "p", 'p'); - parser.processParam( pparam, "Representation" ); - unsigned p = pparam.value(); - - // do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED - // i.e. in case you need parameters somewhere else, postpone these - if (parser.userNeedsHelp()) { - parser.printHelp(cout); - exit(1); - } - if (statusParam.value() != "") { - ofstream os(statusParam.value().c_str()); - os << parser;// and you can use that file as parameter file - } - - /* ========================================================= - * - * Random seed - * - * ========================================================= */ - - //reproducible random seed: if you don't change SEED above, - // you'll always get the same result, NOT a random run - rng.reseed(seed); - - - /* ========================================================= - * - * Eval fitness function - * - * ========================================================= */ - - oneMaxEval< eoBit > eval; - oneMaxPopEval< eoBit > popEval(eval, p); - - - /* ========================================================= - * - * Initilisation of the solution - * - * ========================================================= */ - - eoUniformGenerator uGen; - eoInitFixedLength > rnd(vecSize, uGen); - - popInit random(rnd, popSize); - - - - - /* ========================================================= - * - * evaluation of a neighbor solution - * - * ========================================================= */ - - moPopBitEval evalNeighbor(eval,p); - -// Neighbor n; -// -// n.index(3); -// moEval(sol, n); -// n.move(sol); -// popEval(sol); -// sol.printOn(std::cout); -// std::cout << "fit neighor: " << n.fitness() << std::endl; - - - - - /* ========================================================= - * - * the neighborhood of a solution - * - * ========================================================= */ - - Neighborhood neighborhood(vecSize*popSize); - - moPopFitContinuator cont(vecSize); - - /* ========================================================= - * - * the local search algorithm - * - * ========================================================= */ - - //moSimpleHC ls(neighborhood, popEval, evalNeighbor, cont); - - /* ========================================================= - * - * execute the local search from random solution - * - * ========================================================= */ - -// ls(sol); -// -// std::cout << "final solution:" << std::endl; -// sol.printOn(std::cout); -// std::cout << std::endl; - - - - - /* ========================================================= - * - * The sampling of the search space - * - * ========================================================= */ - - // sampling object : - // - random initialization - // - neighborhood to compute the next step - // - fitness function - // - neighbor evaluation - // - number of steps of the walk - moAutocorrelationSampling sampling(random, neighborhood, popEval, evalNeighbor, nbStep); - - /* ========================================================= - * - * execute the sampling - * - * ========================================================= */ - - sampling(); - - /* ========================================================= - * - * export the sampling - * - * ========================================================= */ - - // to export the statistics into file - sampling.fileExport(str_out); - - // to get the values of statistics - // so, you can compute some statistics in c++ from the data - const std::vector & fitnessValues = sampling.getValues(0); - - std::cout << "First values:" << std::endl; - std::cout << "Fitness " << fitnessValues[0] << std::endl; - - std::cout << "Last values:" << std::endl; - std::cout << "Fitness " << fitnessValues[fitnessValues.size() - 1] << std::endl; - - // more basic statistics on the distribution: - moStatistics statistics; - - vector rho, phi; - - statistics.autocorrelation(fitnessValues, 20, rho, phi); - - for (unsigned s = 0; s < rho.size(); s++) - std::cout << s << " " << "rho=" << rho[s] << ", phi=" << phi[s] << std::endl; - -// Queen solution1, solution2; -// -// init(solution1); -// -// fullEval(solution1); -// -// std::cout << "#########################################" << std::endl; -// std::cout << "initial solution1: " << solution1 << std::endl ; -// -// localSearch1(solution1); -// -// std::cout << "final solution1: " << solution1 << std::endl ; -// std::cout << "#########################################" << std::endl; - - - /* ========================================================= - * - * the cooling schedule of the process - * - * ========================================================= */ - - // initial temp, factor of decrease, number of steps without decrease, final temp. - - - /* ========================================================= - * - * Comparator of neighbors - * - * ========================================================= */ - - - - /* ========================================================= - * - * Example of Checkpointing - * - * ========================================================= */ - -// moTrueContinuator continuator;//always continue -// moCheckpoint checkpoint(continuator); -// moFitnessStat fitStat; -// checkpoint.add(fitStat); -// eoFileMonitor monitor("fitness.out", ""); -// moCounterMonitorSaver countMon(100, monitor); -// checkpoint.add(countMon); -// monitor.add(fitStat); -// -// moSA localSearch2(rndShiftNH, fullEval, shiftEval, coolingSchedule, solComparator, checkpoint); -// -// init(solution2); -// -// fullEval(solution2); -// -// std::cout << "#########################################" << std::endl; -// std::cout << "initial solution2: " << solution2 << std::endl ; -// -// localSearch2(solution2); -// -// std::cout << "final solution2: " << solution2 << std::endl ; -// std::cout << "#########################################" << std::endl; -} - -// A main that catches the exceptions - -int main(int argc, char **argv) -{ - try { - main_function(argc, argv); - } - catch (exception& e) { - cout << "Exception: " << e.what() << '\n'; - } - return 1; -} -