From efb22a6eda37275252ab84a676d32a61ca768649 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 14 Dec 2010 15:27:26 +0100 Subject: [PATCH 1/6] add the parser/logger to the general header --- eo/src/eo | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eo/src/eo b/eo/src/eo index cf18f3ea0..7c988f1c9 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -198,6 +198,8 @@ #include #include +#include + //----------------------------------------------------------------------------- #endif From 5697f6d699dbd1658c0a1c8f235e4f9c446c7490 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 16 Dec 2010 15:50:26 +0100 Subject: [PATCH 2/6] evaluator that throw an exception if a maximum CPU user time has been reached, for POSIX systems --- eo/NEWS | 5 ++- eo/src/eo | 1 + eo/src/eoEvalUserTimeThrowException.h | 61 +++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 eo/src/eoEvalUserTimeThrowException.h diff --git a/eo/NEWS b/eo/NEWS index 50e256087..0f067e003 100644 --- a/eo/NEWS +++ b/eo/NEWS @@ -1,4 +1,7 @@ -* release 1.1 (not yet released) +* current + - evaluators that throw an exception if a maximum time has en reached (wallclock and CPU user time for POSIX systems), independently of the number of generations + +* release 1.1 - provide cmake build system, remove the old autotools one - package generation system - GCC 4.3 compatibility diff --git a/eo/src/eo b/eo/src/eo index 7c988f1c9..89ed7da98 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -77,6 +77,7 @@ #include #include #include +#include // Continuators - all include eoContinue.h #include diff --git a/eo/src/eoEvalUserTimeThrowException.h b/eo/src/eoEvalUserTimeThrowException.h new file mode 100644 index 000000000..d47c064ae --- /dev/null +++ b/eo/src/eoEvalUserTimeThrowException.h @@ -0,0 +1,61 @@ +/* +(c) Thales group, 2010 + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; + version 2 of the License. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Contact: http://eodev.sourceforge.net + +Authors: +Johann Dréo +*/ + +#include +#include + +#include + +/** Check at each evaluation if a given CPU user time contract has been reached. + * + * Throw an eoMaxTimeException if the given max time has been reached. + * Usefull if you want to end the search independently of generations. + * This class uses (almost-)POSIX headers. + * It uses a computation of the user time used on the CPU. For a wallclock time measure, see eoEvalTimeThrowException + * + * @ingroup Evaluation + */ +template< class EOT > +class eoEvalUserTimeThrowException : public eoEvalFuncCounter< EOT > +{ +public: + eoEvalUserTimeThrowException( eoEvalFunc & func, long max ) : _max(max), eoEvalFuncCounter( func, "CPU-user") {} + + virtual void operator() ( EOT & eo ) + { + if( eo.invalid() ) { + + getrusage(RUSAGE_SELF,&_usage); + + if( _usage.ru_utime.tv_sec >= _max ) { + throw eoMaxTimeException( _usage.ru_utime.tv_sec ); + } else { + func(eo); + } + } + } + +protected: + long _max; + struct rusage _usage; +}; From c1841fa9b6a9783914656216b5fe4a87f640402d Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 16 Dec 2010 15:51:28 +0100 Subject: [PATCH 3/6] set the version to 1.1.1-edge --- eo/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eo/CMakeLists.txt b/eo/CMakeLists.txt index 7217df60d..ca2f8580a 100644 --- a/eo/CMakeLists.txt +++ b/eo/CMakeLists.txt @@ -15,11 +15,11 @@ INCLUDE(eo-conf.cmake OPTIONAL) PROJECT(EO) SET(PROJECT_VERSION_MAJOR 1) -SET(PROJECT_VERSION_MINOR 02) +SET(PROJECT_VERSION_MINOR 1) SET(PROJECT_VERSION_PATCH 1) SET(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" CACHE STRING "Package version" FORCE) -SET(VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}" CACHE STRING "Global version" FORCE) -SET(VERSION "1.02" CACHE STRING "Global version" FORCE) +#SET(VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}" CACHE STRING "Global version" FORCE) +SET(VERSION "1.1.1-edge" CACHE STRING "Global version" FORCE) SET(GLOBAL_VERSION "${VERSION}") SET(PACKAGE_BUGREPORT "eodev-help@sourceforge.net" CACHE STRING "Package bug report" FORCE) From db4ece5f1144aee1bb1119da0798f76b02fcc026 Mon Sep 17 00:00:00 2001 From: Caner Candan Date: Wed, 22 Dec 2010 10:25:13 +0100 Subject: [PATCH 4/6] * doc: solved some mistakes --- eo/doc/index.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eo/doc/index.h b/eo/doc/index.h index 7d7921fe0..52a5758cf 100644 --- a/eo/doc/index.h +++ b/eo/doc/index.h @@ -43,17 +43,17 @@ massively use templates, so that you will not be limited by interfaces when using your own representation. Once you have a representation, you will build your own evolutionary algorithm -by assembling @ref Operators in @ref Algorithms. +by assembling @ref Operators in @ref Algorithms. In %EO, most of the objects are functors, that is classes with an operator(), that you -can call just as if they were classical functions. For example, an algorithm is a -functor, that manipulate a population of individuals, it will be implemented as a functor, +can call just as if they were classical functions. For example, an algorithm is a +functor, that manipulate a population of individuals, it will be implemented as a functor, with a member like: operator()(eoPop). Once called on a given population, it will search for the optimum of a given problem. Generally, operators are instanciated once and then binded in an algorithm by reference. -Thus, you can easily build you own algorithm by trying several combination of operators. +Thus, you can easily build your own algorithm by trying several combination of operators. -For an more detailled introduction to the design of %EO you can look at the +For a more detailled introduction to the design of %EO you can look at the slides from a talk at EA 2001 or at the corresponding article in Lecture Notes In Computer Science, 2310, Selected Papers from the 5th European Conference on Artificial Evolution: - http://portal.acm.org/citation.cfm?id=727742 From 1e177e17f922e4493533d3b3fce558cae9c26864 Mon Sep 17 00:00:00 2001 From: Caner Candan Date: Wed, 22 Dec 2010 13:40:49 +0100 Subject: [PATCH 5/6] * package dependancies changed --- eo/Packaging.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo/Packaging.cmake b/eo/Packaging.cmake index c9e2d44b1..de81fadc3 100644 --- a/eo/Packaging.cmake +++ b/eo/Packaging.cmake @@ -67,7 +67,7 @@ SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${PROJECT_VERSION_MAJOR}.${ ### 4) Set up debian packaging information ###################################################################################### -SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++6, libgcc1, libc6, libxml2, libmpich2-1.2") +SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++6, libgcc1, libc6, g++") SET(CPACK_DEBIAN_PACKAGE_SECTION "devel") SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") From 5fe07abc6c51db4802ebd507d86ceb73ab7c1bb6 Mon Sep 17 00:00:00 2001 From: Caner Candan Date: Thu, 23 Dec 2010 12:22:29 +0100 Subject: [PATCH 6/6] + add the value() method in eoParam used by dae --- eo/src/utils/eoParam.h | 46 +++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index 1eb97b306..868507cf7 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -169,32 +169,46 @@ public : eoParam::defValue(getValue()); } - /** Parameter value + /** Get a reference on the parameter value @return parameter value */ - ValueType& value() - { return repValue; } + ValueType& value() { return repValue; } - /** Parameter value + /** Get a const reference on the parameter value @overload @return parameter value */ - const ValueType& value() const - { return repValue; } + const ValueType& value() const { return repValue; } + /** Change the parameter value + */ + void value( ValueType val ) + { + // convert to string + std::ostringstream os; + os << val; + + // convert to ValueType + std::istringstream is( os.str() ); + is >> repValue; + } + + + /** Get the string representation of the value + */ std::string getValue(void) const - { - std::ostringstream os; - os << repValue; - return os.str(); - } + { + std::ostringstream os; + os << repValue; + return os.str(); + } - /** @brief Set value according to the speciied string + /** @brief Set the value according to the speciied string For scalar types the textual represenation is typically quite straigtforward. @@ -208,10 +222,10 @@ public : @param _value Textual representation of the new value */ void setValue(const std::string& _value) - { - std::istringstream is(_value); - is >> repValue; - } + { + std::istringstream is(_value); + is >> repValue; + } protected: