From 814062d01d9e1c4d41f127d04304047f7e278af1 Mon Sep 17 00:00:00 2001 From: verel Date: Mon, 11 Mar 2013 13:47:19 +0100 Subject: [PATCH 001/419] debug moMonOpPerturb : replace "res = res || monOp(_solution);" by " res = monOp(_solution) || res;" ! --- mo/src/perturb/moMonOpPerturb.h | 4 ++-- mo/src/problems/bitString/moBitsWithoutReplNeighborhood.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mo/src/perturb/moMonOpPerturb.h b/mo/src/perturb/moMonOpPerturb.h index a4bcea574..e0dc138da 100644 --- a/mo/src/perturb/moMonOpPerturb.h +++ b/mo/src/perturb/moMonOpPerturb.h @@ -60,8 +60,8 @@ public: bool operator()(EOT& _solution) { bool res = false; - for(unsigned int i = 0; i < nbPerturbation; i++) - res = res || monOp(_solution); + for(unsigned int i = 0; i < nbPerturbation; i++) + res = monOp(_solution) || res; _solution.invalidate(); fullEval(_solution); diff --git a/mo/src/problems/bitString/moBitsWithoutReplNeighborhood.h b/mo/src/problems/bitString/moBitsWithoutReplNeighborhood.h index 652e8ed02..4584a791a 100644 --- a/mo/src/problems/bitString/moBitsWithoutReplNeighborhood.h +++ b/mo/src/problems/bitString/moBitsWithoutReplNeighborhood.h @@ -81,7 +81,7 @@ public: /* all the neighbors */ if (neighborhoodSize >= 1000000) { - std::cout << "moBitsNeighborhood::Warning : the neighborhood size is larger than 10^6 : " << neighborhoodSize << std::endl; + std::cout << "moBitsWithoutReplNeighborhood::Warning : the neighborhood size is larger than 10^6 : " << neighborhoodSize << std::endl; } int j; From 43cb068d539d71a08ebf5b25f045c5f4275ffbaf Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 15 Mar 2013 19:17:40 +0100 Subject: [PATCH 002/419] eoserial:: const correctness for String. --- eo/src/serial/String.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eo/src/serial/String.h b/eo/src/serial/String.h index 526cab365..2ef1f94f5 100644 --- a/eo/src/serial/String.h +++ b/eo/src/serial/String.h @@ -62,7 +62,7 @@ namespace eoserial * @param value The value in which we're writing. */ template - inline void deserialize( T & value ); + inline void deserialize( T & value ) const; protected: // Copy and reaffectation are forbidden @@ -80,7 +80,7 @@ namespace eoserial * invoking. */ template - inline void String::deserialize( T & value ) + inline void String::deserialize( T & value ) const { std::stringstream ss; ss.precision(std::numeric_limits::digits10 + 1); @@ -93,7 +93,7 @@ namespace eoserial * a stringstream. */ template<> - inline void String::deserialize( std::string & value ) + inline void String::deserialize( std::string & value ) const { value = *this; } From 10148ae00bb5e41a73f156db60c949b04847c019 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 15 Mar 2013 19:26:32 +0100 Subject: [PATCH 003/419] eoserial: renamed String/Object/Array into Serial* to avoid compiler confusion. --- eo/src/serial/CMakeLists.txt | 6 +++--- eo/src/serial/Parser.cpp | 6 +++--- eo/src/serial/Parser.h | 4 ++-- eo/src/serial/{Array.cpp => SerialArray.cpp} | 2 +- eo/src/serial/{Array.h => SerialArray.h} | 2 +- eo/src/serial/{Object.cpp => SerialObject.cpp} | 2 +- eo/src/serial/{Object.h => SerialObject.h} | 0 eo/src/serial/{String.cpp => SerialString.cpp} | 2 +- eo/src/serial/{String.h => SerialString.h} | 0 eo/src/serial/Utils.h | 6 +++--- eo/src/serial/eoSerial.h | 6 +++--- 11 files changed, 18 insertions(+), 18 deletions(-) rename eo/src/serial/{Array.cpp => SerialArray.cpp} (98%) rename eo/src/serial/{Array.h => SerialArray.h} (99%) rename eo/src/serial/{Object.cpp => SerialObject.cpp} (98%) rename eo/src/serial/{Object.h => SerialObject.h} (100%) rename eo/src/serial/{String.cpp => SerialString.cpp} (97%) rename eo/src/serial/{String.h => SerialString.h} (100%) diff --git a/eo/src/serial/CMakeLists.txt b/eo/src/serial/CMakeLists.txt index 43d1ce451..efc9f42e2 100644 --- a/eo/src/serial/CMakeLists.txt +++ b/eo/src/serial/CMakeLists.txt @@ -13,10 +13,10 @@ set(EOSERIAL_LIB_OUTPUT_PATH ${EO_BIN_DIR}/lib) set(LIBRARY_OUTPUT_PATH ${EOSERIAL_LIB_OUTPUT_PATH}) set(EOSERIAL_SOURCES - Array.cpp - Object.cpp + SerialArray.cpp + SerialObject.cpp Parser.cpp - String.cpp + SerialString.cpp ) add_library(eoserial STATIC ${EOSERIAL_SOURCES}) diff --git a/eo/src/serial/Parser.cpp b/eo/src/serial/Parser.cpp index 57b52a0dd..e78b35392 100644 --- a/eo/src/serial/Parser.cpp +++ b/eo/src/serial/Parser.cpp @@ -23,9 +23,9 @@ Authors: # include "Parser.h" -# include "Array.h" -# include "Object.h" -# include "String.h" +# include "SerialArray.h" +# include "SerialObject.h" +# include "SerialString.h" // in debug mode only // # define DEBUG(x) std::cout << x << std::endl; diff --git a/eo/src/serial/Parser.h b/eo/src/serial/Parser.h index 20f6a1bb2..392f25ffa 100644 --- a/eo/src/serial/Parser.h +++ b/eo/src/serial/Parser.h @@ -23,8 +23,8 @@ Authors: # define __EOSERIAL_PARSER_H__ # include "Entity.h" -# include "String.h" -# include "Object.h" +# include "SerialString.h" +# include "SerialObject.h" /** * @file Parser.h diff --git a/eo/src/serial/Array.cpp b/eo/src/serial/SerialArray.cpp similarity index 98% rename from eo/src/serial/Array.cpp rename to eo/src/serial/SerialArray.cpp index 180aad16b..5282370f5 100644 --- a/eo/src/serial/Array.cpp +++ b/eo/src/serial/SerialArray.cpp @@ -19,7 +19,7 @@ Contact: http://eodev.sourceforge.net Authors: Benjamin Bouvier */ -# include "Array.h" +# include "SerialArray.h" namespace eoserial { diff --git a/eo/src/serial/Array.h b/eo/src/serial/SerialArray.h similarity index 99% rename from eo/src/serial/Array.h rename to eo/src/serial/SerialArray.h index d453add99..b349953aa 100644 --- a/eo/src/serial/Array.h +++ b/eo/src/serial/SerialArray.h @@ -26,7 +26,7 @@ Authors: # include "Entity.h" # include "Serializable.h" -# include "Object.h" +# include "SerialObject.h" namespace eoserial { diff --git a/eo/src/serial/Object.cpp b/eo/src/serial/SerialObject.cpp similarity index 98% rename from eo/src/serial/Object.cpp rename to eo/src/serial/SerialObject.cpp index dd859052e..e926e448f 100644 --- a/eo/src/serial/Object.cpp +++ b/eo/src/serial/SerialObject.cpp @@ -19,7 +19,7 @@ Contact: http://eodev.sourceforge.net Authors: Benjamin Bouvier */ -# include "Object.h" +# include "SerialObject.h" using namespace eoserial; diff --git a/eo/src/serial/Object.h b/eo/src/serial/SerialObject.h similarity index 100% rename from eo/src/serial/Object.h rename to eo/src/serial/SerialObject.h diff --git a/eo/src/serial/String.cpp b/eo/src/serial/SerialString.cpp similarity index 97% rename from eo/src/serial/String.cpp rename to eo/src/serial/SerialString.cpp index c50882786..6d49106cc 100644 --- a/eo/src/serial/String.cpp +++ b/eo/src/serial/SerialString.cpp @@ -19,7 +19,7 @@ Contact: http://eodev.sourceforge.net Authors: Benjamin Bouvier */ -# include "String.h" +# include "SerialString.h" namespace eoserial { diff --git a/eo/src/serial/String.h b/eo/src/serial/SerialString.h similarity index 100% rename from eo/src/serial/String.h rename to eo/src/serial/SerialString.h diff --git a/eo/src/serial/Utils.h b/eo/src/serial/Utils.h index 33172a747..13b6877b1 100644 --- a/eo/src/serial/Utils.h +++ b/eo/src/serial/Utils.h @@ -22,9 +22,9 @@ Authors: # ifndef __EOSERIAL_UTILS_H__ # define __EOSERIAL_UTILS_H__ -# include "Array.h" -# include "Object.h" -# include "String.h" +# include "SerialArray.h" +# include "SerialObject.h" +# include "SerialString.h" namespace eoserial { diff --git a/eo/src/serial/eoSerial.h b/eo/src/serial/eoSerial.h index 55a116f0c..8ea3a9764 100644 --- a/eo/src/serial/eoSerial.h +++ b/eo/src/serial/eoSerial.h @@ -22,10 +22,10 @@ Authors: # ifndef __EOSERIAL_HEADERS__ # define __EOSERIAL_HEADERS__ -# include "Object.h" +# include "SerialObject.h" # include "Serializable.h" -# include "Array.h" -# include "Object.h" +# include "SerialArray.h" +# include "SerialObject.h" # include "String.h" # include "Parser.h" # include "Utils.h" From f412139549c3b837ecc70cd29dc8aa9940ed5592 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 15 Mar 2013 20:33:25 +0100 Subject: [PATCH 004/419] eoserial: bugfix: String -> SerialString. --- eo/src/serial/eoSerial.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eo/src/serial/eoSerial.h b/eo/src/serial/eoSerial.h index 8ea3a9764..fec5fb4dd 100644 --- a/eo/src/serial/eoSerial.h +++ b/eo/src/serial/eoSerial.h @@ -22,11 +22,10 @@ Authors: # ifndef __EOSERIAL_HEADERS__ # define __EOSERIAL_HEADERS__ -# include "SerialObject.h" # include "Serializable.h" # include "SerialArray.h" # include "SerialObject.h" -# include "String.h" +# include "SerialString.h" # include "Parser.h" # include "Utils.h" From eb047ed39c5d1e948b76448cad8429c336af0902 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 15 Mar 2013 20:33:50 +0100 Subject: [PATCH 005/419] eoserial: easy serialization with eoserial::serialize and eoserial::deserialize. --- eo/src/serial/Serialize.h | 245 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 eo/src/serial/Serialize.h diff --git a/eo/src/serial/Serialize.h b/eo/src/serial/Serialize.h new file mode 100644 index 000000000..1a1e99ca1 --- /dev/null +++ b/eo/src/serial/Serialize.h @@ -0,0 +1,245 @@ +/* +(c) Benjamin Bouvier, 2013 + + 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: + Benjamin Bouvier +*/ + +/** + * @file Serialize.h + * + * This file contains primitive to make serialization and + * deserialization easy. + * + * See the snippet example code below. + * + * @code + * # include + * # include + * + * class MyObject: public eoserial::Persistent + * { + * public: + * + * int value; + * MyObject( int v ) : value(v) {} + * + * eoserial::Entity* pack() const + * { + * eoserial::Object* e = new eoserial::Object; + * (*e)["the_value"] = eoserial::serialize( value ); + * return e; + * } + * + * void unpack( const eoserial::Object* o ) + * { + * eoserial::deserialize( *o, "the_value", value ); + * } + * }; + * + * int main() + * { + * eoserial::Object o; + * o["long"] = eoserial::serialize(123456L); + * o["bool"] = eoserial::serialize(true); + * o["double"] = eoserial::serialize(3.141592653); + * o["float"] = eoserial::serialize(3.141592653f); + * + * std::string str = "Hello, world!"; + * o["str"] = eoserial::serialize( str ); + * + * MyObject obj(42); + * o["obj"] = eoserial::serialize( obj ); + * + * std::vector vec; + * vec.push_back(1); + * vec.push_back(3); + * vec.push_back(3); + * vec.push_back(7); + * o["vec"] = eoserial::serialize( vec ); + * + * o.print( std::cout ); + * return 0; + * } + * @endcode + * + * @todo Encapsulate non private functions. As of today (2013-03-19), it is not + * possible as GCC and Clang refuse to have std::vector specializations of template methods (while it works with + * functions). + * + * @todo Comments coming soon. + * + * @author Benjamin Bouvier + */ + +# include +# include +# include // std::runtime_error +# include // std::is_convertible (C++11) + +# include "SerialString.h" +# include "SerialObject.h" +# include "SerialArray.h" +# include "Utils.h" + +namespace eoserial +{ + + template + eoserial::Entity* serialize( const T & arg ); + + template + void deserialize( const eoserial::Entity& json, const std::string& field, T & value ); + + /* ************************* + * PRIVATE FUNCTIONS ******* + * Use at your own risk! *** + **************************/ + + template + eoserial::Entity* makeSimple( const T & arg ) + { + throw std::runtime_error("eoSerial: makeSimple called with an unknown basic type."); + return 0; + } + + template + eoserial::Entity* makeObject( const T & arg ) + { + throw std::runtime_error("eoSerial: makeObject called with an non eoserial::Printable type."); + return 0; + } + + + template + void deserializeSimple( const eoserial::Entity* json, T & value ) + { + std::runtime_error("eoSerial: deserializeSimple called with an unknown basic type."); + } + + template + void deserializeObject( const eoserial::Entity* json, T & value ) + { + std::runtime_error("eoSerial:: deserializeObject called with a non eoserial::Persistent object."); + } + + template<> + eoserial::Entity* makeObject( const eoserial::Printable & arg ) + { + return arg.pack(); + } + + +# define MKSIMPLE(A) template<>\ + eoserial::Entity* makeSimple( const A& arg ) \ + { \ + return eoserial::make(arg); \ + } \ + + MKSIMPLE(bool) + MKSIMPLE(int) + MKSIMPLE(short) + MKSIMPLE(long) + MKSIMPLE(float) + MKSIMPLE(double) + MKSIMPLE(std::string) +# undef MKSIMPLE + + +# define DSSIMPLE(A) template<> \ + void deserializeSimple( const eoserial::Entity* json, A & value ) \ + { \ + static_cast(json)->deserialize( value ); \ + } + + DSSIMPLE(bool); + DSSIMPLE(int); + DSSIMPLE(short); + DSSIMPLE(long); + DSSIMPLE(float); + DSSIMPLE(double); + DSSIMPLE(std::string); +# undef DSSIMPLE + + template<> + void deserializeObject( const eoserial::Entity* json, eoserial::Persistent & value ) + { + value.unpack( static_cast( json ) ); + } + + template + eoserial::Entity* makeSimple( const std::vector & v ) + { + eoserial::Array* array = new eoserial::Array; + for( auto it = v.begin(), end = v.end(); + it != end; + ++it ) + { + array->push_back( eoserial::serialize( *it ) ); + } + return array; + } + + template + void deserializeBase( const eoserial::Entity* json, T & value ); + + template< class T > + void deserializeSimple( const eoserial::Entity* json, std::vector & v ) + { + const eoserial::Array* sArray = static_cast(json); + for( auto it = sArray->begin(), end = sArray->end(); + it != end; + ++it ) + { + T single; + eoserial::deserializeBase( *it, single ); + v.push_back( single ); + } + } + + template + void deserializeBase( const eoserial::Entity* json, T & value ) + { + if( std::is_convertible< T*, eoserial::Persistent*>::value ) + { + eoserial::deserializeObject( json, reinterpret_cast( value ) ); + } else { + eoserial::deserializeSimple( json, value ); + } + } + + template + eoserial::Entity* serialize( const T & arg ) + { + if( std::is_convertible::value ) + { + return eoserial::makeObject( reinterpret_cast(arg) ); + } else { + return eoserial::makeSimple( arg ); + } + } + + template + void deserialize( const eoserial::Entity& json, const std::string& field, T & value ) + { + const eoserial::Entity* jField = static_cast(json).find(field)->second; + eoserial::deserializeBase( jField, value ); + } +} + + From dc0f995ff4f0de4a91163c64d45c056ec84f53ff Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 22 Mar 2013 00:37:25 +0100 Subject: [PATCH 006/419] eoserial: typos (comment + throw exceptions) --- eo/src/serial/Serialize.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eo/src/serial/Serialize.h b/eo/src/serial/Serialize.h index 1a1e99ca1..f833f427a 100644 --- a/eo/src/serial/Serialize.h +++ b/eo/src/serial/Serialize.h @@ -78,7 +78,7 @@ Authors: * } * @endcode * - * @todo Encapsulate non private functions. As of today (2013-03-19), it is not + * @todo Encapsulate private functions. As of today (2013-03-19), it is not * possible as GCC and Clang refuse to have std::vector specializations of template methods (while it works with * functions). * @@ -129,13 +129,13 @@ namespace eoserial template void deserializeSimple( const eoserial::Entity* json, T & value ) { - std::runtime_error("eoSerial: deserializeSimple called with an unknown basic type."); + throw std::runtime_error("eoSerial: deserializeSimple called with an unknown basic type."); } template void deserializeObject( const eoserial::Entity* json, T & value ) { - std::runtime_error("eoSerial:: deserializeObject called with a non eoserial::Persistent object."); + throw std::runtime_error("eoSerial:: deserializeObject called with a non eoserial::Persistent object."); } template<> From f7e2a6ea7fd75fb86f9186877909e17acc346a4e Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 22 Mar 2013 00:37:59 +0100 Subject: [PATCH 007/419] eoserial: support char + std::list --- eo/src/serial/Serialize.h | 41 ++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/eo/src/serial/Serialize.h b/eo/src/serial/Serialize.h index f833f427a..fe3d21ab8 100644 --- a/eo/src/serial/Serialize.h +++ b/eo/src/serial/Serialize.h @@ -88,6 +88,7 @@ Authors: */ # include +# include # include # include // std::runtime_error # include // std::is_convertible (C++11) @@ -157,6 +158,7 @@ namespace eoserial MKSIMPLE(long) MKSIMPLE(float) MKSIMPLE(double) + MKSIMPLE(char) MKSIMPLE(std::string) # undef MKSIMPLE @@ -173,6 +175,7 @@ namespace eoserial DSSIMPLE(long); DSSIMPLE(float); DSSIMPLE(double); + DSSIMPLE(char); DSSIMPLE(std::string); # undef DSSIMPLE @@ -182,11 +185,11 @@ namespace eoserial value.unpack( static_cast( json ) ); } - template - eoserial::Entity* makeSimple( const std::vector & v ) + template + eoserial::Entity* makeSimpleIterable( const Container & c ) { eoserial::Array* array = new eoserial::Array; - for( auto it = v.begin(), end = v.end(); + for( auto it = c.begin(), end = c.end(); it != end; ++it ) { @@ -195,23 +198,47 @@ namespace eoserial return array; } + template + eoserial::Entity* makeSimple( const std::vector & v ) + { + return makeSimpleIterable( v ); + } + + template + eoserial::Entity* makeSimple( const std::list & l ) + { + return makeSimpleIterable( l ); + } + template void deserializeBase( const eoserial::Entity* json, T & value ); - template< class T > - void deserializeSimple( const eoserial::Entity* json, std::vector & v ) + template< class Container > + void deserializeSimplePushBack( const eoserial::Entity* json, Container & c ) { const eoserial::Array* sArray = static_cast(json); for( auto it = sArray->begin(), end = sArray->end(); it != end; ++it ) { - T single; + typename Container::value_type single; eoserial::deserializeBase( *it, single ); - v.push_back( single ); + c.push_back( single ); } } + template< class T > + void deserializeSimple( const eoserial::Entity* json, std::vector & v ) + { + deserializeSimplePushBack( json, v ); + } + + template< class T > + void deserializeSimple( const eoserial::Entity* json, std::list & v ) + { + deserializeSimplePushBack( json, v ); + } + template void deserializeBase( const eoserial::Entity* json, T & value ) { From 834dcb1bd602078944a4f500828a98af13ba3181 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 22 Mar 2013 01:13:44 +0100 Subject: [PATCH 008/419] eoserial: comments for Serialize. --- eo/src/serial/Serialize.h | 246 +++++++++++++++++++++++++++++--------- 1 file changed, 189 insertions(+), 57 deletions(-) diff --git a/eo/src/serial/Serialize.h b/eo/src/serial/Serialize.h index fe3d21ab8..b3d5c2c1b 100644 --- a/eo/src/serial/Serialize.h +++ b/eo/src/serial/Serialize.h @@ -26,7 +26,7 @@ Authors: * This file contains primitive to make serialization and * deserialization easy. * - * See the snippet example code below. + * See the example code snippet below. * * @code * # include @@ -39,7 +39,7 @@ Authors: * int value; * MyObject( int v ) : value(v) {} * - * eoserial::Entity* pack() const + * eoserial::Object* pack() const * { * eoserial::Object* e = new eoserial::Object; * (*e)["the_value"] = eoserial::serialize( value ); @@ -74,6 +74,13 @@ Authors: * o["vec"] = eoserial::serialize( vec ); * * o.print( std::cout ); + * + * std::list lis; + * eoserial::deserialize( o, "vec", lis ); + * + * long oneTwoThreeFourFiveSix; + * eoserial::deserialize( o, "long", oneTwoThreeFourFiveSix); + * * return 0; * } * @endcode @@ -101,9 +108,42 @@ Authors: namespace eoserial { + /** + * @brief Tries to serialize the given argument into an Entity. + * + * This function can be called with any argument of the following kinds: + * - basic types (int, bool, float, double, char, short, long) + * - standard STL types (std::string, std::list, std::vector). In + * this case, the serialization is automatically called on the + * contained objects. + * - objects which implement eoserial::Printable + * + * @param arg The argument to serialize. + * @return an Entity to be used with the serialization module. + * + * @throws std::runtime_exception when the type T is not known or + * not convertible to a known type. + */ template eoserial::Entity* serialize( const T & arg ); + /** + * @brief Tries to deserialize the given argument from the given field in the entity and loads it into the in-out + * given value. + * + * This function is the reverse operator of the serialize function: + * - basic types are supported + * - standard STL types (std::string, std::list, std::vector) + * - objects which implement eoserial::Persistent + * @see serialize + * + * @param json The entity containing the variable to deserialize + * @param field The name of the field used in the original object + * @param value The in-out value in which we want to store the result of the deserialization. + * + * @throws std::runtime_exception when the type T is not known or + * not convertible to a known type. + */ template void deserialize( const eoserial::Entity& json, const std::string& field, T & value ); @@ -112,6 +152,15 @@ namespace eoserial * Use at your own risk! *** **************************/ + /* ************************* + * SERIALIZATION *********** + **************************/ + + /** + * @brief Function to be called for non eoserial::Printable objects. + * + * The default behaviour is to throw a runtime exception. The function is then specialized for known types. + */ template eoserial::Entity* makeSimple( const T & arg ) { @@ -119,6 +168,12 @@ namespace eoserial return 0; } + /** + * @brief Function to be called for eoserial::Printable objects and only these ones. + * + * The default behaviour is to throw a runtime exception. The function is specialized only for eoserial::Printable + * object. + */ template eoserial::Entity* makeObject( const T & arg ) { @@ -126,26 +181,10 @@ namespace eoserial return 0; } - - template - void deserializeSimple( const eoserial::Entity* json, T & value ) - { - throw std::runtime_error("eoSerial: deserializeSimple called with an unknown basic type."); - } - - template - void deserializeObject( const eoserial::Entity* json, T & value ) - { - throw std::runtime_error("eoSerial:: deserializeObject called with a non eoserial::Persistent object."); - } - - template<> - eoserial::Entity* makeObject( const eoserial::Printable & arg ) - { - return arg.pack(); - } - - + /* + * Specializations of makeSimple for basic types. + * Macro MKSIMPLE can be used to register any type that can be printed into a std::ostream. + */ # define MKSIMPLE(A) template<>\ eoserial::Entity* makeSimple( const A& arg ) \ { \ @@ -160,31 +199,14 @@ namespace eoserial MKSIMPLE(double) MKSIMPLE(char) MKSIMPLE(std::string) -# undef MKSIMPLE - - -# define DSSIMPLE(A) template<> \ - void deserializeSimple( const eoserial::Entity* json, A & value ) \ - { \ - static_cast(json)->deserialize( value ); \ - } - - DSSIMPLE(bool); - DSSIMPLE(int); - DSSIMPLE(short); - DSSIMPLE(long); - DSSIMPLE(float); - DSSIMPLE(double); - DSSIMPLE(char); - DSSIMPLE(std::string); -# undef DSSIMPLE - - template<> - void deserializeObject( const eoserial::Entity* json, eoserial::Persistent & value ) - { - value.unpack( static_cast( json ) ); - } +# undef MKSIMPLE // avoids undebuggable surprises + /** + * @brief Base specialization for objects iterable thanks to + * begin(), end() and basic iterators. + * + * This specialization is used for std::list and std::vector. + */ template eoserial::Entity* makeSimpleIterable( const Container & c ) { @@ -210,9 +232,108 @@ namespace eoserial return makeSimpleIterable( l ); } + /** + * @brief Specialization of makeObject for eoserial::Printable. + * + * For these objects, we can directly use their pack method. + */ + template<> + eoserial::Entity* makeObject( const eoserial::Printable & arg ) + { + return arg.pack(); + } + + /* + * @brief Implementation of Serialize function. + * + * The idea is the following: + * - either the object implements eoserial::Printable and can be serialized directly with makeObject + * - or it's not, and thus we have to try the registered types. + * + * The difficulty of this function is to be callable with any kind of argument, whatever the type. For that purpose, + * templating is frequently used with default behaviours being erroneous. This way, the compiler can try all + * branches of the conditional and find an implementation of the function that works for the given type. + * This trick is used as the templates functions (and methods) are invariant in C++: if A inherits B, the specialization + * f() is not used when calling with the parameter A. + */ + template + eoserial::Entity* serialize( const T & arg ) + { + // static check (introduced by C++11) + // - avoids the invariant template issue + if( std::is_convertible::value ) + { + // at this point, we are sure that we can cast the argument into an eoserial::Printable. + // reinterpret_cast has to be used, otherwise static_cast and dynamic_cast will fail at compile time for + // basic types. + return eoserial::makeObject( reinterpret_cast(arg) ); + } else { + // not an eoserial::Printable, try registered types + return eoserial::makeSimple( arg ); + } + } + + + /* ***************** + * DESERIALIZATION * + ******************/ + + /** + * @brief Function to be called for non eoserial::Persistent objects. + * + * The default behaviour is to throw a runtime exception. The function is then specialized for known types. + */ + template + void deserializeSimple( const eoserial::Entity* json, T & value ) + { + throw std::runtime_error("eoSerial: deserializeSimple called with an unknown basic type."); + } + + /** + * @brief Function to be called for eoserial::Persistent objects and only these ones. + * + * The default behaviour is to throw a runtime exception. The function is specialized only for eoserial::Persistent + * object. + */ + template + void deserializeObject( const eoserial::Entity* json, T & value ) + { + throw std::runtime_error("eoSerial:: deserializeObject called with a non eoserial::Persistent object."); + } + + /* + * Specializations of deserializeSimple for basic types. + * Macro DSSIMPLE can be used to register any type that can be read from a std::istream. + */ +# define DSSIMPLE(A) template<> \ + void deserializeSimple( const eoserial::Entity* json, A & value ) \ + { \ + static_cast(json)->deserialize( value ); \ + } + + DSSIMPLE(bool); + DSSIMPLE(int); + DSSIMPLE(short); + DSSIMPLE(long); + DSSIMPLE(float); + DSSIMPLE(double); + DSSIMPLE(char); + DSSIMPLE(std::string); +# undef DSSIMPLE // avoids undebuggable surprises + + /** + * @brief Deserialize function with two arguments. + * + * Used by list and vector containers. + */ template void deserializeBase( const eoserial::Entity* json, T & value ); + /** + * @brief Base specialization for objects that implement push_back. + * + * This specialization is used for std::list and std::vector. + */ template< class Container > void deserializeSimplePushBack( const eoserial::Entity* json, Container & c ) { @@ -239,6 +360,23 @@ namespace eoserial deserializeSimplePushBack( json, v ); } + /** + * @brief Specialization of deserializeObject for eoserial::Persistent. + * + * For these objects, we can directly use their unpack method. + */ + template<> + void deserializeObject( const eoserial::Entity* json, eoserial::Persistent & value ) + { + value.unpack( static_cast( json ) ); + } + + /* + * Implementation of deserializeBase. + * + * For technical comments, @see makeSimple. The followed scheme + * is exactly the same. + */ template void deserializeBase( const eoserial::Entity* json, T & value ) { @@ -250,17 +388,11 @@ namespace eoserial } } - template - eoserial::Entity* serialize( const T & arg ) - { - if( std::is_convertible::value ) - { - return eoserial::makeObject( reinterpret_cast(arg) ); - } else { - return eoserial::makeSimple( arg ); - } - } - + /* + * Implementation of deserialize. + * + * Simply calls the deserializeBase function with the corresponding Entity. + */ template void deserialize( const eoserial::Entity& json, const std::string& field, T & value ) { From 9ff8c7e499967c0bf23079f3a6362662ab2bf1a6 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 22 Mar 2013 01:14:18 +0100 Subject: [PATCH 009/419] eoserial: added Serialize by default for eoserial. --- eo/src/serial/eoSerial.h | 1 + 1 file changed, 1 insertion(+) diff --git a/eo/src/serial/eoSerial.h b/eo/src/serial/eoSerial.h index fec5fb4dd..ee3a70c78 100644 --- a/eo/src/serial/eoSerial.h +++ b/eo/src/serial/eoSerial.h @@ -28,5 +28,6 @@ Authors: # include "SerialString.h" # include "Parser.h" # include "Utils.h" +# include "Serialize.h" # endif // __EOSERIAL_HEADERS__ From d2680f986baf7a7382e308a0bd98137b02019d92 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 22 Mar 2013 17:01:12 +0100 Subject: [PATCH 010/419] eoserial: traits for knowing whether a class is derived from another one at compile time. Thanks Herb Sutter --- eo/src/serial/Traits.h | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 eo/src/serial/Traits.h diff --git a/eo/src/serial/Traits.h b/eo/src/serial/Traits.h new file mode 100644 index 000000000..7cce0959e --- /dev/null +++ b/eo/src/serial/Traits.h @@ -0,0 +1,58 @@ +/* +(c) Benjamin Bouvier, 2013 + + 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: + Benjamin Bouvier +*/ +# ifndef __EOSERIAL_TRAITS_H__ +# define __EOSERIAL_TRAITS_H__ + +/** + * @file Traits.h + * + * Traits used for serialization purposes. + * + * @author Benjamin Bouvier + */ + +namespace eoserial +{ + + /** + * @brief Trait to know whether Derived is derived from Base or not. + * + * To know whether A is derived from B, just test the boolean IsDerivedFrom::value. + * + * @see http://www.gotw.ca/publications/mxc++-item-4.htm + */ + template + class IsDerivedFrom + { + struct no{}; + struct yes{ no _[2]; }; + + static yes Test( Base* something ); + static no Test( ... ); + + public: + enum { value = sizeof( Test( static_cast(0) ) ) == sizeof(yes) }; + }; + +} + +# endif // __EOSERIAL_TRAITS_H__ From a98563b1189ec59921ab64335784c1b788f271e9 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 22 Mar 2013 17:05:19 +0100 Subject: [PATCH 011/419] eoserial: removed Serialize.h (something else coming soon...) --- eo/src/serial/Serialize.h | 404 -------------------------------------- eo/src/serial/eoSerial.h | 1 - 2 files changed, 405 deletions(-) delete mode 100644 eo/src/serial/Serialize.h diff --git a/eo/src/serial/Serialize.h b/eo/src/serial/Serialize.h deleted file mode 100644 index b3d5c2c1b..000000000 --- a/eo/src/serial/Serialize.h +++ /dev/null @@ -1,404 +0,0 @@ -/* -(c) Benjamin Bouvier, 2013 - - 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: - Benjamin Bouvier -*/ - -/** - * @file Serialize.h - * - * This file contains primitive to make serialization and - * deserialization easy. - * - * See the example code snippet below. - * - * @code - * # include - * # include - * - * class MyObject: public eoserial::Persistent - * { - * public: - * - * int value; - * MyObject( int v ) : value(v) {} - * - * eoserial::Object* pack() const - * { - * eoserial::Object* e = new eoserial::Object; - * (*e)["the_value"] = eoserial::serialize( value ); - * return e; - * } - * - * void unpack( const eoserial::Object* o ) - * { - * eoserial::deserialize( *o, "the_value", value ); - * } - * }; - * - * int main() - * { - * eoserial::Object o; - * o["long"] = eoserial::serialize(123456L); - * o["bool"] = eoserial::serialize(true); - * o["double"] = eoserial::serialize(3.141592653); - * o["float"] = eoserial::serialize(3.141592653f); - * - * std::string str = "Hello, world!"; - * o["str"] = eoserial::serialize( str ); - * - * MyObject obj(42); - * o["obj"] = eoserial::serialize( obj ); - * - * std::vector vec; - * vec.push_back(1); - * vec.push_back(3); - * vec.push_back(3); - * vec.push_back(7); - * o["vec"] = eoserial::serialize( vec ); - * - * o.print( std::cout ); - * - * std::list lis; - * eoserial::deserialize( o, "vec", lis ); - * - * long oneTwoThreeFourFiveSix; - * eoserial::deserialize( o, "long", oneTwoThreeFourFiveSix); - * - * return 0; - * } - * @endcode - * - * @todo Encapsulate private functions. As of today (2013-03-19), it is not - * possible as GCC and Clang refuse to have std::vector specializations of template methods (while it works with - * functions). - * - * @todo Comments coming soon. - * - * @author Benjamin Bouvier - */ - -# include -# include -# include -# include // std::runtime_error -# include // std::is_convertible (C++11) - -# include "SerialString.h" -# include "SerialObject.h" -# include "SerialArray.h" -# include "Utils.h" - -namespace eoserial -{ - - /** - * @brief Tries to serialize the given argument into an Entity. - * - * This function can be called with any argument of the following kinds: - * - basic types (int, bool, float, double, char, short, long) - * - standard STL types (std::string, std::list, std::vector). In - * this case, the serialization is automatically called on the - * contained objects. - * - objects which implement eoserial::Printable - * - * @param arg The argument to serialize. - * @return an Entity to be used with the serialization module. - * - * @throws std::runtime_exception when the type T is not known or - * not convertible to a known type. - */ - template - eoserial::Entity* serialize( const T & arg ); - - /** - * @brief Tries to deserialize the given argument from the given field in the entity and loads it into the in-out - * given value. - * - * This function is the reverse operator of the serialize function: - * - basic types are supported - * - standard STL types (std::string, std::list, std::vector) - * - objects which implement eoserial::Persistent - * @see serialize - * - * @param json The entity containing the variable to deserialize - * @param field The name of the field used in the original object - * @param value The in-out value in which we want to store the result of the deserialization. - * - * @throws std::runtime_exception when the type T is not known or - * not convertible to a known type. - */ - template - void deserialize( const eoserial::Entity& json, const std::string& field, T & value ); - - /* ************************* - * PRIVATE FUNCTIONS ******* - * Use at your own risk! *** - **************************/ - - /* ************************* - * SERIALIZATION *********** - **************************/ - - /** - * @brief Function to be called for non eoserial::Printable objects. - * - * The default behaviour is to throw a runtime exception. The function is then specialized for known types. - */ - template - eoserial::Entity* makeSimple( const T & arg ) - { - throw std::runtime_error("eoSerial: makeSimple called with an unknown basic type."); - return 0; - } - - /** - * @brief Function to be called for eoserial::Printable objects and only these ones. - * - * The default behaviour is to throw a runtime exception. The function is specialized only for eoserial::Printable - * object. - */ - template - eoserial::Entity* makeObject( const T & arg ) - { - throw std::runtime_error("eoSerial: makeObject called with an non eoserial::Printable type."); - return 0; - } - - /* - * Specializations of makeSimple for basic types. - * Macro MKSIMPLE can be used to register any type that can be printed into a std::ostream. - */ -# define MKSIMPLE(A) template<>\ - eoserial::Entity* makeSimple( const A& arg ) \ - { \ - return eoserial::make(arg); \ - } \ - - MKSIMPLE(bool) - MKSIMPLE(int) - MKSIMPLE(short) - MKSIMPLE(long) - MKSIMPLE(float) - MKSIMPLE(double) - MKSIMPLE(char) - MKSIMPLE(std::string) -# undef MKSIMPLE // avoids undebuggable surprises - - /** - * @brief Base specialization for objects iterable thanks to - * begin(), end() and basic iterators. - * - * This specialization is used for std::list and std::vector. - */ - template - eoserial::Entity* makeSimpleIterable( const Container & c ) - { - eoserial::Array* array = new eoserial::Array; - for( auto it = c.begin(), end = c.end(); - it != end; - ++it ) - { - array->push_back( eoserial::serialize( *it ) ); - } - return array; - } - - template - eoserial::Entity* makeSimple( const std::vector & v ) - { - return makeSimpleIterable( v ); - } - - template - eoserial::Entity* makeSimple( const std::list & l ) - { - return makeSimpleIterable( l ); - } - - /** - * @brief Specialization of makeObject for eoserial::Printable. - * - * For these objects, we can directly use their pack method. - */ - template<> - eoserial::Entity* makeObject( const eoserial::Printable & arg ) - { - return arg.pack(); - } - - /* - * @brief Implementation of Serialize function. - * - * The idea is the following: - * - either the object implements eoserial::Printable and can be serialized directly with makeObject - * - or it's not, and thus we have to try the registered types. - * - * The difficulty of this function is to be callable with any kind of argument, whatever the type. For that purpose, - * templating is frequently used with default behaviours being erroneous. This way, the compiler can try all - * branches of the conditional and find an implementation of the function that works for the given type. - * This trick is used as the templates functions (and methods) are invariant in C++: if A inherits B, the specialization - * f() is not used when calling with the parameter A. - */ - template - eoserial::Entity* serialize( const T & arg ) - { - // static check (introduced by C++11) - // - avoids the invariant template issue - if( std::is_convertible::value ) - { - // at this point, we are sure that we can cast the argument into an eoserial::Printable. - // reinterpret_cast has to be used, otherwise static_cast and dynamic_cast will fail at compile time for - // basic types. - return eoserial::makeObject( reinterpret_cast(arg) ); - } else { - // not an eoserial::Printable, try registered types - return eoserial::makeSimple( arg ); - } - } - - - /* ***************** - * DESERIALIZATION * - ******************/ - - /** - * @brief Function to be called for non eoserial::Persistent objects. - * - * The default behaviour is to throw a runtime exception. The function is then specialized for known types. - */ - template - void deserializeSimple( const eoserial::Entity* json, T & value ) - { - throw std::runtime_error("eoSerial: deserializeSimple called with an unknown basic type."); - } - - /** - * @brief Function to be called for eoserial::Persistent objects and only these ones. - * - * The default behaviour is to throw a runtime exception. The function is specialized only for eoserial::Persistent - * object. - */ - template - void deserializeObject( const eoserial::Entity* json, T & value ) - { - throw std::runtime_error("eoSerial:: deserializeObject called with a non eoserial::Persistent object."); - } - - /* - * Specializations of deserializeSimple for basic types. - * Macro DSSIMPLE can be used to register any type that can be read from a std::istream. - */ -# define DSSIMPLE(A) template<> \ - void deserializeSimple( const eoserial::Entity* json, A & value ) \ - { \ - static_cast(json)->deserialize( value ); \ - } - - DSSIMPLE(bool); - DSSIMPLE(int); - DSSIMPLE(short); - DSSIMPLE(long); - DSSIMPLE(float); - DSSIMPLE(double); - DSSIMPLE(char); - DSSIMPLE(std::string); -# undef DSSIMPLE // avoids undebuggable surprises - - /** - * @brief Deserialize function with two arguments. - * - * Used by list and vector containers. - */ - template - void deserializeBase( const eoserial::Entity* json, T & value ); - - /** - * @brief Base specialization for objects that implement push_back. - * - * This specialization is used for std::list and std::vector. - */ - template< class Container > - void deserializeSimplePushBack( const eoserial::Entity* json, Container & c ) - { - const eoserial::Array* sArray = static_cast(json); - for( auto it = sArray->begin(), end = sArray->end(); - it != end; - ++it ) - { - typename Container::value_type single; - eoserial::deserializeBase( *it, single ); - c.push_back( single ); - } - } - - template< class T > - void deserializeSimple( const eoserial::Entity* json, std::vector & v ) - { - deserializeSimplePushBack( json, v ); - } - - template< class T > - void deserializeSimple( const eoserial::Entity* json, std::list & v ) - { - deserializeSimplePushBack( json, v ); - } - - /** - * @brief Specialization of deserializeObject for eoserial::Persistent. - * - * For these objects, we can directly use their unpack method. - */ - template<> - void deserializeObject( const eoserial::Entity* json, eoserial::Persistent & value ) - { - value.unpack( static_cast( json ) ); - } - - /* - * Implementation of deserializeBase. - * - * For technical comments, @see makeSimple. The followed scheme - * is exactly the same. - */ - template - void deserializeBase( const eoserial::Entity* json, T & value ) - { - if( std::is_convertible< T*, eoserial::Persistent*>::value ) - { - eoserial::deserializeObject( json, reinterpret_cast( value ) ); - } else { - eoserial::deserializeSimple( json, value ); - } - } - - /* - * Implementation of deserialize. - * - * Simply calls the deserializeBase function with the corresponding Entity. - */ - template - void deserialize( const eoserial::Entity& json, const std::string& field, T & value ) - { - const eoserial::Entity* jField = static_cast(json).find(field)->second; - eoserial::deserializeBase( jField, value ); - } -} - - diff --git a/eo/src/serial/eoSerial.h b/eo/src/serial/eoSerial.h index ee3a70c78..fec5fb4dd 100644 --- a/eo/src/serial/eoSerial.h +++ b/eo/src/serial/eoSerial.h @@ -28,6 +28,5 @@ Authors: # include "SerialString.h" # include "Parser.h" # include "Utils.h" -# include "Serialize.h" # endif // __EOSERIAL_HEADERS__ From 5ab91c61392cf42f8d96839013cb7aacd09d3700 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 22 Mar 2013 17:05:42 +0100 Subject: [PATCH 012/419] eoserial: merged former Serialize.h with Utils.h: pack / unpack. --- eo/src/serial/Utils.h | 132 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 130 insertions(+), 2 deletions(-) diff --git a/eo/src/serial/Utils.h b/eo/src/serial/Utils.h index 13b6877b1..8046bb557 100644 --- a/eo/src/serial/Utils.h +++ b/eo/src/serial/Utils.h @@ -26,6 +26,22 @@ Authors: # include "SerialObject.h" # include "SerialString.h" +# include "Traits.h" + +# include + +/** + * @file Utils.h + * + * @brief Contains utilities for simple serialization and deserialization. + * + * @todo comment new version. + * + * @todo encapsulate implementations. + * + * @todo provide more composite implementations (map) + */ + namespace eoserial { /* *************************** @@ -42,11 +58,123 @@ namespace eoserial */ template< class T > - inline void unpack( const Object & obj, const std::string & key, T & value ) + inline void unpackBasePushBack( const Entity* obj, T& container ) { - static_cast( obj.find( key )->second )->deserialize( value ); + const Array* arr = static_cast( obj ); + for( auto it = arr->begin(), end = arr->end(); + it != end; + ++it ) + { + typename T::value_type item; + unpackBase( *it, item ); + container.push_back( item ); + } } + template< class T > + inline void unpackBase( const Entity* obj, std::vector& v ) + { + unpackBasePushBack( obj, v ); + } + + template< class T > + inline void unpackBase( const Entity* obj, std::list& l ) + { + unpackBasePushBack( obj, l ); + } + + template + struct UnpackImpl + { + void operator()( const Entity* obj, T& value ) + { + static_cast( obj )->deserialize( value ); + } + }; + + template + struct UnpackImpl + { + void operator()( const Entity* obj, T& value ) + { + value.unpack( static_cast(obj) ); + } + }; + + template + inline void unpackBase( const Entity* obj, T& value ) + { + UnpackImpl< T, IsDerivedFrom< T, Persistent >::value > impl; + impl( obj, value ); + } + + template + inline void unpack( const Object& obj, const std::string& key, T& value ) + { + unpackBase( obj.find(key)->second, value ); + } + + /* ******************* + * SERIALIZATION ***** + ********************/ + + template + struct PackImpl + { + Entity* operator()( const T& value ) + { + std::stringstream ss; + ss.precision(std::numeric_limits::digits10 + 1); + ss << value; + return new String(ss.str()); + } + }; + + template + struct PackImpl + { + Entity* operator()( const T& value ) + { + return value.pack(); + } + }; + + template + inline Entity* pack( const T& value ); + + template + inline Entity* packIterable( const T& container ) + { + Array* arr = new Array; + for( auto it = container.begin(), end = container.end(); + it != end; + ++it ) + { + arr->push_back( pack(*it) ); + } + return arr; + } + + template + inline Entity* pack( const std::vector& v ) + { + return packIterable( v ); + } + + template + inline Entity* pack( const std::list& l ) + { + return packIterable( l ); + } + + template + inline Entity* pack( const T& value ) + { + PackImpl::value> impl; + return impl( value ); + } + + // Kept for compatibility inline void unpackObject( const Object & obj, const std::string & key, Persistent & value ) { static_cast( obj.find( key )->second )->deserialize( value ); From a9bdf2d51b1e262958f7cd760f430d2010f87651 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 22 Mar 2013 17:46:20 +0100 Subject: [PATCH 013/419] eoserial: comments Utils.h --- eo/src/serial/Utils.h | 95 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 15 deletions(-) diff --git a/eo/src/serial/Utils.h b/eo/src/serial/Utils.h index 8046bb557..323283ccf 100644 --- a/eo/src/serial/Utils.h +++ b/eo/src/serial/Utils.h @@ -35,28 +35,24 @@ Authors: * * @brief Contains utilities for simple serialization and deserialization. * - * @todo comment new version. - * * @todo encapsulate implementations. * * @todo provide more composite implementations (map) + * + * @todo provide example + * + * @author Benjamin Bouvier */ namespace eoserial { - /* *************************** - * DESERIALIZATION FUNCTIONS * - ***************************** - These functions are useful for casting eoserial::objects into simple, primitive - variables or into class instance which implement eoserial::Persistent. - - The model is always quite the same : - - the first argument is the containing object (which is a eoserial::Entity, - an object or an array) - - the second argument is the key or index, - - the last argument is the value in which we're writing. - */ + /* ***************** + * DESERIALIZATION * + ******************/ + /** + * @brief Recursively unpack elements of an object which implements push_back. + */ template< class T > inline void unpackBasePushBack( const Entity* obj, T& container ) { @@ -71,18 +67,30 @@ namespace eoserial } } + /** + * @brief Unpack method for std::vector + */ template< class T > inline void unpackBase( const Entity* obj, std::vector& v ) { unpackBasePushBack( obj, v ); } + /** + * @brief Unpack method for std::list + */ template< class T > inline void unpackBase( const Entity* obj, std::list& l ) { unpackBasePushBack( obj, l ); } + /** + * @brief Unpack implementation for non eoserial::Persistent objects. + * + * This implementation is being used for every objects that can be transmitted + * to a std::ostream (i.e. which implements the operator <<) + */ template struct UnpackImpl { @@ -92,6 +100,9 @@ namespace eoserial } }; + /** + * @brief Unpack implementation for eoserial::Persistent objects. + */ template struct UnpackImpl { @@ -101,6 +112,14 @@ namespace eoserial } }; + /** + * @brief Unpack helper for determining which implementation to use. + * + * The trick comes from Herb Sutter: IsDerivedFrom::value is + * true if and only if T inherits from Persistent. In this case, it's equal + * to 1, thus the partial specialization of UnpackImpl is used. In the other + * case, it's equal to 0 and the generic implementation is used. + */ template inline void unpackBase( const Entity* obj, T& value ) { @@ -108,6 +127,13 @@ namespace eoserial impl( obj, value ); } + /** + * @brief Universal unpack method. + * + * @param obj The eoserial::object containing the value to deserialize. + * @param key Name of the field to deserialize + * @param value The object in which we'll store the deserialized value. + */ template inline void unpack( const Object& obj, const std::string& key, T& value ) { @@ -118,6 +144,12 @@ namespace eoserial * SERIALIZATION ***** ********************/ + /** + * @brief Pack implementation for non eoserial::Printable objects. + * + * This implementation is being used for every objects that can be transmitted + * to a std::istream (i.e. which implements the operator >>) + */ template struct PackImpl { @@ -130,6 +162,9 @@ namespace eoserial } }; + /** + * @brief Pack implementation for eoserial::Printable objects. + */ template struct PackImpl { @@ -139,9 +174,13 @@ namespace eoserial } }; + // Pre declaration for being usable in packIterable. template inline Entity* pack( const T& value ); + /** + * @brief Pack method for iterable (begin, end) objects. + */ template inline Entity* packIterable( const T& container ) { @@ -155,18 +194,32 @@ namespace eoserial return arr; } + /** + * @brief Pack method for std::vector + */ template inline Entity* pack( const std::vector& v ) { return packIterable( v ); } + /** + * @brief Pack method for std::list + */ template inline Entity* pack( const std::list& l ) { return packIterable( l ); } + /** + * @brief Universal pack method. + * + * @see unpackBase to understand the trick with the implementation. + * + * @param value Variable to store into an entity. + * @return An entity to store into an object. + */ template inline Entity* pack( const T& value ) { @@ -174,7 +227,19 @@ namespace eoserial return impl( value ); } - // Kept for compatibility + /** ************** + * OLD FUNCTIONS * + **************** + These functions are useful for casting eoserial::objects into simple, primitive + variables or into class instance which implement eoserial::Persistent. + + The model is always quite the same : + - the first argument is the containing object (which is a eoserial::Entity, + an object or an array) + - the second argument is the key or index, + - the last argument is the value in which we're writing. + + */ inline void unpackObject( const Object & obj, const std::string & key, Persistent & value ) { static_cast( obj.find( key )->second )->deserialize( value ); From 6c148f8ae2c7b49ce1e1567f1f89ca213a207547 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 22 Mar 2013 17:53:50 +0100 Subject: [PATCH 014/419] eoserial: example of using the new-new serialization --- eo/src/serial/Utils.h | 91 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/eo/src/serial/Utils.h b/eo/src/serial/Utils.h index 323283ccf..4d943bf63 100644 --- a/eo/src/serial/Utils.h +++ b/eo/src/serial/Utils.h @@ -39,7 +39,96 @@ Authors: * * @todo provide more composite implementations (map) * - * @todo provide example + * Example + * + * @code +# include +# include +# include + +# include "eoSerial.h" + +struct SimpleObject: public eoserial::Persistent +{ + public: + + SimpleObject( int v ) : value(v) + { + // empty + } + + eoserial::Object* pack() const + { + eoserial::Object* obj = new eoserial::Object; + (*obj)["value"] = eoserial::pack( value ); + return obj; + } + + void unpack( const eoserial::Object* json ) + { + eoserial::unpack( *json, "value", value ); + } + + int value; +}; + +int main() +{ + eoserial::Object o; + + std::cout << "packing..." << std::endl; + // directly pack raw types + o["long"] = eoserial::pack(123456L); + o["bool"] = eoserial::pack(true); + o["double"] = eoserial::pack(3.141592653); + o["float"] = eoserial::pack(3.141592653f); + + std::string str = "Hello, world!"; + o["str"] = eoserial::pack( str ); + + // pack objects the same way + SimpleObject obj(42); + o["obj"] = eoserial::pack( obj ); + + // pack vector and list the same way + std::vector vec; + vec.push_back(1); + vec.push_back(3); + vec.push_back(3); + vec.push_back(7); + o["vec"] = eoserial::pack( vec ); + + // print it + o.print( std::cout ); + + std::cout << "unpacking..." << std::endl; + + // unpack as easily raw types + long oneTwoThreeFourFiveSix = 0L; + eoserial::unpack( o, "long", oneTwoThreeFourFiveSix); + std::cout << "the long: " << oneTwoThreeFourFiveSix << std::endl; + + // since vec is encoded as an internal eoserial::Array, it can be + // decoded into a std::vector or a std::list without difference. + std::list lis; + eoserial::unpack( o, "vec", lis ); + + std::cout << "the list: "; + for( auto it = lis.begin(), end = lis.end(); it != end; ++it) + { + std::cout << *it << ';'; + } + std::cout << std::endl; + + obj.value = -1; + // unpack object the same way + eoserial::unpack( o, "obj", obj ); + std::cout << "obj.value = " << obj.value << std::endl; + + return 0; +} + +@endcode * * @author Benjamin Bouvier */ From 95e4dfc625359100aeae219b11d3d751a6642f8f Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 22 Mar 2013 18:03:36 +0100 Subject: [PATCH 015/419] eoserial: packing and unpacking of map --- eo/src/serial/Utils.h | 44 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/eo/src/serial/Utils.h b/eo/src/serial/Utils.h index 4d943bf63..b6ea360b3 100644 --- a/eo/src/serial/Utils.h +++ b/eo/src/serial/Utils.h @@ -29,6 +29,7 @@ Authors: # include "Traits.h" # include +# include /** * @file Utils.h @@ -37,8 +38,6 @@ Authors: * * @todo encapsulate implementations. * - * @todo provide more composite implementations (map) - * * Example * * @code @@ -98,6 +97,12 @@ int main() vec.push_back(7); o["vec"] = eoserial::pack( vec ); + std::map str2int; + str2int["one"] = 1; + str2int["two"] = 2; + str2int["answer"] = 42; + o["map"] = eoserial::pack( str2int ); + // print it o.print( std::cout ); @@ -120,6 +125,10 @@ int main() } std::cout << std::endl; + std::map< std::string, int > readMap; + eoserial::unpack( o, "map", readMap ); + std::cout << "The answer is " << readMap["answer"] << std::endl; + obj.value = -1; // unpack object the same way eoserial::unpack( o, "obj", obj ); @@ -174,6 +183,21 @@ namespace eoserial unpackBasePushBack( obj, l ); } + /** + * @brief Unpack method for std::map< std::string, T > + */ + template< class T > + inline void unpackBase( const Entity* entity, std::map & m ) + { + const Object* obj = static_cast< const Object* >( entity ); + for( auto it = obj->begin(), end = obj->end(); + it != end; + ++it ) + { + unpackBase( it->second, m[ it->first ] ); + } + } + /** * @brief Unpack implementation for non eoserial::Persistent objects. * @@ -301,6 +325,22 @@ namespace eoserial return packIterable( l ); } + /** + * @brief Pack method for std::map< std::string, T > + */ + template + inline Entity* pack( const std::map& map ) + { + Object* obj = new Object; + for( auto it = map.begin(), end = map.end(); + it != end; + ++it ) + { + (*obj)[ it->first ] = pack( it->second ); + } + return obj; + } + /** * @brief Universal pack method. * From 618c0c4cc474c0119a4ac1aaed66af8fe8146e5e Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 16 Apr 2013 14:32:39 +0200 Subject: [PATCH 016/419] EO -> paradisEO --- archive_current.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archive_current.sh b/archive_current.sh index ff710c59e..d43952087 100755 --- a/archive_current.sh +++ b/archive_current.sh @@ -1,3 +1,3 @@ today=`date --iso-8601` -git archive --format zip master > EO-${today}.zip +git archive --format zip master > paradisEO-${today}.zip From c197e6b28669c70fc4c67cda6750c9d070df68fe Mon Sep 17 00:00:00 2001 From: canape Date: Thu, 18 Apr 2013 08:55:00 +0200 Subject: [PATCH 017/419] BUG GNUPLOT: corrected by Titus Cieslewski --- eo/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eo/CMakeLists.txt b/eo/CMakeLists.txt index 9b6962f2c..9966de557 100644 --- a/eo/CMakeLists.txt +++ b/eo/CMakeLists.txt @@ -21,6 +21,8 @@ endif(ENABLE_OPENMP) if(ENABLE_GNUPLOT) include(FindGnuplot) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_GNUPLOT -DGNUPLOT_PROGRAM=\\\"${GNUPLOT_EXECUTABLE}\\\"") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_GNUPLOT -DGNUPLOT_PROGRAM=\\\"${GNUPLOT_EXECUTABLE}\\\"") endif(ENABLE_GNUPLOT) # set a special flag if the environment is windows (should do the same in a config.g file) From 3067f3f8e4144738ba716001c3e89f39c5aec54c Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 18 Apr 2013 10:11:32 +0200 Subject: [PATCH 018/419] Refactor edoBinomialMulti to allow more complex data structures Refactor distribution, sampler and estimator related to the multi-binomial distribution. This introduce tomic methods which may be overloaded for data structures more complex than eoReal of vector of bool (the default implentation). --- edo/src/edoBinomialMulti.h | 7 +++ edo/src/edoEstimatorBinomialMulti.h | 91 +++++++++++++++++------------ edo/src/edoSamplerBinomialMulti.h | 31 ++++++++-- 3 files changed, 88 insertions(+), 41 deletions(-) diff --git a/edo/src/edoBinomialMulti.h b/edo/src/edoBinomialMulti.h index 2670ddfa3..a2e7bfb0a 100644 --- a/edo/src/edoBinomialMulti.h +++ b/edo/src/edoBinomialMulti.h @@ -49,6 +49,13 @@ public: edoBinomialMulti( T initial_probas ) : T(initial_probas) {} + /** Initialize all the probabilities to a constant + * + * 0.5 by default + */ + edoBinomialMulti( unsigned int rows, unsigned int cols, double proba=0.5 ) + : T::Constant(rows,cols,proba) {} + /** Constructor without any assumption. */ edoBinomialMulti() {} diff --git a/edo/src/edoEstimatorBinomialMulti.h b/edo/src/edoEstimatorBinomialMulti.h index 189d7f973..7fd1a45b2 100644 --- a/edo/src/edoEstimatorBinomialMulti.h +++ b/edo/src/edoEstimatorBinomialMulti.h @@ -41,55 +41,72 @@ Authors: template< class EOT, class D = edoBinomialMulti > class edoEstimatorBinomialMulti : public edoEstimator { - protected: - D eot2d( EOT from, unsigned int rows, unsigned int cols ) // FIXME maybe more elegant with Eigen::Map? - { - assert( rows > 0 ); - assert( from.size() == rows ); - assert( cols > 0 ); +protected: + /** Decide whether a given element of the distribution is true or false. + * + * The default implementation is to set the item to the value of the atom itself + * (which is a boolean in the basic version). + * If you have a more complex data structure, you can just overload this. + */ + virtual void make( D & to, unsigned int i, unsigned int j, typename EOT::AtomType::const_iterator iatom ) + { + to(i,j) = *iatom; + } - D to( Eigen::MatrixXd(rows, cols) ); - for( unsigned int i=0; i < rows; ++i ) { - assert( from[i].size() == cols ); - for( unsigned int j=0; j < cols; ++j ) { - to(i,j) = from[i][j]; - } + /** Transliterate a EOT in a boolean matrix + */ + D eot2d( const EOT & from, unsigned int rows, unsigned int cols ) // FIXME maybe more elegant with Eigen::Map? + { + assert( rows > 0 ); + assert( from.size() == rows ); + assert( cols > 0 ); + + D to( Eigen::MatrixXd(rows, cols) ); + unsigned int i=0; + for( typename EOT::const_iterator irow = from.begin(), end=from.end(); irow != end; ++irow ) { + assert( irow->size() == cols ); + unsigned int j=0; + for( typename EOT::AtomType::const_iterator icol = irow->begin(), end=irow->end(); icol != end; ++icol ) { + make( to, i, j, icol ); + j++; } - - return to; + i++; } - public: - /** The expected EOT interface is the same as an Eigen3::MatrixXd. - */ - D operator()( eoPop& pop ) - { - unsigned int popsize = pop.size(); - assert(popsize > 0); + return to; + } - unsigned int rows = pop[0].size(); - assert( rows > 0 ); - unsigned int cols = pop[0][0].size(); - assert( cols > 0 ); +public: + /** The expected EOT interface is the same as an Eigen3::MatrixXd. + */ + D operator()( eoPop& pop ) + { + unsigned int popsize = pop.size(); + assert(popsize > 0); - D probas( D::Zero(rows, cols) ); + unsigned int rows = pop.begin()->size(); + assert( rows > 0 ); + unsigned int cols = pop.begin()->begin()->size(); + assert( cols > 0 ); - // We still need a loop over pop, because it is an eoVector - for (unsigned int i = 0; i < popsize; ++i) { - D indiv = eot2d( pop[i], rows, cols ); - assert( indiv.rows() == rows && indiv.cols() == cols ); + D probas( D::Zero(rows, cols) ); - // the EOT matrix should be filled with 1 or 0 only - assert( indiv.sum() <= popsize ); + // We still need a loop over pop, because it is an eoVector + for (unsigned int i = 0; i < popsize; ++i) { + D indiv = eot2d( pop[i], rows, cols ); + assert( indiv.rows() == rows && indiv.cols() == cols ); - probas += indiv / popsize; + // the EOT matrix should be filled with 1 or 0 only + assert( indiv.sum() <= popsize ); - // sum and scalar product, no size pb expected - assert( probas.rows() == rows && probas.cols() == cols ); - } + probas += indiv / popsize; - return probas; + // sum and scalar product, no size pb expected + assert( probas.rows() == rows && probas.cols() == cols ); } + + return probas; + } }; #endif // WITH_EIGEN diff --git a/edo/src/edoSamplerBinomialMulti.h b/edo/src/edoSamplerBinomialMulti.h index f0e73d699..732cdbed5 100644 --- a/edo/src/edoSamplerBinomialMulti.h +++ b/edo/src/edoSamplerBinomialMulti.h @@ -44,6 +44,24 @@ template< class EOT, class D = edoBinomialMulti > class edoSamplerBinomialMulti : public edoSampler { public: + typedef typename EOT::AtomType AtomType; + + /** Called if the sampler draw the item at (i,j) + * + * The default implementation is to push back a true boolean. + * If you have a more complex data structure, you can just overload this. + */ + virtual void make_true( AtomType & atom, unsigned int i, unsigned int j ) + { + atom.push_back( 1 ); + } + + /** @see make_true */ + virtual void make_false( AtomType & atom, unsigned int i, unsigned int j ) + { + atom.push_back( 0 ); + } + EOT sample( D& distrib ) { unsigned int rows = distrib.rows(); @@ -52,17 +70,22 @@ public: assert(cols > 0); // The point we want to draw - // x = {x1, x2, ..., xn} + // X = {x1, x2, ..., xn} + // with xn a container of booleans EOT solution; // Sampling all dimensions for( unsigned int i = 0; i < rows; ++i ) { - typename EOT::AtomType vec; + AtomType atom; for( unsigned int j = 0; j < cols; ++j ) { // Toss a coin, biased by the proba of being 1. - vec.push_back( rng.flip( distrib(i,j) ) ); + if( rng.flip( distrib(i,j) ) ) { + make_true( atom, i, j ); + } else { + make_false( atom, i, j ); + } } - solution.push_back( vec ); + solution.push_back( atom ); } return solution; From c6f7707c05cb4d1f5aa103ebb0f52b9fb0362b40 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 19 Apr 2013 09:46:58 +0200 Subject: [PATCH 019/419] buildfix: expand Eigen include dir in cmake --- edo/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edo/CMakeLists.txt b/edo/CMakeLists.txt index 1c721097d..50424db45 100644 --- a/edo/CMakeLists.txt +++ b/edo/CMakeLists.txt @@ -10,7 +10,7 @@ if(EDO_USE_LIB STREQUAL "uBLAS") elseif(EDO_USE_LIB STREQUAL "Eigen3") find_package(Eigen3) if(EIGEN3_FOUND) - include_directories(EIGEN3_INCLUDE_DIR) + include_directories( ${EIGEN3_INCLUDE_DIR} ) add_definitions( -DWITH_EIGEN ) else() message(FATAL_ERROR "\n\nERROR: You asked for Eigen3 but it has not been found.\n" ) From 768b08c8d7fd362db11d51835e128617bdd2effb Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Mon, 29 Apr 2013 16:03:58 +0200 Subject: [PATCH 020/419] Remove the DEBUG option of CMake, that was overriding CMAKE_BUILD_TYPE CMAKE_BUILD_TYPE is the expected way of specifying a Debug/Release build. --- cmake/Config.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index c0576397f..8b08ff1c0 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -31,11 +31,11 @@ endif() ### 0) Define general CXX flags for DEBUG and RELEASE ###################################################################################### -if(DEBUG) - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE) -else(DEBUG) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) -endif(DEBUG) +#if(DEBUG) +# set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE) +#else(DEBUG) +# set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) +#endif(DEBUG) add_definitions(-DDEPRECATED_MESSAGES) set(CMAKE_CXX_FLAGS_DEBUG "-Wunknown-pragmas -O0 -g -Wall -Wextra -ansi -pedantic" CACHE STRING "" FORCE) From 74a92bfd6b2b8d426ba77c2b429fbb697c968367 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Mon, 29 Apr 2013 16:05:28 +0200 Subject: [PATCH 021/419] Include edoTrasform in --- edo/src/edo | 2 ++ 1 file changed, 2 insertions(+) diff --git a/edo/src/edo b/edo/src/edo index 816ad4211..1668a2ee2 100644 --- a/edo/src/edo +++ b/edo/src/edo @@ -88,6 +88,8 @@ Authors: #include "utils/edoFileSnapshot.h" #include "utils/edoPopStat.h" +#include "edoTransform.h" + #endif // !_edo_ // Local Variables: From 7a4bc3e6d31b3006d90f1611948779a61a5eba9e Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 30 Apr 2013 11:45:28 +0200 Subject: [PATCH 022/419] eoRealInterval better error handling Replace a logic exception in eoRealInterval by an assert. Add a warning in debug mode when the range is null. --- eo/src/utils/eoRealBounds.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/eo/src/utils/eoRealBounds.h b/eo/src/utils/eoRealBounds.h index 47c061005..a41646d47 100644 --- a/eo/src/utils/eoRealBounds.h +++ b/eo/src/utils/eoRealBounds.h @@ -27,6 +27,7 @@ #ifndef _eoRealBounds_h #define _eoRealBounds_h +#include #include // std::exceptions! #include @@ -226,10 +227,14 @@ public : */ eoRealInterval(double _min=0, double _max=1) : repMinimum(_min), repMaximum(_max), repRange(_max-_min) - { - if (repRange<=0) - throw std::logic_error("Void range in eoRealBounds"); - } + { + assert( repRange >= 0 ); +#ifndef NDEBUG + if( repRange == 0 ) { + eo::log << eo::warnings << "Null range in eoRealBounds (min=" << _min << ", max=" << _max << ")" << std::endl; + } +#endif + } // accessors virtual double minimum() const { return repMinimum; } From 379f71f2883a8c93cec20f11a29ac9155e7a2c4c Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 30 Apr 2013 11:48:34 +0200 Subject: [PATCH 023/419] bugfix: call mother constructor of moeoHypervolumeBinaryMetric Thus the default bounds are initialized. --- moeo/src/metric/moeoHypervolumeBinaryMetric.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moeo/src/metric/moeoHypervolumeBinaryMetric.h b/moeo/src/metric/moeoHypervolumeBinaryMetric.h index d2e61cbf0..a9f3bfe8d 100644 --- a/moeo/src/metric/moeoHypervolumeBinaryMetric.h +++ b/moeo/src/metric/moeoHypervolumeBinaryMetric.h @@ -59,7 +59,7 @@ class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinar * Ctor * @param _rho value used to compute the reference point from the worst values for each objective (default : 1.1) */ - moeoHypervolumeBinaryMetric(double _rho = 1.1) : rho(_rho) + moeoHypervolumeBinaryMetric(double _rho = 1.1) : moeoNormalizedSolutionVsSolutionBinaryMetric(), rho(_rho) { // not-a-maximization problem check for (unsigned int i=0; i Date: Tue, 30 Apr 2013 11:49:24 +0200 Subject: [PATCH 024/419] Add a warning in moeoHyperVolumeUnaryMetric if set size == 1 --- .../metric/moeoHyperVolumeDifferenceMetric.h | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h index 3e222e21b..906923b98 100644 --- a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h +++ b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h @@ -136,27 +136,36 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < * @param _set1 the vector contains all objective Vector of the first pareto front * @param _set2 the vector contains all objective Vector of the second pareto front */ - void setup(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2){ - if(_set1.size() < 1 || _set2.size() < 1) - throw("Error in moeoHyperVolumeUnaryMetric::setup -> argument1: vector size must be greater than 0"); - else{ - double min, max; - unsigned int nbObj=ObjectiveVector::Traits::nObjectives(); - bounds.resize(nbObj); - for (unsigned int i=0; i & _set1, const std::vector < ObjectiveVector > & _set2) + { + if(_set1.size() < 1 || _set2.size() < 1) { + throw("Error in moeoHyperVolumeUnaryMetric::setup -> argument1: vector size must be greater than 0"); + } else { +#ifndef NDEBUG + if( _set1.size() == 1 || _set2.size() == 1 ) { + eo::log << eo::warnings << "Warning in moeoHyperVolumeUnaryMetric::setup one of the pareto set contains only one point (set1.size=" + << _set1.size() << ", set2.size=" << _set2.size() << ")" + << std::endl; + } +#endif + + double min, max; + unsigned int nbObj=ObjectiveVector::Traits::nObjectives(); + bounds.resize(nbObj); + for (unsigned int i=0; i Date: Tue, 30 Apr 2013 15:56:24 +0200 Subject: [PATCH 025/419] bugfix: include nessary headers for eoRealBounds --- eo/src/utils/eoRealBounds.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eo/src/utils/eoRealBounds.h b/eo/src/utils/eoRealBounds.h index a41646d47..9d046be1a 100644 --- a/eo/src/utils/eoRealBounds.h +++ b/eo/src/utils/eoRealBounds.h @@ -27,9 +27,12 @@ #ifndef _eoRealBounds_h #define _eoRealBounds_h +#include #include #include // std::exceptions! + #include +#include "eoLogger.h" /** \defgroup Real Vector of reals From 6e56f634c37af521e9c7f215204a3a2e01bc239b Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 30 Apr 2013 15:56:54 +0200 Subject: [PATCH 026/419] use a sub-directory in the zip archive --- archive_current.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/archive_current.sh b/archive_current.sh index d43952087..3ba2d2bc2 100755 --- a/archive_current.sh +++ b/archive_current.sh @@ -1,3 +1,5 @@ today=`date --iso-8601` -git archive --format zip master > paradisEO-${today}.zip +name=paradiseo_$today +git archive --prefix=$name/ --format zip master > $name.zip +echo $name.zip From defb8382bf00a7502f1e427f4099467a25681d24 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 30 Apr 2013 16:05:29 +0200 Subject: [PATCH 027/419] Explicit iterator instead of auto, for old C++ compat --- eo/src/serial/Utils.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eo/src/serial/Utils.h b/eo/src/serial/Utils.h index b6ea360b3..5acc558ba 100644 --- a/eo/src/serial/Utils.h +++ b/eo/src/serial/Utils.h @@ -155,7 +155,7 @@ namespace eoserial inline void unpackBasePushBack( const Entity* obj, T& container ) { const Array* arr = static_cast( obj ); - for( auto it = arr->begin(), end = arr->end(); + for( Array::const_iterator it = arr->begin(), end = arr->end(); it != end; ++it ) { @@ -190,7 +190,7 @@ namespace eoserial inline void unpackBase( const Entity* entity, std::map & m ) { const Object* obj = static_cast< const Object* >( entity ); - for( auto it = obj->begin(), end = obj->end(); + for( Object::const_iterator it = obj->begin(), end = obj->end(); it != end; ++it ) { @@ -298,7 +298,7 @@ namespace eoserial inline Entity* packIterable( const T& container ) { Array* arr = new Array; - for( auto it = container.begin(), end = container.end(); + for( Array::const_iterator it = container.begin(), end = container.end(); it != end; ++it ) { @@ -332,7 +332,7 @@ namespace eoserial inline Entity* pack( const std::map& map ) { Object* obj = new Object; - for( auto it = map.begin(), end = map.end(); + for( Object::const_iterator it = map.begin(), end = map.end(); it != end; ++it ) { From bc544cc4a4bafaa06bb02b9e700519ab2731dfb7 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sat, 25 May 2013 17:21:08 +0200 Subject: [PATCH 028/419] buildfix: do not always build release Remove a test that was building Release if DEBUG was not set. The correct way to specify build is to use CMAKE_BUILD_TYPE. --- cmake/Config.cmake | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index c0576397f..55e1b7c41 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -31,12 +31,6 @@ endif() ### 0) Define general CXX flags for DEBUG and RELEASE ###################################################################################### -if(DEBUG) - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE) -else(DEBUG) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) -endif(DEBUG) - add_definitions(-DDEPRECATED_MESSAGES) set(CMAKE_CXX_FLAGS_DEBUG "-Wunknown-pragmas -O0 -g -Wall -Wextra -ansi -pedantic" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_RELEASE "-Wunknown-pragmas -O2" CACHE STRING "" FORCE) From 97e1da3e4a1fa32e6ec81143be0009ad30278de1 Mon Sep 17 00:00:00 2001 From: quemy Date: Fri, 31 May 2013 00:10:47 +0200 Subject: [PATCH 029/419] Fix build for SMP --- cmake/Config.cmake | 1 + smp/src/island.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 55e1b7c41..02593bac3 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -36,6 +36,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "-Wunknown-pragmas -O0 -g -Wall -Wextra -ansi -pedant set(CMAKE_CXX_FLAGS_RELEASE "-Wunknown-pragmas -O2" CACHE STRING "" FORCE) if(SMP) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -pthread" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -pthread" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -pthread" CACHE STRING "" FORCE) add_definitions(-D_GLIBCXX_USE_NANOSLEEP) diff --git a/smp/src/island.h b/smp/src/island.h index 9e8e30edd..752b671ef 100644 --- a/smp/src/island.h +++ b/smp/src/island.h @@ -132,7 +132,7 @@ public: */ virtual void receive(void); - AIsland clone() const; + //AIsland clone() const; protected: From effaa56cfd1de9a799a38d54e6b6b22af4f5bbbc Mon Sep 17 00:00:00 2001 From: liefooga Date: Fri, 31 May 2013 16:13:45 +0200 Subject: [PATCH 030/419] special two-objective case of dominance depth ranking in O(n log n) --- .../moeoDominanceDepthFitnessAssignment.h | 350 +++++++++++------- 1 file changed, 209 insertions(+), 141 deletions(-) diff --git a/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h b/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h index 345048c2c..b07b6b7a1 100644 --- a/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h +++ b/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h @@ -1,38 +1,38 @@ /* -* -* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 -* (C) OPAC Team, LIFL, 2002-2008 -* -* Arnaud Liefooghe -* -* This software is governed by the CeCILL license under French law and -* abiding by the rules of distribution of free software. You can use, -* 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". -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited liability. -* -* 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 -* -*/ + * + * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 + * (C) OPAC Team, LIFL, 2002-2008 + * + * Arnaud Liefooghe + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * 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". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited liability. + * + * 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 MOEODOMINANCEDEPTHFITNESSASSIGNMENT_H_ @@ -44,7 +44,7 @@ #include #include #include - +#include /** * Fitness assignment sheme based on Pareto-dominance count proposed in: @@ -55,69 +55,69 @@ */ template < class MOEOT > class moeoDominanceDepthFitnessAssignment : public moeoDominanceBasedFitnessAssignment < MOEOT > - { - public: - +{ +public: + /** the objective vector type of the solutions */ typedef typename MOEOT::ObjectiveVector ObjectiveVector; - - + + /** * Default ctor */ - moeoDominanceDepthFitnessAssignment() : comparator(paretoComparator) + moeoDominanceDepthFitnessAssignment(bool _rm_equiv_flag_in_2D = false) : comparator(paretoComparator), rm_equiv_flag_in_2D(_rm_equiv_flag_in_2D) {} - - + + /** * Ctor where you can choose your own way to compare objective vectors * @param _comparator the functor used to compare objective vectors */ - moeoDominanceDepthFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator) : comparator(_comparator) + moeoDominanceDepthFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _rm_equiv_flag_in_2D = true) : comparator(_comparator), rm_equiv_flag_in_2D(_rm_equiv_flag_in_2D) {} - - + + /** * Sets the fitness values for every solution contained in the population _pop * @param _pop the population */ void operator()(eoPop < MOEOT > & _pop) { - // number of objectives for the problem under consideration - unsigned int nObjectives = MOEOT::ObjectiveVector::nObjectives(); - if (nObjectives == 1) + // number of objectives for the problem under consideration + unsigned int nObjectives = MOEOT::ObjectiveVector::nObjectives(); + if (nObjectives == 1) { - // one objective - oneObjective(_pop); + // one objective + oneObjective(_pop); } - else if (nObjectives == 2) + else if (nObjectives == 2) { - // two objectives (the two objectives function is still to implement) - mObjectives(_pop); + // two objectives + twoObjectives(_pop); } - else if (nObjectives > 2) + else if (nObjectives > 2) { - // more than two objectives - mObjectives(_pop); + // more than two objectives + mObjectives(_pop); } - else + else { - // problem with the number of objectives - throw std::runtime_error("Problem with the number of objectives in moeoDominanceDepthFitnessAssignment"); + // problem with the number of objectives + throw std::runtime_error("Problem with the number of objectives in moeoDominanceDepthFitnessAssignment"); } - // a higher fitness is better, so the values need to be inverted - double max = _pop[0].fitness(); - for (unsigned int i=1 ; i<_pop.size() ; i++) + // a higher fitness is better, so the values need to be inverted + double max = _pop[0].fitness(); + for (unsigned int i=1 ; i<_pop.size() ; i++) { - max = std::max(max, _pop[i].fitness()); + max = std::max(max, _pop[i].fitness()); } - for (unsigned int i=0 ; i<_pop.size() ; i++) + for (unsigned int i=0 ; i<_pop.size() ; i++) { - _pop[i].fitness(max - _pop[i].fitness()); + _pop[i].fitness(max - _pop[i].fitness()); } } - - + + /** * Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account. * @param _pop the population @@ -125,141 +125,209 @@ class moeoDominanceDepthFitnessAssignment : public moeoDominanceBasedFitnessAssi */ void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) { - for (unsigned int i=0; i<_pop.size(); i++) + for (unsigned int i=0; i<_pop.size(); i++) { - // if _pop[i] is dominated by _objVec - if ( comparator(_pop[i].objectiveVector(), _objVec) ) + // if _pop[i] is dominated by _objVec + if ( comparator(_pop[i].objectiveVector(), _objVec) ) { - _pop[i].fitness(_pop[i].fitness()+1); + _pop[i].fitness(_pop[i].fitness()+1); } } } - - - private: - + + +private: + /** Functor to compare two objective vectors */ moeoObjectiveVectorComparator < ObjectiveVector > & comparator; /** Functor to compare two objective vectors according to Pareto dominance relation */ moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; + /** flag to remove equivament solutions */ + bool rm_equiv_flag_in_2D; /** Functor allowing to compare two solutions according to their first objective value, then their second, and so on. */ - class ObjectiveComparator : public moeoComparator < MOEOT > - { - public: + class ObjectiveComparator : public moeoComparator < MOEOT > + { + public: /** - * Returns true if _moeo1 < _moeo2 on the first objective, then on the second, and so on + * Returns true if _moeo1 > _moeo2 on the first objective, then on the second, and so on * @param _moeo1 the first solution * @param _moeo2 the second solution */ bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) { - return cmp(_moeo1.objectiveVector(), _moeo2.objectiveVector()); + return cmp(_moeo2.objectiveVector(), _moeo1.objectiveVector()); } - private: + private: /** the corresponding comparator for objective vectors */ moeoObjectiveObjectiveVectorComparator < ObjectiveVector > cmp; - } + } objComparator; - - + + /** * Sets the fitness values for mono-objective problems * @param _pop the population */ void oneObjective (eoPop < MOEOT > & _pop) { - // sorts the population in the ascending order - std::sort(_pop.begin(), _pop.end(), objComparator); - // assign fitness values - unsigned int rank = 1; - _pop[_pop.size()-1].fitness(rank); - for (int i=_pop.size()-2; i>=0; i--) + // sorts the population in the ascending order + std::sort(_pop.begin(), _pop.end(), objComparator); + // assign fitness values + unsigned int rank = 1; + _pop[0].fitness(rank); + for (unsigned int i=1; i<_pop.size(); i++) { - if (_pop[i].objectiveVector() != _pop[i+1].objectiveVector()) + if (_pop[i].objectiveVector() != _pop[i-1].objectiveVector()) { - rank++; + rank++; } - _pop[i].fitness(rank); + _pop[i].fitness(rank); } } - - + + /** * Sets the fitness values for bi-objective problems with a complexity of O(n log n), where n stands for the population size * @param _pop the population */ void twoObjectives (eoPop < MOEOT > & _pop) { - //... TO DO ! + double value_obj1; + unsigned int front; + unsigned int last_front = 0; + bool equiv_flag; + + // sort pointers to pop's individuals with respect to the first objective (0) in the reverse order + std::vector sortedptrpop; + sortedptrpop.resize(_pop.size()); + for(unsigned int i=0; i<_pop.size(); i++) + { + sortedptrpop[i] = & (_pop[i]); + } + moeoPtrComparator cmp(objComparator); + std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp); + + // compute an upper bound on the second objective (1) + double max_obj1 = std::numeric_limits::min(); + for(unsigned int i=0; i<_pop.size(); i++) + { + max_obj1 = std::max(max_obj1, _pop[i].objectiveVector()[1]); + } + max_obj1 += 1.0; + + // initialize a vector with the max_obj1 value everywhere + std::vector d(_pop.size(), max_obj1); + // initialize fronts + std::vector > fronts(_pop.size()); + // compute rank for each individual + for(unsigned int i=0; i0) + { + if ( (rm_equiv_flag_in_2D) && (sortedptrpop[i]->objectiveVector() == sortedptrpop[i-1]->objectiveVector()) ) + { + equiv_flag = true; + fronts.back().push_back(i); + } + } + if (!equiv_flag) + { + // the value of the second objective for the current solutions + value_obj1 = sortedptrpop[i]->objectiveVector()[1]; + // if we maximize, take the opposite value + if (MOEOT::ObjectiveVector::maximizing(1)) + value_obj1 = max_obj1 - value_obj1; + // perform binary search (log n) + std::vector::iterator it = std::upper_bound(d.begin(), d.begin() + last_front, value_obj1); + // retrieve the corresponding front + front = (unsigned int)(it - d.begin()); + if (front == last_front) + last_front++; + // update + *it = value_obj1; + // add the solution to the corresponding front + fronts[front].push_back(i); + } + } + // assign the fitness value (rank) to each individual + for (unsigned int i=0; ifitness(i+1); + } + } } - - + + /** * Sets the fitness values for problems with more than two objectives with a complexity of O(n² log n), where n stands for the population size * @param _pop the population */ void mObjectives (eoPop < MOEOT > & _pop) { - // S[i] = indexes of the individuals dominated by _pop[i] - std::vector < std::vector > S(_pop.size()); - // n[i] = number of individuals that dominate the individual _pop[i] - std::vector < unsigned int > n(_pop.size(), 0); - // fronts: F[i] = indexes of the individuals contained in the ith front - std::vector < std::vector > F(_pop.size()+2); - // used to store the number of the first front - F[1].reserve(_pop.size()); - for (unsigned int p=0; p<_pop.size(); p++) + // S[i] = indexes of the individuals dominated by _pop[i] + std::vector < std::vector > S(_pop.size()); + // n[i] = number of individuals that dominate the individual _pop[i] + std::vector < unsigned int > n(_pop.size(), 0); + // fronts: F[i] = indexes of the individuals contained in the ith front + std::vector < std::vector > F(_pop.size()+2); + // used to store the number of the first front + F[1].reserve(_pop.size()); + for (unsigned int p=0; p<_pop.size(); p++) { - for (unsigned int q=0; q<_pop.size(); q++) + for (unsigned int q=0; q<_pop.size(); q++) { - // if q is dominated by p - if ( comparator(_pop[q].objectiveVector(), _pop[p].objectiveVector()) ) + // if q is dominated by p + if ( comparator(_pop[q].objectiveVector(), _pop[p].objectiveVector()) ) { - // add q to the set of solutions dominated by p - S[p].push_back(q); + // add q to the set of solutions dominated by p + S[p].push_back(q); } - // if p is dominated by q - else if ( comparator(_pop[p].objectiveVector(), _pop[q].objectiveVector()) ) + // if p is dominated by q + else if ( comparator(_pop[p].objectiveVector(), _pop[q].objectiveVector()) ) { - // increment the domination counter of p - n[p]++; + // increment the domination counter of p + n[p]++; } } - // if no individual dominates p - if (n[p] == 0) + // if no individual dominates p + if (n[p] == 0) { - // p belongs to the first front - _pop[p].fitness(1); - F[1].push_back(p); + // p belongs to the first front + _pop[p].fitness(1); + F[1].push_back(p); } } - // front counter - unsigned int counter=1; - unsigned int p,q; - while (! F[counter].empty()) + // front counter + unsigned int counter=1; + unsigned int p,q; + while (! F[counter].empty()) { - // used to store the number of the next front - F[counter+1].reserve(_pop.size()); - for (unsigned int i=0; i Date: Thu, 6 Jun 2013 11:43:34 +0200 Subject: [PATCH 031/419] bugfix: do not allow null interval in hypervolume diff metric --- eo/src/utils/eoRealBounds.h | 2 +- .../metric/moeoHyperVolumeDifferenceMetric.h | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/eo/src/utils/eoRealBounds.h b/eo/src/utils/eoRealBounds.h index 9d046be1a..8d55d793a 100644 --- a/eo/src/utils/eoRealBounds.h +++ b/eo/src/utils/eoRealBounds.h @@ -234,7 +234,7 @@ public : assert( repRange >= 0 ); #ifndef NDEBUG if( repRange == 0 ) { - eo::log << eo::warnings << "Null range in eoRealBounds (min=" << _min << ", max=" << _max << ")" << std::endl; + eo::log << eo::warnings << "Warning: null range in eoRealBounds (min=" << _min << ", max=" << _max << ")" << std::endl; } #endif } diff --git a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h index 906923b98..533d29296 100644 --- a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h +++ b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h @@ -163,12 +163,26 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < min = std::min(min, _set2[j][i]); max = std::max(max, _set2[j][i]); } - bounds[i] = eoRealInterval(min, max); + if( min == max ) { + bounds[i] = eoRealInterval(min-tiny(), max+tiny()); + } else { + bounds[i] = eoRealInterval(min, max); + } } } } - private: + protected: + + /** + * Returns a very small value that can be used to avoid extreme cases (where the min bound == the max bound) + */ + static double tiny() + { + return 1e-6; + } + + private: /*boolean indicates if data must be normalized or not*/ bool normalize; From 9aec7780dcf52033a4101e16516403bc3730d2b3 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 7 Jun 2013 11:21:02 +0200 Subject: [PATCH 032/419] Add moeoScalarObjectiveVector, a generic OV with templatized atomic type Because sometime, we may want to use something else than a double (for example an eoDualFitness, a complex or whatever). --- moeo/src/core/moeoScalarObjectiveVector.h | 179 ++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 moeo/src/core/moeoScalarObjectiveVector.h diff --git a/moeo/src/core/moeoScalarObjectiveVector.h b/moeo/src/core/moeoScalarObjectiveVector.h new file mode 100644 index 000000000..0f33812c3 --- /dev/null +++ b/moeo/src/core/moeoScalarObjectiveVector.h @@ -0,0 +1,179 @@ +/* + +(c) 2010 Thales group + + 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 + +*/ + + +#ifndef MOEOSCALAROBJECTIVEVECTOR_H_ +#define MOEOSCALAROBJECTIVEVECTOR_H_ + +#include +#include +#include +#include +#include + +/** + * This class allows to represent a solution in the objective space (phenotypic representation) by a std::vector of typed values, + * i.e. that an objective value is represented using a T, and this for any objective. + */ +template < class ObjectiveVectorTraits, class T > +class moeoScalarObjectiveVector : public moeoObjectiveVector < ObjectiveVectorTraits, T > +{ + public: + + using moeoObjectiveVector < ObjectiveVectorTraits, T >::size; + using moeoObjectiveVector < ObjectiveVectorTraits, T >::operator[]; + + /** + * Ctor + */ + moeoScalarObjectiveVector(T _value = 0.0) : moeoObjectiveVector < ObjectiveVectorTraits, T > (_value) + {} + + + /** + * Ctor from a vector of Ts + * @param _v the std::vector < T > + */ + moeoScalarObjectiveVector(std::vector < T > & _v) : moeoObjectiveVector < ObjectiveVectorTraits, T > (_v) + {} + + + /** + * Returns true if the current objective vector dominates _other according to the Pareto dominance relation + * (but it's better to use a moeoObjectiveVectorComparator object to compare solutions) + * @param _other the other moeoScalarObjectiveVector object to compare with + */ + bool dominates(const moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _other) const + { + moeoParetoObjectiveVectorComparator < moeoScalarObjectiveVector > comparator; + return comparator(_other, *this); + } + + + /** + * Returns true if the current objective vector is equal to _other (according to a tolerance value) + * @param _other the other moeoScalarObjectiveVector object to compare with + */ + bool operator==(const moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _other) const + { + for (unsigned int i=0; i < size(); i++) + { + if ( fabs(operator[](i) - _other[i]) > ObjectiveVectorTraits::tolerance() ) + { + return false; + } + } + return true; + } + + + /** + * Returns true if the current objective vector is different than _other (according to a tolerance value) + * @param _other the other moeoScalarObjectiveVector object to compare with + */ + bool operator!=(const moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _other) const + { + return ! operator==(_other); + } + + + /** + * Returns true if the current objective vector is smaller than _other on the first objective, then on the second, and so on + * (can be usefull for sorting/printing) + * @param _other the other moeoScalarObjectiveVector object to compare with + */ + bool operator<(const moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _other) const + { + moeoObjectiveObjectiveVectorComparator < moeoScalarObjectiveVector < ObjectiveVectorTraits, T > > cmp; + return cmp(*this, _other); + } + + + /** + * Returns true if the current objective vector is greater than _other on the first objective, then on the second, and so on + * (can be usefull for sorting/printing) + * @param _other the other moeoScalarObjectiveVector object to compare with + */ + bool operator>(const moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _other) const + { + return _other < *this; + } + + + /** + * Returns true if the current objective vector is smaller than or equal to _other on the first objective, then on the second, and so on + * (can be usefull for sorting/printing) + * @param _other the other moeoScalarObjectiveVector object to compare with + */ + bool operator<=(const moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _other) const + { + return operator==(_other) || operator<(_other); + } + + + /** + * Returns true if the current objective vector is greater than or equal to _other on the first objective, then on the second, and so on + * (can be usefull for sorting/printing) + * @param _other the other moeoScalarObjectiveVector object to compare with + */ + bool operator>=(const moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _other) const + { + return operator==(_other) || operator>(_other); + } + +}; + + +/** + * Output for a moeoScalarObjectiveVector object + * @param _os output stream + * @param _objectiveVector the objective vector to write + */ +template < class ObjectiveVectorTraits > +std::ostream & operator<<(std::ostream & _os, const moeoScalarObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) +{ + for (unsigned int i=0; i<_objectiveVector.size()-1; i++) + _os << _objectiveVector[i] << " "; + _os << _objectiveVector[_objectiveVector.size()-1]; + return _os; +} + +/** + * Input for a moeoScalarObjectiveVector object + * @param _is input stream + * @param _objectiveVector the objective vector to read + */ +template < class ObjectiveVectorTraits > +std::istream & operator>>(std::istream & _is, moeoScalarObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) +{ + _objectiveVector = moeoScalarObjectiveVector < ObjectiveVectorTraits > (); + for (unsigned int i=0; i<_objectiveVector.size(); i++) + { + _is >> _objectiveVector[i]; + } + return _is; +} + +#endif /*MOEOSCALAROBJECTIVEVECTOR_H_*/ From 54e181d4603274f8b61e11c4d51c9183993504b2 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 7 Jun 2013 11:22:26 +0200 Subject: [PATCH 033/419] Use generic objective vector atomic type in HV continuator One should not use specific OV types in continuators, but get it from ObjectiveVector::Type instead. --- moeo/src/continue/moeoHypContinue.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/moeo/src/continue/moeoHypContinue.h b/moeo/src/continue/moeoHypContinue.h index 4e656bf69..9ecc5424e 100644 --- a/moeo/src/continue/moeoHypContinue.h +++ b/moeo/src/continue/moeoHypContinue.h @@ -56,15 +56,16 @@ class moeoHypContinue: public eoContinue public: typedef typename MOEOT::ObjectiveVector ObjectiveVector; + typedef typename ObjectiveVector::Type AtomType; /// Ctor - moeoHypContinue( const std::vector & _OptimVec, moeoArchive < MOEOT > & _archive, bool _normalize=true, double _rho=1.1) + moeoHypContinue( const std::vector & _OptimVec, moeoArchive < MOEOT > & _archive, bool _normalize=true, AtomType _rho=1.1) : eoContinue(), arch(_archive), metric(_normalize,_rho) { vectorToParetoSet(_OptimVec); } - moeoHypContinue( const std::vector & _OptimVec, moeoArchive < MOEOT > & _archive, bool _normalize=true, ObjectiveVector& _ref_point=NULL) + moeoHypContinue( const std::vector & _OptimVec, moeoArchive < MOEOT > & _archive, bool _normalize=true, ObjectiveVector& _ref_point=NULL) : eoContinue (), arch(_archive), metric(_normalize,_ref_point) { vectorToParetoSet(_OptimVec); @@ -79,7 +80,7 @@ public: bestCurrentParetoSet.push_back(arch[i].objectiveVector()); } - double hypervolume= metric(bestCurrentParetoSet,OptimSet ); + AtomType hypervolume= metric(bestCurrentParetoSet,OptimSet ); if (hypervolume==0) { eo::log << eo::logging << "STOP in moeoHypContinue: Best ParetoSet has been reached " @@ -90,7 +91,7 @@ public: } /** Translate a vector given as param to the ParetoSet that should be reached. */ - void vectorToParetoSet(const std::vector & _OptimVec) + void vectorToParetoSet(const std::vector & _OptimVec) { unsigned dim = (unsigned)(_OptimVec.size()/ObjectiveVector::Traits::nObjectives()); OptimSet.resize(dim); From 3adff8518f18ed2453e2d24aa08114ccba7b26ed Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 7 Jun 2013 11:26:49 +0200 Subject: [PATCH 034/419] Add moeoDualRealObjectiveVector, to implement OV with feasability --- moeo/src/core/moeoDualRealObjectiveVector.h | 114 ++++++++++++++++++++ moeo/src/moeo | 2 + 2 files changed, 116 insertions(+) create mode 100644 moeo/src/core/moeoDualRealObjectiveVector.h diff --git a/moeo/src/core/moeoDualRealObjectiveVector.h b/moeo/src/core/moeoDualRealObjectiveVector.h new file mode 100644 index 000000000..9be12d8f7 --- /dev/null +++ b/moeo/src/core/moeoDualRealObjectiveVector.h @@ -0,0 +1,114 @@ +/* + +(c) 2010 Thales group + + 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 + +*/ + +#ifndef _DUALREALOBJECTIVEVECTOR_H_ +#define _DUALREALOBJECTIVEVECTOR_H_ + +#include +#include + +#include + +#include +#include +#include + +template < class ObjectiveVectorTraits > +class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector +{ + protected: + bool _is_feasible; + + public: + + moeoDualRealObjectiveVector(double value=0.0) : moeoScalarObjectiveVector(value, false) {} + + bool is_feasible() const + { +#ifndef NDEBUG + // if the feasibility is correctly assigned, + // every scalar's feasibility should be equal to the objective vector + for( typename moeoDualRealObjectiveVector::const_iterator it = this->begin(), end = this->end(); it != end; ++it ) { + assert( it->is_feasible() == _is_feasible ); + } +#endif + return _is_feasible; + } + + //! One should ensure that feasabilities of scalars are all the same + void is_feasible( bool value ) + { +#ifndef NDEBUG + for( typename moeoDualRealObjectiveVector::const_iterator it = this->begin(), end = this->end(); it != end; ++it ) { + assert( it->is_feasible() == value ); + } +#endif + _is_feasible = value; + } + + bool dominates(const moeoRealObjectiveVector < ObjectiveVectorTraits > & other) const + { + // am I better than the other ? + + // if I'm feasible and the other is not + if( this->is_feasible() && !other.is_feasible() ) { + // no, the other has a better objective + return true; + + } else if( !this->is_feasible() && other.is_feasible() ) { + // yes, a feasible objective is always better than an unfeasible one + return false; + + } else { + // the two objective are of the same type + // lets rely on the comparator + moeoParetoObjectiveVectorComparator< moeoDualRealObjectiveVector > comparator; + return comparator(other, *this); + } + } + + //! Use when maximizing an + bool operator<(const moeoDualRealObjectiveVector < ObjectiveVectorTraits > & other) const + { + // am I better than the other ? + + // if I'm feasible and the other is not + if( this->is_feasible() && !other.is_feasible() ) { + // no, the other has a better objective + return true; + + } else if( !this->is_feasible() && other.is_feasible() ) { + // yes, a feasible objective is always better than an unfeasible one + return false; + + } else { + moeoObjectiveObjectiveVectorComparator < moeoDualRealObjectiveVector < ObjectiveVectorTraits > > cmp; + return cmp(*this, other); + } + } +}; + + +#endif /*_DUALREALOBJECTIVEVECTOR_H_*/ diff --git a/moeo/src/moeo b/moeo/src/moeo index 9ac18c050..b2e7b4db1 100644 --- a/moeo/src/moeo +++ b/moeo/src/moeo @@ -88,7 +88,9 @@ #include #include #include +#include #include +#include #include #include From 818425565deb0e2964a6962b95bd55951dda6613 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 7 Jun 2013 11:52:50 +0200 Subject: [PATCH 035/419] Correct templatized types across ObjectiveVector-dependant code --- moeo/src/continue/moeoHypContinue.h | 2 +- moeo/src/core/moeoDualRealObjectiveVector.h | 10 ++++++---- moeo/src/core/moeoScalarObjectiveVector.h | 10 +++++----- .../moeoExpBinaryIndicatorBasedFitnessAssignment.h | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/moeo/src/continue/moeoHypContinue.h b/moeo/src/continue/moeoHypContinue.h index 9ecc5424e..5fd5c47ad 100644 --- a/moeo/src/continue/moeoHypContinue.h +++ b/moeo/src/continue/moeoHypContinue.h @@ -59,7 +59,7 @@ public: typedef typename ObjectiveVector::Type AtomType; /// Ctor - moeoHypContinue( const std::vector & _OptimVec, moeoArchive < MOEOT > & _archive, bool _normalize=true, AtomType _rho=1.1) + moeoHypContinue( const std::vector & _OptimVec, moeoArchive < MOEOT > & _archive, bool _normalize=true, double _rho=1.1) : eoContinue(), arch(_archive), metric(_normalize,_rho) { vectorToParetoSet(_OptimVec); diff --git a/moeo/src/core/moeoDualRealObjectiveVector.h b/moeo/src/core/moeoDualRealObjectiveVector.h index 9be12d8f7..dbba265c0 100644 --- a/moeo/src/core/moeoDualRealObjectiveVector.h +++ b/moeo/src/core/moeoDualRealObjectiveVector.h @@ -33,17 +33,19 @@ Authors: #include #include -#include +#include -template < class ObjectiveVectorTraits > -class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector +template < class ObjectiveVectorTraits, class T = eoMinimizingDualFitness /* can be an eoMaximizingDualFitness */> +class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector { protected: bool _is_feasible; public: - moeoDualRealObjectiveVector(double value=0.0) : moeoScalarObjectiveVector(value, false) {} + moeoDualRealObjectiveVector(double value=0.0) + : moeoScalarObjectiveVector + ( T(value, false) ) {} bool is_feasible() const { diff --git a/moeo/src/core/moeoScalarObjectiveVector.h b/moeo/src/core/moeoScalarObjectiveVector.h index 0f33812c3..9d1183ad7 100644 --- a/moeo/src/core/moeoScalarObjectiveVector.h +++ b/moeo/src/core/moeoScalarObjectiveVector.h @@ -151,8 +151,8 @@ class moeoScalarObjectiveVector : public moeoObjectiveVector < ObjectiveVectorTr * @param _os output stream * @param _objectiveVector the objective vector to write */ -template < class ObjectiveVectorTraits > -std::ostream & operator<<(std::ostream & _os, const moeoScalarObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) +template < class ObjectiveVectorTraits, class T > +std::ostream & operator<<(std::ostream & _os, const moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _objectiveVector) { for (unsigned int i=0; i<_objectiveVector.size()-1; i++) _os << _objectiveVector[i] << " "; @@ -165,10 +165,10 @@ std::ostream & operator<<(std::ostream & _os, const moeoScalarObjectiveVector < * @param _is input stream * @param _objectiveVector the objective vector to read */ -template < class ObjectiveVectorTraits > -std::istream & operator>>(std::istream & _is, moeoScalarObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) +template < class ObjectiveVectorTraits, class T > +std::istream & operator>>(std::istream & _is, moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _objectiveVector) { - _objectiveVector = moeoScalarObjectiveVector < ObjectiveVectorTraits > (); + _objectiveVector = moeoScalarObjectiveVector < ObjectiveVectorTraits, T > (); for (unsigned int i=0; i<_objectiveVector.size(); i++) { _is >> _objectiveVector[i]; diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h index a25382f41..3159c2840 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h @@ -154,7 +154,7 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB */ void setup(const eoPop < MOEOT > & _pop) { - double min, max; + typename MOEOT::ObjectiveVector::Type min, max; for (unsigned int i=0; i Date: Fri, 7 Jun 2013 12:42:27 +0200 Subject: [PATCH 036/419] Add missing arithmetic operators to eoDualFitness --- eo/src/eoDualFitness.h | 52 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index 674fe075c..7bf88ed47 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -108,12 +108,11 @@ public: * type, if needed. For example, this is possible: * eoDualFitness > fit; * double val = 1.0; - * fit = val; * val = fit; */ - operator BaseType(void) const { return _value; } + operator BaseType(void) const { return _value; } + - inline bool is_feasible() const { return _is_feasible; @@ -143,6 +142,14 @@ public: return *this; } + //! Copy operator from a std::pair + template + eoDualFitness& operator=(const T v) + { + _value = v; + return *this; + } + //! Comparison that separate feasible individuals from unfeasible ones. Feasible are always better /*! * Use less as a default comparison operator @@ -183,6 +190,11 @@ public: public: + /* FIXME it would be better to raise errors (or warnings) if one try to apply arithmetics operators between feasible + * and unfeasible fitnesses. This necessitates to add wrappers for operators that aggregates sets of dual fitnesses + * (like eoStat), both for separating feasibility and for aggregating them. + */ + //! Add a given fitness to the current one template friend @@ -209,6 +221,31 @@ public: return from; } + + //! Add a given fitness to the current one + template + friend + eoDualFitness & operator/=( eoDualFitness & from, const eoDualFitness & that ) + { + from._value /= that._value; + + // true only if the two are feasible, else false + from._is_feasible = from._is_feasible && that._is_feasible; + + return from; + } + + + //! Add a given fitness to the current one + template + friend + eoDualFitness & operator/=( eoDualFitness & from, T that ) + { + from._value /= that; + + return from; + } + // Add this fitness's value to that other, and return a _new_ instance with the result. template eoDualFitness operator+(const eoDualFitness & that) @@ -225,6 +262,15 @@ public: return from -= that; } + + // Add this fitness's value to that other, and return a _new_ instance with the result. + template + eoDualFitness operator/(const eoDualFitness & that) + { + eoDualFitness from( *this ); + return from /= that; + } + //! Print an eoDualFitness instance as a pair of numbers, separated by a space template friend From 9787d4d89c44ac97d100f33b26a578268a9483d4 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 7 Jun 2013 12:43:09 +0200 Subject: [PATCH 037/419] Generic ObjectiveVector types --- moeo/src/continue/moeoHypContinue.h | 2 +- moeo/src/core/moeoDualRealObjectiveVector.h | 36 +++++++++++++++++-- .../metric/moeoHyperVolumeDifferenceMetric.h | 6 ++-- moeo/src/metric/moeoHyperVolumeMetric.h | 2 +- .../metric/moeoVecVsVecEpsilonBinaryMetric.h | 2 +- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/moeo/src/continue/moeoHypContinue.h b/moeo/src/continue/moeoHypContinue.h index 5fd5c47ad..85be8281e 100644 --- a/moeo/src/continue/moeoHypContinue.h +++ b/moeo/src/continue/moeoHypContinue.h @@ -80,7 +80,7 @@ public: bestCurrentParetoSet.push_back(arch[i].objectiveVector()); } - AtomType hypervolume= metric(bestCurrentParetoSet,OptimSet ); + double hypervolume= metric(bestCurrentParetoSet,OptimSet ); if (hypervolume==0) { eo::log << eo::logging << "STOP in moeoHypContinue: Best ParetoSet has been reached " diff --git a/moeo/src/core/moeoDualRealObjectiveVector.h b/moeo/src/core/moeoDualRealObjectiveVector.h index dbba265c0..ce66ed329 100644 --- a/moeo/src/core/moeoDualRealObjectiveVector.h +++ b/moeo/src/core/moeoDualRealObjectiveVector.h @@ -43,9 +43,9 @@ class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector - ( T(value, false) ) {} + ( T(value, feasible) ) {} bool is_feasible() const { @@ -113,4 +113,36 @@ class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector +std::ostream & operator<<(std::ostream & _os, const moeoDualRealObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) +{ + for (unsigned int i=0; i<_objectiveVector.size()-1; i++) + _os << _objectiveVector[i] << " "; + _os << _objectiveVector[_objectiveVector.size()-1]; + return _os; +} + +/** + * Input for a moeoDualRealObjectiveVector object + * @param _is input stream + * @param _objectiveVector the objective vector to read + */ +template < class ObjectiveVectorTraits > +std::istream & operator>>(std::istream & _is, moeoDualRealObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) +{ + _objectiveVector = moeoDualRealObjectiveVector < ObjectiveVectorTraits > (); + for (unsigned int i=0; i<_objectiveVector.size(); i++) + { + _is >> _objectiveVector[i]; + } + return _is; +} + + #endif /*_DUALREALOBJECTIVEVECTOR_H_*/ diff --git a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h index 906923b98..296da1733 100644 --- a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h +++ b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h @@ -56,7 +56,7 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < * @param _normalize allow to normalize data (default true) * @param _rho coefficient to determine the reference point. */ - moeoHyperVolumeDifferenceMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho), ref_point(NULL){ + moeoHyperVolumeDifferenceMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho), ref_point(/*NULL*/){ bounds.resize(ObjectiveVector::Traits::nObjectives()); // initialize bounds in case someone does not want to use them for (unsigned int i=0; i argument1: vector size must be greater than 0"); else{ - double min, max; + typename ObjectiveVector::Type min, max; unsigned int nbObj=ObjectiveVector::Traits::nObjectives(); bounds.resize(nbObj); for (unsigned int i=0; i & _set1, const std::vector < ObjectiveVector > & _set2){ - double min, max; + typename ObjectiveVector::Type min, max; unsigned int nbObj=ObjectiveVector::Traits::nObjectives(); bounds.resize(nbObj); for (unsigned int i=0; i Date: Fri, 7 Jun 2013 17:32:30 +0200 Subject: [PATCH 038/419] More generic eoDualFitness Allow an imitialization on a double only, BUT an assert fails if it is not 0.0 Remove friendship on operators, because there is two differerent templated classes declared later. More operators with base types. --- eo/src/eoDualFitness.h | 94 ++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 30 deletions(-) diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index 7bf88ed47..f51ebb9a6 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -81,10 +81,23 @@ public: * Unfeasible by default */ eoDualFitness() : - _value(), + _value(0.0), _is_feasible(false) {} + //! Empty initialization + /*! + * Unfeasible by default + */ + template + eoDualFitness( T value ) : + _value(value), + _is_feasible(false) + { + assert( _value == 0 ); + } + + //! Copy constructor eoDualFitness(const eoDualFitness& other) : _value(other._value), @@ -126,8 +139,8 @@ public: //! Copy operator from a std::pair eoDualFitness& operator=(const std::pair& v) { - _value = v.first; - _is_feasible = v.second; + this->_value = v.first; + this->_is_feasible = v.second; return *this; } @@ -142,13 +155,16 @@ public: return *this; } - //! Copy operator from a std::pair + /* + //! Copy operator from a scalar template eoDualFitness& operator=(const T v) { - _value = v; + this->_value = v; + this->_is_feasible = false; return *this; } + */ //! Comparison that separate feasible individuals from unfeasible ones. Feasible are always better /*! @@ -195,55 +211,74 @@ public: * (like eoStat), both for separating feasibility and for aggregating them. */ + // NOTE: we cannot declare this set of operator classes as friend, because there is two differerent templated classes declared later + // (for minimizing and maximizing) + //! Add a given fitness to the current one template - friend - eoDualFitness & operator+=( eoDualFitness & from, const eoDualFitness & that ) + // friend + eoDualFitness & operator+=( /*eoDualFitness & from,*/ const eoDualFitness & that ) { - from._value += that._value; + // from._value += that._value; + this->_value += that._value; // true only if the two are feasible, else false - from._is_feasible = from._is_feasible && that._is_feasible; + // from._is_feasible = from._is_feasible && that._is_feasible; + this->_is_feasible = this->_is_feasible && that._is_feasible; - return from; + return *this; } //! Substract a given fitness to the current one template - friend - eoDualFitness & operator-=( eoDualFitness & from, const eoDualFitness & that ) + eoDualFitness & operator-=( const eoDualFitness & that ) { - from._value -= that._value; + this->_value -= that._value; // true only if the two are feasible, else false - from._is_feasible = from._is_feasible && that._is_feasible; + this->_is_feasible = this->_is_feasible && that._is_feasible; - return from; + return *this; } + //! Add a given fitness to the current one + template + eoDualFitness & operator+=( const T that ) + { + this->_value += that; + return *this; + } + + //! Substract a given fitness to the current one + template + eoDualFitness & operator-=( const T that ) + { + this->_value -= that; + return *this; + } + + //! Add a given fitness to the current one template - friend - eoDualFitness & operator/=( eoDualFitness & from, const eoDualFitness & that ) + eoDualFitness & operator/=( const eoDualFitness & that ) { - from._value /= that._value; + this->_value /= that._value; // true only if the two are feasible, else false - from._is_feasible = from._is_feasible && that._is_feasible; + this->_is_feasible = this->_is_feasible && that._is_feasible; - return from; + return *this; } //! Add a given fitness to the current one template - friend - eoDualFitness & operator/=( eoDualFitness & from, T that ) + eoDualFitness & operator/=( T that ) { - from._value /= that; + this->_value /= that; - return from; + return *this; } // Add this fitness's value to that other, and return a _new_ instance with the result. @@ -273,17 +308,15 @@ public: //! Print an eoDualFitness instance as a pair of numbers, separated by a space template - friend - std::ostream& operator<<(std::ostream& os, const eoDualFitness& f) + std::ostream& operator<<(std::ostream& os) { - os << f._value << " " << f._is_feasible; + os << this->_value << " " << this->_is_feasible; return os; } //! Read an eoDualFitness instance as a pair of numbers, separated by a space template - friend - std::istream& operator>>(std::istream& is, eoDualFitness& f) + std::istream& operator>>(std::istream& is) { F value; is >> value; @@ -291,7 +324,8 @@ public: bool feasible; is >> feasible; - f = std::make_pair( value, feasible ); + this->_value = value; + this->_is_feasible = feasible; return is; } }; From 89374247a4c3c82674fadfdfa970dac21b8656f9 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 7 Jun 2013 17:34:59 +0200 Subject: [PATCH 039/419] Add constructors with explicit fitness assignement to IBEA --- moeo/src/algo/moeoIBEA.h | 59 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/moeo/src/algo/moeoIBEA.h b/moeo/src/algo/moeoIBEA.h index b0c1d0207..928e8f5a0 100644 --- a/moeo/src/algo/moeoIBEA.h +++ b/moeo/src/algo/moeoIBEA.h @@ -80,7 +80,20 @@ public: * @param _kappa scaling factor kappa */ moeoIBEA (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) : - defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select (2), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), genBreed (select, defaultSGAGenOp), breed (genBreed), fitnessAssignment(_metric, _kappa), replace (fitnessAssignment, diversityAssignment) + defaultGenContinuator(_maxGen), + continuator(defaultGenContinuator), + eval(_eval), + defaultPopEval(_eval), + popEval(defaultPopEval), + select (2), + selectMany(select,0.0), + selectTransform(defaultSelect, defaultTransform), + defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), + genBreed (select, defaultSGAGenOp), + breed (genBreed), + default_fitnessAssignment( new moeoExpBinaryIndicatorBasedFitnessAssignment(_metric, _kappa) ), + fitnessAssignment(*default_fitnessAssignment), + replace(fitnessAssignment, diversityAssignment) {} @@ -94,7 +107,7 @@ public: */ moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) : defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(2), - selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), fitnessAssignment(_metric, _kappa), replace (fitnessAssignment, diversityAssignment) + selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), default_fitnessAssignment( new moeoExpBinaryIndicatorBasedFitnessAssignment(_metric, _kappa)), fitnessAssignment(*default_fitnessAssignment), replace (fitnessAssignment, diversityAssignment) {} @@ -108,7 +121,7 @@ public: */ moeoIBEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) : defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(2), - selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), fitnessAssignment(_metric, _kappa), replace (fitnessAssignment, diversityAssignment) + selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), default_fitnessAssignment( new moeoExpBinaryIndicatorBasedFitnessAssignment(_metric, _kappa)), fitnessAssignment(*default_fitnessAssignment), replace (fitnessAssignment, diversityAssignment) {} @@ -122,7 +135,7 @@ public: */ moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoTransform < MOEOT > & _transform, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) : defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), - select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), fitnessAssignment(_metric, _kappa), replace(fitnessAssignment, diversityAssignment) + select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), default_fitnessAssignment( new moeoExpBinaryIndicatorBasedFitnessAssignment(_metric, _kappa)), fitnessAssignment(*default_fitnessAssignment), replace(fitnessAssignment, diversityAssignment) {} @@ -136,10 +149,43 @@ public: */ moeoIBEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoTransform < MOEOT > & _transform, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa=0.05) : defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), - select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), fitnessAssignment(_metric, _kappa), replace(fitnessAssignment, diversityAssignment) + select(2), selectMany(select, 1.0), selectTransform(selectMany, _transform), defaultSGAGenOp(defaultQuadOp, 0.0, defaultMonOp, 0.0), genBreed(select, defaultSGAGenOp), breed(selectTransform), default_fitnessAssignment( new moeoExpBinaryIndicatorBasedFitnessAssignment(_metric, _kappa)), fitnessAssignment(*default_fitnessAssignment), replace(fitnessAssignment, diversityAssignment) {} + /** + * Ctor with a eoContinue, a eoPopEval, a eoGenOp and an explicit fitnessAssignment + * @param _continuator stopping criteria + * @param _popEval population evaluation function + * @param _op variation operators + * @param _fitnessAssignment fitness assignment + */ + moeoIBEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op, moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT >& _fitnessAssignment) : + defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(2), + selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), default_fitnessAssignment(NULL), fitnessAssignment(_fitnessAssignment), replace(fitnessAssignment, diversityAssignment) + {} + + + /** + * Ctor with a eoContinue, a eoGenOp and an explicit fitnessAssignment + * @param _continuator stopping criteria + * @param _eval evaluation function + * @param _op variation operators + * @param _fitnessAssignment fitness assignment + */ + moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT >& _fitnessAssignment) : + defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(2), + selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), default_fitnessAssignment(NULL), fitnessAssignment(_fitnessAssignment), replace(fitnessAssignment, diversityAssignment) + {} + + + ~moeoIBEA() + { + if( default_fitnessAssignment != NULL ) { + delete default_fitnessAssignment; + } + } + /** * Apply the algorithm to the population _pop until the stopping criteria is satified. * @param _pop the population @@ -214,7 +260,8 @@ protected: /** breeder */ eoBreed < MOEOT > & breed; /** fitness assignment used in IBEA */ - moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT > fitnessAssignment; + moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT >& fitnessAssignment; + moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT >* default_fitnessAssignment; /** dummy diversity assignment */ moeoDummyDiversityAssignment < MOEOT > diversityAssignment; /** environmental replacement */ From 45123abbf3313e95077a0be3664d5e404ed968f4 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 7 Jun 2013 17:50:04 +0200 Subject: [PATCH 040/419] Add the DUAL fitness assignment class Change a bit the machinery of moeoExpBinaryIndicatorBasedFitnessAssignment to allow subclassing. --- ...inaryIndicatorBasedDualFitnessAssignment.h | 67 +++++++++++++++++++ ...ExpBinaryIndicatorBasedFitnessAssignment.h | 14 ++-- moeo/src/moeo | 1 + 3 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h new file mode 100644 index 000000000..d0a0e1317 --- /dev/null +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -0,0 +1,67 @@ + +#include + +template +class moeoExpBinaryIndicatorBasedDualFitnessAssignment : public moeoExpBinaryIndicatorBasedFitnessAssignment +{ +protected: + eoPop _feasible_pop; + eoPop _unfeasible_pop; + +public: + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + moeoExpBinaryIndicatorBasedDualFitnessAssignment( + moeoNormalizedSolutionVsSolutionBinaryMetric & metric, + const double kappa = 0.05 + ) : moeoExpBinaryIndicatorBasedFitnessAssignment( metric, kappa ) {} + + //! Split up the population in two: in one pop the feasible individual, in the other the feasible ones + virtual void split( eoPop & pop ) + { + _feasible_pop.reserve(pop.size()); + _unfeasible_pop.reserve(pop.size()); + + for( typename eoPop::iterator it=pop.begin(), end=pop.end(); it != end; ++it ) { + // The ObjectiveVector should implement "is_feasible" + if( it->objectiveVector().is_feasible() ) { + _feasible_pop.push_back( *it ); + } else { + _unfeasible_pop.push_back( *it ); + } + } + } + + /*! If the population is homogeneous (only composed of feasible individuals or unfeasible ones), + * then apply the operators on the whole population. + * But, if there is at least one feasible individual, then apply them only on the feasible individuals. + */ + virtual void operator()(eoPop < MOEOT > & pop) + { + // separate the pop in the members + split( pop ); + + eoPop* ppop; + // if there is at least one feasible individual, it will supersede all the unfeasible ones + if( _feasible_pop.size() == 0 ) { + ppop = & _unfeasible_pop; + } else { + ppop = & _feasible_pop; + } + + this->setup(*ppop); + this->computeValues(*ppop); + this->setFitnesses(*ppop); + } + + virtual void setFitnesses(eoPop < MOEOT > & pop) + { + for (unsigned int i=0; icomputeFitness(i), pop[i].is_feasible() ); + } + } + + +}; + diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h index 3159c2840..7d8bb63b8 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h @@ -58,6 +58,7 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB /** The type of objective vector */ typedef typename MOEOT::ObjectiveVector ObjectiveVector; + typedef typename ObjectiveVector::Type Type; /** * Ctor. @@ -72,7 +73,7 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB * Sets the fitness values for every solution contained in the population _pop * @param _pop the population */ - void operator()(eoPop < MOEOT > & _pop) + virtual void operator()(eoPop < MOEOT > & _pop) { // 1 - setting of the bounds setup(_pop); @@ -145,7 +146,7 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB /** the scaling factor */ double kappa; /** the computed indicator values */ - std::vector < std::vector > values; + std::vector < std::vector > values; /** @@ -181,6 +182,7 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB for (unsigned int i=0; i<_pop.size(); i++) { values[i].resize(_pop.size()); + // the metric may not be symetric, thus neither is the matrix for (unsigned int j=0; j<_pop.size(); j++) { if (i != j) @@ -193,10 +195,10 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB /** - * Sets the fitness value of the whple population + * Sets the fitness value of the whole population * @param _pop the population */ - void setFitnesses(eoPop < MOEOT > & _pop) + virtual void setFitnesses(eoPop < MOEOT > & _pop) { for (unsigned int i=0; i<_pop.size(); i++) { @@ -209,9 +211,9 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB * Returns the fitness value of the _idx th individual of the population * @param _idx the index */ - double computeFitness(const unsigned int _idx) + Type computeFitness(const unsigned int _idx) { - double result = 0; + Type result(0.0); for (unsigned int i=0; i #include #include +#include #include #include #include From ac61b782c36b78395f493a61eca57dc1d793830f Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 7 Jun 2013 17:51:01 +0200 Subject: [PATCH 041/419] Use the objective type instead of double in metrics --- .../src/metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/moeo/src/metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h b/moeo/src/metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h index 95a4e54ab..6a6368f1d 100644 --- a/moeo/src/metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h +++ b/moeo/src/metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h @@ -52,6 +52,8 @@ class moeoNormalizedSolutionVsSolutionBinaryMetric : public moeoSolutionVsSoluti { public: + typedef typename ObjectiveVector::Type Type; + /** * Default ctr for any moeoNormalizedSolutionVsSolutionBinaryMetric object */ @@ -72,7 +74,7 @@ class moeoNormalizedSolutionVsSolutionBinaryMetric : public moeoSolutionVsSoluti * @param _max upper bound * @param _obj the objective index */ - void setup(double _min, double _max, unsigned int _obj) + void setup( Type _min, Type _max, unsigned int _obj) { if (_min == _max) { From 55a1783605f452261af0ac89b3602708564e7c2a Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 11 Jun 2013 09:23:16 +0200 Subject: [PATCH 042/419] Use member arithmetic operators and friend stream operators in dual fitness --- eo/src/eoDualFitness.h | 103 +++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 46 deletions(-) diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index f51ebb9a6..4d8831799 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -146,7 +146,7 @@ public: //! Copy operator from another eoDualFitness template - eoDualFitness & operator=(const eoDualFitness& other ) + eoDualFitness & operator=(const eoDualFitness& other ) { if (this != &other) { this->_value = other._value; @@ -215,9 +215,15 @@ public: // (for minimizing and maximizing) //! Add a given fitness to the current one - template - // friend - eoDualFitness & operator+=( /*eoDualFitness & from,*/ const eoDualFitness & that ) + template + eoDualFitness & operator+=( const T that ) + { + this->_value += that; + return *this; + } + + //! Add a given fitness to the current one + eoDualFitness & operator+=( const eoDualFitness & that ) { // from._value += that._value; this->_value += that._value; @@ -230,8 +236,15 @@ public: } //! Substract a given fitness to the current one - template - eoDualFitness & operator-=( const eoDualFitness & that ) + template + eoDualFitness & operator-=( const T that ) + { + this->_value -= that; + return *this; + } + + //! Substract a given fitness to the current one + eoDualFitness & operator-=( const eoDualFitness & that ) { this->_value -= that._value; @@ -241,27 +254,17 @@ public: return *this; } + //! Add a given fitness to the current one - template - eoDualFitness & operator+=( const T that ) + template + eoDualFitness & operator/=( T that ) { - this->_value += that; + this->_value /= that; return *this; } - //! Substract a given fitness to the current one - template - eoDualFitness & operator-=( const T that ) - { - this->_value -= that; - return *this; - } - - - //! Add a given fitness to the current one - template - eoDualFitness & operator/=( const eoDualFitness & that ) + eoDualFitness & operator/=( const eoDualFitness & that ) { this->_value /= that._value; @@ -271,61 +274,69 @@ public: return *this; } - - //! Add a given fitness to the current one - template - eoDualFitness & operator/=( T that ) + template + eoDualFitness operator+( T that ) { - this->_value /= that; - + this->_value += that; return *this; } // Add this fitness's value to that other, and return a _new_ instance with the result. - template - eoDualFitness operator+(const eoDualFitness & that) + eoDualFitness operator+( const eoDualFitness & that ) { - eoDualFitness from( *this ); + eoDualFitness from( *this ); return from += that; } - // Add this fitness's value to that other, and return a _new_ instance with the result. - template - eoDualFitness operator-(const eoDualFitness & that) + template + eoDualFitness operator-( T that ) { - eoDualFitness from( *this ); + this->_value -= that; + return *this; + } + + // Add this fitness's value to that other, and return a _new_ instance with the result. + eoDualFitness operator-( const eoDualFitness & that ) + { + eoDualFitness from( *this ); return from -= that; } - // Add this fitness's value to that other, and return a _new_ instance with the result. - template - eoDualFitness operator/(const eoDualFitness & that) + template + eoDualFitness operator/( T that ) { - eoDualFitness from( *this ); + this->_value /= that; + return *this; + } + + // Add this fitness's value to that other, and return a _new_ instance with the result. + eoDualFitness operator/( const eoDualFitness & that ) + { + eoDualFitness from( *this ); return from /= that; } //! Print an eoDualFitness instance as a pair of numbers, separated by a space - template - std::ostream& operator<<(std::ostream& os) + friend + std::ostream& operator<<( std::ostream& os, const eoDualFitness & fitness ) { - os << this->_value << " " << this->_is_feasible; + os << fitness._value << " " << fitness._is_feasible; return os; } //! Read an eoDualFitness instance as a pair of numbers, separated by a space - template - std::istream& operator>>(std::istream& is) + friend + std::istream& operator>>( std::istream& is, eoDualFitness & fitness ) { - F value; + BaseType value; is >> value; bool feasible; is >> feasible; - this->_value = value; - this->_is_feasible = feasible; + fitness._value = value; + fitness._is_feasible = feasible; return is; } }; From 97156dd69ad6b90584a3e72c5988852c9b11f5f3 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 11 Jun 2013 09:24:11 +0200 Subject: [PATCH 043/419] Fix the templates of moeoDualRealObjectiveVector --- moeo/src/core/moeoDualRealObjectiveVector.h | 35 +++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/moeo/src/core/moeoDualRealObjectiveVector.h b/moeo/src/core/moeoDualRealObjectiveVector.h index ce66ed329..1ed62a8ff 100644 --- a/moeo/src/core/moeoDualRealObjectiveVector.h +++ b/moeo/src/core/moeoDualRealObjectiveVector.h @@ -35,7 +35,7 @@ Authors: #include #include -template < class ObjectiveVectorTraits, class T = eoMinimizingDualFitness /* can be an eoMaximizingDualFitness */> +template < class ObjectiveVectorTraits, class T = eoMaximizingDualFitness /* can be an eoMinimizingDualFitness */> class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector { protected: @@ -43,14 +43,17 @@ class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector::size; + using moeoScalarObjectiveVector < ObjectiveVectorTraits, T >::operator[]; + moeoDualRealObjectiveVector(double value=0.0, bool feasible = false) - : moeoScalarObjectiveVector + : moeoScalarObjectiveVector ( T(value, feasible) ) {} bool is_feasible() const { #ifndef NDEBUG - // if the feasibility is correctly assigned, + // if the feasibility is correctly assigned, // every scalar's feasibility should be equal to the objective vector for( typename moeoDualRealObjectiveVector::const_iterator it = this->begin(), end = this->end(); it != end; ++it ) { assert( it->is_feasible() == _is_feasible ); @@ -119,13 +122,14 @@ class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector -std::ostream & operator<<(std::ostream & _os, const moeoDualRealObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) +template +std::ostream & operator<<( std::ostream & _os, const moeoDualRealObjectiveVector & _objectiveVector ) { - for (unsigned int i=0; i<_objectiveVector.size()-1; i++) - _os << _objectiveVector[i] << " "; - _os << _objectiveVector[_objectiveVector.size()-1]; - return _os; + for( unsigned int i=0; i<_objectiveVector.size()-1; i++ ) { + _os << _objectiveVector[i] << " "; + } + _os << _objectiveVector[_objectiveVector.size()-1]; + return _os; } /** @@ -133,15 +137,14 @@ std::ostream & operator<<(std::ostream & _os, const moeoDualRealObjectiveVector * @param _is input stream * @param _objectiveVector the objective vector to read */ -template < class ObjectiveVectorTraits > -std::istream & operator>>(std::istream & _is, moeoDualRealObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) +template +std::istream & operator>>( std::istream & _is, moeoDualRealObjectiveVector & _objectiveVector ) { - _objectiveVector = moeoDualRealObjectiveVector < ObjectiveVectorTraits > (); - for (unsigned int i=0; i<_objectiveVector.size(); i++) - { - _is >> _objectiveVector[i]; + _objectiveVector = moeoDualRealObjectiveVector (); + for( unsigned int i=0; i<_objectiveVector.size(); i++ ) { + _is >> _objectiveVector[i]; } - return _is; + return _is; } From 82ce471aef216978ec83c292e55965dcea3234a8 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 11 Jun 2013 13:28:51 +0200 Subject: [PATCH 044/419] Add a warning in eoDualFitness comments --- eo/src/eoDualFitness.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index 4d8831799..59d6f6d05 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -85,8 +85,9 @@ public: _is_feasible(false) {} - //! Empty initialization + //! Initialization with only the value, the fitness will be unfeasible. /*! + * WARNING: this is what is used when you initialize a new fitness from a double. * Unfeasible by default */ template @@ -137,7 +138,7 @@ public: } //! Copy operator from a std::pair - eoDualFitness& operator=(const std::pair& v) + eoDualFitness& operator=( const std::pair& v ) { this->_value = v.first; this->_is_feasible = v.second; @@ -146,7 +147,7 @@ public: //! Copy operator from another eoDualFitness template - eoDualFitness & operator=(const eoDualFitness& other ) + eoDualFitness & operator=( const eoDualFitness& other ) { if (this != &other) { this->_value = other._value; From 75340a5c91468a2d98ecb356914ee9b725f4f675 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 11 Jun 2013 13:29:57 +0200 Subject: [PATCH 045/419] Add hyper volume continuators & metrics handling feasibility constraint on objectives --- moeo/src/continue/moeoHypContinue.h | 119 +++++++++++++- ...inaryIndicatorBasedDualFitnessAssignment.h | 27 +++- ...ExpBinaryIndicatorBasedFitnessAssignment.h | 2 +- .../metric/moeoHyperVolumeDifferenceMetric.h | 153 ++++++++++++++---- 4 files changed, 258 insertions(+), 43 deletions(-) diff --git a/moeo/src/continue/moeoHypContinue.h b/moeo/src/continue/moeoHypContinue.h index 85be8281e..f6fbac34a 100644 --- a/moeo/src/continue/moeoHypContinue.h +++ b/moeo/src/continue/moeoHypContinue.h @@ -46,11 +46,11 @@ #include /** - Continues until the optimum ParetoSet level is reached. + Continues until the given ParetoSet level is reached. @ingroup Continuators */ -template< class MOEOT> +template< class MOEOT, class MetricT = moeoHyperVolumeDifferenceMetric > class moeoHypContinue: public eoContinue { public: @@ -71,8 +71,20 @@ public: vectorToParetoSet(_OptimVec); } + /** Returns false when a ParetoSet is reached. */ virtual bool operator() ( const eoPop& _pop ) + { + std::vector bestCurrentParetoSet = pareto( arch ); + + return is_null_hypervolume( bestCurrentParetoSet ); + } + + virtual std::string className(void) const { return "moeoHypContinue"; } + +protected: + + std::vector pareto( moeoArchive & _archive ) { std::vector < ObjectiveVector > bestCurrentParetoSet; @@ -80,7 +92,12 @@ public: bestCurrentParetoSet.push_back(arch[i].objectiveVector()); } - double hypervolume= metric(bestCurrentParetoSet,OptimSet ); + return bestCurrentParetoSet; + } + + bool is_null_hypervolume( std::vector& bestCurrentParetoSet ) + { + double hypervolume= metric( bestCurrentParetoSet, OptimSet ); if (hypervolume==0) { eo::log << eo::logging << "STOP in moeoHypContinue: Best ParetoSet has been reached " @@ -91,7 +108,7 @@ public: } /** Translate a vector given as param to the ParetoSet that should be reached. */ - void vectorToParetoSet(const std::vector & _OptimVec) + virtual void vectorToParetoSet(const std::vector & _OptimVec) { unsigned dim = (unsigned)(_OptimVec.size()/ObjectiveVector::Traits::nObjectives()); OptimSet.resize(dim); @@ -104,12 +121,98 @@ public: } } - virtual std::string className(void) const { return "moeoHypContinue"; } - -private: +protected: moeoArchive & arch; - moeoHyperVolumeDifferenceMetric metric; + MetricT metric; std::vector OptimSet; }; + +/** + Continues until the (feasible or unfeasible) given Pareto set is reached. + + + @ingroup Continuators + */ +template< class MOEOT, class MetricT = moeoDualHyperVolumeDifferenceMetric > +class moeoDualHypContinue: public moeoHypContinue +{ +protected: + bool is_feasible; + + using moeoHypContinue::arch; + using moeoHypContinue::OptimSet; + +public: + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + typedef typename ObjectiveVector::Type AtomType; + + /** A continuator that stops once a given Pareto front has been reached + * + * You should specify the feasibility of the targeted front. + * NOTE: the MOEOT::ObjectiveVector is supposed to implement the moeoDualRealObjectiveVector interface. + * + */ + moeoDualHypContinue( const std::vector & _OptimVec, bool _is_feasible, moeoArchive < MOEOT > & _archive, bool _normalize=true, double _rho=1.1 ) + : moeoHypContinue( _OptimVec, _archive, _normalize, _rho ), is_feasible(_is_feasible) + { + assert( _OptimVec.size() > 0); + vectorToParetoSet(_OptimVec); + } + + /** A continuator that stops once a given Pareto front has been reached + * + * You should specify the feasibility of the targeted front. + * NOTE: the MOEOT::ObjectiveVector is supposed to implement the moeoDualRealObjectiveVector interface. + * + */ + moeoDualHypContinue( const std::vector & _OptimVec, bool _is_feasible, moeoArchive < MOEOT > & _archive, bool _normalize=true, ObjectiveVector& _ref_point=NULL ) + : moeoHypContinue( _OptimVec, _archive, _normalize, _ref_point ), is_feasible(_is_feasible) + { + assert( _OptimVec.size() > 0); + vectorToParetoSet(_OptimVec); + } + + /** Returns false when a ParetoSet is reached. */ + virtual bool operator() ( const eoPop& _pop ) + { + std::vector bestCurrentParetoSet = pareto( arch ); + +#ifndef NDEBUG + assert( bestCurrentParetoSet.size() > 0 ); + for( unsigned int i=1; i::pareto; + using moeoHypContinue::is_null_hypervolume; + + /** Translate a vector given as param to the ParetoSet that should be reached. */ + virtual void vectorToParetoSet(const std::vector & _OptimVec) + { + unsigned dim = (unsigned)(_OptimVec.size()/ObjectiveVector::Traits::nObjectives()); + OptimSet.resize(dim); + + unsigned k=0; + for(size_t i=0; i < dim; i++) { + for (size_t j=0; j < ObjectiveVector::Traits::nObjectives(); j++) { + // Use the feasibility declaration of an eoDualFitness + OptimSet[i][j] = AtomType(_OptimVec[k++], is_feasible); + } + } + } +}; + #endif diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h index d0a0e1317..bff35769c 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -10,6 +10,9 @@ protected: public: typedef typename MOEOT::ObjectiveVector ObjectiveVector; + typedef typename ObjectiveVector::Type Type; + + using moeoExpBinaryIndicatorBasedFitnessAssignment::values; moeoExpBinaryIndicatorBasedDualFitnessAssignment( moeoNormalizedSolutionVsSolutionBinaryMetric & metric, @@ -54,11 +57,33 @@ public: this->setFitnesses(*ppop); } + /** + * Compute every indicator value in values (values[i] = I(_v[i], _o)) + * @param _pop the population + */ + void computeValues(const eoPop < MOEOT > & _pop) + { + values.clear(); + values.resize(_pop.size()); + for (unsigned int i=0; i<_pop.size(); i++) + { + values[i].resize(_pop.size()); + // the metric may not be symetric, thus neither is the matrix + for (unsigned int j=0; j<_pop.size(); j++) + { + if (i != j) + { + values[i][j] = Type( metric(_pop[i].objectiveVector(), _pop[j].objectiveVector()), _pop[i].objectiveVector().is_feasible() ); + } + } + } + } + virtual void setFitnesses(eoPop < MOEOT > & pop) { for (unsigned int i=0; icomputeFitness(i), pop[i].is_feasible() ); + pop[i].fitness( this->computeFitness(i), pop[i].fitness().is_feasible() ); } } diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h index 7d8bb63b8..d84b052e9 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h @@ -187,7 +187,7 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB { if (i != j) { - values[i][j] = metric(_pop[i].objectiveVector(), _pop[j].objectiveVector()); + values[i][j] = Type( metric(_pop[i].objectiveVector(), _pop[j].objectiveVector()) ); } } } diff --git a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h index 9d3a1c4b9..aaa899827 100644 --- a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h +++ b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h @@ -86,41 +86,42 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < */ double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) { - double hypervolume_set1; - double hypervolume_set2; - if(rho >= 1.0){ - //determine bounds - setup(_set1, _set2); - //determine reference point - for (unsigned int i=0; i= 1.0){ + //determine bounds + setup(_set1, _set2); + //determine reference point + for (unsigned int i=0; i unaryMetric(ref_point, bounds); - hypervolume_set1 = unaryMetric(_set1); - hypervolume_set2 = unaryMetric(_set2); + } + else if(normalize) + setup(_set1, _set2); - return hypervolume_set1 - hypervolume_set2; + moeoHyperVolumeMetric unaryMetric(ref_point, bounds); + hypervolume_set1 = unaryMetric(_set1); + hypervolume_set2 = unaryMetric(_set2); + + return hypervolume_set1 - hypervolume_set2; } /** @@ -132,7 +133,7 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < } /** - * method caclulate bounds for the normalization + * method calculate bounds for the normalization * @param _set1 the vector contains all objective Vector of the first pareto front * @param _set2 the vector contains all objective Vector of the second pareto front */ @@ -182,7 +183,7 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < return 1e-6; } - private: + protected: /*boolean indicates if data must be normalized or not*/ bool normalize; @@ -196,4 +197,90 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < }; + +template +class moeoDualHyperVolumeDifferenceMetric : public moeoHyperVolumeDifferenceMetric +{ +protected: + using moeoHyperVolumeDifferenceMetric::rho; + using moeoHyperVolumeDifferenceMetric::normalize; + using moeoHyperVolumeDifferenceMetric::ref_point; + using moeoHyperVolumeDifferenceMetric::bounds; + +public: + + typedef typename ObjectiveVector::Type Type; + + moeoDualHyperVolumeDifferenceMetric( bool _normalize=true, double _rho=1.1) + : moeoHyperVolumeDifferenceMetric(_normalize, _rho) + { + + } + + moeoDualHyperVolumeDifferenceMetric( bool _normalize/*=true*/, ObjectiveVector& _ref_point/*=NULL*/ ) + : moeoHyperVolumeDifferenceMetric( _normalize, _ref_point ) + { + + } + + /** + * calculates and returns the HyperVolume value of a pareto front + * @param _set1 the vector contains all objective Vector of the first pareto front + * @param _set2 the vector contains all objective Vector of the second pareto front + */ + double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) + { +#ifndef NDEBUG + // the two sets must be homogeneous in feasibility + assert( _set1.size() > 0 ); + for( unsigned int i=1; i<_set1.size(); ++i ) { + assert( _set1[i].is_feasible() == _set1[0].is_feasible() ); + } + assert( _set2.size() > 0 ); + for( unsigned int i=1; i<_set2.size(); ++i ) { + assert( _set2[i].is_feasible() == _set2[0].is_feasible() ); + } + // and they must have the same feasibility + assert( _set1[0].is_feasible() == _set2[0].is_feasible() ); +#endif + bool feasible = _set1[0].is_feasible(); + + double hypervolume_set1; + double hypervolume_set2; + + if(rho >= 1.0){ + //determine bounds + setup(_set1, _set2); + //determine reference point + for (unsigned int i=0; i unaryMetric(ref_point, bounds); + hypervolume_set1 = unaryMetric(_set1); + hypervolume_set2 = unaryMetric(_set2); + + return hypervolume_set1 - hypervolume_set2; + } +}; + #endif /*MOEOHYPERVOLUMEMETRIC_H_*/ From 83673d48b21380944e7ebf42004ff178edfa4ece Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 12 Jun 2013 09:45:35 +0200 Subject: [PATCH 046/419] bugfix: clear previous pop when calling split --- ...inaryIndicatorBasedDualFitnessAssignment.h | 69 ++++++++++--------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h index bff35769c..251e590ae 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -19,27 +19,12 @@ public: const double kappa = 0.05 ) : moeoExpBinaryIndicatorBasedFitnessAssignment( metric, kappa ) {} - //! Split up the population in two: in one pop the feasible individual, in the other the feasible ones - virtual void split( eoPop & pop ) - { - _feasible_pop.reserve(pop.size()); - _unfeasible_pop.reserve(pop.size()); - - for( typename eoPop::iterator it=pop.begin(), end=pop.end(); it != end; ++it ) { - // The ObjectiveVector should implement "is_feasible" - if( it->objectiveVector().is_feasible() ) { - _feasible_pop.push_back( *it ); - } else { - _unfeasible_pop.push_back( *it ); - } - } - } /*! If the population is homogeneous (only composed of feasible individuals or unfeasible ones), * then apply the operators on the whole population. * But, if there is at least one feasible individual, then apply them only on the feasible individuals. */ - virtual void operator()(eoPop < MOEOT > & pop) + virtual void operator()( eoPop& pop ) { // separate the pop in the members split( pop ); @@ -57,26 +42,48 @@ public: this->setFitnesses(*ppop); } + +protected: + + //! Split up the population in two: in one pop the feasible individual, in the other the feasible ones + virtual void split( eoPop & pop ) + { + // clear previously used populations + _feasible_pop.clear(); + _unfeasible_pop.clear(); + _feasible_pop.reserve(pop.size()); + _unfeasible_pop.reserve(pop.size()); + + for( typename eoPop::iterator it=pop.begin(), end=pop.end(); it != end; ++it ) { + // The ObjectiveVector should implement "is_feasible" + if( it->objectiveVector().is_feasible() ) { + _feasible_pop.push_back( *it ); + } else { + _unfeasible_pop.push_back( *it ); + } + } + } + /** * Compute every indicator value in values (values[i] = I(_v[i], _o)) * @param _pop the population */ - void computeValues(const eoPop < MOEOT > & _pop) + virtual void computeValues(const eoPop < MOEOT > & pop) { - values.clear(); - values.resize(_pop.size()); - for (unsigned int i=0; i<_pop.size(); i++) - { - values[i].resize(_pop.size()); - // the metric may not be symetric, thus neither is the matrix - for (unsigned int j=0; j<_pop.size(); j++) - { - if (i != j) - { - values[i][j] = Type( metric(_pop[i].objectiveVector(), _pop[j].objectiveVector()), _pop[i].objectiveVector().is_feasible() ); - } - } - } + values.clear(); + values.resize(pop.size()); + for (unsigned int i=0; i & pop) From a7134a658c882c5a40efb31fea1bb514b91daab1 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 12 Jun 2013 09:50:46 +0200 Subject: [PATCH 047/419] Correct types for fitness assignment in IBEA While the default fitness assignment of IBEA is the Exp indicator one, the used interface is a binary indicator. --- moeo/src/algo/moeoIBEA.h | 8 ++++---- .../moeoExpBinaryIndicatorBasedFitnessAssignment.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/moeo/src/algo/moeoIBEA.h b/moeo/src/algo/moeoIBEA.h index 928e8f5a0..7af91058b 100644 --- a/moeo/src/algo/moeoIBEA.h +++ b/moeo/src/algo/moeoIBEA.h @@ -160,7 +160,7 @@ public: * @param _op variation operators * @param _fitnessAssignment fitness assignment */ - moeoIBEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op, moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT >& _fitnessAssignment) : + moeoIBEA (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op, moeoBinaryIndicatorBasedFitnessAssignment < MOEOT >& _fitnessAssignment) : defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(2), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), default_fitnessAssignment(NULL), fitnessAssignment(_fitnessAssignment), replace(fitnessAssignment, diversityAssignment) {} @@ -173,7 +173,7 @@ public: * @param _op variation operators * @param _fitnessAssignment fitness assignment */ - moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT >& _fitnessAssignment) : + moeoIBEA (eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoGenOp < MOEOT > & _op, moeoBinaryIndicatorBasedFitnessAssignment < MOEOT >& _fitnessAssignment) : defaultGenContinuator(0), continuator(_continuator), eval(_eval), defaultPopEval(_eval), popEval(defaultPopEval), select(2), selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), genBreed(select, _op), breed(genBreed), default_fitnessAssignment(NULL), fitnessAssignment(_fitnessAssignment), replace(fitnessAssignment, diversityAssignment) {} @@ -190,7 +190,7 @@ public: * Apply the algorithm to the population _pop until the stopping criteria is satified. * @param _pop the population */ - virtual void operator () (eoPop < MOEOT > &_pop) + virtual void operator() (eoPop < MOEOT > &_pop) { eoPop < MOEOT > offspring, empty_pop; popEval (empty_pop, _pop); // a first eval of _pop @@ -260,7 +260,7 @@ protected: /** breeder */ eoBreed < MOEOT > & breed; /** fitness assignment used in IBEA */ - moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT >& fitnessAssignment; + moeoBinaryIndicatorBasedFitnessAssignment < MOEOT >& fitnessAssignment; moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT >* default_fitnessAssignment; /** dummy diversity assignment */ moeoDummyDiversityAssignment < MOEOT > diversityAssignment; diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h index d84b052e9..cbcbb33c4 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h @@ -175,7 +175,7 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB * Compute every indicator value in values (values[i] = I(_v[i], _o)) * @param _pop the population */ - void computeValues(const eoPop < MOEOT > & _pop) + virtual void computeValues(const eoPop < MOEOT > & _pop) { values.clear(); values.resize(_pop.size()); @@ -211,7 +211,7 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB * Returns the fitness value of the _idx th individual of the population * @param _idx the index */ - Type computeFitness(const unsigned int _idx) + virtual Type computeFitness(const unsigned int _idx) { Type result(0.0); for (unsigned int i=0; i Date: Wed, 12 Jun 2013 10:14:02 +0200 Subject: [PATCH 048/419] Makes operator() of Hypcontinues virtual when inheritating --- moeo/src/metric/moeoHyperVolumeDifferenceMetric.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h index aaa899827..64a001281 100644 --- a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h +++ b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h @@ -84,7 +84,7 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < * @param _set1 the vector contains all objective Vector of the first pareto front * @param _set2 the vector contains all objective Vector of the second pareto front */ - double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) + virtual double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) { double hypervolume_set1; @@ -228,7 +228,7 @@ public: * @param _set1 the vector contains all objective Vector of the first pareto front * @param _set2 the vector contains all objective Vector of the second pareto front */ - double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) + virtual double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) { #ifndef NDEBUG // the two sets must be homogeneous in feasibility From 0badb71c6580f2acae6b203cdde3310ee88f3203 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 12 Jun 2013 10:37:30 +0200 Subject: [PATCH 049/419] reorder members, for safe initialization --- moeo/src/algo/moeoIBEA.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moeo/src/algo/moeoIBEA.h b/moeo/src/algo/moeoIBEA.h index 7af91058b..b8170a08e 100644 --- a/moeo/src/algo/moeoIBEA.h +++ b/moeo/src/algo/moeoIBEA.h @@ -260,8 +260,8 @@ protected: /** breeder */ eoBreed < MOEOT > & breed; /** fitness assignment used in IBEA */ - moeoBinaryIndicatorBasedFitnessAssignment < MOEOT >& fitnessAssignment; moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT >* default_fitnessAssignment; + moeoBinaryIndicatorBasedFitnessAssignment < MOEOT >& fitnessAssignment; /** dummy diversity assignment */ moeoDummyDiversityAssignment < MOEOT > diversityAssignment; /** environmental replacement */ From 557b24694a674bd5d041eb41ab22e00d4fa6c277 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 12 Jun 2013 10:38:34 +0200 Subject: [PATCH 050/419] Do not declare unused variable This silents warnings about unused variables --- moeo/src/diversity/moeoDummyDiversityAssignment.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moeo/src/diversity/moeoDummyDiversityAssignment.h b/moeo/src/diversity/moeoDummyDiversityAssignment.h index f36a75252..b233f3863 100644 --- a/moeo/src/diversity/moeoDummyDiversityAssignment.h +++ b/moeo/src/diversity/moeoDummyDiversityAssignment.h @@ -74,7 +74,7 @@ class moeoDummyDiversityAssignment : public moeoDiversityAssignment < MOEOT > * @param _pop the population * @param _objVec the objective vector */ - void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + void updateByDeleting(eoPop < MOEOT > & /*_pop*/, ObjectiveVector & /*_objVec*/) { // nothing to do... ;-) } From 9250e0c3a511ffe9d6e696219a19b90948bc058c Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 12 Jun 2013 10:39:23 +0200 Subject: [PATCH 051/419] Backport feasability when computing fitness in fitness assignment --- ...ExpBinaryIndicatorBasedDualFitnessAssignment.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h index 251e590ae..793c6191a 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -45,6 +45,8 @@ public: protected: + using moeoExpBinaryIndicatorBasedFitnessAssignment::kappa; + //! Split up the population in two: in one pop the feasible individual, in the other the feasible ones virtual void split( eoPop & pop ) { @@ -94,6 +96,19 @@ protected: } } + virtual Type computeFitness(const unsigned int _idx) + { + Type result( 0.0, values[_idx][_idx].is_feasible() ); + for (unsigned int i=0; i Date: Wed, 12 Jun 2013 10:40:20 +0200 Subject: [PATCH 052/419] In hyp continue, do not declare unused variable and group using --- moeo/src/continue/moeoHypContinue.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/moeo/src/continue/moeoHypContinue.h b/moeo/src/continue/moeoHypContinue.h index f6fbac34a..228006d3a 100644 --- a/moeo/src/continue/moeoHypContinue.h +++ b/moeo/src/continue/moeoHypContinue.h @@ -73,7 +73,7 @@ public: /** Returns false when a ParetoSet is reached. */ - virtual bool operator() ( const eoPop& _pop ) + virtual bool operator() ( const eoPop& /*_pop*/ ) { std::vector bestCurrentParetoSet = pareto( arch ); @@ -143,6 +143,9 @@ protected: using moeoHypContinue::arch; using moeoHypContinue::OptimSet; + using moeoHypContinue::pareto; + using moeoHypContinue::is_null_hypervolume; + public: typedef typename MOEOT::ObjectiveVector ObjectiveVector; typedef typename ObjectiveVector::Type AtomType; @@ -174,7 +177,7 @@ public: } /** Returns false when a ParetoSet is reached. */ - virtual bool operator() ( const eoPop& _pop ) + virtual bool operator() ( const eoPop& /*_pop*/ ) { std::vector bestCurrentParetoSet = pareto( arch ); @@ -196,9 +199,6 @@ public: protected: - using moeoHypContinue::pareto; - using moeoHypContinue::is_null_hypervolume; - /** Translate a vector given as param to the ParetoSet that should be reached. */ virtual void vectorToParetoSet(const std::vector & _OptimVec) { From 4af7f3d1bc873677aee9c3377a4df679c9e9f5b7 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 09:45:29 +0200 Subject: [PATCH 053/419] Allow scalar init of dual fitness; add a pop splitter Scalar init of a dual fitness is dangerous, thus adds an explicit security against use of a partially initialized object. Use the pop splitter in the dual stat switch and in the MOEO dual fitness assignment. --- eo/src/eoDualFitness.h | 155 ++++++++++++------ ...inaryIndicatorBasedDualFitnessAssignment.h | 44 ++--- 2 files changed, 124 insertions(+), 75 deletions(-) diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index 59d6f6d05..da70e760a 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -74,6 +74,25 @@ protected: //! Flag that marks if the individual is feasible bool _is_feasible; + /** Flag to prevent partial initialization + * + * The reason behind the use of this flag is a bit complicated. + * Normally, we would not want to allow initialization on a scalar. + * But in MOEO, this would necessitate to re-implement most of the + * operator computing metrics, as they expect generic scalars. + * + * As this would be too much work, we use derived metric classes and + * overload them so that they initialize dual fitnesses with the + * feasibility flag. But the compiler still must compile the base + * methods, that use the scalar interface. + * + * Thus, eoDualFitness has a scalar interface, but this flag add a + * security against partial initialization. In DEBUG mode, asserts + * will fail if the feasibility has not been explicitly initialized + * at runtime. + */ + bool _feasible_init; + public: //! Empty initialization @@ -82,58 +101,71 @@ public: */ eoDualFitness() : _value(0.0), - _is_feasible(false) + _is_feasible(false), + _feasible_init(false) {} //! Initialization with only the value, the fitness will be unfeasible. /*! * WARNING: this is what is used when you initialize a new fitness from a double. - * Unfeasible by default + * If you use this interface, you MUST set the feasibility BEFORE + * asking for it or the value. Or else, an assert will fail in debug mode. */ template eoDualFitness( T value ) : _value(value), - _is_feasible(false) + _is_feasible(false), + _feasible_init(false) { - assert( _value == 0 ); } //! Copy constructor eoDualFitness(const eoDualFitness& other) : _value(other._value), - _is_feasible(other._is_feasible) + _is_feasible(other._is_feasible), + _feasible_init(true) {} //! Constructor from explicit value/feasibility eoDualFitness(const BaseType& v, const bool& is_feasible) : _value(v), - _is_feasible(is_feasible) + _is_feasible(is_feasible), + _feasible_init(true) {} //! From a std::pair (first element is the value, second is the feasibility) eoDualFitness(const std::pair& dual) : _value(dual.first), - _is_feasible(dual.second) + _is_feasible(dual.second), + _feasible_init(true) {} - // FIXME is it a good idea to include implicit conversion here? /** Conversion operator: it permits to use a fitness instance as its scalar * type, if needed. For example, this is possible: * eoDualFitness > fit; * double val = 1.0; * val = fit; */ - operator BaseType(void) const { return _value; } + operator BaseType(void) const { return _value; } inline bool is_feasible() const { + assert( _feasible_init ); return _is_feasible; } + //! Explicitly set the feasibility. Useful if you have used previously the instantiation on a single scalar. + inline void is_feasible( bool feasible ) + { + this->is_feasible( feasible ); + this->_feasible_init = true; + } + inline BaseType value() const { + assert( _feasible_init ); return _value; } @@ -141,7 +173,7 @@ public: eoDualFitness& operator=( const std::pair& v ) { this->_value = v.first; - this->_is_feasible = v.second; + this->is_feasible( v.second ); return *this; } @@ -151,21 +183,20 @@ public: { if (this != &other) { this->_value = other._value; - this->_is_feasible = other._is_feasible; + this->is_feasible( other.is_feasible() ); } return *this; } - /* //! Copy operator from a scalar template eoDualFitness& operator=(const T v) { this->_value = v; this->_is_feasible = false; + this->_feasible_init = false; return *this; } - */ //! Comparison that separate feasible individuals from unfeasible ones. Feasible are always better /*! @@ -178,11 +209,11 @@ public: // am I better (less, by default) than the other ? // if I'm feasible and the other is not - if( this->_is_feasible && !other._is_feasible ) { + if( this->is_feasible() && !other.is_feasible() ) { // no, the other has a better fitness return false; - } else if( !this->_is_feasible && other._is_feasible ) { + } else if( !this->is_feasible() && other.is_feasible() ) { // yes, a feasible fitness is always better than an unfeasible one return true; @@ -322,7 +353,7 @@ public: friend std::ostream& operator<<( std::ostream& os, const eoDualFitness & fitness ) { - os << fitness._value << " " << fitness._is_feasible; + os << fitness._value << " " << fitness.is_feasible(); return os; } @@ -337,7 +368,7 @@ public: is >> feasible; fitness._value = value; - fitness._is_feasible = feasible; + fitness.is_feasible( feasible ); return is; } }; @@ -355,18 +386,72 @@ template< class EOT> bool eoIsFeasible ( const EOT & sol ) { return sol.fitness().is_feasible(); } +/** Separate the population into two: one with only feasible individuals, the other with unfeasible ones. + */ +template +class eoDualPopSplit : public eoUF&, void> +{ +protected: + eoPop _pop_feasible; + eoPop _pop_unfeasible; + +public: + //! Split the pop and keep them in members + void operator()( const eoPop& pop ) + { + _pop_feasible.clear(); + _pop_feasible.reserve(pop.size()); + + _pop_unfeasible.clear(); + _pop_unfeasible.reserve(pop.size()); + + for( typename eoPop::const_iterator ieot=pop.begin(), iend=pop.end(); ieot!=iend; ++ieot ) { + /* + if( ieot->invalid() ) { + eo::log << eo::errors << "ERROR: trying to access to an invalid fitness" << std::endl; + } + */ + if( ieot->fitness().is_feasible() ) { + _pop_feasible.push_back( *ieot ); + } else { + _pop_unfeasible.push_back( *ieot ); + } + } + } + + //! Merge feasible and unfeasible populations into a new one + eoPop merge() const + { + eoPop merged; + merged.reserve( _pop_feasible.size() + _pop_unfeasible.size() ); + std::copy( _pop_feasible.begin(), _pop_feasible.end(), std::back_inserter >(merged) ); + std::copy( _pop_unfeasible.begin(), _pop_unfeasible.end(), std::back_inserter >(merged) ); + return merged; + } + + eoPop& feasible() { return _pop_feasible; } + eoPop& unfeasible() { return _pop_unfeasible; } +}; + + /** Embed two eoStat and call the first one on the feasible individuals and * the second one on the unfeasible ones, merge the two resulting value in * a string, separated by a given marker. */ -//template template class eoDualStatSwitch : public eoStat< EOT, std::string > { +protected: + EOSTAT & _stat_feasible; + EOSTAT & _stat_unfeasible; + + std::string _sep; + + eoDualPopSplit _pop_split; + public: using eoStat::value; -// eoDualStatSwitch( eoStat & stat_feasible, eoStat & stat_unfeasible, std::string sep=" " ) : eoDualStatSwitch( EOSTAT & stat_feasible, EOSTAT & stat_unfeasible, std::string sep=" " ) : eoStat( "?"+sep+"?", @@ -379,41 +464,17 @@ public: virtual void operator()( const eoPop & pop ) { - eoPop pop_feasible; - pop_feasible.reserve(pop.size()); + // create two separated pop in this operator + _pop_split( pop ); - eoPop pop_unfeasible; - pop_unfeasible.reserve(pop.size()); - - for( typename eoPop::const_iterator ieot=pop.begin(), iend=pop.end(); ieot!=iend; ++ieot ) { - /* - if( ieot->invalid() ) { - eo::log << eo::errors << "ERROR: trying to access to an invalid fitness" << std::endl; - } - */ - if( ieot->fitness().is_feasible() ) { - pop_feasible.push_back( *ieot ); - } else { - pop_unfeasible.push_back( *ieot ); - } - } - - _stat_feasible( pop_feasible ); - _stat_unfeasible( pop_unfeasible ); + _stat_feasible( _pop_split.feasible() ); + _stat_unfeasible( _pop_split.unfeasible() ); std::ostringstream out; out << _stat_feasible.value() << _sep << _stat_unfeasible.value(); value() = out.str(); } - -protected: -// eoStat & _stat_feasible; -// eoStat & _stat_unfeasible; - EOSTAT & _stat_feasible; - EOSTAT & _stat_unfeasible; - - std::string _sep; }; /** @} */ diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h index 793c6191a..0fce27148 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -1,12 +1,14 @@ +#ifndef MOEOEXPBINARYINDICATORBASEDDUALFITNESSASSIGNMENT_H_ +#define MOEOEXPBINARYINDICATORBASEDDUALFITNESSASSIGNMENT_H_ + #include template class moeoExpBinaryIndicatorBasedDualFitnessAssignment : public moeoExpBinaryIndicatorBasedFitnessAssignment { protected: - eoPop _feasible_pop; - eoPop _unfeasible_pop; + eoDualPopSplit _pop_split; public: typedef typename MOEOT::ObjectiveVector ObjectiveVector; @@ -26,20 +28,24 @@ public: */ virtual void operator()( eoPop& pop ) { - // separate the pop in the members - split( pop ); + // separate the pop in feasible/unfeasible + _pop_split( pop ); eoPop* ppop; - // if there is at least one feasible individual, it will supersede all the unfeasible ones - if( _feasible_pop.size() == 0 ) { - ppop = & _unfeasible_pop; + // if there is at least one feasible individual, + // it will supersede all the unfeasible ones + if( _pop_split.feasible().size() == 0 ) { + ppop = & _pop_split.unfeasible(); } else { - ppop = & _feasible_pop; + ppop = & _pop_split.feasible(); } this->setup(*ppop); this->computeValues(*ppop); - this->setFitnesses(*ppop); + this->setFitnesses(*ppop); // NOTE: this alter individuals + + // bring back altered individuals in the pop + pop = _pop_split.merge(); } @@ -47,25 +53,6 @@ protected: using moeoExpBinaryIndicatorBasedFitnessAssignment::kappa; - //! Split up the population in two: in one pop the feasible individual, in the other the feasible ones - virtual void split( eoPop & pop ) - { - // clear previously used populations - _feasible_pop.clear(); - _unfeasible_pop.clear(); - _feasible_pop.reserve(pop.size()); - _unfeasible_pop.reserve(pop.size()); - - for( typename eoPop::iterator it=pop.begin(), end=pop.end(); it != end; ++it ) { - // The ObjectiveVector should implement "is_feasible" - if( it->objectiveVector().is_feasible() ) { - _feasible_pop.push_back( *it ); - } else { - _unfeasible_pop.push_back( *it ); - } - } - } - /** * Compute every indicator value in values (values[i] = I(_v[i], _o)) * @param _pop the population @@ -112,3 +99,4 @@ protected: }; +#endif // MOEOEXPBINARYINDICATORBASEDDUALFITNESSASSIGNMENT_H_ From c44264e703e5daafe4243217185c21b01adaff15 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 10:00:15 +0200 Subject: [PATCH 054/419] Move the hyper volume dual difference metric in a separated file --- .../moeoDualHyperVolumeDifferenceMetric.h | 117 ++++++++++++++++++ .../metric/moeoHyperVolumeDifferenceMetric.h | 86 ------------- 2 files changed, 117 insertions(+), 86 deletions(-) create mode 100644 moeo/src/metric/moeoDualHyperVolumeDifferenceMetric.h diff --git a/moeo/src/metric/moeoDualHyperVolumeDifferenceMetric.h b/moeo/src/metric/moeoDualHyperVolumeDifferenceMetric.h new file mode 100644 index 000000000..b7774bb51 --- /dev/null +++ b/moeo/src/metric/moeoDualHyperVolumeDifferenceMetric.h @@ -0,0 +1,117 @@ +/* + +(c) 2013 Thales group + + 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 + +*/ + +#ifndef MOEODUALHYPERVOLUMEDIFFERENCEMETRIC_H_ +#define MOEODUALHYPERVOLUMEDIFFERENCEMETRIC_H_ + +#include + + +template +class moeoDualHyperVolumeDifferenceMetric : public moeoHyperVolumeDifferenceMetric +{ +protected: + using moeoHyperVolumeDifferenceMetric::rho; + using moeoHyperVolumeDifferenceMetric::normalize; + using moeoHyperVolumeDifferenceMetric::ref_point; + using moeoHyperVolumeDifferenceMetric::bounds; + +public: + + typedef typename ObjectiveVector::Type Type; + + moeoDualHyperVolumeDifferenceMetric( bool _normalize=true, double _rho=1.1) + : moeoHyperVolumeDifferenceMetric(_normalize, _rho) + { + + } + + moeoDualHyperVolumeDifferenceMetric( bool _normalize/*=true*/, ObjectiveVector& _ref_point/*=NULL*/ ) + : moeoHyperVolumeDifferenceMetric( _normalize, _ref_point ) + { + + } + + /** + * calculates and returns the HyperVolume value of a pareto front + * @param _set1 the vector contains all objective Vector of the first pareto front + * @param _set2 the vector contains all objective Vector of the second pareto front + */ + virtual double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) + { +#ifndef NDEBUG + // the two sets must be homogeneous in feasibility + assert( _set1.size() > 0 ); + for( unsigned int i=1; i<_set1.size(); ++i ) { + assert( _set1[i].is_feasible() == _set1[0].is_feasible() ); + } + assert( _set2.size() > 0 ); + for( unsigned int i=1; i<_set2.size(); ++i ) { + assert( _set2[i].is_feasible() == _set2[0].is_feasible() ); + } + // and they must have the same feasibility + assert( _set1[0].is_feasible() == _set2[0].is_feasible() ); +#endif + bool feasible = _set1[0].is_feasible(); + + double hypervolume_set1; + double hypervolume_set2; + + if(rho >= 1.0){ + //determine bounds + setup(_set1, _set2); + //determine reference point + for (unsigned int i=0; i unaryMetric(ref_point, bounds); + hypervolume_set1 = unaryMetric(_set1); + hypervolume_set2 = unaryMetric(_set2); + + return hypervolume_set1 - hypervolume_set2; + } +}; + +#endif /*MOEODUALHYPERVOLUMEDIFFERENCEMETRIC_H_*/ diff --git a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h index 64a001281..ad3336cd7 100644 --- a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h +++ b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h @@ -197,90 +197,4 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < }; - -template -class moeoDualHyperVolumeDifferenceMetric : public moeoHyperVolumeDifferenceMetric -{ -protected: - using moeoHyperVolumeDifferenceMetric::rho; - using moeoHyperVolumeDifferenceMetric::normalize; - using moeoHyperVolumeDifferenceMetric::ref_point; - using moeoHyperVolumeDifferenceMetric::bounds; - -public: - - typedef typename ObjectiveVector::Type Type; - - moeoDualHyperVolumeDifferenceMetric( bool _normalize=true, double _rho=1.1) - : moeoHyperVolumeDifferenceMetric(_normalize, _rho) - { - - } - - moeoDualHyperVolumeDifferenceMetric( bool _normalize/*=true*/, ObjectiveVector& _ref_point/*=NULL*/ ) - : moeoHyperVolumeDifferenceMetric( _normalize, _ref_point ) - { - - } - - /** - * calculates and returns the HyperVolume value of a pareto front - * @param _set1 the vector contains all objective Vector of the first pareto front - * @param _set2 the vector contains all objective Vector of the second pareto front - */ - virtual double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) - { -#ifndef NDEBUG - // the two sets must be homogeneous in feasibility - assert( _set1.size() > 0 ); - for( unsigned int i=1; i<_set1.size(); ++i ) { - assert( _set1[i].is_feasible() == _set1[0].is_feasible() ); - } - assert( _set2.size() > 0 ); - for( unsigned int i=1; i<_set2.size(); ++i ) { - assert( _set2[i].is_feasible() == _set2[0].is_feasible() ); - } - // and they must have the same feasibility - assert( _set1[0].is_feasible() == _set2[0].is_feasible() ); -#endif - bool feasible = _set1[0].is_feasible(); - - double hypervolume_set1; - double hypervolume_set2; - - if(rho >= 1.0){ - //determine bounds - setup(_set1, _set2); - //determine reference point - for (unsigned int i=0; i unaryMetric(ref_point, bounds); - hypervolume_set1 = unaryMetric(_set1); - hypervolume_set2 = unaryMetric(_set2); - - return hypervolume_set1 - hypervolume_set2; - } -}; - #endif /*MOEOHYPERVOLUMEMETRIC_H_*/ From 32b4f077c4ee70d64dd616518e98710967950891 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 10:36:33 +0200 Subject: [PATCH 055/419] Move the dual hypervolume continuator in a separated file --- moeo/src/continue/moeoDualHypContinue.h | 121 ++++++++++++++++++++++++ moeo/src/continue/moeoHypContinue.h | 111 ++++------------------ 2 files changed, 139 insertions(+), 93 deletions(-) create mode 100644 moeo/src/continue/moeoDualHypContinue.h diff --git a/moeo/src/continue/moeoDualHypContinue.h b/moeo/src/continue/moeoDualHypContinue.h new file mode 100644 index 000000000..99c33d45f --- /dev/null +++ b/moeo/src/continue/moeoDualHypContinue.h @@ -0,0 +1,121 @@ +/* + +(c) 2013 Thales group + + 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 + +*/ + +#ifndef _moeoDualHypContinue_h +#define _moeoDualHypContinue_h + +#include + +/** + Continues until the (feasible or unfeasible) given Pareto set is reached. + + + @ingroup Continuators + */ +template< class MOEOT, class MetricT = moeoDualHyperVolumeDifferenceMetric > +class moeoDualHypContinue: public moeoHypContinue +{ +protected: + bool is_feasible; + + using moeoHypContinue::arch; + using moeoHypContinue::OptimSet; + + using moeoHypContinue::pareto; + using moeoHypContinue::is_null_hypervolume; + +public: + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + typedef typename ObjectiveVector::Type AtomType; + + /** A continuator that stops once a given Pareto front has been reached + * + * You should specify the feasibility of the targeted front. + * NOTE: the MOEOT::ObjectiveVector is supposed to implement the moeoDualRealObjectiveVector interface. + * + */ + moeoDualHypContinue( const std::vector & _OptimVec, bool _is_feasible, moeoArchive < MOEOT > & _archive, bool _normalize=true, double _rho=1.1 ) + : moeoHypContinue( _OptimVec, _archive, _normalize, _rho ), + is_feasible(_is_feasible) + { + assert( _OptimVec.size() > 0); + vectorToParetoSet(_OptimVec); + } + + /** A continuator that stops once a given Pareto front has been reached + * + * You should specify the feasibility of the targeted front. + * NOTE: the MOEOT::ObjectiveVector is supposed to implement the moeoDualRealObjectiveVector interface. + * + */ + moeoDualHypContinue( const std::vector & _OptimVec, bool _is_feasible, moeoArchive < MOEOT > & _archive, bool _normalize=true, ObjectiveVector& _ref_point=NULL ) + : moeoHypContinue( _OptimVec, _archive, _normalize, _ref_point ), + is_feasible(_is_feasible) + { + assert( _OptimVec.size() > 0); + vectorToParetoSet(_OptimVec); + } + + + /** Returns false when a ParetoSet is reached. */ + virtual bool operator() ( const eoPop& /*_pop*/ ) + { + std::vector bestCurrentParetoSet = pareto( arch ); + +#ifndef NDEBUG + assert( bestCurrentParetoSet.size() > 0 ); + for( unsigned int i=1; i & _OptimVec) + { + unsigned dim = (unsigned)(_OptimVec.size()/ObjectiveVector::Traits::nObjectives()); + OptimSet.resize(dim); + + unsigned k=0; + for(size_t i=0; i < dim; i++) { + for (size_t j=0; j < ObjectiveVector::Traits::nObjectives(); j++) { + // Use the feasibility declaration of an eoDualFitness + OptimSet[i][j] = AtomType(_OptimVec[k++], is_feasible); + } + } + } +}; + +#endif diff --git a/moeo/src/continue/moeoHypContinue.h b/moeo/src/continue/moeoHypContinue.h index 228006d3a..bbc1a799b 100644 --- a/moeo/src/continue/moeoHypContinue.h +++ b/moeo/src/continue/moeoHypContinue.h @@ -36,7 +36,6 @@ //----------------------------------------------------------------------------- - #ifndef _moeoHypContinue_h #define _moeoHypContinue_h @@ -60,17 +59,29 @@ public: /// Ctor moeoHypContinue( const std::vector & _OptimVec, moeoArchive < MOEOT > & _archive, bool _normalize=true, double _rho=1.1) - : eoContinue(), arch(_archive), metric(_normalize,_rho) + : eoContinue(), arch(_archive), default_metric(new MetricT(_normalize,_rho)), metric(*default_metric) { vectorToParetoSet(_OptimVec); } moeoHypContinue( const std::vector & _OptimVec, moeoArchive < MOEOT > & _archive, bool _normalize=true, ObjectiveVector& _ref_point=NULL) - : eoContinue (), arch(_archive), metric(_normalize,_ref_point) + : eoContinue(), arch(_archive), default_metric(new MetricT(_normalize,_ref_point)), metric(*default_metric) { vectorToParetoSet(_OptimVec); } + moeoHypContinue( MetricT& _metric, const std::vector & _OptimVec, moeoArchive < MOEOT > & _archive ) + : eoContinue(), arch(_archive), default_metric(NULL), metric(_metric) + { + vectorToParetoSet(_OptimVec); + } + + ~moeoHypContinue() + { + if( default_metric != NULL ) { + delete default_metric; + } + } /** Returns false when a ParetoSet is reached. */ virtual bool operator() ( const eoPop& /*_pop*/ ) @@ -88,8 +99,8 @@ protected: { std::vector < ObjectiveVector > bestCurrentParetoSet; - for (size_t i=0; i & arch; - MetricT metric; + MetricT* default_metric; + MetricT& metric; std::vector OptimSet; }; -/** - Continues until the (feasible or unfeasible) given Pareto set is reached. - - - @ingroup Continuators - */ -template< class MOEOT, class MetricT = moeoDualHyperVolumeDifferenceMetric > -class moeoDualHypContinue: public moeoHypContinue -{ -protected: - bool is_feasible; - - using moeoHypContinue::arch; - using moeoHypContinue::OptimSet; - - using moeoHypContinue::pareto; - using moeoHypContinue::is_null_hypervolume; - -public: - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - typedef typename ObjectiveVector::Type AtomType; - - /** A continuator that stops once a given Pareto front has been reached - * - * You should specify the feasibility of the targeted front. - * NOTE: the MOEOT::ObjectiveVector is supposed to implement the moeoDualRealObjectiveVector interface. - * - */ - moeoDualHypContinue( const std::vector & _OptimVec, bool _is_feasible, moeoArchive < MOEOT > & _archive, bool _normalize=true, double _rho=1.1 ) - : moeoHypContinue( _OptimVec, _archive, _normalize, _rho ), is_feasible(_is_feasible) - { - assert( _OptimVec.size() > 0); - vectorToParetoSet(_OptimVec); - } - - /** A continuator that stops once a given Pareto front has been reached - * - * You should specify the feasibility of the targeted front. - * NOTE: the MOEOT::ObjectiveVector is supposed to implement the moeoDualRealObjectiveVector interface. - * - */ - moeoDualHypContinue( const std::vector & _OptimVec, bool _is_feasible, moeoArchive < MOEOT > & _archive, bool _normalize=true, ObjectiveVector& _ref_point=NULL ) - : moeoHypContinue( _OptimVec, _archive, _normalize, _ref_point ), is_feasible(_is_feasible) - { - assert( _OptimVec.size() > 0); - vectorToParetoSet(_OptimVec); - } - - /** Returns false when a ParetoSet is reached. */ - virtual bool operator() ( const eoPop& /*_pop*/ ) - { - std::vector bestCurrentParetoSet = pareto( arch ); - -#ifndef NDEBUG - assert( bestCurrentParetoSet.size() > 0 ); - for( unsigned int i=1; i & _OptimVec) - { - unsigned dim = (unsigned)(_OptimVec.size()/ObjectiveVector::Traits::nObjectives()); - OptimSet.resize(dim); - - unsigned k=0; - for(size_t i=0; i < dim; i++) { - for (size_t j=0; j < ObjectiveVector::Traits::nObjectives(); j++) { - // Use the feasibility declaration of an eoDualFitness - OptimSet[i][j] = AtomType(_OptimVec[k++], is_feasible); - } - } - } -}; - #endif From b132f48de2ed7f36570dbb1bdd9fbf26f4493984 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 10:37:25 +0200 Subject: [PATCH 056/419] Insert a copyright header --- ...inaryIndicatorBasedDualFitnessAssignment.h | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h index 0fce27148..78c3d08fe 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -1,3 +1,28 @@ +/* + +(c) 2013 Thales group + + 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 + +*/ + #ifndef MOEOEXPBINARYINDICATORBASEDDUALFITNESSASSIGNMENT_H_ #define MOEOEXPBINARYINDICATORBASEDDUALFITNESSASSIGNMENT_H_ From 70aa40f8887deafeafb3fc530093b654b8ab4937 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 10:37:48 +0200 Subject: [PATCH 057/419] Add dual hypervolume operators in the framewok header --- moeo/src/moeo | 2 ++ 1 file changed, 2 insertions(+) diff --git a/moeo/src/moeo b/moeo/src/moeo index eae7add7f..bc7282ffa 100644 --- a/moeo/src/moeo +++ b/moeo/src/moeo @@ -144,6 +144,7 @@ #include #include #include +#include #include #include #include @@ -217,5 +218,6 @@ #include #include +#include #endif /*MOEO_*/ From 272342bc16dd198a728756a6c24d4059be5149c3 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 14:44:02 +0200 Subject: [PATCH 058/419] Abstract base class for wrapping an estimator and a sampler as an eoTransform --- edo/src/edoTransform.h | 111 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 edo/src/edoTransform.h diff --git a/edo/src/edoTransform.h b/edo/src/edoTransform.h new file mode 100644 index 000000000..20421d5b1 --- /dev/null +++ b/edo/src/edoTransform.h @@ -0,0 +1,111 @@ +/* +The Evolving Distribution Objects framework (EDO) is a template-based, +ANSI-C++ evolutionary computation library which helps you to write your +own estimation of distribution algorithms. + +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; either +version 2.1 of the License, or (at your option) any later version. + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Copyright (C) 2013 Thales group +*/ +/* +Authors: + Johann Dréo +*/ + +#ifndef _edoTransform_h +#define _edoTransform_h + +#include // eoTransform + +/** @defgroup Wrappers + * + * Wrappers to interact with other parts of the framework + */ + +/** Abstract base class for wrapping an estimator and a sampler as an eoTransform + * + * @ingroup Wrappers + */ +template +class edoTransform : public eoTransform< eoPop& > +{ +public: + typedef typename D::EOType EOType; + + edoTransform( edoEstimator & estimator, edoSampler & sampler ) : + _estimator(estimator), _sampler(sampler) + {} + + virtual void operator()( eoPop & pop ) = 0; + +protected: + edoEstimator & _estimator; + edoSampler & _sampler; +}; + + +/** Wrapping an estimator and a sampler as an eoTransform. + * + * @ingroup Wrappers + */ +template +class edoTransformAdaptive : public edoTransform +{ +public: + typedef typename D::EOType EOType; + + edoTransformAdaptive( D & distrib, edoEstimator & estimator, edoSampler & sampler ) + : _distrib(distrib), _estimator(estimator), _sampler(sampler) + {} + + virtual void operator()( eoPop & pop ) + { + _distrib = _estimator( pop ); + pop.clear(); + for( unsigned int i = 0; i < pop.size(); ++i ) { + pop.push_back( _sampler(_distrib) ); + } + } + +protected: + D & _distrib; + edoEstimator & _estimator; + edoSampler & _sampler; +}; + + +/** Wrapping an estimator and a sampler as an eoTransform, + * the distribution is created at instanciation and replaced at each call. + * + * @ingroup Wrappers + */ +template +class edoTransformStateless : public edoTransformAdaptive +{ +public: + typedef typename D::EOType EOType; + + edoTransformStateless( edoEstimator & estimator, edoSampler & sampler ) + : edoTransformAdaptive( *(new D), estimator, sampler ) + {} + + ~edoTransformStateless() + { + // delete the temporary distrib allocated in constructor + delete &(this->_distrib); + } +}; + +#endif // !_edoTransform_h From 67e4bb01fd1a403e253ddf747e5c6a966450fbc1 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 14:45:51 +0200 Subject: [PATCH 059/419] Use EOType as a ref to the template in stats --- eo/src/eoDualFitness.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index da70e760a..ff952db66 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -438,22 +438,24 @@ public: * the second one on the unfeasible ones, merge the two resulting value in * a string, separated by a given marker. */ -template -class eoDualStatSwitch : public eoStat< EOT, std::string > +template +class eoDualStatSwitch : public eoStat< typename EOSTAT::EOType, std::string > { +public: + typedef typename EOSTAT::EOType EOType; protected: EOSTAT & _stat_feasible; EOSTAT & _stat_unfeasible; std::string _sep; - eoDualPopSplit _pop_split; + eoDualPopSplit _pop_split; public: - using eoStat::value; + using eoStat::value; eoDualStatSwitch( EOSTAT & stat_feasible, EOSTAT & stat_unfeasible, std::string sep=" " ) : - eoStat( + eoStat( "?"+sep+"?", stat_feasible.longName()+sep+stat_unfeasible.longName() ), @@ -462,7 +464,7 @@ public: _sep(sep) { } - virtual void operator()( const eoPop & pop ) + virtual void operator()( const eoPop & pop ) { // create two separated pop in this operator _pop_split( pop ); From f4b71dffadfec840c4bbfd29f7471a6ae0659d5d Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 14:48:00 +0200 Subject: [PATCH 060/419] Add a warning when computing stat in empty pop --- eo/src/utils/eoStat.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index fd26ec228..ccf3c4137 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -40,6 +40,7 @@ Contact: http://eodev.sourceforge.net #include #include //#include +#include /** @defgroup Stats Statistics computation * @@ -485,7 +486,8 @@ public: virtual void operator()( const eoPop & _pop ) { if( _pop.size() == 0 ) { - // how to implement value() = 0 ? + //FIXME how to implement value() = 0 ? + eo::log << eo::warnings << "Called " << className() << " on an empty pop, value unchanged" << std::endl; } else { eoPop pop = _pop; From 8679da695c288af5214df5b595e01a9668e28532 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 14:48:40 +0200 Subject: [PATCH 061/419] Add a reference to the template type in eoStat --- eo/src/utils/eoStat.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index ccf3c4137..e44eff33d 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -85,6 +85,7 @@ template class eoStat : public eoValueParam, public eoStatBase { public: + typedef EOT EOType; eoStat(T _value, std::string _description) : eoValueParam(_value, _description) @@ -121,6 +122,7 @@ template class eoSortedStat : public eoSortedStatBase, public eoValueParam { public : + typedef EOT EOType; eoSortedStat(ParamType _value, std::string _desc) : eoValueParam(_value, _desc) {} virtual std::string className(void) const { return "eoSortedStat"; } From 819c2c3106376e13228fa72053332c0d7675197e Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 14:49:08 +0200 Subject: [PATCH 062/419] [COMPATIBILITY] Remove a unused parameter in eoInterquartileRangeStat constructor --- eo/src/utils/eoStat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index e44eff33d..ae2569ab7 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -483,7 +483,7 @@ class eoInterquartileRangeStat : public eoStat< EOT, typename EOT::Fitness > public: using eoStat::value; - eoInterquartileRangeStat( typename EOT::Fitness start, std::string description = "IQR" ) : eoStat( start, description ) {} + eoInterquartileRangeStat( std::string description = "IQR" ) : eoStat( 0.0, description ) {} virtual void operator()( const eoPop & _pop ) { From 0c82be47df56cd913794446c438afba988def763 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 14:50:08 +0200 Subject: [PATCH 063/419] Add an Nth element stat to compute median without sorting the pop --- eo/src/utils/eoStat.h | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index ae2569ab7..7099470cd 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -475,6 +475,51 @@ public : }; */ +//! A robust measure of the mass (generally used to compute the median). Do not alter the given pop. +template +class eoNthElementStat : public eoStat< EOT, typename EOT::Fitness > +{ +protected: + int _nth; + double _ratio; + +public: + using eoStat::value; + + eoNthElementStat( int nth = 0, std::string description = "NthElement") + : eoStat( 0.0, description ), _nth(nth), _ratio(-1.0) + {} + + eoNthElementStat( double ratio = 0.5, std::string description = "Median" ) + : eoStat( 0.0, description ), _nth(-1), _ratio(ratio) + {} + + virtual void operator()( const eoPop & _pop ) + { + if( _nth == -1 ) { // asked for a ratio + _nth = static_cast( std::floor(_pop.size() * _ratio) ); + } else { + assert( _ratio == -1 ); // asked for a position + } + + if( _pop.size() == 0 ) { + //FIXME how to implement value() = 0 ? + eo::log << eo::warnings << "Called " << className() << " on an empty pop, value unchanged" << std::endl; + + } else { + eoPop pop = _pop; // copy, thus no sorting of the original pop + + std::nth_element( pop.begin(), pop.begin()+_nth, pop.end() ); + value() = pop[_nth].fitness(); + } + } + + virtual std::string className(void) const { return "eoNthElementStat"; } +}; +/** @example t-eoIQRStat.cpp + */ + + //! A robust measure of dispersion (also called midspread or middle fifty) that is the difference between the third and the first quartile. template From 6fa57622bed9c845ed7b6e3c3dfdde9eafe13911 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 14:50:44 +0200 Subject: [PATCH 064/419] Missing header and include guards for moeoBinaryMetricStat --- moeo/src/utils/moeoBinaryMetricStat.h | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/moeo/src/utils/moeoBinaryMetricStat.h b/moeo/src/utils/moeoBinaryMetricStat.h index f60d20c29..42b34ff11 100644 --- a/moeo/src/utils/moeoBinaryMetricStat.h +++ b/moeo/src/utils/moeoBinaryMetricStat.h @@ -1,5 +1,38 @@ +/* +(c) 2013 Thales group + 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 + +*/ + +#ifndef _MOEOBINARYMETRICSTAT_H_ +#define _MOEOBINARYMETRICSTAT_H_ + +#include + +/** A wrapper to save a moeoMetric in an eoStat + * + * This wrap a MOEO binary metric into an eoStat + * This is useful if you want to use it in a checkpoint, for instance. + */ template class moeoBinaryMetricStat : public eoStat { @@ -57,3 +90,5 @@ protected: bool _first_gen; }; + +#endif // _MOEOBINARYMETRICSTAT_H_ From 966a5670cbfe67068cf03ae17a36e12364dbc262 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 15:41:03 +0200 Subject: [PATCH 065/419] Add an option to print names in front of values in stream monitor --- eo/src/utils/eoOStreamMonitor.cpp | 6 ++++-- eo/src/utils/eoOStreamMonitor.h | 13 +++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/eo/src/utils/eoOStreamMonitor.cpp b/eo/src/utils/eoOStreamMonitor.cpp index 6836f337e..b9e848c58 100644 --- a/eo/src/utils/eoOStreamMonitor.cpp +++ b/eo/src/utils/eoOStreamMonitor.cpp @@ -47,8 +47,10 @@ eoMonitor& eoOStreamMonitor::operator()(void) */ for (iterator it = vec.begin (); it != vec.end (); ++it) { - // value only - out << (*it)->getValue (); + if( print_names ) { + out << (*it)->longName() << name_sep; + } + out << (*it)->getValue(); out << delim << std::left << std::setfill(fill) << std::setw(width); } // for it in vec diff --git a/eo/src/utils/eoOStreamMonitor.h b/eo/src/utils/eoOStreamMonitor.h index 982c954f9..032665224 100644 --- a/eo/src/utils/eoOStreamMonitor.h +++ b/eo/src/utils/eoOStreamMonitor.h @@ -56,8 +56,15 @@ public : } */ - eoOStreamMonitor( std::ostream & _out, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) : - out(_out), delim(_delim), width(_width), fill(_fill), firsttime(true) + eoOStreamMonitor( + std::ostream & _out, + std::string _delim = "\t", unsigned int _width=20, char _fill=' ', + bool _print_names = false, std::string _name_sep = ":" + ) : + out(_out), + delim(_delim), width(_width), fill(_fill), + firsttime(true), + print_names(_print_names), name_sep(_name_sep) {} eoMonitor& operator()(void); @@ -70,6 +77,8 @@ private : unsigned int width; char fill; bool firsttime; + bool print_names; + std::string name_sep; }; #endif // _eoOStreamMonitor_h_ From eef624e3f67a5207f041e805d7581e2bc84b3a67 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 16:25:00 +0200 Subject: [PATCH 066/419] Do not try to call dual stats on empty pop, print "?" instead --- eo/src/eoDualFitness.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index ff952db66..c7c6b4d71 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -469,11 +469,22 @@ public: // create two separated pop in this operator _pop_split( pop ); - _stat_feasible( _pop_split.feasible() ); - _stat_unfeasible( _pop_split.unfeasible() ); - std::ostringstream out; - out << _stat_feasible.value() << _sep << _stat_unfeasible.value(); + // do not call stat if the pop is empty + // and it can be, because of the split + if( _pop_split.feasible().size() > 0 ) { + _stat_feasible( _pop_split.feasible() ); + out << _stat_feasible.value(); + } else { + out << "?"; + } + out << _sep; + if( _pop_split.unfeasible().size() > 0 ) { + _stat_unfeasible( _pop_split.unfeasible() ); + out << _stat_unfeasible.value(); + } else { + out << "?"; + } value() = out.str(); } From c6868cf494927c804b41e398962b140e0ab0ba14 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 16:25:32 +0200 Subject: [PATCH 067/419] bugfix: correct nth position in nth element stat --- eo/src/utils/eoStat.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index 7099470cd..06cf2f451 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -488,19 +488,27 @@ public: eoNthElementStat( int nth = 0, std::string description = "NthElement") : eoStat( 0.0, description ), _nth(nth), _ratio(-1.0) - {} + { + assert( _nth >= 0 ); + } eoNthElementStat( double ratio = 0.5, std::string description = "Median" ) : eoStat( 0.0, description ), _nth(-1), _ratio(ratio) - {} + { + assert( _ratio >= 0 ); + } virtual void operator()( const eoPop & _pop ) { + unsigned int nth; if( _nth == -1 ) { // asked for a ratio - _nth = static_cast( std::floor(_pop.size() * _ratio) ); + nth = static_cast( std::floor(_pop.size() * _ratio) ); } else { assert( _ratio == -1 ); // asked for a position + nth = static_cast(_nth); } + assert( nth >= 0 ); + assert( nth < _pop.size() ); if( _pop.size() == 0 ) { //FIXME how to implement value() = 0 ? @@ -509,8 +517,8 @@ public: } else { eoPop pop = _pop; // copy, thus no sorting of the original pop - std::nth_element( pop.begin(), pop.begin()+_nth, pop.end() ); - value() = pop[_nth].fitness(); + std::nth_element( pop.begin(), pop.begin()+nth, pop.end() ); + value() = pop[nth].fitness(); } } From 2b80b91d281534e3af603805f04607fef5fc04f9 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 16:25:55 +0200 Subject: [PATCH 068/419] Use the templatized type for the metric in binary metric stat --- moeo/src/utils/moeoBinaryMetricStat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moeo/src/utils/moeoBinaryMetricStat.h b/moeo/src/utils/moeoBinaryMetricStat.h index 42b34ff11..a75ed20a2 100644 --- a/moeo/src/utils/moeoBinaryMetricStat.h +++ b/moeo/src/utils/moeoBinaryMetricStat.h @@ -81,7 +81,7 @@ public: protected: /** binary metric comparing two Pareto sets */ - moeoVectorVsVectorBinaryMetric & _metric; + moeoVectorVsVectorBinaryMetric & _metric; /** (n-1) population */ eoPop _prev_pop; From 6f4ecc603bf8360c4ae9c926a7247f4421cb57db Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 13 Jun 2013 16:28:51 +0200 Subject: [PATCH 069/419] bugfix correct asserts for nth element stat --- eo/src/utils/eoStat.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index 06cf2f451..313426c3f 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -502,12 +502,13 @@ public: { unsigned int nth; if( _nth == -1 ) { // asked for a ratio + assert( _ratio >= 0 && _ratio <= 1 ); nth = static_cast( std::floor(_pop.size() * _ratio) ); } else { assert( _ratio == -1 ); // asked for a position + assert( _nth >= 0 ); nth = static_cast(_nth); } - assert( nth >= 0 ); assert( nth < _pop.size() ); if( _pop.size() == 0 ) { From f8603acf3c561b10a933a45b802cd2edab3f0771 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Mon, 17 Jun 2013 13:59:09 +0200 Subject: [PATCH 070/419] bugfix: consider a dual fitness to be correctly initialized from a pair --- eo/src/eoDualFitness.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index c7c6b4d71..a6d6aa54e 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -174,6 +174,7 @@ public: { this->_value = v.first; this->is_feasible( v.second ); + this->_feasible_init = true; return *this; } @@ -184,6 +185,7 @@ public: if (this != &other) { this->_value = other._value; this->is_feasible( other.is_feasible() ); + this->_feasible_init = other._feasible_init; } return *this; } From 8340168ee8dbb26a28db34c21c6ef6cfd12ec741 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 20 Jun 2013 13:48:28 +0200 Subject: [PATCH 071/419] BUGFIX: correct handling of initialization security in dual fitness Remove the operator= overloads. Represent badly initialized dual fitness by a "?" for the feasibility. --- eo/src/eoDualFitness.h | 61 ++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 41 deletions(-) diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index a6d6aa54e..32bd91851 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -111,20 +111,17 @@ public: * If you use this interface, you MUST set the feasibility BEFORE * asking for it or the value. Or else, an assert will fail in debug mode. */ - template - eoDualFitness( T value ) : + eoDualFitness( const double value ) : _value(value), _is_feasible(false), _feasible_init(false) - { - } - + {} //! Copy constructor eoDualFitness(const eoDualFitness& other) : _value(other._value), _is_feasible(other._is_feasible), - _feasible_init(true) + _feasible_init(other._feasible_init) {} //! Constructor from explicit value/feasibility @@ -159,7 +156,7 @@ public: //! Explicitly set the feasibility. Useful if you have used previously the instantiation on a single scalar. inline void is_feasible( bool feasible ) { - this->is_feasible( feasible ); + this->_is_feasible = feasible; this->_feasible_init = true; } @@ -169,37 +166,6 @@ public: return _value; } - //! Copy operator from a std::pair - eoDualFitness& operator=( const std::pair& v ) - { - this->_value = v.first; - this->is_feasible( v.second ); - this->_feasible_init = true; - return *this; - } - - //! Copy operator from another eoDualFitness - template - eoDualFitness & operator=( const eoDualFitness& other ) - { - if (this != &other) { - this->_value = other._value; - this->is_feasible( other.is_feasible() ); - this->_feasible_init = other._feasible_init; - } - return *this; - } - - //! Copy operator from a scalar - template - eoDualFitness& operator=(const T v) - { - this->_value = v; - this->_is_feasible = false; - this->_feasible_init = false; - return *this; - } - //! Comparison that separate feasible individuals from unfeasible ones. Feasible are always better /*! * Use less as a default comparison operator @@ -236,7 +202,7 @@ public: bool operator>=(const eoDualFitness& other ) const { return !(*this < other); } //! Equal: if the other is equal to me - bool operator==(const eoDualFitness& other) const { return ( _is_feasible == other._is_feasible ) && ( _value == other._value ); } + bool operator==(const eoDualFitness& other) const { return ( this->is_feasible() == other.is_feasible() ) && ( _value == other._value ); } public: @@ -263,9 +229,11 @@ public: this->_value += that._value; // true only if the two are feasible, else false - // from._is_feasible = from._is_feasible && that._is_feasible; this->_is_feasible = this->_is_feasible && that._is_feasible; + // If the other was not correctly initialized + this->_feasible_init = that._feasible_init; + return *this; } @@ -282,9 +250,13 @@ public: { this->_value -= that._value; + // true only if the two are feasible, else false this->_is_feasible = this->_is_feasible && that._is_feasible; + // If the other was not correctly initialized + this->_feasible_init = that._feasible_init; + return *this; } @@ -305,6 +277,9 @@ public: // true only if the two are feasible, else false this->_is_feasible = this->_is_feasible && that._is_feasible; + // If the other was not correctly initialized + this->_feasible_init = that._feasible_init; + return *this; } @@ -355,7 +330,11 @@ public: friend std::ostream& operator<<( std::ostream& os, const eoDualFitness & fitness ) { - os << fitness._value << " " << fitness.is_feasible(); + if( fitness._feasible_init ) { + os << fitness._value << " " << fitness.is_feasible(); + } else { + os << fitness._value << " ?"; + } return os; } From 161d137d50835028c3fa2ac8b325e477535b9c94 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 21 Jun 2013 09:51:25 +0200 Subject: [PATCH 072/419] Add templates types as members of the dual fitness --- eo/src/eoDualFitness.h | 54 ++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index 32bd91851..44839ed67 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -64,12 +64,12 @@ Authors: * (i.e. when adding or substracting dual fitness, the only case when the result will be * a feasible fitness is when both are feasible, else the result is an unfeasibe fitness) */ -template +template class eoDualFitness { protected: //! Scalar type of the fitness (generally a double) - BaseType _value; + BaseT _value; //! Flag that marks if the individual is feasible bool _is_feasible; @@ -94,6 +94,8 @@ protected: bool _feasible_init; public: + typedef BaseT Base; + typedef Cmp Compare; //! Empty initialization /*! @@ -125,14 +127,14 @@ public: {} //! Constructor from explicit value/feasibility - eoDualFitness(const BaseType& v, const bool& is_feasible) : + eoDualFitness(const BaseT& v, const bool& is_feasible) : _value(v), _is_feasible(is_feasible), _feasible_init(true) {} //! From a std::pair (first element is the value, second is the feasibility) - eoDualFitness(const std::pair& dual) : + eoDualFitness(const std::pair& dual) : _value(dual.first), _is_feasible(dual.second), _feasible_init(true) @@ -144,7 +146,7 @@ public: * double val = 1.0; * val = fit; */ - operator BaseType(void) const { return _value; } + operator BaseT(void) const { return _value; } inline bool is_feasible() const @@ -160,7 +162,7 @@ public: this->_feasible_init = true; } - inline BaseType value() const + inline BaseT value() const { assert( _feasible_init ); return _value; @@ -169,7 +171,7 @@ public: //! Comparison that separate feasible individuals from unfeasible ones. Feasible are always better /*! * Use less as a default comparison operator - * (see the "Compare" template of the class to change this behaviour, + * (see the "Cmp" template of the class to change this behaviour, * @see eoMinimizingDualFitness for an example). */ bool operator<(const eoDualFitness& other) const @@ -188,7 +190,7 @@ public: } else { // the two fitness are of the same type // lets rely on the comparator - return Compare()(_value, other._value); + return Cmp()(_value, other._value); } } @@ -216,14 +218,14 @@ public: //! Add a given fitness to the current one template - eoDualFitness & operator+=( const T that ) + eoDualFitness & operator+=( const T that ) { this->_value += that; return *this; } //! Add a given fitness to the current one - eoDualFitness & operator+=( const eoDualFitness & that ) + eoDualFitness & operator+=( const eoDualFitness & that ) { // from._value += that._value; this->_value += that._value; @@ -239,14 +241,14 @@ public: //! Substract a given fitness to the current one template - eoDualFitness & operator-=( const T that ) + eoDualFitness & operator-=( const T that ) { this->_value -= that; return *this; } //! Substract a given fitness to the current one - eoDualFitness & operator-=( const eoDualFitness & that ) + eoDualFitness & operator-=( const eoDualFitness & that ) { this->_value -= that._value; @@ -263,14 +265,14 @@ public: //! Add a given fitness to the current one template - eoDualFitness & operator/=( T that ) + eoDualFitness & operator/=( T that ) { this->_value /= that; return *this; } //! Add a given fitness to the current one - eoDualFitness & operator/=( const eoDualFitness & that ) + eoDualFitness & operator/=( const eoDualFitness & that ) { this->_value /= that._value; @@ -284,51 +286,51 @@ public: } template - eoDualFitness operator+( T that ) + eoDualFitness operator+( T that ) { this->_value += that; return *this; } // Add this fitness's value to that other, and return a _new_ instance with the result. - eoDualFitness operator+( const eoDualFitness & that ) + eoDualFitness operator+( const eoDualFitness & that ) { - eoDualFitness from( *this ); + eoDualFitness from( *this ); return from += that; } template - eoDualFitness operator-( T that ) + eoDualFitness operator-( T that ) { this->_value -= that; return *this; } // Add this fitness's value to that other, and return a _new_ instance with the result. - eoDualFitness operator-( const eoDualFitness & that ) + eoDualFitness operator-( const eoDualFitness & that ) { - eoDualFitness from( *this ); + eoDualFitness from( *this ); return from -= that; } template - eoDualFitness operator/( T that ) + eoDualFitness operator/( T that ) { this->_value /= that; return *this; } // Add this fitness's value to that other, and return a _new_ instance with the result. - eoDualFitness operator/( const eoDualFitness & that ) + eoDualFitness operator/( const eoDualFitness & that ) { - eoDualFitness from( *this ); + eoDualFitness from( *this ); return from /= that; } //! Print an eoDualFitness instance as a pair of numbers, separated by a space friend - std::ostream& operator<<( std::ostream& os, const eoDualFitness & fitness ) + std::ostream& operator<<( std::ostream& os, const eoDualFitness & fitness ) { if( fitness._feasible_init ) { os << fitness._value << " " << fitness.is_feasible(); @@ -340,9 +342,9 @@ public: //! Read an eoDualFitness instance as a pair of numbers, separated by a space friend - std::istream& operator>>( std::istream& is, eoDualFitness & fitness ) + std::istream& operator>>( std::istream& is, eoDualFitness & fitness ) { - BaseType value; + BaseT value; is >> value; bool feasible; From 80aa04d6da1a0e949441381d80c5016f0f5db668 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Fri, 21 Jun 2013 09:52:12 +0200 Subject: [PATCH 073/419] Overload setup in the dual fitness assignment, to handle comparison overloading --- ...inaryIndicatorBasedDualFitnessAssignment.h | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h index 78c3d08fe..af57e372f 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -77,6 +77,41 @@ public: protected: using moeoExpBinaryIndicatorBasedFitnessAssignment::kappa; + using moeoExpBinaryIndicatorBasedFitnessAssignment::metric; + + + /** + * Sets the bounds for every objective using the min and the max value for every objective vector of _pop + * @param _pop the population + */ + void setup(const eoPop < MOEOT > & _pop) + { + Type worst, best; + typename MOEOT::ObjectiveVector::Type::Compare cmp; + + for (unsigned int i=0; i Date: Fri, 21 Jun 2013 11:09:15 +0200 Subject: [PATCH 074/419] Use the feasibility of the current individual for the feasability of the metric in dual fitness assignment --- ...BinaryIndicatorBasedDualFitnessAssignment.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h index af57e372f..d3b01eaed 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -130,7 +130,10 @@ protected: metric( pop[i].objectiveVector(), pop[j].objectiveVector() ), pop[i].objectiveVector().is_feasible() ); - } // if i != j + } else { // if i != j + assert( i == j ); + values[i][j] = Type( 0.0, pop[i].objectiveVector().is_feasible() ); + } } // for j in pop } // for i in pop } @@ -145,15 +148,14 @@ protected: virtual Type computeFitness(const unsigned int _idx) { - Type result( 0.0, values[_idx][_idx].is_feasible() ); - for (unsigned int i=0; i Date: Fri, 21 Jun 2013 11:26:41 +0200 Subject: [PATCH 075/419] Use a dedicated setup in dual HV metric, with feasibility --- .../moeoDualHyperVolumeDifferenceMetric.h | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/moeo/src/metric/moeoDualHyperVolumeDifferenceMetric.h b/moeo/src/metric/moeoDualHyperVolumeDifferenceMetric.h index b7774bb51..9cea4fd76 100644 --- a/moeo/src/metric/moeoDualHyperVolumeDifferenceMetric.h +++ b/moeo/src/metric/moeoDualHyperVolumeDifferenceMetric.h @@ -34,6 +34,7 @@ class moeoDualHyperVolumeDifferenceMetric : public moeoHyperVolumeDifferenceMetr { protected: using moeoHyperVolumeDifferenceMetric::rho; + using moeoHyperVolumeDifferenceMetric::tiny; using moeoHyperVolumeDifferenceMetric::normalize; using moeoHyperVolumeDifferenceMetric::ref_point; using moeoHyperVolumeDifferenceMetric::bounds; @@ -54,6 +55,60 @@ public: } + + /** + * method calculate bounds for the normalization + * @param _set1 the vector contains all objective Vector of the first pareto front + * @param _set2 the vector contains all objective Vector of the second pareto front + */ + void setup(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) + { + typename ObjectiveVector::Type::Compare cmp; + + if(_set1.size() < 1 || _set2.size() < 1) { + throw("Error in moeoHyperVolumeUnaryMetric::setup -> argument1: vector size must be greater than 0"); + } else { +#ifndef NDEBUG + if( _set1.size() == 1 || _set2.size() == 1 ) { + eo::log << eo::warnings << "Warning in moeoHyperVolumeUnaryMetric::setup one of the pareto set contains only one point (set1.size=" + << _set1.size() << ", set2.size=" << _set2.size() << ")" + << std::endl; + } +#endif + + typename ObjectiveVector::Type worst, best; + unsigned int nbObj=ObjectiveVector::Traits::nObjectives(); + bounds.resize(nbObj); + for (unsigned int i=0; i= 1 + } + /** * calculates and returns the HyperVolume value of a pareto front * @param _set1 the vector contains all objective Vector of the first pareto front From 0567d7be6ccbb29b17891362e4fd8c86c8278745 Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 25 Jun 2013 15:41:29 +0200 Subject: [PATCH 076/419] Use a specific comparator for the dual objective vector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because we want to have a separated comparator to use in the archive or… --- .../moeoParetoDualObjectiveVectorComparator.h | 58 +++++++++++++++++++ moeo/src/core/moeoDualRealObjectiveVector.h | 31 ++++------ moeo/src/moeo | 1 + 3 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 moeo/src/comparator/moeoParetoDualObjectiveVectorComparator.h diff --git a/moeo/src/comparator/moeoParetoDualObjectiveVectorComparator.h b/moeo/src/comparator/moeoParetoDualObjectiveVectorComparator.h new file mode 100644 index 000000000..e7e1ffd06 --- /dev/null +++ b/moeo/src/comparator/moeoParetoDualObjectiveVectorComparator.h @@ -0,0 +1,58 @@ +/* + +(c) 2010 Thales group + + 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 + Pierre Savéant + +*/ + +#ifndef MOEOPARETODUALOBJECTIVEVECTORCOMPARATOR_H_ +#define MOEOPARETODUALOBJECTIVEVECTORCOMPARATOR_H_ + +#include + +/** + * This functor class allows to compare 2 objective vectors according to Pareto dominance. + */ +template < class ObjectiveVector > +class moeoParetoDualObjectiveVectorComparator : public moeoParetoObjectiveVectorComparator< ObjectiveVector > + { + public: + + /** + * Returns true if ov1 is dominated by ov2 + * @param _ov1 the first objective vector + * @param _ov2 the second objective vector + */ + bool operator()(const ObjectiveVector & ov1, const ObjectiveVector & ov2) + { + if( ov1.is_feasible() && !ov2.is_feasible() ) { + return false; + } else if( !ov1.is_feasible() && ov2.is_feasible() ) { + return true; + } else { + return moeoParetoObjectiveVectorComparator::operator()(ov1, ov2); + } + } + + }; + +#endif /*MOEOPARETODUALOBJECTIVEVECTORCOMPARATOR_H_*/ diff --git a/moeo/src/core/moeoDualRealObjectiveVector.h b/moeo/src/core/moeoDualRealObjectiveVector.h index 1ed62a8ff..64bf65f57 100644 --- a/moeo/src/core/moeoDualRealObjectiveVector.h +++ b/moeo/src/core/moeoDualRealObjectiveVector.h @@ -42,6 +42,8 @@ class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector::size; using moeoScalarObjectiveVector < ObjectiveVectorTraits, T >::operator[]; @@ -73,28 +75,16 @@ class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector & other) const { - // am I better than the other ? - - // if I'm feasible and the other is not - if( this->is_feasible() && !other.is_feasible() ) { - // no, the other has a better objective - return true; - - } else if( !this->is_feasible() && other.is_feasible() ) { - // yes, a feasible objective is always better than an unfeasible one - return false; - - } else { - // the two objective are of the same type - // lets rely on the comparator - moeoParetoObjectiveVectorComparator< moeoDualRealObjectiveVector > comparator; - return comparator(other, *this); - } + moeoParetoDualObjectiveVectorComparator cmp; + return cmp( other, *this ); } - //! Use when maximizing an + //! True if this is smaller than other bool operator<(const moeoDualRealObjectiveVector < ObjectiveVectorTraits > & other) const { // am I better than the other ? @@ -102,14 +92,15 @@ class moeoDualRealObjectiveVector : public moeoScalarObjectiveVectoris_feasible() && !other.is_feasible() ) { // no, the other has a better objective - return true; + return false; } else if( !this->is_feasible() && other.is_feasible() ) { // yes, a feasible objective is always better than an unfeasible one - return false; + return true; } else { moeoObjectiveObjectiveVectorComparator < moeoDualRealObjectiveVector < ObjectiveVectorTraits > > cmp; + // Returns true if this is smaller than other return cmp(*this, other); } } diff --git a/moeo/src/moeo b/moeo/src/moeo index bc7282ffa..3b310d64f 100644 --- a/moeo/src/moeo +++ b/moeo/src/moeo @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include From e6beab8e5c5290c1bc30aa15d6f492d5a3e31ded Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Tue, 25 Jun 2013 15:42:56 +0200 Subject: [PATCH 077/419] Use the fitness type instead of the objective vectors in fitness assignments --- .../moeoExpBinaryIndicatorBasedDualFitnessAssignment.h | 7 ++++--- .../fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h index d3b01eaed..959be717d 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -38,6 +38,7 @@ protected: public: typedef typename MOEOT::ObjectiveVector ObjectiveVector; typedef typename ObjectiveVector::Type Type; + typedef typename MOEOT::Fitness Fitness; using moeoExpBinaryIndicatorBasedFitnessAssignment::values; @@ -146,10 +147,10 @@ protected: } } - virtual Type computeFitness(const unsigned int _idx) + virtual Fitness computeFitness(const unsigned int _idx) { - // Type result( 0.0, values[_idx][_idx].is_feasible() ); - Type result( 0.0, values[_idx][_idx].is_feasible() ); + // Fitness result( 0.0, values[_idx][_idx].is_feasible() ); + Fitness result( 0.0, values[_idx][_idx].is_feasible() ); for (unsigned int i=0; i Date: Tue, 25 Jun 2013 16:28:25 +0200 Subject: [PATCH 078/419] fast computation of dominance-depth corrected for minimizing objectives --- .../moeoDominanceDepthFitnessAssignment.h | 16 +++++++++++++++- .../t-moeoDominanceDepthFitnessAssignment.cpp | 10 +++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h b/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h index b07b6b7a1..6aad16fe2 100644 --- a/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h +++ b/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h @@ -155,7 +155,10 @@ private: */ bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) { - return cmp(_moeo2.objectiveVector(), _moeo1.objectiveVector()); + if (MOEOT::ObjectiveVector::maximizing(0)) + return cmp(_moeo2.objectiveVector(), _moeo1.objectiveVector()); + else + return cmp(_moeo1.objectiveVector(), _moeo2.objectiveVector()); } private: /** the corresponding comparator for objective vectors */ @@ -207,6 +210,17 @@ private: moeoPtrComparator cmp(objComparator); std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp); + + // + std::cout << std::endl << "sorted pop" << std::endl; + std::cout << "====================" << std::endl; + for(unsigned int i=0; i<_pop.size(); i++) + { + std::cout << i << " : " << (*sortedptrpop[i]) << std::endl; + } + std::cout << "====================" << std::endl; + // + // compute an upper bound on the second objective (1) double max_obj1 = std::numeric_limits::min(); for(unsigned int i=0; i<_pop.size(); i++) diff --git a/moeo/test/t-moeoDominanceDepthFitnessAssignment.cpp b/moeo/test/t-moeoDominanceDepthFitnessAssignment.cpp index 58a636769..71fae12dc 100644 --- a/moeo/test/t-moeoDominanceDepthFitnessAssignment.cpp +++ b/moeo/test/t-moeoDominanceDepthFitnessAssignment.cpp @@ -81,8 +81,8 @@ int main() obj3[1] = 5; obj4[0] = 5; obj4[1] = 1; - obj5[0] = 3; - obj5[1] = 3; + obj5[0] = 4; + obj5[1] = 4; // population eoPop < Solution > pop; @@ -97,6 +97,10 @@ int main() // fitness assignment moeoDominanceDepthFitnessAssignment< Solution > fitnessAssignment; fitnessAssignment(pop); + + for (unsigned int fun=0; fun Date: Wed, 26 Jun 2013 18:09:26 +0200 Subject: [PATCH 079/419] Replace a cout msg by a eo::log warning --- moeo/src/metric/moeoHypervolumeBinaryMetric.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moeo/src/metric/moeoHypervolumeBinaryMetric.h b/moeo/src/metric/moeoHypervolumeBinaryMetric.h index a9f3bfe8d..bd6b1e606 100644 --- a/moeo/src/metric/moeoHypervolumeBinaryMetric.h +++ b/moeo/src/metric/moeoHypervolumeBinaryMetric.h @@ -72,8 +72,7 @@ class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinar // consistency check if (rho < 1) { - std::cout << "Warning, value used to compute the reference point rho for the hypervolume calculation must not be smaller than 1" << std::endl; - std::cout << "Adjusted to 1" << std::endl; + eo::log << eo::warnings << "Warning, value used to compute the reference point rho for the hypervolume calculation must not be smaller than 1, adjusted to 1" << std::endl; rho = 1; } } @@ -123,6 +122,7 @@ class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinar double result; double range = rho * bounds[_obj].range(); double max = bounds[_obj].minimum() + range; + // value of _1 for the objective _obj double v1 = _o1[_obj]; // value of _2 for the objective _obj (if _flag=true, v2=max) From 5b39705a20cd1161cc51df3a7141e1366678984c Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 26 Jun 2013 18:09:49 +0200 Subject: [PATCH 080/419] BUGFIX pop split everywhere in exp dual fitness assignment Apply the fitness assignment on both splited pop, not just one. Apply also the partial update on splited pop. Confine numeric valuesto double limits, to avoid overflows. --- ...inaryIndicatorBasedDualFitnessAssignment.h | 89 ++++++++++++++++--- 1 file changed, 77 insertions(+), 12 deletions(-) diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h index 959be717d..98c6a51d2 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -57,21 +57,28 @@ public: // separate the pop in feasible/unfeasible _pop_split( pop ); - eoPop* ppop; // if there is at least one feasible individual, // it will supersede all the unfeasible ones - if( _pop_split.feasible().size() == 0 ) { - ppop = & _pop_split.unfeasible(); - } else { - ppop = & _pop_split.feasible(); + if( _pop_split.unfeasible().size() != 0 ) { + this->setup(_pop_split.unfeasible()); + this->computeValues(_pop_split.unfeasible()); + this->setFitnesses(_pop_split.unfeasible()); // NOTE: this alter individuals } - this->setup(*ppop); - this->computeValues(*ppop); - this->setFitnesses(*ppop); // NOTE: this alter individuals + if( _pop_split.feasible().size() != 0 ) { + this->setup(_pop_split.feasible()); + this->computeValues(_pop_split.feasible()); + this->setFitnesses(_pop_split.feasible()); // NOTE: this alter individuals + } // bring back altered individuals in the pop - pop = _pop_split.merge(); + // pop = _pop_split.merge(); + + eoPop merged = _pop_split.merge(); + assert( pop.size() == merged.size()); + for( unsigned int i=0; i & pop, ObjectiveVector & objVec) + { + _pop_split(pop); + + if( objVec.is_feasible() ) { + setup(_pop_split.feasible()); + updateFitnessByDeleting( _pop_split.feasible(), objVec); + } else { + setup(_pop_split.unfeasible()); + updateFitnessByDeleting( _pop_split.unfeasible(), objVec ); + } + // pop = _pop_split.merge(); + eoPop merged = _pop_split.merge(); + assert( pop.size() == merged.size()); + for( unsigned int i=0; i & pop, ObjectiveVector & objVec ) + { + std::vector < double > v; + v.resize(pop.size()); + for (unsigned int i=0; i + T confine( T n ) + { + T tmax = std::numeric_limits::max(); + T tmin = -1 * tmax; + + tmin.is_feasible( n.is_feasible() ); + tmax.is_feasible( n.is_feasible() ); + + if( n < tmin ) { + return tmin; + } else if( n > tmax ) { + return tmax; + } else { + return n; + } + } }; From b1c7e1f256d73fab9605475fe5ebfd03220f2d52 Mon Sep 17 00:00:00 2001 From: quemy Date: Thu, 21 Nov 2013 12:40:24 +0100 Subject: [PATCH 081/419] Wrapper on eoFitContinue in order to allow islands to stop as soon as an island found a good solution --- CMakeLists.txt | 10 +-- eo/src/serial/CMakeLists.txt | 4 +- moeo/src/CMakeLists.txt | 2 +- smp/src/CMakeLists.txt | 1 + smp/src/sharedFitContinue.cpp | 47 +++++++++++ smp/src/sharedFitContinue.h | 78 +++++++++++++++++++ smp/src/smp.h | 2 + smp/test/CMakeLists.txt | 1 + smp/test/t-smpSharedFitContinue.cpp | 116 ++++++++++++++++++++++++++++ smp/tutorial/Lesson3/CMakeLists.txt | 1 + 10 files changed, 254 insertions(+), 8 deletions(-) create mode 100644 smp/src/sharedFitContinue.cpp create mode 100644 smp/src/sharedFitContinue.h create mode 100644 smp/test/t-smpSharedFitContinue.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f279e5a3e..9253f007d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,12 +77,12 @@ set( MPI_BIN_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "ParadisEO-MPI binary dir set(EO_ONLY "false" CACHE BOOL "Only build EO and not the other modules") -set(ENABLE_OPENMP "false" CACHE BOOL "Build EO with the OpenMP support (shared-memory parallel evaluators on multi-core)") -set(ENABLE_GNUPLOT "false" CACHE BOOL "Build EO with the GNUplot support (real-time convergence plotting)") -set(EDO "false" CACHE BOOL "Build the EDO module") +set(ENABLE_OPENMP "true" CACHE BOOL "Build EO with the OpenMP support (shared-memory parallel evaluators on multi-core)") +set(ENABLE_GNUPLOT "true" CACHE BOOL "Build EO with the GNUplot support (real-time convergence plotting)") +set(EDO "true" CACHE BOOL "Build the EDO module") set(EDO_USE_LIB "Eigen3" CACHE STRING "Which linear algebra library to use to build EDO ('UBlas' or 'Eigen3', Eigen3 is recommended)") -set(SMP "false" CACHE BOOL "Build the SMP module") -set(MPI "false" CACHE BOOL "Build the MPI module") +set(SMP "true" CACHE BOOL "Build the SMP module") +set(MPI "true" CACHE BOOL "Build the MPI module") ## EO Module set(EO_MODULE_NAME "Evolving Object") diff --git a/eo/src/serial/CMakeLists.txt b/eo/src/serial/CMakeLists.txt index efc9f42e2..d7a6fb574 100644 --- a/eo/src/serial/CMakeLists.txt +++ b/eo/src/serial/CMakeLists.txt @@ -20,10 +20,10 @@ set(EOSERIAL_SOURCES ) add_library(eoserial STATIC ${EOSERIAL_SOURCES}) -install(TARGETS eoserial ARCHIVE DESTINATION lib COMPONENT libraries) +install(TARGETS eoserial ARCHIVE DESTINATION ${LIB} COMPONENT libraries) file(GLOB HDRS *.h) -install(FILES ${HDRS} DESTINATION include/eo/serial COMPONENT headers) +install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/eo/serial COMPONENT headers) ###################################################################################### ### 3) Optionnal diff --git a/moeo/src/CMakeLists.txt b/moeo/src/CMakeLists.txt index 6c645008b..a696cdbb5 100644 --- a/moeo/src/CMakeLists.txt +++ b/moeo/src/CMakeLists.txt @@ -36,7 +36,7 @@ install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/moeo COMPONENT heade ### 4) Install directories ###################################################################################### -install(DIRECTORY acceptCrit algo archive comparator core distance diversity do explorer fitness hybridization metric replacement scalarStuffs selection utils +install(DIRECTORY acceptCrit algo archive continue comparator core distance diversity do explorer fitness hybridization metric replacement scalarStuffs selection utils DESTINATION include${INSTALL_SUB_DIR}/moeo COMPONENT headers FILES_MATCHING PATTERN "*.h" diff --git a/smp/src/CMakeLists.txt b/smp/src/CMakeLists.txt index 1135119a0..07cde8272 100644 --- a/smp/src/CMakeLists.txt +++ b/smp/src/CMakeLists.txt @@ -32,6 +32,7 @@ set (SMP_FILE topology/customStochasticTopology.cpp notifier.cpp islandModelWrapper.h + sharedFitContinue.h ) add_library(smp STATIC ${SMP_FILE}) diff --git a/smp/src/sharedFitContinue.cpp b/smp/src/sharedFitContinue.cpp new file mode 100644 index 000000000..30e53ac3d --- /dev/null +++ b/smp/src/sharedFitContinue.cpp @@ -0,0 +1,47 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2013 + +Alexandre Quemy - INSA Rouen + +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 +*/ + +template +bool paradiseo::smp::SharedFitContinue::operator()(const eoPop& _pop) +{ + if(found) + return false; + else + { + found = fit(_pop); + return found; + } +} + +template +std::string paradiseo::smp::SharedFitContinue::className(void) const +{ + return "smp::SharedFitContinue"; +} + diff --git a/smp/src/sharedFitContinue.h b/smp/src/sharedFitContinue.h new file mode 100644 index 000000000..b2c26d063 --- /dev/null +++ b/smp/src/sharedFitContinue.h @@ -0,0 +1,78 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012 + +Alexandre Quemy - INSA Rouen + +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 SMP_SHARED_FIT_CONTINUE_H_ +#define SMP_SHARED_FIT_CONTINUE_H_ + +#include + +#include +#include + +namespace paradiseo +{ +namespace smp +{ + +/** SharedFitContinue + +Wrapper on the eoFitContinue in order to allow the island model to stop as soon as an island found a good solution. + +@see smp::Island, eoFitContinue +*/ + +template +class SharedFitContinue : public eoContinue +{ +public: + + typedef typename EOT::Fitness Fitness; + + SharedFitContinue(const Fitness _optimum) : + fit(_optimum), + found(false) + {}; + + virtual bool operator() ( const eoPop& _pop ); + + virtual std::string className(void) const; + +protected: + eoFitContinue fit; + std::atomic found; + +}; + +#include + +} + +} + +#endif diff --git a/smp/src/smp.h b/smp/src/smp.h index c2bbcdada..7bfb17864 100644 --- a/smp/src/smp.h +++ b/smp/src/smp.h @@ -52,5 +52,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr #include #include +// Continuators +#include #endif diff --git a/smp/test/CMakeLists.txt b/smp/test/CMakeLists.txt index b855a1e4f..a31fbcef3 100644 --- a/smp/test/CMakeLists.txt +++ b/smp/test/CMakeLists.txt @@ -21,6 +21,7 @@ set (TEST_LIST t-smpMI_Heterogeneous t-smpMI_Wrapper t-smpCustomTopo + t-smpSharedFitContinue ) ###################################################################################### diff --git a/smp/test/t-smpSharedFitContinue.cpp b/smp/test/t-smpSharedFitContinue.cpp new file mode 100644 index 000000000..56afa7cbb --- /dev/null +++ b/smp/test/t-smpSharedFitContinue.cpp @@ -0,0 +1,116 @@ +#include +#include + +#include "smpTestClass.h" + +using namespace paradiseo::smp; +using namespace std; + +int main(void) +{ + // Defining parameters + typedef struct { + unsigned popSize = 1000; + unsigned tSize = 2; + double pCross = 0.8; + double pMut = 0.7; + unsigned maxGen = 1000; + } Param; + + Param param; + + // Fixing the seed + rng.reseed(42); + + // Load instance + loadInstances("t-data.dat", n, bkv, a, b); + + //Common part to all islands + IndiEvalFunc plainEval; + IndiInit chromInit; + eoDetTournamentSelect selectOne(param.tSize); + eoSelectPerc select(selectOne);// by default rate==1 + IndiXover Xover; // CROSSOVER + IndiSwapMutation mutationSwap; // MUTATION + eoSGATransform transform(Xover, param.pCross, mutationSwap, param.pMut); + eoPlusReplacement replace; + + SharedFitContinue cont(5000); + + // MODEL + // Topologies + Topology topo; + IslandModel model(topo); + + // ISLAND 1 + // // Algorithm part + eoPop pop(param.popSize, chromInit); + // // Emigration policy + // // // Element 1 + eoPeriodicContinue criteria(5); + eoDetTournamentSelect selectOne1(20); + eoSelectNumber who(selectOne1, 3); + + MigPolicy migPolicy; + migPolicy.push_back(PolicyElement(who, criteria)); + + // // Integration policy + eoPlusReplacement intPolicy; + + Island test(pop, intPolicy, migPolicy, cont, plainEval, select, transform, replace); + + // ISLAND 1 + // // Algorithm part + eoPop pop2(30, chromInit); + // // Emigration policy + // // // Element 1 + eoPeriodicContinue criteria_2(5); + eoDetTournamentSelect selectOne_2(25); + eoSelectNumber who_2(selectOne_2, 5); + + MigPolicy migPolicy_2; + migPolicy_2.push_back(PolicyElement(who_2, criteria_2)); + + // // Integration policy + eoPlusReplacement intPolicy_2; + + Island test2(pop2, intPolicy_2, migPolicy_2, cont, plainEval, select, transform, replace); + + // Island 3 + // // Algorithm part + eoPop pop3(30, chromInit); + // // Emigration policy + // // // Element 1 + eoPeriodicContinue criteria_3(10); + eoDetTournamentSelect selectOne_3(15); + eoSelectNumber who_3(selectOne_3, 1); + + MigPolicy migPolicy_3; + migPolicy.push_back(PolicyElement(who_3, criteria_3)); + + // // Integration policy + eoPlusReplacement intPolicy_3; + + Island test3(pop3, intPolicy_3, migPolicy_3, cont, plainEval, select, transform, replace); + + + try + { + + model.add(test); + model.add(test2); + model.add(test3); + + model(); + + cout << test.getPop() << endl; + cout << test2.getPop() << endl; + cout << test3.getPop() << endl; + } + catch(exception& e) + { + cout << "Exception: " << e.what() << '\n'; + } + + return 0; +} diff --git a/smp/tutorial/Lesson3/CMakeLists.txt b/smp/tutorial/Lesson3/CMakeLists.txt index 9e199afd4..363e5d956 100644 --- a/smp/tutorial/Lesson3/CMakeLists.txt +++ b/smp/tutorial/Lesson3/CMakeLists.txt @@ -6,6 +6,7 @@ set(files lesson3_heterogeneous + #mo-tsp ) ###################################################################################### From 7c4346d0904fab9bd2964a2ff4c9003e171930b3 Mon Sep 17 00:00:00 2001 From: quemy Date: Thu, 21 Nov 2013 12:56:47 +0100 Subject: [PATCH 082/419] Revert some modifications in the main CMakefiles accidentally pushed. --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9253f007d..f279e5a3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,12 +77,12 @@ set( MPI_BIN_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "ParadisEO-MPI binary dir set(EO_ONLY "false" CACHE BOOL "Only build EO and not the other modules") -set(ENABLE_OPENMP "true" CACHE BOOL "Build EO with the OpenMP support (shared-memory parallel evaluators on multi-core)") -set(ENABLE_GNUPLOT "true" CACHE BOOL "Build EO with the GNUplot support (real-time convergence plotting)") -set(EDO "true" CACHE BOOL "Build the EDO module") +set(ENABLE_OPENMP "false" CACHE BOOL "Build EO with the OpenMP support (shared-memory parallel evaluators on multi-core)") +set(ENABLE_GNUPLOT "false" CACHE BOOL "Build EO with the GNUplot support (real-time convergence plotting)") +set(EDO "false" CACHE BOOL "Build the EDO module") set(EDO_USE_LIB "Eigen3" CACHE STRING "Which linear algebra library to use to build EDO ('UBlas' or 'Eigen3', Eigen3 is recommended)") -set(SMP "true" CACHE BOOL "Build the SMP module") -set(MPI "true" CACHE BOOL "Build the MPI module") +set(SMP "false" CACHE BOOL "Build the SMP module") +set(MPI "false" CACHE BOOL "Build the MPI module") ## EO Module set(EO_MODULE_NAME "Evolving Object") From cfbe7ad24207f6a9162d5563b98bf20de22e5875 Mon Sep 17 00:00:00 2001 From: quemy Date: Thu, 21 Nov 2013 13:20:22 +0100 Subject: [PATCH 083/419] Fix a bug in IslandModel in order to clean the list of emigrants at the end of the algorithm --- smp/src/islandModel.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/smp/src/islandModel.cpp b/smp/src/islandModel.cpp index 597818bd2..f93362011 100644 --- a/smp/src/islandModel.cpp +++ b/smp/src/islandModel.cpp @@ -56,7 +56,7 @@ void paradiseo::smp::IslandModel::operator()() // Launching threads unsigned i = 0; - for(auto it : islands) + for(auto& it : islands) { it.first->setRunning(); threads[i] = std::thread(&AIsland::operator(), it.first); @@ -104,18 +104,21 @@ void paradiseo::smp::IslandModel::operator()() sentMessages.clear(); // Force last integration + while(!listEmigrants.empty()) + send(); i = 0; - for(auto it : islands) + for(auto& it : islands) { threads[i] = std::thread(&AIsland::receive, it.first); i++; } - + // Wait the end of the last integration for(auto& thread : threads) thread.join(); running = false; + std::cout << "hhhhhhh" << listEmigrants.size() << std::endl; } template From 84b3601f9027b2fd2241c543db13f0d64ec6380d Mon Sep 17 00:00:00 2001 From: quemy Date: Fri, 22 Nov 2013 08:31:46 +0100 Subject: [PATCH 084/419] Invalidate individuals in order to force evaluation in Island. Remove some debug messages. --- smp/src/island.cpp | 5 ++++- smp/src/islandModel.cpp | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/smp/src/island.cpp b/smp/src/island.cpp index ea3e5ea92..783d42d75 100644 --- a/smp/src/island.cpp +++ b/smp/src/island.cpp @@ -140,7 +140,6 @@ void paradiseo::smp::Island::receive(void) std::lock_guard lock(this->m); while (!listImigrants.empty()) { - //std::cout << "On reçoit dans l'île : " << listImigrants.size() << std::endl; eoPop base_offspring = std::move(listImigrants.front()); // Convert objects from base to our objects type @@ -149,8 +148,12 @@ void paradiseo::smp::Island::receive(void) offspring.push_back(std::move(convertFromBase(indi))); // Evaluate objects to integrate + // We first invalidate the individuals in order to explicitly force the evaluation for(auto& indi : offspring) + { + indi.invalidate(); eval(indi); + } intPolicy(pop, offspring); listImigrants.pop(); diff --git a/smp/src/islandModel.cpp b/smp/src/islandModel.cpp index f93362011..e32fb8e4f 100644 --- a/smp/src/islandModel.cpp +++ b/smp/src/islandModel.cpp @@ -118,7 +118,6 @@ void paradiseo::smp::IslandModel::operator()() thread.join(); running = false; - std::cout << "hhhhhhh" << listEmigrants.size() << std::endl; } template From 33d82973d265b1d1fb8a279b5593092c5208ca8f Mon Sep 17 00:00:00 2001 From: manu Date: Fri, 18 Apr 2014 18:03:43 +0200 Subject: [PATCH 085/419] * mo/src/acceptCrit/moBetterAcceptCrit.h: Fix typo. Signed-off-by: quemy --- mo/src/acceptCrit/moBetterAcceptCrit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mo/src/acceptCrit/moBetterAcceptCrit.h b/mo/src/acceptCrit/moBetterAcceptCrit.h index 13f2f867c..e8bfae9d5 100644 --- a/mo/src/acceptCrit/moBetterAcceptCrit.h +++ b/mo/src/acceptCrit/moBetterAcceptCrit.h @@ -46,7 +46,7 @@ public: /* constructor with a specific comparator - @param _comparator the comparaison method of two solutions + @param _comparator the comparison method of two solutions */ moBetterAcceptCrit(moSolComparator& _comparator):comparator(_comparator) {} From 38ccef5058074192dce513c48432ffd6c48b4199 Mon Sep 17 00:00:00 2001 From: manu Date: Fri, 25 Apr 2014 21:27:52 +0200 Subject: [PATCH 086/419] Update various comments * moeo/src/algo/moeoSPEA2.h: replace NSGA-II by SPEA2 in comments. * moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h: Fix typos. * moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h: Mention SPEA2. Cite Zitzler. --- moeo/src/algo/moeoSPEA2.h | 4 ++-- .../moeoFrontByFrontCrowdingDiversityAssignment.h | 4 ++-- .../diversity/moeoNearestNeighborDiversityAssignment.h | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/moeo/src/algo/moeoSPEA2.h b/moeo/src/algo/moeoSPEA2.h index a6416ecc2..8b419b5f5 100644 --- a/moeo/src/algo/moeoSPEA2.h +++ b/moeo/src/algo/moeoSPEA2.h @@ -255,7 +255,7 @@ protected: eoQuadCloneOp < MOEOT > defaultQuadOp; /** an object for genetic operators (used as default) */ eoSGAGenOp < MOEOT > defaultSGAGenOp; - /** fitness assignment used in NSGA-II */ + /** fitness assignment used in SPEA2 */ moeoDominanceCountRankingFitnessAssignment < MOEOT > fitnessAssignment; /** general breeder */ eoGeneralBreeder < MOEOT > genBreed; @@ -265,7 +265,7 @@ protected: eoSelectTransform selectTransform; /** breeder */ eoBreed < MOEOT > & breed; - /** diversity assignment used in NSGA-II */ + /** diversity assignment used in SPEA2 */ moeoNearestNeighborDiversityAssignment < MOEOT > diversityAssignment; /** elitist replacement */ moeoGenerationalReplacement < MOEOT > replace; diff --git a/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h b/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h index 7ab4e0067..c4909d504 100644 --- a/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h +++ b/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h @@ -44,9 +44,9 @@ /** - * Diversity assignment sheme based on crowding proposed in: + * Diversity assignment scheme based on crowding proposed in: * K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002). - * Tis strategy assigns diversity values FRONT BY FRONT. It is, for instance, used in NSGA-II. + * This strategy assigns diversity values FRONT BY FRONT. It is, for instance, used in NSGA-II. */ template < class MOEOT > class moeoFrontByFrontCrowdingDiversityAssignment : public moeoCrowdingDiversityAssignment < MOEOT > diff --git a/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h b/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h index 8571ed475..5b5680eef 100644 --- a/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h +++ b/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h @@ -46,7 +46,14 @@ #include /** - * moeoNearestNeighborDiversityAssignment is a moeoDiversityAssignment using distance between individuals to assign diversity. + * moeoNearestNeighborDiversityAssignment is a moeoDiversityAssignment + * using distance between individuals to assign diversity. Proposed in: + * E. Zitzler, M. Laumanns, and L. Thiele. SPEA2: Improving the + * Strength Pareto Evolutionary Algorithm. Technical Report 103, + * Computer Engineering and Networks Laboratory (TIK), ETH Zurich, + * Zurich, Switzerland, 2001. + + * It is used in moeoSPEA2. */ template < class MOEOT > class moeoNearestNeighborDiversityAssignment : public moeoDiversityAssignment < MOEOT > From f87617e21e53fa83f2f3cae026b44d5584fec29c Mon Sep 17 00:00:00 2001 From: manu Date: Mon, 28 Apr 2014 18:39:54 +0200 Subject: [PATCH 087/419] * Fix typo: betwenn -> between. --- mo/src/continuator/moNeighborBestStat.h | 2 +- mo/src/continuator/moNeighborhoodStat.h | 2 +- mo/src/explorer/moFirstImprHCexplorer.h | 2 +- mo/src/explorer/moMetropolisHastingExplorer.h | 2 +- mo/src/explorer/moRandomBestHCexplorer.h | 2 +- mo/src/explorer/moRandomNeutralWalkExplorer.h | 2 +- mo/src/explorer/moSAexplorer.h | 2 +- mo/src/explorer/moSimpleHCexplorer.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mo/src/continuator/moNeighborBestStat.h b/mo/src/continuator/moNeighborBestStat.h index 7aa4b2ed6..f7e607985 100644 --- a/mo/src/continuator/moNeighborBestStat.h +++ b/mo/src/continuator/moNeighborBestStat.h @@ -150,7 +150,7 @@ private: Neighborhood& neighborhood ; moEval& eval; - // comparator betwenn solution and neighbor or between neighbors + // comparator between solution and neighbor or between neighbors moNeighborComparator& neighborComparator; moSolNeighborComparator& solNeighborComparator; diff --git a/mo/src/continuator/moNeighborhoodStat.h b/mo/src/continuator/moNeighborhoodStat.h index c3fdc278e..6dfe4fde9 100644 --- a/mo/src/continuator/moNeighborhoodStat.h +++ b/mo/src/continuator/moNeighborhoodStat.h @@ -239,7 +239,7 @@ protected: Neighborhood& neighborhood ; moEval& eval; - // comparator betwenn solution and neighbor or between neighbors + // comparator between solution and neighbor or between neighbors moNeighborComparator& neighborComparator; moSolNeighborComparator& solNeighborComparator; diff --git a/mo/src/explorer/moFirstImprHCexplorer.h b/mo/src/explorer/moFirstImprHCexplorer.h index 16378e429..8edf9f976 100644 --- a/mo/src/explorer/moFirstImprHCexplorer.h +++ b/mo/src/explorer/moFirstImprHCexplorer.h @@ -155,7 +155,7 @@ public: }; private: - // comparator betwenn solution and neighbor or between neighbors + // comparator between solution and neighbor or between neighbors moNeighborComparator& neighborComparator; moSolNeighborComparator& solNeighborComparator; diff --git a/mo/src/explorer/moMetropolisHastingExplorer.h b/mo/src/explorer/moMetropolisHastingExplorer.h index 3123c4914..1989ff1c3 100644 --- a/mo/src/explorer/moMetropolisHastingExplorer.h +++ b/mo/src/explorer/moMetropolisHastingExplorer.h @@ -162,7 +162,7 @@ public: }; private: - // comparator betwenn solution and neighbor or between neighbors + // comparator between solution and neighbor or between neighbors moNeighborComparator& neighborComparator; moSolNeighborComparator& solNeighborComparator; diff --git a/mo/src/explorer/moRandomBestHCexplorer.h b/mo/src/explorer/moRandomBestHCexplorer.h index d5e12f087..e96f6673b 100644 --- a/mo/src/explorer/moRandomBestHCexplorer.h +++ b/mo/src/explorer/moRandomBestHCexplorer.h @@ -189,7 +189,7 @@ public: }; protected: - // comparator betwenn solution and neighbor or between neighbors + // comparator between solution and neighbor or between neighbors moNeighborComparator& neighborComparator; moSolNeighborComparator& solNeighborComparator; diff --git a/mo/src/explorer/moRandomNeutralWalkExplorer.h b/mo/src/explorer/moRandomNeutralWalkExplorer.h index 3a5eddc3e..95995c753 100644 --- a/mo/src/explorer/moRandomNeutralWalkExplorer.h +++ b/mo/src/explorer/moRandomNeutralWalkExplorer.h @@ -158,7 +158,7 @@ public: }; private: - // comparator betwenn solution and neighbor or between neighbors + // comparator between solution and neighbor or between neighbors moSolNeighborComparator& solNeighborComparator; // current number of step diff --git a/mo/src/explorer/moSAexplorer.h b/mo/src/explorer/moSAexplorer.h index 3d9f477ee..08d859035 100644 --- a/mo/src/explorer/moSAexplorer.h +++ b/mo/src/explorer/moSAexplorer.h @@ -166,7 +166,7 @@ public: } private: - // comparator betwenn solution and neighbor + // comparator between solution and neighbor moSolNeighborComparator& solNeighborComparator; moCoolingSchedule& coolingSchedule; diff --git a/mo/src/explorer/moSimpleHCexplorer.h b/mo/src/explorer/moSimpleHCexplorer.h index 573881d2f..b4f235ae8 100644 --- a/mo/src/explorer/moSimpleHCexplorer.h +++ b/mo/src/explorer/moSimpleHCexplorer.h @@ -155,7 +155,7 @@ public: } private: - // comparator betwenn solution and neighbor or between neighbors + // comparator between solution and neighbor or between neighbors moNeighborComparator& neighborComparator; moSolNeighborComparator& solNeighborComparator; From 1f09aa656f3db2433b329563829dafc6f5172e78 Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 1 May 2014 19:21:43 +0200 Subject: [PATCH 088/419] Typo in moeo comments. --- moeo/src/algo/moeoSPEA2.h | 4 ++-- .../moeoFrontByFrontCrowdingDiversityAssignment.h | 4 ++-- .../diversity/moeoNearestNeighborDiversityAssignment.h | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/moeo/src/algo/moeoSPEA2.h b/moeo/src/algo/moeoSPEA2.h index a6416ecc2..8b419b5f5 100644 --- a/moeo/src/algo/moeoSPEA2.h +++ b/moeo/src/algo/moeoSPEA2.h @@ -255,7 +255,7 @@ protected: eoQuadCloneOp < MOEOT > defaultQuadOp; /** an object for genetic operators (used as default) */ eoSGAGenOp < MOEOT > defaultSGAGenOp; - /** fitness assignment used in NSGA-II */ + /** fitness assignment used in SPEA2 */ moeoDominanceCountRankingFitnessAssignment < MOEOT > fitnessAssignment; /** general breeder */ eoGeneralBreeder < MOEOT > genBreed; @@ -265,7 +265,7 @@ protected: eoSelectTransform selectTransform; /** breeder */ eoBreed < MOEOT > & breed; - /** diversity assignment used in NSGA-II */ + /** diversity assignment used in SPEA2 */ moeoNearestNeighborDiversityAssignment < MOEOT > diversityAssignment; /** elitist replacement */ moeoGenerationalReplacement < MOEOT > replace; diff --git a/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h b/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h index 7ab4e0067..c4909d504 100644 --- a/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h +++ b/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h @@ -44,9 +44,9 @@ /** - * Diversity assignment sheme based on crowding proposed in: + * Diversity assignment scheme based on crowding proposed in: * K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002). - * Tis strategy assigns diversity values FRONT BY FRONT. It is, for instance, used in NSGA-II. + * This strategy assigns diversity values FRONT BY FRONT. It is, for instance, used in NSGA-II. */ template < class MOEOT > class moeoFrontByFrontCrowdingDiversityAssignment : public moeoCrowdingDiversityAssignment < MOEOT > diff --git a/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h b/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h index 8571ed475..5b5680eef 100644 --- a/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h +++ b/moeo/src/diversity/moeoNearestNeighborDiversityAssignment.h @@ -46,7 +46,14 @@ #include /** - * moeoNearestNeighborDiversityAssignment is a moeoDiversityAssignment using distance between individuals to assign diversity. + * moeoNearestNeighborDiversityAssignment is a moeoDiversityAssignment + * using distance between individuals to assign diversity. Proposed in: + * E. Zitzler, M. Laumanns, and L. Thiele. SPEA2: Improving the + * Strength Pareto Evolutionary Algorithm. Technical Report 103, + * Computer Engineering and Networks Laboratory (TIK), ETH Zurich, + * Zurich, Switzerland, 2001. + + * It is used in moeoSPEA2. */ template < class MOEOT > class moeoNearestNeighborDiversityAssignment : public moeoDiversityAssignment < MOEOT > From e71dea0c5a4d0aab7aebccca6bd841e476e76d43 Mon Sep 17 00:00:00 2001 From: quemy Date: Sat, 3 May 2014 18:58:55 +0200 Subject: [PATCH 089/419] Fix some warnings in eo and moeo. --- eo/src/eoNDSorting.h | 2 +- eo/src/eoTimeContinue.h | 1 + moeo/src/utils/moeoBinaryMetricSavingUpdater.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eo/src/eoNDSorting.h b/eo/src/eoNDSorting.h index 6ab86c177..bb2e94fcc 100644 --- a/eo/src/eoNDSorting.h +++ b/eo/src/eoNDSorting.h @@ -273,7 +273,7 @@ private : { unsigned i; - typedef typename EOT::Fitness::fitness_traits traits; + //typedef typename EOT::Fitness::fitness_traits traits; std::vector > S(_pop.size()); // which individuals does guy i dominate std::vector n(_pop.size(), 0); // how many individuals dominate guy i diff --git a/eo/src/eoTimeContinue.h b/eo/src/eoTimeContinue.h index d49f5ea56..c0fcc3fe5 100644 --- a/eo/src/eoTimeContinue.h +++ b/eo/src/eoTimeContinue.h @@ -56,6 +56,7 @@ public: */ virtual bool operator() (const eoPop < EOT > & _pop) { + (void)_pop; time_t elapsed = (time_t) difftime(time(NULL), start); if (elapsed >= max) { diff --git a/moeo/src/utils/moeoBinaryMetricSavingUpdater.h b/moeo/src/utils/moeoBinaryMetricSavingUpdater.h index 0d8df0759..0848ef8ae 100644 --- a/moeo/src/utils/moeoBinaryMetricSavingUpdater.h +++ b/moeo/src/utils/moeoBinaryMetricSavingUpdater.h @@ -65,7 +65,7 @@ class moeoBinaryMetricSavingUpdater : public eoUpdater * @param _filename the target filename */ moeoBinaryMetricSavingUpdater (moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > & _metric, const eoPop < MOEOT > & _pop, std::string _filename) : - metric(_metric), pop(_pop), filename(_filename), counter(1), firstGen(true) + metric(_metric), pop(_pop), filename(_filename), firstGen(true), counter(1) {} From b0479a15e939be205af6075b79f0b28c3682f8f2 Mon Sep 17 00:00:00 2001 From: quemy Date: Sun, 25 May 2014 21:52:22 +0200 Subject: [PATCH 090/419] Fix a bug in SMP Master / Worker model when the population size is lower than the number of workers. --- smp/src/scheduler.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/smp/src/scheduler.cpp b/smp/src/scheduler.cpp index 68b366c08..9a5210e0a 100644 --- a/smp/src/scheduler.cpp +++ b/smp/src/scheduler.cpp @@ -67,17 +67,21 @@ void paradiseo::smp::Scheduler::operator()(eoUF& func, e indice = i*nbIndi+j; } } - - for(unsigned i = 0; i < remaining; i++) - popPackages[i].push_back(&pop[indice+i+1]); + + if(nbIndi != 0) // Handle the offset if there is less individuals than workers + indice++; + for(unsigned i = 0; i < remaining; i++) + popPackages[i].push_back(&pop[indice+i]); // Starting threads for(unsigned i = 0; i < workers.size(); i++) - workers[i] = std::thread(&Scheduler::applyLinearPolicy, this, std::ref(func), std::ref(popPackages[i])); - + if(!popPackages[i].empty()) + workers[i] = std::thread(&Scheduler::applyLinearPolicy, this, std::ref(func), std::ref(popPackages[i])); + // Wait the end of tasks for(unsigned i = 0; i < workers.size(); i++) - workers[i].join(); + if(!popPackages[i].empty() && workers[i].joinable()) + workers[i].join(); } template @@ -117,7 +121,7 @@ void paradiseo::smp::Scheduler::operator()(eoUF& func, e } done = true; - + for(unsigned i = 0; i < workers.size(); i++) workers[i].join(); } From af1b621a105a1cfec13b8a9ee9c87bf2a72332b0 Mon Sep 17 00:00:00 2001 From: verel Date: Sun, 22 Jun 2014 15:45:33 +0200 Subject: [PATCH 091/419] add incremental eval for NK landscapes with corresponding test. Update INSTAL section test with the correct option --- mo/src/problems/eval/moNKlandscapesIncrEval.h | 131 ++++++++++++++++++ mo/test/t-moNKlandscapesIncrEval.cpp | 89 ++++++++++++ 2 files changed, 220 insertions(+) create mode 100644 mo/src/problems/eval/moNKlandscapesIncrEval.h create mode 100644 mo/test/t-moNKlandscapesIncrEval.cpp diff --git a/mo/src/problems/eval/moNKlandscapesIncrEval.h b/mo/src/problems/eval/moNKlandscapesIncrEval.h new file mode 100644 index 000000000..6635c0de0 --- /dev/null +++ b/mo/src/problems/eval/moNKlandscapesIncrEval.h @@ -0,0 +1,131 @@ +/* + +Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + +Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moNKlandscapesIncrEval_H +#define _moNKlandscapesIncrEval_H + +#include +#include +#include + +/** + * + * Incremental evaluation function (1 bit flip, Hamming distance 1) + * for the NK-landscapes problem + * + * + */ +template< class Neighbor > +class moNKlandscapesIncrEval : public moEval +{ +public: + typedef typename Neighbor::EOT EOT; + + /* + * Constructor + * + * @param _nk fitness function of the NK landscapes + */ + moNKlandscapesIncrEval(nkLandscapesEval & _nk) : nk(_nk) { + inverseLinks = new std::vector[ nk.N ]; + + // compute the contributions which are modified by flipping one bit + for(unsigned int i = 0; i < nk.N; i++) + for(unsigned int j = 0; j < nk.K + 1; j++) { + inverseLinks[ nk.links[i][j] ].push_back(i); + } + } + + /* + * Destructor + * + */ + ~moNKlandscapesIncrEval() { + delete [] inverseLinks; + } + + /* + * incremental evaluation of the neighbor for the oneMax problem + * @param _solution the solution to move (bit string) + * @param _neighbor the neighbor to consider (of type moBitNeigbor) + */ + virtual void operator()(EOT & _solution, Neighbor & _neighbor) { + unsigned bit = _neighbor.index() ; + unsigned sig, nonSig; + unsigned i; + + double delta = 0 ; + + for(unsigned int j = 0; j < inverseLinks[bit].size(); j++) { + i = inverseLinks[bit][j]; + sigma(_solution, i, bit, sig, nonSig); + delta += nk.tables[i][nonSig] - nk.tables[i][sig]; + } + + _neighbor.fitness(_solution.fitness() + delta / (double) nk.N); + } + +private: + // Original nk fitness function + nkLandscapesEval & nk; + + // give the list of contributions which are modified when the corresponding bit is flipped + std::vector * inverseLinks; + + /** + * Compute the mask of the linked bits, and the mask when the bit is flipped + * + * @param _solution the solution to evaluate + * @param i the bit of the contribution + * @param _bit the bit to flip + * @param sig value of the mask of contribution i + * @param nonSig value of the mask of contribution i when the bit _bit is flipped + */ + void sigma(EOT & _solution, int i, unsigned _bit, unsigned & sig, unsigned & nonSig) { + sig = 0; + nonSig = 0; + + unsigned int n = 1; + for(int j = 0; j < nk.K + 1; j++) { + if (_solution[ nk.links[i][j] ] == 1) + sig = sig | n; + + if (nk.links[i][j] == _bit) + nonSig = n; + + n = n << 1; + } + + nonSig = sig ^ nonSig; + } + +}; + +#endif + diff --git a/mo/test/t-moNKlandscapesIncrEval.cpp b/mo/test/t-moNKlandscapesIncrEval.cpp new file mode 100644 index 000000000..cf9df9de1 --- /dev/null +++ b/mo/test/t-moNKlandscapesIncrEval.cpp @@ -0,0 +1,89 @@ +/* + + 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 use, + 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". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + 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 +*/ + +#include +#include +#include +#include +#include + +#include +#include + +typedef eoBit Solution; +typedef moBitNeighbor Neighbor ; + +int main() { + + std::cout << "[t-moNKlandscapesIncrEval] => START" << std::endl; + + // nk fitness function + int N = 18; + int K = 4; + rng.reseed(0); // random seed = 0 + + nkLandscapesEval eval(N, K); + + // init + eoUniformGenerator uGen; + eoInitFixedLength init(N, uGen); + + // verif constructor + moNKlandscapesIncrEval neighborEval(eval); + + Solution solution; + + // random initialization + rng.reseed(1); // random seed = 1 + + init(solution); + + // evaluation + eval(solution); + + Neighbor n ; + n.index(0); + + neighborEval(solution, n); + + n.move(solution); + eval(solution); + + // verif incremental eval + assert(solution.fitness() == n.fitness()); + + std::cout << "[t-moNKlandscapesIncrEval] => OK" << std::endl; + + return EXIT_SUCCESS; +} From d3d88d4cc5fa0d4fa23fedb3c7dbd5c44038bebe Mon Sep 17 00:00:00 2001 From: verel Date: Mon, 23 Jun 2014 08:11:47 +0200 Subject: [PATCH 092/419] Add MPX crossover --- eo/src/eoPartiallyMappedXover.h | 126 +++++++++++++++++++++++++++ eo/test/t-eoPartiallyMappedXover.cpp | 71 +++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 eo/src/eoPartiallyMappedXover.h create mode 100644 eo/test/t-eoPartiallyMappedXover.cpp diff --git a/eo/src/eoPartiallyMappedXover.h b/eo/src/eoPartiallyMappedXover.h new file mode 100644 index 000000000..16b23f6c9 --- /dev/null +++ b/eo/src/eoPartiallyMappedXover.h @@ -0,0 +1,126 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sébastien Verel + + 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 eoPartiallyMappedXover__h +#define eoPartiallyMappedXover__h + +//----------------------------------------------------------------------------- + +#include +#include + +/** + * + * Partially Mapped CrossOver (PMX) + * for permutation representation + * + */ +template +class eoPartiallyMappedXover : public eoQuadOp +{ +public: + /** + * + * @param _solution1 The first solution + * @param _solution2 The second solution + * @return true if the solution has changed + */ + bool operator()(EOT & _solution1, EOT & _solution2) { + if (_solution1.size() > 1) { + // random indexes such that i1 < i2 + int i1 = rng.random(_solution1.size()); + int i2 = rng.random(_solution1.size()); + + while (i1 == i2) + i2 = rng.random(_solution1.size()); + + if (i1 > i2) { + int tmp = i1; + i1 = i2; + i2 = tmp; + } + + // the permutations between s1 and s2 + int * p1 = new int[_solution1.size()]; + int * p2 = new int[_solution1.size()]; + + int i; + for(i = 0; i < _solution1.size(); i++) { + p1[i] = -1; + p2[i] = -1; + } + + for(i = i1; i <= i2; i++) { + p1[ _solution2[i] ] = _solution1[i] ; + p2[ _solution1[i] ] = _solution2[i] ; + } + + // replace if necessary + for(i = 0; i < i1; i++) { + while (p1[ _solution1[i] ] != -1) + _solution1[i] = p1[_solution1[i]]; + while (p2[ _solution2[i] ] != -1) + _solution2[i] = p2[_solution2[i]]; + } + + // swap between solution1 and solution2 for [i1..i2] + for(i = i1; i <= i2; i++) { + _solution1[i] = p2[ _solution1[i] ]; + _solution2[i] = p1[ _solution2[i] ]; + } + + // replace if necessary + for(i = i2 + 1; i < _solution1.size(); i++) { + while (p1[ _solution1[i] ] != -1) + _solution1[i] = p1[_solution1[i]]; + while (p2[ _solution2[i] ] != -1) + _solution2[i] = p2[_solution2[i]]; + } + + // invalidate the solutions because they have been modified + _solution1.invalidate(); + _solution2.invalidate(); + + delete [] p1; + delete [] p2; + + return true; + } else + return false; + } + + /** + * The class name. + */ + virtual std::string className() const { + return "eoPartiallyMappedXover"; + } + +}; + +#endif diff --git a/eo/test/t-eoPartiallyMappedXover.cpp b/eo/test/t-eoPartiallyMappedXover.cpp new file mode 100644 index 000000000..371c45a18 --- /dev/null +++ b/eo/test/t-eoPartiallyMappedXover.cpp @@ -0,0 +1,71 @@ +/* + +*/ + +#include +#include + +#include + +#include +#include + +//----------------------------------------------------------------------------- + +typedef eoInt Solution; + +int main() { + + std::cout << "[t-eoPartiallyMappedXover] => START" << std::endl; + + Solution sol1, sol2; + sol1.resize(9); + sol2.resize(9); + + for(int i = 0; i < sol1.size(); i++) + sol1[i] = i; + + sol2[0] = 3; + sol2[1] = 4; + sol2[2] = 1; + sol2[3] = 0; + sol2[4] = 7; + sol2[5] = 6; + sol2[6] = 5; + sol2[7] = 8; + sol2[8] = 2; + + std::cout << sol1 << std::endl; + std::cout << sol2 << std::endl; + + eoPartiallyMappedXover xover; + xover(sol1, sol2); + + std::cout << "apres" << std::endl; + std::cout << sol1 << std::endl; + std::cout << sol2 << std::endl; + + int verif[9]; + for(int i = 0; i < sol1.size(); i++) + verif[i] = -1; + + for(int i = 0; i < sol1.size(); i++) + verif[ sol1[i] ] = 1; + + for(int i = 0; i < sol1.size(); i++) + assert(verif[i] != -1); + + + for(int i = 0; i < sol2.size(); i++) + verif[i] = -1; + + for(int i = 0; i < sol2.size(); i++) + verif[ sol2[i] ] = 1; + + for(int i = 0; i < sol2.size(); i++) + assert(verif[i] != -1); + + std::cout << "[t-eoPartiallyMappedXover] => OK" << std::endl; + + return EXIT_SUCCESS; +} From edefae4b281e6a93097bcbd5646b017922825831 Mon Sep 17 00:00:00 2001 From: verel Date: Wed, 25 Jun 2014 17:02:38 +0200 Subject: [PATCH 093/419] Small modif in moIndexedSwapNeighbor --- INSTALL | 4 +- eo/src/CMakeLists.txt | 2 +- eo/src/utils/eoDistance.h | 25 ++++++- eo/test/CMakeLists.txt | 1 + mo/src/algo/moRandomWalk.h | 2 +- mo/src/continuator/moVectorMonitor.h | 28 ++++++-- mo/src/mo.h | 1 + mo/src/neighborhood/moIndexNeighbor.h | 22 +++++- .../moRndWithoutReplNeighborhood.h | 2 +- .../permutation/moIndexedSwapNeighbor.h | 33 ++++++++- mo/test/CMakeLists.txt | 1 + mo/tutorial/Lesson6/adaptiveWalks.cpp | 1 + mo/tutorial/Lesson6/autocorrelation.cpp | 1 + mo/tutorial/Lesson6/densityOfStates.cpp | 1 + moeo/src/metric/moeoHyperVolumeMetric.h | 2 +- moeo/src/selection/moeoRouletteSelect.h | 2 +- problems/eval/nkLandscapesEval.h | 67 ++++++++++--------- 17 files changed, 141 insertions(+), 54 deletions(-) diff --git a/INSTALL b/INSTALL index 9734fc95a..6f1d121a7 100644 --- a/INSTALL +++ b/INSTALL @@ -183,9 +183,9 @@ Easy, isn't it ? By performing tests, you can check your installation. Testing is disable by default, except if you build with the full install type. -To enable testing, define -DENABLE_TESTING when you launch cmake. +To enable testing, define -DENABLE_CMAKE_TESTING=true when you launch cmake. -To perform tests simply type ctest ou make test. +To perform tests simply type ctest or make test. ------------------------------------------------------------------------------------------ 5.2 REPORTING diff --git a/eo/src/CMakeLists.txt b/eo/src/CMakeLists.txt index d38543098..b2b445a93 100644 --- a/eo/src/CMakeLists.txt +++ b/eo/src/CMakeLists.txt @@ -47,7 +47,7 @@ install(DIRECTORY do es ga gp other utils add_subdirectory(es) add_subdirectory(ga) add_subdirectory(utils) -add_subdirectory(serial) +#add_subdirectory(serial) if(ENABLE_PYEO) add_subdirectory(pyeo) diff --git a/eo/src/utils/eoDistance.h b/eo/src/utils/eoDistance.h index b26f249d6..35ce9a109 100644 --- a/eo/src/utils/eoDistance.h +++ b/eo/src/utils/eoDistance.h @@ -62,13 +62,15 @@ public: }; /** + SV: from eoHammingDistance, it is in fact the L1 distance + This is a generic class for L1 distance computation: assumes the 2 things are std::vectors of something that is double-castable For bitstrings, this is the Hamming distance */ template< class EOT > -class eoHammingDistance : public eoDistance +class eoL1Distance : public eoDistance { public: double operator()(const EOT & _v1, const EOT & _v2) @@ -83,6 +85,27 @@ public: } }; +/** + SV: change to have the Hamming (number of differences) + + For bitstrings, this is the Hamming distance +*/ +template< class EOT > +class eoHammingDistance : public eoDistance +{ +public: + double operator()(const EOT & _v1, const EOT & _v2) + { + double sum=0.0; + for (unsigned i=0; i<_v1.size(); i++) + { + if (_v1[i] != _v2[i]) + sum++; + } + return sum; + } +}; + /* this distance measures the difference in fitness * I am not sure it can be of any use, though ... * except for some testing diff --git a/eo/test/CMakeLists.txt b/eo/test/CMakeLists.txt index 15fd22464..4a0c74e43 100644 --- a/eo/test/CMakeLists.txt +++ b/eo/test/CMakeLists.txt @@ -69,6 +69,7 @@ set (TEST_LIST #t-openmp # does not work anymore since functions used in this test were removed from EO #t-eoDualFitness t-eoParser + t-eoPartiallyMappedXover ) diff --git a/mo/src/algo/moRandomWalk.h b/mo/src/algo/moRandomWalk.h index dafa3f277..6ccdbc107 100644 --- a/mo/src/algo/moRandomWalk.h +++ b/mo/src/algo/moRandomWalk.h @@ -60,7 +60,7 @@ public: */ moRandomWalk(Neighborhood& _neighborhood, eoEvalFunc& _fullEval, moEval& _eval, unsigned _nbStepMax): moLocalSearch(explorer, iterCont, _fullEval), - iterCont(_nbStepMax), + iterCont(_nbStepMax, false), explorer(_neighborhood, _eval) {} diff --git a/mo/src/continuator/moVectorMonitor.h b/mo/src/continuator/moVectorMonitor.h index b04eb8adf..d6870bb80 100644 --- a/mo/src/continuator/moVectorMonitor.h +++ b/mo/src/continuator/moVectorMonitor.h @@ -53,7 +53,7 @@ public: * Constructor * @param _param the parameter of type double to save in the vector */ - moVectorMonitor(eoValueParam & _param) : doubleParam(&_param), intParam(NULL), eotParam(NULL) + moVectorMonitor(eoValueParam & _param) : doubleParam(&_param), intParam(NULL), intLongParam(NULL), eotParam(NULL) { // precision of the output by default precisionOutput = std::cout.precision(); @@ -63,7 +63,17 @@ public: * Default Constructor * @param _param the parameter of type unsigned int to save in the vector */ - moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(&_param), eotParam(NULL) + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(&_param), intLongParam(NULL), eotParam(NULL) + { + // precision of the output by default + precisionOutput = std::cout.precision(); + } + + /** + * Default Constructor + * @param _param the parameter of type unsigned int to save in the vector + */ + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(&_param), eotParam(NULL) { // precision of the output by default precisionOutput = std::cout.precision(); @@ -73,7 +83,7 @@ public: * Default Constructor * @param _param the parameter of type EOT to save in the vector */ - moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), eotParam(&_param) + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(NULL), eotParam(&_param) { // precision of the output by default precisionOutput = std::cout.precision(); @@ -84,7 +94,7 @@ public: * @param _param the parameter of type eoScalarFitness to save in the vector */ template - moVectorMonitor(eoValueParam > & _param) : doubleParam( & (eoValueParam&)_param), intParam(NULL), eotParam(NULL) + moVectorMonitor(eoValueParam > & _param) : doubleParam( & (eoValueParam&)_param), intParam(NULL), intLongParam(NULL), eotParam(NULL) { // precision of the output by default precisionOutput = std::cout.precision(); @@ -95,7 +105,7 @@ public: * @param _param unvalid Parameter */ template - moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), eotParam(NULL) + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(NULL), eotParam(NULL) { std::cerr << "Sorry the type can not be in a vector of moVectorMonitor" << std::endl; } @@ -120,8 +130,11 @@ public: else if (intParam != NULL) valueVec.push_back((double) intParam->value()); - else - eotVec.push_back(eotParam->value()); + else + if (intLongParam != NULL) + valueVec.push_back((double) intLongParam->value()); + else + eotVec.push_back(eotParam->value()); return *this ; } @@ -227,6 +240,7 @@ public: protected: eoValueParam * doubleParam ; eoValueParam * intParam ; + eoValueParam * intLongParam ; eoValueParam * eotParam ; std::vector valueVec; diff --git a/mo/src/mo.h b/mo/src/mo.h index 2a56a86a5..2ba411388 100755 --- a/mo/src/mo.h +++ b/mo/src/mo.h @@ -190,6 +190,7 @@ //#include //#include //#include +#include #include diff --git a/mo/src/neighborhood/moIndexNeighbor.h b/mo/src/neighborhood/moIndexNeighbor.h index 5ce17cdda..eaf302966 100644 --- a/mo/src/neighborhood/moIndexNeighbor.h +++ b/mo/src/neighborhood/moIndexNeighbor.h @@ -109,9 +109,9 @@ public: * @param _solution solution from which the neighborhood is visited * @param _key index of the IndexNeighbor */ - virtual void index(EOT & _solution, unsigned int _key) { - key = _key; - } + virtual void index(EOT & _solution, unsigned int _key) { + key = _key; + } /** * @param _neighbor a neighbor @@ -121,6 +121,22 @@ public: return (key == _neighbor.index()); } + /** + * Write object with its index + * @param _os A std::ostream. + */ + virtual void printOn(std::ostream& _os) const { + if (this->invalid()) { + _os << "INVALID "; + } + else + { + _os << this->fitness() << ' '; + } + + _os << key ; + } + protected: // key allowing to describe the neighbor unsigned int key; diff --git a/mo/src/neighborhood/moRndWithoutReplNeighborhood.h b/mo/src/neighborhood/moRndWithoutReplNeighborhood.h index 52113cc07..e51c6d6e7 100644 --- a/mo/src/neighborhood/moRndWithoutReplNeighborhood.h +++ b/mo/src/neighborhood/moRndWithoutReplNeighborhood.h @@ -130,7 +130,7 @@ public: return "moRndWithoutReplNeighborhood"; } -private: +protected: unsigned int maxIndex; std::vector indexVector; }; diff --git a/mo/src/problems/permutation/moIndexedSwapNeighbor.h b/mo/src/problems/permutation/moIndexedSwapNeighbor.h index d30305100..d3ddababf 100644 --- a/mo/src/problems/permutation/moIndexedSwapNeighbor.h +++ b/mo/src/problems/permutation/moIndexedSwapNeighbor.h @@ -46,6 +46,33 @@ public: using moIndexNeighbor::index; /** + * Default Constructor + */ + moIndexedSwapNeighbor() : moIndexNeighbor() { + } + + /** + * Copy Constructor + * @param _n the neighbor to copy + */ + moIndexedSwapNeighbor(const moIndexedSwapNeighbor & _n) : moIndexNeighbor(_n) + { + indices.first = _n.first(); + indices.second = _n.second(); + } + + /** + * Assignment operator + * @param _source the source neighbor + */ + moIndexedSwapNeighbor & operator=(const moIndexedSwapNeighbor & _source) { + moIndexNeighbor::operator=(_source); + indices.first = _source.first(); + indices.second = _source.second(); + return *this; + } + + /** * Apply the swap * @param _solution the solution to move */ @@ -111,7 +138,7 @@ public: * Getter of the firt location * @return first indice */ - unsigned int first() { + unsigned int first() const { return indices.first; } @@ -119,11 +146,11 @@ public: * Getter of the second location * @return second indice */ - unsigned int second() { + unsigned int second() const { return indices.second; } -private: +protected: std::pair indices; }; diff --git a/mo/test/CMakeLists.txt b/mo/test/CMakeLists.txt index 652b66be3..a27f97db9 100644 --- a/mo/test/CMakeLists.txt +++ b/mo/test/CMakeLists.txt @@ -18,6 +18,7 @@ set (TEST_LIST t-moOrderNeighborhood t-moFullEvalByCopy t-moFullEvalByModif + t-moNKlandscapesIncrEval t-moNeighborComparator t-moSolNeighborComparator t-moTrueContinuator diff --git a/mo/tutorial/Lesson6/adaptiveWalks.cpp b/mo/tutorial/Lesson6/adaptiveWalks.cpp index 36ab47ca0..1976f577b 100644 --- a/mo/tutorial/Lesson6/adaptiveWalks.cpp +++ b/mo/tutorial/Lesson6/adaptiveWalks.cpp @@ -85,6 +85,7 @@ void main_function(int argc, char **argv) string str_out = "out.dat"; // default value eoValueParam outParam(str_out.c_str(), "out", "Output file of the sampling", 'o'); parser.processParam(outParam, "Persistence" ); + str_out = outParam.value(); // the name of the "status" file where all actual parameter values will be saved string str_status = parser.ProgramName() + ".status"; // default value diff --git a/mo/tutorial/Lesson6/autocorrelation.cpp b/mo/tutorial/Lesson6/autocorrelation.cpp index 6f07d8ae7..f034efc43 100644 --- a/mo/tutorial/Lesson6/autocorrelation.cpp +++ b/mo/tutorial/Lesson6/autocorrelation.cpp @@ -89,6 +89,7 @@ void main_function(int argc, char **argv) string str_out = "out.dat"; // default value eoValueParam outParam(str_out.c_str(), "out", "Output file of the sampling", 'o'); parser.processParam(outParam, "Persistence" ); + str_out = outParam.value(); // the name of the "status" file where all actual parameter values will be saved string str_status = parser.ProgramName() + ".status"; // default value diff --git a/mo/tutorial/Lesson6/densityOfStates.cpp b/mo/tutorial/Lesson6/densityOfStates.cpp index a47323423..9e2eeddca 100644 --- a/mo/tutorial/Lesson6/densityOfStates.cpp +++ b/mo/tutorial/Lesson6/densityOfStates.cpp @@ -83,6 +83,7 @@ void main_function(int argc, char **argv) string str_out = "out.dat"; // default value eoValueParam outParam(str_out.c_str(), "out", "Output file of the sampling", 'o'); parser.processParam(outParam, "Persistence" ); + str_out = outParam.value(); // the name of the "status" file where all actual parameter values will be saved string str_status = parser.ProgramName() + ".status"; // default value diff --git a/moeo/src/metric/moeoHyperVolumeMetric.h b/moeo/src/metric/moeoHyperVolumeMetric.h index f59ba19a6..99f132131 100644 --- a/moeo/src/metric/moeoHyperVolumeMetric.h +++ b/moeo/src/metric/moeoHyperVolumeMetric.h @@ -83,7 +83,7 @@ class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , d * @param _ref_point the reference point * @param _bounds bounds value */ - moeoHyperVolumeMetric(ObjectiveVector& _ref_point=NULL, std::vector < eoRealInterval >& _bounds=NULL): normalize(false), rho(0.0), ref_point(_ref_point), bounds(_bounds){} + moeoHyperVolumeMetric(ObjectiveVector& _ref_point, std::vector < eoRealInterval >& _bounds): normalize(false), rho(0.0), ref_point(_ref_point), bounds(_bounds){} /** * calculates and returns the HyperVolume value of a pareto front diff --git a/moeo/src/selection/moeoRouletteSelect.h b/moeo/src/selection/moeoRouletteSelect.h index b5adcb0c2..fb34259e7 100644 --- a/moeo/src/selection/moeoRouletteSelect.h +++ b/moeo/src/selection/moeoRouletteSelect.h @@ -80,7 +80,7 @@ class moeoRouletteSelect:public moeoSelectOne < MOEOT > protected: /** size */ - double & tSize; + unsigned int & tSize; }; diff --git a/problems/eval/nkLandscapesEval.h b/problems/eval/nkLandscapesEval.h index 29fd20d5f..070fb1b43 100644 --- a/problems/eval/nkLandscapesEval.h +++ b/problems/eval/nkLandscapesEval.h @@ -31,6 +31,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr #define __nkLandscapesEval_H #include +#include template< class EOT > class nkLandscapesEval : public eoEvalFunc { @@ -79,7 +80,7 @@ public: */ nkLandscapesEval(const char * _fileName) { - string fname(_fileName); + std::string fname(_fileName); load(fname); }; @@ -132,16 +133,16 @@ public: * * @param _fileName file name of the instance */ - virtual void load(const string _fileName) + virtual void load(const std::string _fileName) { - fstream file; - file.open(_fileName.c_str(), ios::in); + std::fstream file; + file.open(_fileName.c_str(), std::fstream::in); if (file.is_open()) { - string s; + std::string s; // Read the commentairies - string line; + std::string line; file >> s; while (s[0] == 'c') { getline(file,line,'\n'); @@ -150,14 +151,14 @@ public: // Read the parameters if (s[0] != 'p') { - string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] at the begining." ; - throw runtime_error(str); + std::string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] at the begining." ; + throw std::runtime_error(str); } file >> s; if (s != "NK") { - string str = "nkLandscapesEval.load: -- NK -- expected in [" + _fileName + "] at the begining." ; - throw runtime_error(str); + std::string str = "nkLandscapesEval.load: -- NK -- expected in [" + _fileName + "] at the begining." ; + throw std::runtime_error(str); } // read parameters N and K @@ -166,22 +167,22 @@ public: // read the links if (s[0] != 'p') { - string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the parameters N and K." ; - throw runtime_error(str); + std::string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the parameters N and K." ; + throw std::runtime_error(str); } file >> s; if (s == "links") { loadLinks(file); } else { - string str = "nkLandscapesEval.load: -- links -- expected in [" + _fileName + "] after the parameters N and K." ; - throw runtime_error(str); + std::string str = "nkLandscapesEval.load: -- links -- expected in [" + _fileName + "] after the parameters N and K." ; + throw std::runtime_error(str); } // lecture des tables if (s[0] != 'p') { - string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the links." ; - throw runtime_error(str); + std::string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the links." ; + throw std::runtime_error(str); } file >> s; @@ -189,14 +190,14 @@ public: if (s == "tables") { loadTables(file); } else { - string str = "nkLandscapesEval.load: -- tables -- expected in [" + _fileName + "] after the links." ; - throw runtime_error(str); + std::string str = "nkLandscapesEval.load: -- tables -- expected in [" + _fileName + "] after the links." ; + throw std::runtime_error(str); } file.close(); } else { - string str = "nkLandscapesEval.load: Could not open file [" + _fileName + "]." ; - throw runtime_error(str); + std::string str = "nkLandscapesEval.load: Could not open file [" + _fileName + "]." ; + throw std::runtime_error(str); } }; @@ -206,7 +207,7 @@ public: * * @param file the file to read */ - void loadLinks(fstream & file) { + void loadLinks(std::fstream & file) { for(int j = 0; j < K+1; j++) for(int i = 0; i < N; i++) { file >> links[i][j]; @@ -218,7 +219,7 @@ public: * * @param file the file to read */ - void loadTables(fstream & file) { + void loadTables(std::fstream & file) { for(int j = 0; j < (1<<(K+1)); j++) for(int i = 0; i < N; i++) file >> tables[i][j]; @@ -230,29 +231,29 @@ public: * @param _fileName the file name of instance */ virtual void save(const char * _fileName) { - fstream file; - file.open(_fileName, ios::out); + std::fstream file; + file.open(_fileName, std::fstream::out); if (file.is_open()) { - file << "c name of the file : " << _fileName << endl; - file << "p NK " << N << " " << K < Date: Wed, 25 Jun 2014 22:54:15 +0200 Subject: [PATCH 094/419] Update moMonOpPerturb --- mo/src/perturb/moMonOpPerturb.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mo/src/perturb/moMonOpPerturb.h b/mo/src/perturb/moMonOpPerturb.h index e0dc138da..87b409069 100644 --- a/mo/src/perturb/moMonOpPerturb.h +++ b/mo/src/perturb/moMonOpPerturb.h @@ -50,7 +50,16 @@ public: * @param _fullEval a full evaluation function * @param _nbPerturbation number of operator executions for perturbation */ - moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval, unsigned int _nbPerturbation = 1):monOp(_monOp), fullEval(_fullEval), nbPerturbation(_nbPerturbation) {} + moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval, unsigned int _nbPerturbation = 1):monOp(_monOp), fullEval(_fullEval), nbPerturbation(_nbPerturbation), rndPerturb(false) {} + + /** + * Constructor with random value at each iteration of the number of perturbation moves + * @param _monOp an eoMonOp (pertubation operator) + * @param _fullEval a full evaluation function + * @param _nbPerturbationMin minimum number of operator executions for perturbation + * @param _nbPerturbationMax maximum number of operator executions for perturbation + */ + moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval, unsigned int _nbPerturbationMin, unsigned int _nbPerturbationMax):monOp(_monOp), fullEval(_fullEval), nbPerturbationMin(_nbPerturbationMin), nbPerturbationMax(_nbPerturbationMax), rndPerturb(true) { } /** * Apply monOp on the solution @@ -60,6 +69,9 @@ public: bool operator()(EOT& _solution) { bool res = false; + if (rndPerturb) + nbPerturbation = nbPerturbationMin + rng.random(nbPerturbationMax); + for(unsigned int i = 0; i < nbPerturbation; i++) res = monOp(_solution) || res; @@ -74,6 +86,9 @@ private: eoMonOp& monOp; eoEvalFunc& fullEval; unsigned int nbPerturbation; + unsigned int nbPerturbationMin; + unsigned int nbPerturbationMax; + bool rndPerturb; }; #endif From fa03cd7efe0f3016ad9f42f811753ad3d3a97e4b Mon Sep 17 00:00:00 2001 From: verel Date: Fri, 27 Jun 2014 21:25:08 +0200 Subject: [PATCH 095/419] update moIndexedVectorTabuList --- mo/src/memory/moIndexedVectorTabuList.h | 31 ++++++++++++++++++++++--- mo/src/perturb/moMonOpPerturb.h | 2 +- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/mo/src/memory/moIndexedVectorTabuList.h b/mo/src/memory/moIndexedVectorTabuList.h index f01e17f1b..cbb2c9c1e 100644 --- a/mo/src/memory/moIndexedVectorTabuList.h +++ b/mo/src/memory/moIndexedVectorTabuList.h @@ -35,8 +35,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr #include /** + * * Tabu List of indexed neighbors save in a vector * each neighbor can not used during howlong iterations + * + * The tabu tenure could be random between two bounds + * such as in robust tabu search + * */ template class moIndexedVectorTabuList : public moTabuList @@ -49,7 +54,17 @@ public: * @param _maxSize maximum size of the tabu list * @param _howlong how many iteration a move is tabu */ - moIndexedVectorTabuList(unsigned int _maxSize, unsigned int _howlong) : maxSize(_maxSize), howlong(_howlong) { + moIndexedVectorTabuList(unsigned int _maxSize, unsigned int _howlong) : maxSize(_maxSize), howlong(_howlong), robust(false) { + tabuList.resize(_maxSize); + } + + /** + * Constructor + * @param _maxSize maximum size of the tabu list + * @param _howlongMin minimal number of iterations during a move is tabu + * @param _howlongMax maximal number of iterations during a move is tabu + */ + moIndexedVectorTabuList(unsigned int _maxSize, unsigned int _howlongMin, unsigned int _howlongMax) : maxSize(_maxSize), howlongMin(_howlongMin), howlongMax(_howlongMax), robust(true) { tabuList.resize(_maxSize); } @@ -68,8 +83,13 @@ public: * @param _neighbor the current neighbor */ virtual void add(EOT & _sol, Neighbor & _neighbor) { - if (_neighbor.index() < maxSize) + if (_neighbor.index() < maxSize) { + if (robust) + // random value between min and max + howlong = howlongMin + rng.random(howlongMax - howlongMin); + tabuList[_neighbor.index()] = howlong; + } } /** @@ -115,7 +135,12 @@ protected: unsigned int maxSize; //how many iteration a move is tabu unsigned int howlong; - + // Minimum number of iterations during a move is tabu + unsigned int howlongMin; + // Maximum number of iterations during a move is tabu + unsigned int howlongMax; + // true: robust tabu search way + bool robust; }; #endif diff --git a/mo/src/perturb/moMonOpPerturb.h b/mo/src/perturb/moMonOpPerturb.h index 87b409069..b043a99e9 100644 --- a/mo/src/perturb/moMonOpPerturb.h +++ b/mo/src/perturb/moMonOpPerturb.h @@ -70,7 +70,7 @@ public: bool res = false; if (rndPerturb) - nbPerturbation = nbPerturbationMin + rng.random(nbPerturbationMax); + nbPerturbation = nbPerturbationMin + rng.random(nbPerturbationMax - nbPerturbationMin); for(unsigned int i = 0; i < nbPerturbation; i++) res = monOp(_solution) || res; From 7a1b38aa02b22a958024af8dc2d2ce0c5625c56e Mon Sep 17 00:00:00 2001 From: verel Date: Wed, 23 Jul 2014 12:02:18 +0200 Subject: [PATCH 096/419] add include in indextabulist --- mo/src/memory/moIndexedVectorTabuList.h | 1 + 1 file changed, 1 insertion(+) diff --git a/mo/src/memory/moIndexedVectorTabuList.h b/mo/src/memory/moIndexedVectorTabuList.h index cbb2c9c1e..e1ea94492 100644 --- a/mo/src/memory/moIndexedVectorTabuList.h +++ b/mo/src/memory/moIndexedVectorTabuList.h @@ -30,6 +30,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr #ifndef _moIndexedVectorTabuList_h #define _moIndexedVectorTabuList_h +#include #include #include #include From 84651f7a92f7c018123b4f9cfac26d17f18da52c Mon Sep 17 00:00:00 2001 From: manu Date: Tue, 23 Sep 2014 17:32:37 +0200 Subject: [PATCH 097/419] * Remove executable bit from header files. --- moeo/src/algo/moeoEasyEA.h | 0 moeo/src/algo/moeoPopLS.h | 0 moeo/src/algo/moeoUnifiedDominanceBasedLS.h | 0 moeo/src/comparator/moeoFitnessComparator.h | 0 moeo/src/do/make_checkpoint_moeo.h | 0 moeo/src/do/make_continue_moeo.h | 0 moeo/src/do/make_ea_moeo.h | 0 moeo/src/explorer/moeoPopNeighborhoodExplorer.h | 0 .../fitness/moeoReferencePointIndicatorBasedFitnessAssignment.h | 0 moeo/src/replacement/moeoEnvironmentalReplacement.h | 0 moeo/src/scalarStuffs/algo/moeoSolAlgo.h | 0 moeo/src/scalarStuffs/archive/moeoArchiveIndex.h | 0 moeo/src/scalarStuffs/archive/moeoIndexedArchive.h | 0 moeo/src/scalarStuffs/archive/moeoQuadTree.h | 0 moeo/src/scalarStuffs/archive/moeoQuickUnboundedArchiveIndex.h | 0 moeo/src/scalarStuffs/explorer/moeoHCMoveLoopExpl.h | 0 moeo/src/scalarStuffs/explorer/moeoTSMoveLoopExpl.h | 0 moeo/src/scalarStuffs/weighting/moeoAnytimeWeightStrategy.h | 0 .../scalarStuffs/weighting/moeoAugmentedQexploreWeightStrategy.h | 0 moeo/src/scalarStuffs/weighting/moeoDummyRefPointStrategy.h | 0 moeo/src/scalarStuffs/weighting/moeoDummyWeightStrategy.h | 0 .../weighting/moeoFixedTimeBothDirectionWeightStrategy.h | 0 .../weighting/moeoFixedTimeOneDirectionWeightStrategy.h | 0 moeo/src/scalarStuffs/weighting/moeoQexploreWeightStrategy.h | 0 moeo/src/scalarStuffs/weighting/moeoRandWeightStrategy.h | 0 moeo/src/scalarStuffs/weighting/moeoVariableRefPointStrategy.h | 0 moeo/src/scalarStuffs/weighting/moeoVariableWeightStrategy.h | 0 27 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 moeo/src/algo/moeoEasyEA.h mode change 100755 => 100644 moeo/src/algo/moeoPopLS.h mode change 100755 => 100644 moeo/src/algo/moeoUnifiedDominanceBasedLS.h mode change 100755 => 100644 moeo/src/comparator/moeoFitnessComparator.h mode change 100755 => 100644 moeo/src/do/make_checkpoint_moeo.h mode change 100755 => 100644 moeo/src/do/make_continue_moeo.h mode change 100755 => 100644 moeo/src/do/make_ea_moeo.h mode change 100755 => 100644 moeo/src/explorer/moeoPopNeighborhoodExplorer.h mode change 100755 => 100644 moeo/src/fitness/moeoReferencePointIndicatorBasedFitnessAssignment.h mode change 100755 => 100644 moeo/src/replacement/moeoEnvironmentalReplacement.h mode change 100755 => 100644 moeo/src/scalarStuffs/algo/moeoSolAlgo.h mode change 100755 => 100644 moeo/src/scalarStuffs/archive/moeoArchiveIndex.h mode change 100755 => 100644 moeo/src/scalarStuffs/archive/moeoIndexedArchive.h mode change 100755 => 100644 moeo/src/scalarStuffs/archive/moeoQuadTree.h mode change 100755 => 100644 moeo/src/scalarStuffs/archive/moeoQuickUnboundedArchiveIndex.h mode change 100755 => 100644 moeo/src/scalarStuffs/explorer/moeoHCMoveLoopExpl.h mode change 100755 => 100644 moeo/src/scalarStuffs/explorer/moeoTSMoveLoopExpl.h mode change 100755 => 100644 moeo/src/scalarStuffs/weighting/moeoAnytimeWeightStrategy.h mode change 100755 => 100644 moeo/src/scalarStuffs/weighting/moeoAugmentedQexploreWeightStrategy.h mode change 100755 => 100644 moeo/src/scalarStuffs/weighting/moeoDummyRefPointStrategy.h mode change 100755 => 100644 moeo/src/scalarStuffs/weighting/moeoDummyWeightStrategy.h mode change 100755 => 100644 moeo/src/scalarStuffs/weighting/moeoFixedTimeBothDirectionWeightStrategy.h mode change 100755 => 100644 moeo/src/scalarStuffs/weighting/moeoFixedTimeOneDirectionWeightStrategy.h mode change 100755 => 100644 moeo/src/scalarStuffs/weighting/moeoQexploreWeightStrategy.h mode change 100755 => 100644 moeo/src/scalarStuffs/weighting/moeoRandWeightStrategy.h mode change 100755 => 100644 moeo/src/scalarStuffs/weighting/moeoVariableRefPointStrategy.h mode change 100755 => 100644 moeo/src/scalarStuffs/weighting/moeoVariableWeightStrategy.h diff --git a/moeo/src/algo/moeoEasyEA.h b/moeo/src/algo/moeoEasyEA.h old mode 100755 new mode 100644 diff --git a/moeo/src/algo/moeoPopLS.h b/moeo/src/algo/moeoPopLS.h old mode 100755 new mode 100644 diff --git a/moeo/src/algo/moeoUnifiedDominanceBasedLS.h b/moeo/src/algo/moeoUnifiedDominanceBasedLS.h old mode 100755 new mode 100644 diff --git a/moeo/src/comparator/moeoFitnessComparator.h b/moeo/src/comparator/moeoFitnessComparator.h old mode 100755 new mode 100644 diff --git a/moeo/src/do/make_checkpoint_moeo.h b/moeo/src/do/make_checkpoint_moeo.h old mode 100755 new mode 100644 diff --git a/moeo/src/do/make_continue_moeo.h b/moeo/src/do/make_continue_moeo.h old mode 100755 new mode 100644 diff --git a/moeo/src/do/make_ea_moeo.h b/moeo/src/do/make_ea_moeo.h old mode 100755 new mode 100644 diff --git a/moeo/src/explorer/moeoPopNeighborhoodExplorer.h b/moeo/src/explorer/moeoPopNeighborhoodExplorer.h old mode 100755 new mode 100644 diff --git a/moeo/src/fitness/moeoReferencePointIndicatorBasedFitnessAssignment.h b/moeo/src/fitness/moeoReferencePointIndicatorBasedFitnessAssignment.h old mode 100755 new mode 100644 diff --git a/moeo/src/replacement/moeoEnvironmentalReplacement.h b/moeo/src/replacement/moeoEnvironmentalReplacement.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/algo/moeoSolAlgo.h b/moeo/src/scalarStuffs/algo/moeoSolAlgo.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/archive/moeoArchiveIndex.h b/moeo/src/scalarStuffs/archive/moeoArchiveIndex.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/archive/moeoIndexedArchive.h b/moeo/src/scalarStuffs/archive/moeoIndexedArchive.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/archive/moeoQuadTree.h b/moeo/src/scalarStuffs/archive/moeoQuadTree.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/archive/moeoQuickUnboundedArchiveIndex.h b/moeo/src/scalarStuffs/archive/moeoQuickUnboundedArchiveIndex.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/explorer/moeoHCMoveLoopExpl.h b/moeo/src/scalarStuffs/explorer/moeoHCMoveLoopExpl.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/explorer/moeoTSMoveLoopExpl.h b/moeo/src/scalarStuffs/explorer/moeoTSMoveLoopExpl.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/weighting/moeoAnytimeWeightStrategy.h b/moeo/src/scalarStuffs/weighting/moeoAnytimeWeightStrategy.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/weighting/moeoAugmentedQexploreWeightStrategy.h b/moeo/src/scalarStuffs/weighting/moeoAugmentedQexploreWeightStrategy.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/weighting/moeoDummyRefPointStrategy.h b/moeo/src/scalarStuffs/weighting/moeoDummyRefPointStrategy.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/weighting/moeoDummyWeightStrategy.h b/moeo/src/scalarStuffs/weighting/moeoDummyWeightStrategy.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/weighting/moeoFixedTimeBothDirectionWeightStrategy.h b/moeo/src/scalarStuffs/weighting/moeoFixedTimeBothDirectionWeightStrategy.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/weighting/moeoFixedTimeOneDirectionWeightStrategy.h b/moeo/src/scalarStuffs/weighting/moeoFixedTimeOneDirectionWeightStrategy.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/weighting/moeoQexploreWeightStrategy.h b/moeo/src/scalarStuffs/weighting/moeoQexploreWeightStrategy.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/weighting/moeoRandWeightStrategy.h b/moeo/src/scalarStuffs/weighting/moeoRandWeightStrategy.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/weighting/moeoVariableRefPointStrategy.h b/moeo/src/scalarStuffs/weighting/moeoVariableRefPointStrategy.h old mode 100755 new mode 100644 diff --git a/moeo/src/scalarStuffs/weighting/moeoVariableWeightStrategy.h b/moeo/src/scalarStuffs/weighting/moeoVariableWeightStrategy.h old mode 100755 new mode 100644 From dffd8737747d976494be2b9e76a6f2863076d79a Mon Sep 17 00:00:00 2001 From: manu Date: Tue, 23 Sep 2014 17:43:47 +0200 Subject: [PATCH 098/419] * Delete executable bit from *.cpp files. --- moeo/test/t-moeoASFAMetric.cpp | 0 moeo/test/t-moeoASFAOrMetric.cpp | 0 moeo/test/t-moeoAggregationFitnessAssignment.cpp | 0 moeo/test/t-moeoChebyshevMetric.cpp | 0 moeo/test/t-moeoChebyshevOrientedMetric.cpp | 0 moeo/test/t-moeoConstraintFitnessAssignment.cpp | 0 moeo/test/t-moeoQuadTreeIndex.cpp | 0 moeo/test/t-moeoQuickUnboundedArchiveIndex.cpp | 0 8 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 moeo/test/t-moeoASFAMetric.cpp mode change 100755 => 100644 moeo/test/t-moeoASFAOrMetric.cpp mode change 100755 => 100644 moeo/test/t-moeoAggregationFitnessAssignment.cpp mode change 100755 => 100644 moeo/test/t-moeoChebyshevMetric.cpp mode change 100755 => 100644 moeo/test/t-moeoChebyshevOrientedMetric.cpp mode change 100755 => 100644 moeo/test/t-moeoConstraintFitnessAssignment.cpp mode change 100755 => 100644 moeo/test/t-moeoQuadTreeIndex.cpp mode change 100755 => 100644 moeo/test/t-moeoQuickUnboundedArchiveIndex.cpp diff --git a/moeo/test/t-moeoASFAMetric.cpp b/moeo/test/t-moeoASFAMetric.cpp old mode 100755 new mode 100644 diff --git a/moeo/test/t-moeoASFAOrMetric.cpp b/moeo/test/t-moeoASFAOrMetric.cpp old mode 100755 new mode 100644 diff --git a/moeo/test/t-moeoAggregationFitnessAssignment.cpp b/moeo/test/t-moeoAggregationFitnessAssignment.cpp old mode 100755 new mode 100644 diff --git a/moeo/test/t-moeoChebyshevMetric.cpp b/moeo/test/t-moeoChebyshevMetric.cpp old mode 100755 new mode 100644 diff --git a/moeo/test/t-moeoChebyshevOrientedMetric.cpp b/moeo/test/t-moeoChebyshevOrientedMetric.cpp old mode 100755 new mode 100644 diff --git a/moeo/test/t-moeoConstraintFitnessAssignment.cpp b/moeo/test/t-moeoConstraintFitnessAssignment.cpp old mode 100755 new mode 100644 diff --git a/moeo/test/t-moeoQuadTreeIndex.cpp b/moeo/test/t-moeoQuadTreeIndex.cpp old mode 100755 new mode 100644 diff --git a/moeo/test/t-moeoQuickUnboundedArchiveIndex.cpp b/moeo/test/t-moeoQuickUnboundedArchiveIndex.cpp old mode 100755 new mode 100644 From 521c7e5bf58fbc50c6e5d3def21d5459795ec071 Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 25 Sep 2014 15:28:21 +0200 Subject: [PATCH 099/419] * Add problems/DTLZ from http://paradiseo.gforge.inria.fr/index.php?n=Problems.DTLZ --- problems/DTLZ/CMakeLists.txt | 106 +++++ problems/DTLZ/README.txt | 45 ++ problems/DTLZ/application/CMakeLists.txt | 76 ++++ problems/DTLZ/application/DTLZ_IBEA.cpp | 172 ++++++++ problems/DTLZ/application/DTLZ_NSGAII.cpp | 169 ++++++++ problems/DTLZ/application/DTLZ_SPEA2.cpp | 190 +++++++++ problems/DTLZ/application/IBEA.param | 28 ++ problems/DTLZ/application/NSGAII.param | 28 ++ problems/DTLZ/application/SPEA2.param | 30 ++ problems/DTLZ/doc/CMakeLists.txt | 26 ++ problems/DTLZ/doc/html/doxygen.css | 433 ++++++++++++++++++++ problems/DTLZ/doc/html/doxygen.png | Bin 0 -> 1281 bytes problems/DTLZ/doc/html/ftv2blank.png | Bin 0 -> 174 bytes problems/DTLZ/doc/html/ftv2doc.png | Bin 0 -> 255 bytes problems/DTLZ/doc/html/ftv2folderclosed.png | Bin 0 -> 259 bytes problems/DTLZ/doc/html/ftv2folderopen.png | Bin 0 -> 261 bytes problems/DTLZ/doc/html/ftv2lastnode.png | Bin 0 -> 233 bytes problems/DTLZ/doc/html/ftv2link.png | Bin 0 -> 358 bytes problems/DTLZ/doc/html/ftv2mlastnode.png | Bin 0 -> 160 bytes problems/DTLZ/doc/html/ftv2mnode.png | Bin 0 -> 194 bytes problems/DTLZ/doc/html/ftv2node.png | Bin 0 -> 235 bytes problems/DTLZ/doc/html/ftv2plastnode.png | Bin 0 -> 165 bytes problems/DTLZ/doc/html/ftv2pnode.png | Bin 0 -> 200 bytes problems/DTLZ/doc/html/ftv2vertline.png | Bin 0 -> 229 bytes problems/DTLZ/doc/html/installdox | 117 ++++++ problems/DTLZ/doc/html/search.idx | Bin 0 -> 279856 bytes problems/DTLZ/doc/html/search.php | 382 +++++++++++++++++ problems/DTLZ/doc/html/tab_b.gif | Bin 0 -> 35 bytes problems/DTLZ/doc/html/tab_l.gif | Bin 0 -> 706 bytes problems/DTLZ/doc/html/tab_r.gif | Bin 0 -> 2585 bytes problems/DTLZ/doc/html/tabs.css | 102 +++++ problems/DTLZ/doc/index.h | 57 +++ problems/DTLZ/doc/moeo.doxyfile.cmake | 237 +++++++++++ problems/DTLZ/install.cmake | 28 ++ problems/DTLZ/run.sh | 50 +++ problems/DTLZ/src/CMakeLists.txt | 33 ++ problems/DTLZ/src/DTLZ.cpp | 44 ++ problems/DTLZ/src/DTLZ.h | 58 +++ problems/DTLZ/src/DTLZ1Eval.cpp | 74 ++++ problems/DTLZ/src/DTLZ1Eval.h | 58 +++ problems/DTLZ/src/DTLZ2Eval.cpp | 73 ++++ problems/DTLZ/src/DTLZ2Eval.h | 57 +++ problems/DTLZ/src/DTLZ3Eval.cpp | 74 ++++ problems/DTLZ/src/DTLZ3Eval.h | 58 +++ problems/DTLZ/src/DTLZ4Eval.cpp | 75 ++++ problems/DTLZ/src/DTLZ4Eval.h | 68 +++ problems/DTLZ/src/DTLZ5Eval.cpp | 82 ++++ problems/DTLZ/src/DTLZ5Eval.h | 59 +++ problems/DTLZ/src/DTLZ6Eval.cpp | 81 ++++ problems/DTLZ/src/DTLZ6Eval.h | 60 +++ problems/DTLZ/src/DTLZ7Eval.cpp | 74 ++++ problems/DTLZ/src/DTLZ7Eval.h | 59 +++ problems/DTLZ/src/DTLZObjectiveVector.h | 47 +++ problems/DTLZ/src/PolynomialMutation.h | 123 ++++++ problems/DTLZ/src/SBXCrossover.h | 194 +++++++++ problems/DTLZ/test/CMakeLists.txt | 62 +++ problems/DTLZ/test/t-DTLZ.cpp | 62 +++ problems/DTLZ/test/t-DTLZ1Eval.cpp | 130 ++++++ problems/DTLZ/test/t-DTLZ2Eval.cpp | 131 ++++++ problems/DTLZ/test/t-DTLZ3Eval.cpp | 131 ++++++ problems/DTLZ/test/t-DTLZ4Eval.cpp | 131 ++++++ problems/DTLZ/test/t-DTLZ5Eval.cpp | 132 ++++++ problems/DTLZ/test/t-DTLZ6Eval.cpp | 133 ++++++ problems/DTLZ/test/t-DTLZ7Eval.cpp | 131 ++++++ 64 files changed, 4770 insertions(+) create mode 100644 problems/DTLZ/CMakeLists.txt create mode 100644 problems/DTLZ/README.txt create mode 100644 problems/DTLZ/application/CMakeLists.txt create mode 100644 problems/DTLZ/application/DTLZ_IBEA.cpp create mode 100644 problems/DTLZ/application/DTLZ_NSGAII.cpp create mode 100644 problems/DTLZ/application/DTLZ_SPEA2.cpp create mode 100644 problems/DTLZ/application/IBEA.param create mode 100644 problems/DTLZ/application/NSGAII.param create mode 100644 problems/DTLZ/application/SPEA2.param create mode 100644 problems/DTLZ/doc/CMakeLists.txt create mode 100644 problems/DTLZ/doc/html/doxygen.css create mode 100644 problems/DTLZ/doc/html/doxygen.png create mode 100644 problems/DTLZ/doc/html/ftv2blank.png create mode 100644 problems/DTLZ/doc/html/ftv2doc.png create mode 100644 problems/DTLZ/doc/html/ftv2folderclosed.png create mode 100644 problems/DTLZ/doc/html/ftv2folderopen.png create mode 100644 problems/DTLZ/doc/html/ftv2lastnode.png create mode 100644 problems/DTLZ/doc/html/ftv2link.png create mode 100644 problems/DTLZ/doc/html/ftv2mlastnode.png create mode 100644 problems/DTLZ/doc/html/ftv2mnode.png create mode 100644 problems/DTLZ/doc/html/ftv2node.png create mode 100644 problems/DTLZ/doc/html/ftv2plastnode.png create mode 100644 problems/DTLZ/doc/html/ftv2pnode.png create mode 100644 problems/DTLZ/doc/html/ftv2vertline.png create mode 100755 problems/DTLZ/doc/html/installdox create mode 100644 problems/DTLZ/doc/html/search.idx create mode 100644 problems/DTLZ/doc/html/search.php create mode 100644 problems/DTLZ/doc/html/tab_b.gif create mode 100644 problems/DTLZ/doc/html/tab_l.gif create mode 100644 problems/DTLZ/doc/html/tab_r.gif create mode 100644 problems/DTLZ/doc/html/tabs.css create mode 100644 problems/DTLZ/doc/index.h create mode 100644 problems/DTLZ/doc/moeo.doxyfile.cmake create mode 100644 problems/DTLZ/install.cmake create mode 100644 problems/DTLZ/run.sh create mode 100644 problems/DTLZ/src/CMakeLists.txt create mode 100644 problems/DTLZ/src/DTLZ.cpp create mode 100644 problems/DTLZ/src/DTLZ.h create mode 100644 problems/DTLZ/src/DTLZ1Eval.cpp create mode 100644 problems/DTLZ/src/DTLZ1Eval.h create mode 100644 problems/DTLZ/src/DTLZ2Eval.cpp create mode 100644 problems/DTLZ/src/DTLZ2Eval.h create mode 100644 problems/DTLZ/src/DTLZ3Eval.cpp create mode 100644 problems/DTLZ/src/DTLZ3Eval.h create mode 100644 problems/DTLZ/src/DTLZ4Eval.cpp create mode 100644 problems/DTLZ/src/DTLZ4Eval.h create mode 100644 problems/DTLZ/src/DTLZ5Eval.cpp create mode 100644 problems/DTLZ/src/DTLZ5Eval.h create mode 100644 problems/DTLZ/src/DTLZ6Eval.cpp create mode 100644 problems/DTLZ/src/DTLZ6Eval.h create mode 100644 problems/DTLZ/src/DTLZ7Eval.cpp create mode 100644 problems/DTLZ/src/DTLZ7Eval.h create mode 100644 problems/DTLZ/src/DTLZObjectiveVector.h create mode 100644 problems/DTLZ/src/PolynomialMutation.h create mode 100644 problems/DTLZ/src/SBXCrossover.h create mode 100644 problems/DTLZ/test/CMakeLists.txt create mode 100644 problems/DTLZ/test/t-DTLZ.cpp create mode 100644 problems/DTLZ/test/t-DTLZ1Eval.cpp create mode 100644 problems/DTLZ/test/t-DTLZ2Eval.cpp create mode 100644 problems/DTLZ/test/t-DTLZ3Eval.cpp create mode 100644 problems/DTLZ/test/t-DTLZ4Eval.cpp create mode 100644 problems/DTLZ/test/t-DTLZ5Eval.cpp create mode 100644 problems/DTLZ/test/t-DTLZ6Eval.cpp create mode 100644 problems/DTLZ/test/t-DTLZ7Eval.cpp diff --git a/problems/DTLZ/CMakeLists.txt b/problems/DTLZ/CMakeLists.txt new file mode 100644 index 000000000..d74bba102 --- /dev/null +++ b/problems/DTLZ/CMakeLists.txt @@ -0,0 +1,106 @@ +###################################################################################### +### 0) Set your application properties +###################################################################################### +# check cmake version compatibility +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +# Define your project name +PROJECT(DTLZ) + +SET(PACKAGE_NAME "DTLZ" CACHE STRING "Package name" FORCE) +SET(PACKAGE_VERSION "1.0" CACHE STRING "Package version" FORCE) + +# regular expression checking +INCLUDE_REGULAR_EXPRESSION("^.*$" "^$") + +# set a language for the entire project. +ENABLE_LANGUAGE(CXX) +ENABLE_LANGUAGE(C) + +###################################################################################### + +###################################################################################### +### 1) Include the install configuration file where are defined the main variables +###################################################################################### + +INCLUDE(${DTLZ_SOURCE_DIR}/install.cmake) + +###################################################################################### + +###################################################################################### +### 2) Include the sources +###################################################################################### +###################################### +### Include required modules & utilities +##################################################################################### +INCLUDE(CMakeBackwardCompatibilityCXX) + +INCLUDE(FindDoxygen) + +INCLUDE(CheckLibraryExists) + +INCLUDE(Dart OPTIONAL) + +# Set a special flag if the environment is windows (should do the same in a config.g file) +IF (WIN32) + ADD_DEFINITIONS(-D_WINDOWS=1) +ENDIF (WIN32) + +###################################################################################### + +##################################################################################### +### Manage the build type +##################################################################################### + +# the user should choose the build type on windows environments,excepted under cygwin (default=none) +SET(CMAKE_DEFAULT_BUILD_TYPE "Release" CACHE STRING "Variable that stores the default CMake build type" FORCE) + +FIND_PROGRAM(MEMORYCHECK_COMMAND + NAMES purify valgrind + PATHS + "/usr/local/bin /usr/bin [HKEY_LOCAL_MACHINE\\SOFTWARE\\Rational Software\\Purify\\Setup;InstallFolder]" + DOC "Path to the memory checking command, used for memory error detection.") + +IF(NOT CMAKE_BUILD_TYPE) + SET( CMAKE_BUILD_TYPE + ${CMAKE_DEFAULT_BUILD_TYPE} CACHE STRING + "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." + FORCE) +ENDIF(NOT CMAKE_BUILD_TYPE) + +IF(WIN32 AND NOT CYGWIN) + IF(CMAKE_CXX_COMPILER MATCHES cl) + IF(NOT WITH_SHARED_LIBS) + IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008") + SET(CMAKE_CXX_FLAGS "/nologo /Gy") + SET(CMAKE_CXX_FLAGS_DEBUG "/W3 /MTd /Z7 /Od") + SET(CMAKE_CXX_FLAGS_RELEASE "/w /MT /O2 /wd4530") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") + ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008") + ENDIF(NOT WITH_SHARED_LIBS) + ENDIF(CMAKE_CXX_COMPILER MATCHES cl) +ELSE(WIN32 AND NOT CYGWIN) + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -fprofile-arcs -ftest-coverage -Wall -Wextra -Wno-unused-parameter") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -O6") + ENDIF(CMAKE_COMPILER_IS_GNUCXX) +ENDIF(WIN32 AND NOT CYGWIN) + +IF(CMAKE_BUILD_TYPE MATCHES Debug) + ADD_DEFINITIONS(-DCMAKE_VERBOSE_MAKEFILE=ON) +ENDIF(CMAKE_BUILD_TYPE MATCHES Debug) + +###################################################################################### +### 3) Link the librairies for your executable +###################################################################################### + +ADD_SUBDIRECTORY(doc) +ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(test) +ADD_SUBDIRECTORY(application) + +###################################################################################### + diff --git a/problems/DTLZ/README.txt b/problems/DTLZ/README.txt new file mode 100644 index 000000000..9fc0a210d --- /dev/null +++ b/problems/DTLZ/README.txt @@ -0,0 +1,45 @@ +This package contains the source code for DTLZ problems. + +# Step 1 - Configuration +------------------------ +Edit the "install.cmake" file by entering the FULL PATH of the "ParadisEO". +On Windows write your path with double antislash (ex: C:\\Users\\...) + + +# Step 2 - Build process +------------------------ +ParadisEO is assumed to be compiled. To download ParadisEO, please visit http://paradiseo.gforge.inria.fr/. +Go to the DLTZ/build/ directory and lunch cmake: +(Unix) > cmake .. +(Windows) > cmake .. -G"Visual Studio 9 2008" + +Note for windows users: if you don't use VisualStudio 9, enter the name of your generator instead of "VisualStudio 9 2008". + + +# Step 3 - Compilation +---------------------- +In the DTLZ/build/ directory: +(Unix) > make +(Windows) Open the VisualStudio solution and compile it (Windows). +You can refer to this tutorial if you don't know how to compile a solution: http://paradiseo.gforge.inria.fr/index.php?n=Paradiseo.VisualCTutorial + + +# Step 4 - Execution +--------------------- +A toy example is given to test the components. You can run these tests as following. +To define problem-related components for your own problem, please refer to the tutorials available on the website : http://paradiseo.gforge.inria.fr/. +In the DTLZ/build/ directory: +(Unix) > ctest +Windows users, please refer to this tutorial: http://paradiseo.gforge.inria.fr/index.php?n=Paradiseo.VisualCTutorial + +In the directory "application", there are three ".cpp" which instantiate IBEA, NSGAII and SPEA2 on ZDT problems. To change of algorithms, you can compare these three files and see the few changes to do. + +(Unix) After compilation you can run the script "DTLZ/run.sh" and see results in "IBEA.out", "NSGAII.out" and "SPEA2.out". Parameters can be modified in the script. + +(Windows) Add argument "IBEA.param", "SPEA2.param" or "NSGAII.param" and execute the corresponding algorithms. +Windows users, please refer to this tutorial: http://paradiseo.gforge.inria.fr/index.php?n=Paradiseo.VisualCTutorial + +# Documentation +--------------- +The API-documentation is available in doc/html/index.html + diff --git a/problems/DTLZ/application/CMakeLists.txt b/problems/DTLZ/application/CMakeLists.txt new file mode 100644 index 000000000..a3e65fd72 --- /dev/null +++ b/problems/DTLZ/application/CMakeLists.txt @@ -0,0 +1,76 @@ +###################################################################################### +### 1) Include the sources +###################################################################################### + +INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src + ${PARADISEO_MO_SRC_DIR}/src + ${PARADISEO_MOEO_SRC_DIR}/src + ${DTLZ_SOURCE_DIR}/src) + +###################################################################################### + + +###################################################################################### +### 2) Specify where CMake can find the libraries +###################################################################################### + +LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib) +LINK_DIRECTORIES(${PARADISEO_MOEO_BIN_DIR}/lib) +LINK_DIRECTORIES(${DTLZ_BINARY_DIR}/lib) +###################################################################################### + + +###################################################################################### +### 3) Define your target: just an executable here +###################################################################################### + +ADD_EXECUTABLE(DTLZ_SPEA2 DTLZ_SPEA2.cpp) +ADD_EXECUTABLE(DTLZ_NSGAII DTLZ_NSGAII.cpp) +ADD_EXECUTABLE(DTLZ_IBEA DTLZ_IBEA.cpp) +ADD_DEPENDENCIES(DTLZ_SPEA2 lDTLZ) +ADD_DEPENDENCIES(DTLZ_NSGAII lDTLZ) +ADD_DEPENDENCIES(DTLZ_IBEA lDTLZ) + +###################################################################################### + + +###################################################################################### +### 4) Link the librairies for your executable +###################################################################################### + +# Only if you need to link libraries +TARGET_LINK_LIBRARIES(DTLZ_SPEA2 moeo eo eoutils lDTLZ) +TARGET_LINK_LIBRARIES(DTLZ_NSGAII moeo eo eoutils lDTLZ) +TARGET_LINK_LIBRARIES(DTLZ_IBEA moeo eo eoutils lDTLZ) + +###################################################################################### + + +###################################################################################### +### 5) Copy the instances and the "param" file in the build path for an easy use. +### +### --> run the "make install" target to copy the parameter file / instances +### in the directory where you build the application +###################################################################################### + +ADD_CUSTOM_TARGET(install DEPENDS ${DTLZ_SOURCE_DIR}/application/IBEA.param + ${DTLZ_SOURCE_DIR}/application/NSGAII.param + ${DTLZ_SOURCE_DIR}/application/SPEA2.param + ${DTLZ_SOURCE_DIR}/application) +ADD_CUSTOM_COMMAND( + TARGET install + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + ${DTLZ_SOURCE_DIR}/application/IBEA.param + ${DTLZ_BINARY_DIR}/application + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + ${DTLZ_SOURCE_DIR}/application/NSGAII.param + ${DTLZ_BINARY_DIR}/application + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + ${DTLZ_SOURCE_DIR}/application/SPEA2.param + ${DTLZ_BINARY_DIR}/application) + +###################################################################################### diff --git a/problems/DTLZ/application/DTLZ_IBEA.cpp b/problems/DTLZ/application/DTLZ_IBEA.cpp new file mode 100644 index 000000000..15143abbf --- /dev/null +++ b/problems/DTLZ/application/DTLZ_IBEA.cpp @@ -0,0 +1,172 @@ +// moeo general include + +#include +#include +#include +#include +// how to initialize the population +#include +// the stopping criterion +#include +// outputs (stats, population dumps, ...) +#include +// evolution engine (selection and replacement) +#include +// simple call to the algo +#include + +// checks for help demand, and writes the status file and make_help; in libutils +void make_help(eoParser & _parser); +// definition of the representation +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +int main(int argc, char* argv[]) +{ + try + { + + eoParser parser(argc, argv); // for user-parameter reading + eoState state; // to keep all things allocated + + unsigned int MAX_GEN = parser.createParam((unsigned int)(10000), "maxGen", "Maximum number of generations",'G',"Param").value(); + double P_CROSS = parser.createParam(1.0, "pCross", "Crossover probability",'C',"Param").value(); + double EXT_P_MUT = parser.createParam(1.0, "extPMut", "External Mutation probability",'E',"Param").value(); + double INT_P_MUT = parser.createParam(0.083, "intPMut", "Internal Mutation probability",'I',"Param").value(); + unsigned int VEC_SIZE = parser.createParam((unsigned int)(12), "vecSize", "Genotype Size",'V',"Param").value(); + unsigned int NB_OBJ= parser.createParam((unsigned int)(3), "nbObj", "Number of Objective",'N',"Param").value(); + std::string OUTPUT_FILE = parser.createParam(std::string("dtlz_ibea"), "outputFile", "Path of the output file",'o',"Output").value(); + unsigned int EVAL = parser.createParam((unsigned int)(1), "eval", "Number of the DTLZ evaluation fonction",'F',"Param").value(); + unsigned int DTLZ4_PARAM = parser.createParam((unsigned int)(100), "dtlz4_param", "Parameter of the DTLZ4 evaluation fonction",'P',"Param").value(); + unsigned int NB_EVAL = parser.createParam((unsigned int)(0), "nbEval", "Number of evaluation before Stop",'P',"Param").value(); + unsigned int TIME = parser.createParam((unsigned int)(0), "time", "Time(seconds) before Stop",'T',"Param").value(); + + + + /*** the representation-dependent things ***/ + std::vector bObjectives(NB_OBJ); + for (unsigned int i=0; i * eval; + + if (EVAL == 1) + eval= new DTLZ1Eval; + else if (EVAL == 2) + eval= new DTLZ2Eval; + else if (EVAL == 3) + eval= new DTLZ3Eval; + else if (EVAL == 4) + eval= new DTLZ4Eval(DTLZ4_PARAM); + else if (EVAL == 5) + eval= new DTLZ5Eval; + else if (EVAL == 6) + eval= new DTLZ6Eval; + else if (EVAL == 7) + eval= new DTLZ7Eval; + + // the genotype (through a genotype initializer) + eoRealVectorBounds bounds(VEC_SIZE, 0.0, 1.0); + + eoRealInitBounded init (bounds); + // the variation operators + SBXCrossover < DTLZ > xover(bounds, 15); + + PolynomialMutation < DTLZ > mutation (bounds, INT_P_MUT, 20); + + /*** the representation-independent things ***/ + + // initialization of the population + + // definition of the archive + // stopping criteria + + eoGenContinue term(MAX_GEN); + + eoEvalFuncCounter evalFunc(*eval); + + /*eoTimeContinue timeContinuator(TIME); + eoCheckPoint checkpoint(timeContinuator);*/ + + eoCheckPoint* checkpoint; + + if (TIME > 0) + checkpoint = new eoCheckPoint(*(new eoTimeContinue(TIME))); + else if (NB_EVAL > 0) + checkpoint = new eoCheckPoint(*(new eoEvalContinue(evalFunc, NB_EVAL))); + else { + cout << "ERROR!!! : TIME or NB_EVAL must be > 0 : used option --time or --nbEval\n"; + return EXIT_FAILURE; + } + + checkpoint->add(term); + + /*moeoArchiveObjectiveVectorSavingUpdater < DTLZ > updater(arch, OUTPUT_FILE); + checkpoint->add(updater);*/ + + // algorithm + + eoSGAGenOp < DTLZ > op(xover, P_CROSS, mutation, EXT_P_MUT); + + /* moeoArchiveUpdater < DTLZ > up(arch, pop); + checkpoint.add(up);*/ + + //moeoNSGAII algo(*checkpoint, *eval ,op); + + moeoAdditiveEpsilonBinaryMetric < DTLZObjectiveVector > metric; + moeoIBEA algo(*checkpoint, evalFunc ,op, metric); + + + /*** Go ! ***/ + + // help ? + + + eoPop& pop = do_make_pop(parser, state, init); + + make_help(parser); + + // run the algo + do_run(algo, pop); + + moeoUnboundedArchive finalArchive; + finalArchive(pop); + + // printing of the final population + //cout << "Final Archive \n"; + //finalArchive.sortedPrintOn(outfile); + + ofstream outfile(OUTPUT_FILE.c_str(), ios::app); + if ((unsigned int)outfile.tellp() != 0) + outfile << endl; + + for (unsigned int i=0 ; i < finalArchive.size(); i++) { + for (unsigned int j=0 ; j +#include +#include +#include +// how to initialize the population +#include +// the stopping criterion +#include +// outputs (stats, population dumps, ...) +#include +// evolution engine (selection and replacement) +#include +// simple call to the algo +#include + +// checks for help demand, and writes the status file and make_help; in libutils +void make_help(eoParser & _parser); +// definition of the representation +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +int main(int argc, char* argv[]) +{ + try + { + + eoParser parser(argc, argv); // for user-parameter reading + eoState state; // to keep all things allocated + + unsigned int MAX_GEN = parser.createParam((unsigned int)(10000), "maxGen", "Maximum number of generations",'G',"Param").value(); + double P_CROSS = parser.createParam(1.0, "pCross", "Crossover probability",'C',"Param").value(); + double EXT_P_MUT = parser.createParam(1.0, "extPMut", "External Mutation probability",'E',"Param").value(); + double INT_P_MUT = parser.createParam(0.083, "intPMut", "Internal Mutation probability",'I',"Param").value(); + unsigned int VEC_SIZE = parser.createParam((unsigned int)(12), "vecSize", "Genotype Size",'V',"Param").value(); + unsigned int NB_OBJ= parser.createParam((unsigned int)(3), "nbObj", "Number of Objective",'N',"Param").value(); + std::string OUTPUT_FILE = parser.createParam(std::string("dtlz_nsgaII"), "outputFile", "Path of the output file",'o',"Output").value(); + unsigned int EVAL = parser.createParam((unsigned int)(1), "eval", "Number of the DTLZ evaluation fonction",'F',"Param").value(); + unsigned int DTLZ4_PARAM = parser.createParam((unsigned int)(100), "dtlz4_param", "Parameter of the DTLZ4 evaluation fonction",'P',"Param").value(); + unsigned int NB_EVAL = parser.createParam((unsigned int)(0), "nbEval", "Number of evaluation before Stop",'P',"Param").value(); + unsigned int TIME = parser.createParam((unsigned int)(0), "time", "Time(seconds) before Stop",'T',"Param").value(); + + /*** the representation-dependent things ***/ + std::vector bObjectives(NB_OBJ); + for (unsigned int i=0; i * eval; + + if (EVAL == 1) + eval= new DTLZ1Eval; + else if (EVAL == 2) + eval= new DTLZ2Eval; + else if (EVAL == 3) + eval= new DTLZ3Eval; + else if (EVAL == 4) + eval= new DTLZ4Eval(DTLZ4_PARAM); + else if (EVAL == 5) + eval= new DTLZ5Eval; + else if (EVAL == 6) + eval= new DTLZ6Eval; + else if (EVAL == 7) + eval= new DTLZ7Eval; + + // the genotype (through a genotype initializer) + eoRealVectorBounds bounds(VEC_SIZE, 0.0, 1.0); + + eoRealInitBounded init (bounds); + // the variation operators + SBXCrossover < DTLZ > xover(bounds, 15); + + PolynomialMutation < DTLZ > mutation (bounds, INT_P_MUT, 20); + + /*** the representation-independent things ***/ + + // initialization of the population + + // definition of the archive + // stopping criteria + + eoGenContinue term(MAX_GEN); + + eoEvalFuncCounter evalFunc(*eval); + + /*eoTimeContinue timeContinuator(TIME); + eoCheckPoint checkpoint(timeContinuator);*/ + + eoCheckPoint* checkpoint; + + if (TIME > 0) + checkpoint = new eoCheckPoint(*(new eoTimeContinue(TIME))); + else if (NB_EVAL > 0) + checkpoint = new eoCheckPoint(*(new eoEvalContinue(evalFunc, NB_EVAL))); + else { + cout << "ERROR!!! : TIME or NB_EVAL must be > 0 : used option --time or --nbEval\n"; + return EXIT_FAILURE; + } + + checkpoint->add(term); + + /*moeoArchiveObjectiveVectorSavingUpdater < DTLZ > updater(arch, OUTPUT_FILE); + checkpoint->add(updater);*/ + + // algorithm + + eoSGAGenOp < DTLZ > op(xover, P_CROSS, mutation, EXT_P_MUT); + + /* moeoArchiveUpdater < DTLZ > up(arch, pop); + checkpoint.add(up);*/ + + moeoNSGAII algo(*checkpoint, evalFunc ,op); + + /*moeoAdditiveEpsilonBinaryMetric < DTLZObjectiveVector > metric; + moeoIBEA algo(checkpoint, eval ,op, metric);*/ + + + /*** Go ! ***/ + + // help ? + + + eoPop& pop = do_make_pop(parser, state, init); + + make_help(parser); + // run the algo + do_run(algo, pop); + + moeoUnboundedArchive finalArchive; + finalArchive(pop); + + // printing of the final population + //cout << "Final Archive \n"; + //finalArchive.sortedPrintOn(outfile); + + ofstream outfile(OUTPUT_FILE.c_str(), ios::app); + if ((unsigned int)outfile.tellp() != 0) + outfile << endl; + + for (unsigned int i=0 ; i < finalArchive.size(); i++) { + for (unsigned int j=0 ; j +#include +#include +#include +// how to initialize the population +#include +// the stopping criterion +#include +// outputs (stats, population dumps, ...) +#include +// evolution engine (selection and replacement) +#include +// simple call to the algo +#include + +#include +#include + +// checks for help demand, and writes the status file and make_help; in libutils +void make_help(eoParser & _parser); +// definition of the representation +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +int main(int argc, char* argv[]) +{ + try + { + + eoParser parser(argc, argv); // for user-parameter reading + eoState state; // to keep all things allocated + + unsigned int ARC_SIZE = parser.createParam((unsigned int)(100), "arcSize", "Archive size",'A',"Param").value(); + unsigned int MAX_GEN = parser.createParam((unsigned int)(10000), "maxGen", "Maximum number of generations",'G',"Param").value(); + double P_CROSS = parser.createParam(1.0, "pCross", "Crossover probability",'C',"Param").value(); + double EXT_P_MUT = parser.createParam(1.0, "extPMut", "External Mutation probability",'E',"Param").value(); + double INT_P_MUT = parser.createParam(0.083, "intPMut", "Internal Mutation probability",'I',"Param").value(); + unsigned int VEC_SIZE = parser.createParam((unsigned int)(12), "vecSize", "Genotype Size",'V',"Param").value(); + unsigned int NB_OBJ= parser.createParam((unsigned int)(3), "nbObj", "Number of Objective",'N',"Param").value(); + unsigned int K = parser.createParam((unsigned int)(10), "k", "k-th nearest neighbor",'K',"Param").value(); + std::string OUTPUT_FILE = parser.createParam(std::string("dtlz_spea2"), "outputFile", "Path of the output file",'o',"Output").value(); + unsigned int EVAL = parser.createParam((unsigned int)(1), "eval", "Number of the DTLZ evaluation fonction",'F',"Param").value(); + unsigned int DTLZ4_PARAM = parser.createParam((unsigned int)(100), "dtlz4_param", "Parameter of the DTLZ4 evaluation fonction",'P',"Param").value(); + unsigned int NB_EVAL = parser.createParam((unsigned int)(0), "nbEval", "Number of evaluation before Stop",'P',"Param").value(); + unsigned int TIME = parser.createParam((unsigned int)(0), "time", "Time(seconds) before Stop",'T',"Param").value(); + + /*cout << "ARC_SIZE : " << ARC_SIZE << endl; + cout << "P_CROSS : " << P_CROSS << endl; + cout << "EXT_P_MUT : " << EXT_P_MUT << endl; + cout << "INT_P_MUT : " << INT_P_MUT << endl; + cout << "VEC_SIZE : " << VEC_SIZE << endl; + cout << "NB_OBJ : " << NB_OBJ << endl; + cout << "K : " << K << endl; + cout << "DTLZ EVAL :" << EVAL << endl; + cout << "DTLZ4_PARAM : " << DTLZ4_PARAM << endl; + cout << "NB_EVAL : " << NB_EVAL << endl; + cout << "TIME : " << TIME << endl; */ + + + /*** the representation-dependent things ***/ + std::vector bObjectives(NB_OBJ); + for (unsigned int i=0; i * eval; + + if (EVAL == 1) + eval= new DTLZ1Eval; + else if (EVAL == 2) + eval= new DTLZ2Eval; + else if (EVAL == 3) + eval= new DTLZ3Eval; + else if (EVAL == 4) + eval= new DTLZ4Eval(DTLZ4_PARAM); + else if (EVAL == 5) + eval= new DTLZ5Eval; + else if (EVAL == 6) + eval= new DTLZ6Eval; + else if (EVAL == 7) + eval= new DTLZ7Eval; + + // the genotype (through a genotype initializer) + eoRealVectorBounds bounds(VEC_SIZE, 0.0, 1.0); + + eoRealInitBounded init (bounds); + // the variation operators + SBXCrossover < DTLZ > xover(bounds, 20); + + PolynomialMutation < DTLZ > mutation (bounds, INT_P_MUT, 20); + + /*** the representation-independent things ***/ + + // initialization of the population + + // definition of the archive + moeoSPEA2Archive arch(ARC_SIZE); + //moeoUnboundedArchive arch; + // stopping criteria + + eoGenContinue term(MAX_GEN); + + eoEvalFuncCounter evalFunc(*eval); + + /*eoTimeContinue timeContinuator(TIME); + eoCheckPoint checkpoint(timeContinuator);*/ + + eoCheckPoint* checkpoint; + + if (TIME > 0) + checkpoint = new eoCheckPoint(*(new eoTimeContinue(TIME))); + else if (NB_EVAL > 0) + checkpoint = new eoCheckPoint(*(new eoEvalContinue(evalFunc, NB_EVAL))); + else { + cout << "ERROR!!! : TIME or NB_EVAL must be > 0 : used option --time or --nbEval\n"; + return EXIT_FAILURE; + } + + checkpoint->add(term); + + /*moeoArchiveObjectiveVectorSavingUpdater < DTLZ > updater(arch, OUTPUT_FILE); + checkpoint->add(updater);*/ + + // algorithm + + moeoSPEA2 algo(*checkpoint, evalFunc ,xover, P_CROSS, mutation, EXT_P_MUT, arch, K, false); + /* eoSGAGenOp < DTLZ > op(xover, 1.0, mutation, 1/12); + + moeoArchiveUpdater < DTLZ > up(arch, pop); + checkpoint.add(up); + + moeoNSGAII algo(checkpoint, eval ,op); + + /*moeoAdditiveEpsilonBinaryMetric < DTLZObjectiveVector > metric; + moeoIBEA algo(checkpoint, eval ,op, metric);*/ + + + /*** Go ! ***/ + + // help ? + + eoPop& pop = do_make_pop(parser, state, init); + // run the algo + make_help(parser); + + do_run(algo, pop); + + moeoUnboundedArchive finalArchive; + finalArchive(arch); + + + // printing of the final population + //cout << "Final Archive \n"; + //finalArchive.sortedPrintOn(outfile); + + ofstream outfile(OUTPUT_FILE.c_str(), ios::app); + if ((unsigned int)outfile.tellp() != 0) + outfile << endl; + + for (unsigned int i=0 ; i < finalArchive.size(); i++) { + for (unsigned int j=0 ; j h3 { + margin-top: 0; +} +.directory p { + margin: 0px; + white-space: nowrap; +} +.directory div { + display: none; + margin: 0px; +} +.directory img { + vertical-align: -30%; +} + diff --git a/problems/DTLZ/doc/html/doxygen.png b/problems/DTLZ/doc/html/doxygen.png new file mode 100644 index 0000000000000000000000000000000000000000..f0a274bbaffdd67f6d784c894d9cf28729db0e14 GIT binary patch literal 1281 zcmaJ>ZA?>F7(Vx-ms?uoS`b@hdRtpo6o^%HU>M$hfGrBvQnk$LE?p^P!kn&ikhyq! zX~V@&tPF5Qt@V?oTL96Bi%aRiwbe1)9DWQI#?)=HxS7QSw`J`5fAJ*eJbB;uNuKA& zdERDo*{Y<(If(#(B$Lr#;nB(8Y#ia=ZCeW?JfPLuQY`=@cW$k}Rivq|vbxGrRq1Tl9;+(gNt?}UtVKM2`T5t1jLzuL@0UIs`S#vlhl4)^ zLgSYrPj@$+`|j?eSbXTmiHGkWxV8V}BzNR?pl9k_s4pDu9vd5a_UzZEPk)}Ad{AV_ zzddrjrh4=Imr`E06;LY{)YYt?o}L~H@7C}F^WB!Ra=v`Q0bj{>5&$66CWF>mf6vjP z2N>RRY6ZYa=K`76>+|_)Xdwko+7wv}7cN|btOhWb(*{sta~6b?S8Omrxw}!4`NhGr zZVpNqpu1@BE`QGWNTpEpcJVW5izu~2B^GlM?1(OPg)zwW;QcP@Ltcclm>XbJL9C|j z=9!2?ua=uIlf0%AndzHsRC}IyTL$EhAee(fdKB`?27KeS^2M8M_7b~PiCFO&r5LC7 z7gl1*a<8;SjNaw#h=843_AV9iZbWQOAp5YOC^&_F*9K0> zB|6%IDb?aM#3viTxkLU4aXg&@+CkNTOnQ1iMP*^?b|^lJy$4C)Zk4isV!|RZ*XhXh zw8q3$=*0LeGC!XI_Wc?dkT~3+*Gu%%yIqP+Wr3H$=&ROMQU6q}Ag^P~>c5vAEO;a- z_dK-3PPeKar%)6$j~vI2#*-YH!1h6HYVtwCX5_wM`iF#UKz&&@9Oo5w3%XGYrX zW>dY~)SG-((Yim%`InwgTvyRC?e=Wh^8KCao!R6Eg&TpVWUY1sN~4G}V?nFnEGo-; zHZ_$eW9-GnC%^WS9b z@p;-$oH#MtC0v>Q$HX%4^JdFdO$0cbv-W)Q TtK}Eh@>>I#ipmV1>S*>q-hkC} literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/ftv2blank.png b/problems/DTLZ/doc/html/ftv2blank.png new file mode 100644 index 0000000000000000000000000000000000000000..493c3c0b615ade5b22027bde773faf2c0e076d66 GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr2qYM%T@!Q%(o7{me!&ckj8p!u14)&*MwA5S zr6z#mEsk^N1FBF3sc_EE%}vcKVF=AhO-xa6_jFST&P^;T z2~I3aEm8;rVk12R#UIz>f`J-DJY5_^DsClP9B62eH+WF*G=YJMp~A-KbWwke5Kx}M M)78&qol`;+0EL(^EC2ui literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/ftv2doc.png b/problems/DTLZ/doc/html/ftv2doc.png new file mode 100644 index 0000000000000000000000000000000000000000..f72999f92172cca6edaa2538286b3e369bec9f49 GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^5yjnX4egh%q=bp-`Pe zR7&bp17l3gfhmh7Fm(iZ2eAfco|q!h5)>qKG?UBh!IC9QGMbJAHf6IEiufk_g|d7~ qkWqJ4k(|I-Aeo-5U~n{Fnc?dN!3Uwu?t6hQVDNPHb6Mw<&;$TLIZ`G7 literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/ftv2folderclosed.png b/problems/DTLZ/doc/html/ftv2folderclosed.png new file mode 100644 index 0000000000000000000000000000000000000000..d6d063440cbf13c4128dacd96661b6fce58abf26 GIT binary patch literal 259 zcmeAS@N?(olHy`uVBq!ia0vp^55uo^`BphW;jCHO69?}tw{JfcdnZ<*@N=4I z?xF5Qc|QYEmKAIZ;JRGVHe=bn*tx1_|J^^vyg*oVM#A1kZlFULJYD@<);T3K0RTgB BWg7qh literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/ftv2folderopen.png b/problems/DTLZ/doc/html/ftv2folderopen.png new file mode 100644 index 0000000000000000000000000000000000000000..bbe2c913cf493ee37ad8e3a5132382138d93ac92 GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^5u(C zYP)Mg%H-DB+{J~>rPn_#pYTax?r*V6ubqGX{lvROQ{?n5_cbm+cQAOm`njxgN@xNA D92;js literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/ftv2lastnode.png b/problems/DTLZ/doc/html/ftv2lastnode.png new file mode 100644 index 0000000000000000000000000000000000000000..e7b9ba90cb0cf71c8ce662956bfee7d64cf60fa6 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6UZ?L@CkAK|NlRbNhD}!Xpp$P zU;Pg)ksC(lf|p%(p+w2Gk+!>EaktaVt4N i!r*{E4>QXNV>t$uAA#a^n)TVt_DW*G8-srQl%FeIsRSdYm zeDdtWec}u&7@8h5rqv#p7g*pRdwwmugmlS-+cHV~j}#7`Nwj9m+AU)JGGo`8z_}`K z?s#Xsy%Z;1_jl5Y+?Gum8WyK6`MBvup0SAOKJ)mWcHyteJ?WLL>>-)=?&<$H&t5oH Vd!azZ1yDdSc)I$ztaD0e0sw}(dc*(# literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/ftv2mlastnode.png b/problems/DTLZ/doc/html/ftv2mlastnode.png new file mode 100644 index 0000000000000000000000000000000000000000..09ceb6adb01054ce799ad20c0e818ab9272f2df2 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr#LU3Jc=+&fg$isFPOjJ*AaIJQGm()YSDb0rfjgNefXW#>UHx3vIVCg! E0ORy6RsaA1 literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/ftv2mnode.png b/problems/DTLZ/doc/html/ftv2mnode.png new file mode 100644 index 0000000000000000000000000000000000000000..3254c05112199fbc80aad313611c58a5b388792d GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6Ub2s@Ck7}aNq!ti3c<^Gz9OH zn+a6GSQ6wH%;50sMjDVKR^l2_5}cn_Ql40p%8;I!W>k=uu3)5RqGz-?&YcgaLd(;| zF{I*Fa>4?=2W(CyOv{5p*uLi}G<-ambjQcb>&~4!CzK3KXWY6d$*{eWU47N}X+XCz OFnGH9xvXPg)ksC(lf|p%(p+w2Gk+y>EaktaVt4N l!r*{E4>Lv;t literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/ftv2plastnode.png b/problems/DTLZ/doc/html/ftv2plastnode.png new file mode 100644 index 0000000000000000000000000000000000000000..0b07e00913d8069ebbb51bd7fd6d70d8bba88f75 GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr#LU3Jc=+&MJ literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/ftv2pnode.png b/problems/DTLZ/doc/html/ftv2pnode.png new file mode 100644 index 0000000000000000000000000000000000000000..2001b797ba2b98a4127f1d3efca64aef08bf6d51 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6Ub2s@Ck7}aNq!ti3c<^Gz9OH zn+a6GSQ6wH%;50sMjDVKR^l2_5}cn_Ql40p%8;I!W>k=uu3)5RqGz-?&Ycga!obtT zF{I*Fa>4?=2W(Dkd1@Anj~<0|oqBMOmqox%*rjK-r)THv+0v0L%h-agt(X~hWwYzA SIxU|Ma*U^|pUXO@geCywmoZiV literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/ftv2vertline.png b/problems/DTLZ/doc/html/ftv2vertline.png new file mode 100644 index 0000000000000000000000000000000000000000..b330f3a33c0085c183ff39fc56b1b274160c1da0 GIT binary patch literal 229 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6UZ?L@CkAK|NlRbNhD}!Xpp$P zU;Pg)ksC(lf|p%(p+w2Gqgt>EaktaVt4N e!r*{^G#i7W2*a|cHZQDzQVgE1elF{r5}E+)J2fZ( literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/installdox b/problems/DTLZ/doc/html/installdox new file mode 100755 index 000000000..1628445b3 --- /dev/null +++ b/problems/DTLZ/doc/html/installdox @@ -0,0 +1,117 @@ +#!/usr/bin/perl + +%subst = ( "eo.doxytag", ""); +$quiet = 0; + +if (open(F,"search.cfg")) +{ + $_= ; s/[ \t\n]*$//g ; $subst{"_doc"} = $_; + $_= ; s/[ \t\n]*$//g ; $subst{"_cgi"} = $_; +} + +while ( @ARGV ) { + $_ = shift @ARGV; + if ( s/^-// ) { + if ( /^l(.*)/ ) { + $v = ($1 eq "") ? shift @ARGV : $1; + ($v =~ /\/$/) || ($v .= "/"); + $_ = $v; + if ( /(.+)\@(.+)/ ) { + if ( exists $subst{$1} ) { + $subst{$1} = $2; + } else { + print STDERR "Unknown tag file $1 given with option -l\n"; + &usage(); + } + } else { + print STDERR "Argument $_ is invalid for option -l\n"; + &usage(); + } + } + elsif ( /^q/ ) { + $quiet = 1; + } + elsif ( /^\?|^h/ ) { + &usage(); + } + else { + print STDERR "Illegal option -$_\n"; + &usage(); + } + } + else { + push (@files, $_ ); + } +} + +foreach $sub (keys %subst) +{ + if ( $subst{$sub} eq "" ) + { + print STDERR "No substitute given for tag file `$sub'\n"; + &usage(); + } + elsif ( ! $quiet && $sub ne "_doc" && $sub ne "_cgi" ) + { + print "Substituting $subst{$sub} for each occurence of tag file $sub\n"; + } +} + +if ( ! @files ) { + if (opendir(D,".")) { + foreach $file ( readdir(D) ) { + $match = ".html"; + next if ( $file =~ /^\.\.?$/ ); + ($file =~ /$match/) && (push @files, $file); + ($file =~ "tree.js") && (push @files, $file); + } + closedir(D); + } +} + +if ( ! @files ) { + print STDERR "Warning: No input files given and none found!\n"; +} + +foreach $f (@files) +{ + if ( ! $quiet ) { + print "Editing: $f...\n"; + } + $oldf = $f; + $f .= ".bak"; + unless (rename $oldf,$f) { + print STDERR "Error: cannot rename file $oldf\n"; + exit 1; + } + if (open(F,"<$f")) { + unless (open(G,">$oldf")) { + print STDERR "Error: opening file $oldf for writing\n"; + exit 1; + } + if ($oldf ne "tree.js") { + while () { + s/doxygen\=\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\" (href|src)=\"\2/doxygen\=\"$1:$subst{$1}\" \3=\"$subst{$1}/g; + print G "$_"; + } + } + else { + while () { + s/\"([^ \"\:\t\>\<]*)\:([^ \"\t\>\<]*)\", \"\2/\"$1:$subst{$1}\" ,\"$subst{$1}/g; + print G "$_"; + } + } + } + else { + print STDERR "Warning file $f does not exist\n"; + } + unlink $f; +} + +sub usage { + print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n"; + print STDERR "Options:\n"; + print STDERR " -l tagfile\@linkName tag file + URL or directory \n"; + print STDERR " -q Quiet mode\n\n"; + exit 1; +} diff --git a/problems/DTLZ/doc/html/search.idx b/problems/DTLZ/doc/html/search.idx new file mode 100644 index 0000000000000000000000000000000000000000..e4dd70968047dfc6edba245373b45af20a44e919 GIT binary patch literal 279856 zcmeI(dyHJyT?g>v(q%i-i_nLYkOw)HM`k796R8YrZJ7xMyO?T=gyto z+sw?J%)?$+2qK6?ON}u9phyiOL{>Xmlo_Df7^!SrcDEtos5P$##AOHafKmY;|fB*y_ z009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz z00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_< z0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb z2tWV=5P$##AOHafTx$Ya=~Y!ptDURLhfENF00bZa0SG_<0uX=z1Rwwb2tWV=5P$## zAOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;| z_$UOln*1nUi+4f*0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa z0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV= z5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHaf zKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_ zU50DbwrEkc%1bxFp64y8QlwL`t|F?@H0s#nIKLYy3o7*a@ zZ`|B*eZ1{DzR))&=X`zRtCFm5{6>5mAp{_B9SP{0o>_Hm^-aI1^i6-H^v(a(_Kd#y zf8|;am^DQY+}Cy=7Z8BJwI!ejes#qP>4D_;06ma=^Xq}XaL?(1@3}Z45P-n-E1=g7 zD!umL6&s+}KJN19wO?>?L?8fx>qkJZ{o;qJtX}(@J)hHS|FCB|5+MMA>t8^x{RW*6 z{z~a}t+vMKb-zq$Uu{dn#p(t0y05K1Gjc)z0uX=z1bzepdfo5+2uekf5P-nd7SQYd zbj4Tdb;5O{)t?5g|Apn8vNI zMy`DjhAn?Nx&>I)q3ep=_{&)R);|r2sZ+zK?|LmUE8^7z~ zh(G`W*QS8JWrI{q-!i)D3hG;)a(VSFKc9-9b8$o<0D&K00e$OTKfaAe%OP-`3FuoV z+iI+DJ=}5qH*ME^p>O^7uCzEo-)jC1P<)LL0uZ=%1@xx1N^km@tDxTWpo?=vZ+fil zI=;}G7Ux>CM~RHAnR3*|uw3KmY>Qu7KYBldf`lbA{$_@4xlYn_o-i zyWrx8KmY>&zXkN>e{E}^9$cgJ;JUUnTtEN<*S>%rJk(Z6J@~n{>wXt{u-5Mu(jfqW z>qI~geyOdddhpBcS`WTN`}!GojR*uF009=zgMYFr2tD}CRpmn_2waZ>dhjo4F8uZN zSoQC_&U)}~-7|XdA6+~h(Sz;34W#cO4gm;200Izz00bZa0SG_<0uX=z1Rwwb2tWV= z5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHaf zKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_ z009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz z00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_< z0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb z2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$## zAOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;| zfB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U< z00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa z0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV= z5P$##AOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHaf zKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY;|fB*y_ z009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=KNbQzmzvGm-2VN?k00OX2Yy&C?+dG? zXs1$o@RHhD54>U}*w~b)%I?c>WP@7p%C#kra&$!jfhT2mGHr&f2&djZpPMe<+JkEyz&`&>mfz;ZE{Pu9#Ot^r5 z)R5RkNvE{o4a%?9xsJob%8#l|FRaSdm`~%S8Puuc*<(24M@4>gc;1g{+<@W3epIQI zL*EuQe3Y+S^a$U4ir!TWnNQwUmRI}ore)3-mV^32$oRu2{YdgWPbEr*x0O$0x*1T> zUWId9R7Fq5=(Y{2NXGOqKe=tV7&O8~?x1aB#o$;_j%sEwZp+xqK$^B~z8I979&>Ly zEKwHUc2uI=VcVXP=t9Ngp50bf#gMupEVOL@Z(CNyi0(ceEYzYJXL*jU>n$nz#bVSd zl-Xw6>#A7yj!WvBs@N=li4))E$lP4ICvJO%)3U)auRJ#w)q=X$jOx4Z8KLaAy>7C* z@pFuZQB+L_h!C2!dJOo<$U5fcZ)Ng;;V_C8PB;}obfzg zO`41@N;kG^ch%XX?ZfUCXB^|Jsa{2Gf6CqBjAg!>?wRpLcZ)Ng;j5XR8NcIhamM%g zYLXW-8CbWE@HG#M+vg?L`3k;snD6j-x&5fbdgYONPjDWobC)CES>~rFIVSR!FzI~0 z^StCSCB%#5?WZ|$if_Lvv0fFBK{L&HWL$Ki@f{h5GaO4$(p|-O-d6$5)Tk2jVtV@r zDyY(=tb1m8xkCq4uTVBq?2b)Awb81}M7(2rP%W0}i92?yAaYy99fyLb(WHsYcb0;P zD_&|<{Sm=_fK#6fBAV)DGko0|dB=+;Ijn|FNeqgqXWj~;MXnbu&ec|syz9NB1iN;* zdpmRxC97tVJQ76Bu)$)g(8M&@PsjBrDCG^yQDEqU{ogQ!A~ zyjJWuO{H-7Y7jls@`@($To4somC6azbei1p_Ppb~3TiyXcU(|rW7+YZVmeN`92?Tb z$PvD1d3KE&DceigaYkNI!7?o@AxTLejl3HyH{I4faxqvAn+qjcN~sU&Wp{1}XoIQQ zcip*LZZ}%-j(+DMRq|x{zVpSBSK#X1c}A6JA?DcGQdsrMyvNdh#|h_DsT^|K@BEG` z$*y_lrBYNbN5{?J**QR|oO9<;DXP*oX|{=-Bk>jA8ds${)t>k5ol6vz{7psnv|g6W zya(-kb}^vEv3r{Jg*k1tVM}mP>a#Apk5V_o$sl|x<^|aZzVe~sU=V9 zKFSeO%h3%>9^V`tUh*2rE;~A=mZEY|_PNo_QdFUhO5Q&@ua;Vsz-#d{hgC?sqnxth z9vVHWXmf2+-CfF4A#WC=G^d(%8V@4D3D1VrddS=T=*h6Uw@4ks45Kgdxo;ufKRM-$ zq}1q*)JongN6&^;8Wv%(dv6#$N5!}yFh-RLd0dWdw@;XvI+j;q)R>#|YTSWiO%-x) zkDXFsQz9>zhh9-%{MOg&-}-tbWZJRU)YH}IIPJ?KG4_Tkd&fEbEmaPKQWPyNNw#s%VCrI_^yF+xVXd>y=zF7qxiUS*GM^vp61l? za^%@V=v{e^bK)UYS*V2^JHn9#Ucm1bu_KgpM9<);;Qyxw%HrY;k?>9^*`O+NNXIv4GZ) zupCtjG&AcbOy%r?)$tlxzwUmPpA8Fv=a#U$PjXVLY8PNTyOZ0`^X)1vhGCc_zQ&1- zTHxin^1tD3CE4HNG~NI@>NL;k9ciYyyx89Tj-n5ccn;nDE?v;EjECE9rR-UE_Xbrh z&}PGl!_~quk58q$k5&r{^jeOdq9_Y<{EVVRT8KIRW=FALW7Fdd;6 z?818Q>vSE*-%+&%zaGg4*1ebFZ?HX^RL%3BHVe?6?R>JKv#Wf_?b+>i;yv?riQ4m| zoP7dwO5amd@ycP&;(L~9$?{}+?s-lb(>xd!T4K>4l41Hp1W!M9eQ)kzTn+@K(C|K z*UZfEi(G2`n5os}da&r#<->XJKs|V-71m`@=L+r}qQPL7p1mXXCZ~_n8_cKY-aJJ) ziN;O*S+@68Rp%v5($Cey#?ulzuj*3Uy%*~8MZNbuRd1Ee)0b7le8cS

sT}j04`v z(jBpHD1C>@q@MvAf#0f|b#&jnvUS>bxFO5kzB8&pyBFo$PmxyL54e_cy`d46n#aw@ z_5NXVlk<(m>34IL_fr9c7?xz=+fM~NBOia>l? znI$_yS0S$_*>Q@=hiNvi_#nw?pHj`Jwzo*bgumN(;muSW+mzIs+s zgQ~op@zv{!ew~pcMfQBF8rsb~dqK78yhLR$s+LU4>}3jNm&^@tO!^@=)S@2cUtw}1 zoXC-Jim-DoulSV6h2##I^)9!h2s{39B-b?ZoZ*x@7Rg6>?gd4?&&MNfK<*WFJSa41 zv*wG}D9+0X_ipYDb=(-`-d4v$Ii=(-s%0LVeEYIm<`+y1s}ua0H8G}6|OnB%63OAW}TRjFSjoKq=HZJw!yp%5STPRL#njvhd8~r4~;p{g} zD0#U2_&wUh`+2!^_Uir4cH^6@YwSXGxzGB}|1_0F@45eTsk#iBGl7!u5(7UgC8Dx-llDO?#@vvjW_2GbR_nt=vvxEp|p!aX%~gk zE()bx+*h%CzrL|^PV)0ujPu)c8Gq|cx*M(l=h0>=qR%Kn}cgKd^^EJ7*#kQY9@x6_n z`vKb~=C*IT;&%KPtFzz$AF7A^0n?9ucZjXD(q)VT&5x3v2 zu`<>rk1qUy%07JFTP4 z#hH(pvb)~N`Ke7Zhv<1Z)_TbN%_rzx)nbWq9?U-5d`GZHy^BvfGN_(qaG`S&)? zeVvhba>k^0&+Sd}%Gt=4^AKCbHV-86Lu_EvCu&K2`nySd=AV-I_qBG%>ky4E8J84F zpYwW0HsaT96z@NYWB0gT`Chy~cR$yC29N95op8gmazN0nQ!qo36D>X^O&GA<+=DgGel_=m-#^Jp44Zj?OO_^Zz+^Ditfvr zL!qo46w3UjQ06Ixa-QPzWNgyQi}rLo{r0v+&cK&ELrs>(qubOsD{hJAA z?Ot==edhYXlO}wa{xcM}_uwx`C?;;K$Mx$Tt4ZDI*^ae$<$Lk@l%DJ8SGO*@{qozU zZt)r(uf=XZJa6ucr=82L?&YPrRy8V?bvngpmZ6poK9`%*Wd9OWi|btZb!PDu6U2Sr1OZOJ=>+zSN;C9JAGfe z-x6Yr^nD&jeZEoUd~ECL;ygF_w+9}#FPm`H=aqQutTZ2b-Q%&q-^g@N)(8q^Oj9Uh znnD@V6v`Swp^Ry+dt4^hxBZNh%vJlnBi8A@>Cp#Wd3wwn$;0y@_D;XEU;Yo1PHRD1 zUr@U{`@%Wdy)*Wbb55rljTJfD*>>A+prjq0b?p4@g2z(t-(})&LeqbgZ`Es3+<#P8 z=|2i(y-D|NuX|KR*IE?!N4g!hZ=~KFU+K9k^rQWLkuz+3E}r(xJLBKu;`6vWd+sv# z?O9T(k9d8z{Ud$q;;}Kcz1JMEY4VKNTfcPNe!C>|tyiCrzx0Wn8}9o*UQ=j1$(q9F z2L9cWL;Jg>e6!HCj9dDBQ^qOJ+xS_!C(qJa-u5hA%d;HvHyDNTZ2J7byl!w;xV+=rA$)~aEc-RpRv$${i8nk(BqxTv2!n; z-%70|BmSnKK9KJg?hF2wpisV3DD0TqTE2%U{Q!TXP$=I)H&UF(#}9gzOS|+M*HoUg zfySkbBMPPO_&3M+Ua#lk`H>4D_G;ZA99KUC~ErUWSV}#0}_qcrI8ULo8-uK;a zUFp2!9FJc+FO#wMCcT&DL%-j_?3pncOL6^rjhpx$wMTp?l)BsXRLZt-X?J>kUTvJm z44)A`X~#0vL(akEF7t)bWxh}-dmx1}KPZ&>L7}wilO3LEFN({V(XL+--(>RloEMaT z#r9mG&C+LF7LDQfw*+YmwN2VW;T6yH@v~#rA!DE2XP?bk2f7vqx-Sm%R4%=LYPSie z@0Tz+3-qYF^dpaXdd~J~a>njw5swXe#_ls_Y}kHJdplzqm#bYnr5^NdcP`>_&DZ94 zqGavt{C#d+QbxQU$Ipm8jjOhGm#^(R+Rmc!ezTf!oIZ!9^Y^fpKH_~U?Mi*!v6i~u zG3|Wo_nUpPPW9@CxR0of(nl1!`TJ3xSIADrJ^jWkbD7o+8UJ)GeL$g%e+tE%LK(vp ziqCDv$9+?#t*#XBG+)UezSqkxE{Eqa-Ip;u=hmpC|I+_`DqS|mx6;#B-=e9oz1w%TC8TpNoCcd3wa% zUPfb2#(4LCQ)ydkq%LWvUSpTaPLGZB9@({S+kWU;595AVsqgvOIA5Q7xcX9^WX z%+hgszvQ8_h1^f~Gqt{3u@u-E+Q zjmhk?w$;t0c0Dj!&SWx^6Dn0^5?{zKwY~fZ{Y8gVmi`8}K61qT9oZv~(_c)6Ra5+9 zL8U-{al~)CNLrh?L zI=PbjtD0(x>S_nZ!lMsAazN_I?_ZG1?)tg1=jL2g;H1Q^{OK8(ynB@syT=$AotP-* zr~J~)j6dn+r!tdyZ#F+u$Yy9BWJ;M?JFo;$YLoz`NVw+x?UK2&@aZRh>cFFqCKa~{ zUCm4c+QzIC>UzMqOv`ijUq*eJ|Gtr*=#x2{o*yze+RFM+SgwNU-gIwD#73uPCo|L2 z*-|hYOk|4LQm!|JaQnHa+K??h9-=5fwF_DeWB(` z+xxxNE_tRmO{zgbwv?Zko%E-sgIso&R@CW<$=qzIFjJh&<}yLHt7n{wS&yf3Q<-d` z;AgUVe`10*z!@)?p33DXrgKwMKK%(k*YffBpFnq%?h-y9^DOh<149mYCK$V<#Ww$tF3cP2u8EnT#=4%6G0(6 zH90ez@e9+XLe?)%6@uB^L?&Yozp_l4b8zqeHUq;P;jBn|8(ozWk`Cka5+bkYKbUQ4 z9S1aN*41jUF-ngAw&Qvo|D`s`^jM);xwh#eSKXY+$Tcr^-Ii)KYs%yOjZ9fG;Z4US zg{Q8&i|1F%r-a)Y<*Ii^d1o8Bt6A3rrhm<1B~592u170Jixb7!ATu>FRVbEHE0Uh^@{0bWS#F!dTWYnG*I%u+o9UIbU9MMXd!o?M(dlL- + +Search + + + + +

+
    +
  • Main Page
  • +
  • Related Pages
  • +
  • Classes
  • +
  • Files
  • +
  • +
    + + + + +1 document matching your query."; + } + else // $num>1 + { + return "Found $num documents matching your query. Showing best matches first."; + } +} + +function report_matches() +{ + return "Matches: "; +} +function end_form($value) +{ + echo " \n \n
    \n
    \n
  • \n
\n
\n"; +} + +function readInt($file) +{ + $b1 = ord(fgetc($file)); $b2 = ord(fgetc($file)); + $b3 = ord(fgetc($file)); $b4 = ord(fgetc($file)); + return ($b1<<24)|($b2<<16)|($b3<<8)|$b4; +} + +function readString($file) +{ + $result=""; + while (ord($c=fgetc($file))) $result.=$c; + return $result; +} + +function readHeader($file) +{ + $header =fgetc($file); $header.=fgetc($file); + $header.=fgetc($file); $header.=fgetc($file); + return $header; +} + +function computeIndex($word) +{ + // Fast string hashing + //$lword = strtolower($word); + //$l = strlen($lword); + //for ($i=0;$i<$l;$i++) + //{ + // $c = ord($lword{$i}); + // $v = (($v & 0xfc00) ^ ($v << 6) ^ $c) & 0xffff; + //} + //return $v; + + // Simple hashing that allows for substring search + if (strlen($word)<2) return -1; + // high char of the index + $hi = ord($word{0}); + if ($hi==0) return -1; + // low char of the index + $lo = ord($word{1}); + if ($lo==0) return -1; + // return index + return $hi*256+$lo; +} + +function search($file,$word,&$statsList) +{ + $index = computeIndex($word); + if ($index!=-1) // found a valid index + { + fseek($file,$index*4+4); // 4 bytes per entry, skip header + $index = readInt($file); + if ($index) // found words matching the hash key + { + $start=sizeof($statsList); + $count=$start; + fseek($file,$index); + $w = readString($file); + while ($w) + { + $statIdx = readInt($file); + if ($word==substr($w,0,strlen($word))) + { // found word that matches (as substring) + $statsList[$count++]=array( + "word"=>$word, + "match"=>$w, + "index"=>$statIdx, + "full"=>strlen($w)==strlen($word), + "docs"=>array() + ); + } + $w = readString($file); + } + $totalHi=0; + $totalFreqHi=0; + $totalFreqLo=0; + for ($count=$start;$count $idx, + "freq" => $freq>>1, + "rank" => 0.0, + "hi" => $freq&1 + ); + if ($freq&1) // word occurs in high priority doc + { + $totalHi++; + $totalFreqHi+=$freq*$multiplier; + } + else // word occurs in low priority doc + { + $totalFreqLo+=$freq*$multiplier; + } + } + // read name and url info for the doc + for ($i=0;$i<$numDocs;$i++) + { + fseek($file,$docInfo[$i]["idx"]); + $docInfo[$i]["name"]=readString($file); + $docInfo[$i]["url"]=readString($file); + } + $statInfo["docs"]=$docInfo; + } + $totalFreq=($totalHi+1)*$totalFreqLo + $totalFreqHi; + for ($count=$start;$count$key, + "name"=>$di["name"], + "rank"=>$rank + ); + } + $docs[$key]["words"][] = array( + "word"=>$wordInfo["word"], + "match"=>$wordInfo["match"], + "freq"=>$di["freq"] + ); + } + } + return $docs; +} + +function filter_results($docs,&$requiredWords,&$forbiddenWords) +{ + $filteredDocs=array(); + while (list ($key, $val) = each ($docs)) + { + $words = &$docs[$key]["words"]; + $copy=1; // copy entry by default + if (sizeof($requiredWords)>0) + { + foreach ($requiredWords as $reqWord) + { + $found=0; + foreach ($words as $wordInfo) + { + $found = $wordInfo["word"]==$reqWord; + if ($found) break; + } + if (!$found) + { + $copy=0; // document contains none of the required words + break; + } + } + } + if (sizeof($forbiddenWords)>0) + { + foreach ($words as $wordInfo) + { + if (in_array($wordInfo["word"],$forbiddenWords)) + { + $copy=0; // document contains a forbidden word + break; + } + } + } + if ($copy) $filteredDocs[$key]=$docs[$key]; + } + return $filteredDocs; +} + +function compare_rank($a,$b) +{ + if ($a["rank"] == $b["rank"]) + { + return 0; + } + return ($a["rank"]>$b["rank"]) ? -1 : 1; +} + +function sort_results($docs,&$sorted) +{ + $sorted = $docs; + usort($sorted,"compare_rank"); + return $sorted; +} + +function report_results(&$docs) +{ + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + $numDocs = sizeof($docs); + if ($numDocs==0) + { + echo " \n"; + echo " \n"; + echo " \n"; + } + else + { + echo " \n"; + echo " \n"; + echo " \n"; + $num=1; + foreach ($docs as $doc) + { + echo " \n"; + echo " "; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + $num++; + } + } + echo "

".search_results()."

".matches_text(0)."
".matches_text($numDocs); + echo "\n"; + echo "
$num.".$doc["name"]."
".report_matches()." "; + foreach ($doc["words"] as $wordInfo) + { + $word = $wordInfo["word"]; + $matchRight = substr($wordInfo["match"],strlen($word)); + echo "$word$matchRight(".$wordInfo["freq"].") "; + } + echo "
\n"; +} + +function main() +{ + if(strcmp('4.1.0', phpversion()) > 0) + { + die("Error: PHP version 4.1.0 or above required!"); + } + if (!($file=fopen("search.idx","rb"))) + { + die("Error: Search index file could NOT be opened!"); + } + if (readHeader($file)!="DOXS") + { + die("Error: Header of index file is invalid!"); + } + $query=""; + if (array_key_exists("query", $_GET)) + { + $query=$_GET["query"]; + } + end_form(ereg_replace("[^[:alnum:]:\\.\\t ]", " ", $query )); + echo " \n
\n"; + $results = array(); + $requiredWords = array(); + $forbiddenWords = array(); + $foundWords = array(); + $word=strtok($query," "); + while ($word) // for each word in the search query + { + if (($word{0}=='+')) { $word=substr($word,1); $requiredWords[]=$word; } + if (($word{0}=='-')) { $word=substr($word,1); $forbiddenWords[]=$word; } + if (!in_array($word,$foundWords)) + { + $foundWords[]=$word; + search($file,strtolower($word),$results); + } + $word=strtok(" "); + } + $docs = array(); + combine_results($results,$docs); + // filter out documents with forbidden word or that do not contain + // required words + $filteredDocs = filter_results($docs,$requiredWords,$forbiddenWords); + // sort the results based on rank + $sorted = array(); + sort_results($filteredDocs,$sorted); + // report results to the user + report_results($sorted); + echo "
\n"; + fclose($file); +} + +main(); + + +?> +
Generated on Mon Mar 30 14:40:04 2009 for DTLZ by  + +doxygen 1.5.5
+ + diff --git a/problems/DTLZ/doc/html/tab_b.gif b/problems/DTLZ/doc/html/tab_b.gif new file mode 100644 index 0000000000000000000000000000000000000000..0d623483ffdf5f9f96900108042a7ab0643fe2a3 GIT binary patch literal 35 ncmZ?wbhEHbWMp7uXkcJy*>IeJfk6j|fqX^=1|}vKMh0sDa2W*H literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/tab_l.gif b/problems/DTLZ/doc/html/tab_l.gif new file mode 100644 index 0000000000000000000000000000000000000000..9b1e6337c9299a700401a2a78a2c6ffced475216 GIT binary patch literal 706 zcmZ?wbhEHbZT`}F1e&(Gg}Y(8=I;HA5#Z$3JI=gGB)FQ#odI(O&E^@q;x zK6mr*m3xOS-#u~t!I@i+u0DKm^U160k6t`|^WpV}&n+8{U%dD9&a>B#U%!9-@yol< zU%&tQ{rk_K|NsC0`}dE5ET99@1@a36+kb~?0UJ*yc&I3X_m z!ND^5$O7$#8OFRuDhG}!?8z?cdZK&!`PWjdR;Aj^wZ` zeK{IEYHBJ)6K8VIp1`BVt++swf6j+=L{p1*nO(VhE`pFexG@5$|>uaCcd z`0m=9m+yak{QmXN#Sc$^{$X9h9&q2jiKAI|&T)a;PPx2K9p`YIdw8HtR5k2Q$2-O2 z*;3y{MQ-RnJTgJfI&R5|O)AHxDf_00XbPvDZPy4t=hHd)nfLPvms&O`Ok(sD()5v$ z5U@&h;a=#xbxVbo2~X&Xj0Ie(f{v>vERH+qC+nTG=B8Nca=wU-O$?1&vUgV~9=!H; zx>3p9Yn%*<>t~sk+&0xfyS8RsPfYBd<~wWK%j-LmpU>O7yX^h#UCp1x-p#i7@bE;py8XI6 zmY<)m>~)W~yIWcMVoiPg{duuf<*)9qZ9l$m*Ph&W&$jlv*Vpa+{pH@n=IQ$L?0$ax ec60Ul|8o2P|NVbd{6P)#weSbE3}s?04AuZvx_~SI literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/tab_r.gif b/problems/DTLZ/doc/html/tab_r.gif new file mode 100644 index 0000000000000000000000000000000000000000..ce9dd9f533cb5486d6941844f442b59d4a9e9175 GIT binary patch literal 2585 zcmbV}`9Bkk1ILFF--w5zJc=ZZT(zjE=;2|_S)Qm~rCWz1Pc)KPl;jv%A#&v2*x}yc zmf2~Jm~&=xjJY?PqwIN}f8qQ2{r$uH{c*nJbmr{cR5??*egHrs-B=MzCF`3%e{FAW z{oL5xTHn~5TM{jaB;@|_Ue5F&Zb@p(kMyG{*;gWDg zyeL|eZf7Qd8=#bXzSiR{yzRgLSj-fJS8>lBjVHN z^o-0eS=nE6a`W;LChBs=`+QAJP~{b93>H^eRb5kCSC1zUNezun%`L5M?RDzv#%jk7 zYVRX=vATPD`+oEfum^{RM@GjuP?-r=yh0!p;Vx^T9G7~`7%5ydH%70=jyJ;;`d;hv92x3R=z{xp+Lg2!*@OK*K15-t&okoPtSED)h&$RLxdbA zseWm^C3d%-yRNi-ryk^!ek+C`n&~cd$#ZWct_cUL{l~i+Nzx^5d!n94(>bW-iL~Rl z&8r)?q|1DIo=0=judQ{FaGcfLERz8gfn3-Qt<2lksh{mzpT}DXxUuR^z=^key&q4! z+wWI45vL0k$R^(F#{qfqhUsN@WA+w-V?LPH33!Q?WFSB3)WBojE@hK41Nb?KfS+Qo zXgrzfsP$wr4Qzy*{OD>uJBjdgGM@VMml5)2f~_}lD*YyOb}Hjeobhz#4c`w(l^>KK zr?Ud;W~Z}*w;%hZ|2^p^+f06gJDJQD zeIhGADbDmm&6arh(q>EZ<7mjzg7l|z$hRL8=1>)Nv=S7CY$B}iYJ&*T_-T_OG*L1q ztZ3Lana33?y3AKnyq^YCF|4x%Rb5WU&2qcl{TFKey%QJeMxn^SdT!hZ5+0i1zeusiYVp-phBl7b5+Px-X&LhByq z0F&<;K0l2+v>qiHlXb#$jXMv$uK-dEGE9L~qtdU(XeRXmvu*K2Q&6!fD**JxYP4b4BR7FdJ$Qx9G9`J%-_X!a#LGpp3g9)VWytGCa;7`S1_e8F~!R+aSJ zOF17p2`H?2kPs8Q`_;U}+D%3p zs2-0BTqFwpUoBk`?P;iPQ(IbEA|JmMx!P&YYG|R@S=5Mnw;-?A6rEEVyV%d7{iU4a zNk`i!%F(Ykpm`}#oH;BjY->@b8vQedv;pza2FL&*6ufjd+*3Ute&>kes~TU?^KkojsTh(o~(3tk1Y6>4(yn( z#U*ID9@eg-beKo1B;HXe+}{Z%n@7m0+yxivuqk9~;!1LGQlah)xYK4>wgL}l6dsaN zIxlRlq`*`j9PG4*0hD6YV_b_2w5b#)o7J?`q#{GjvvKlD`T*dWcZx<-s(ZvLB44E# z=!|sw!?)@%y$oRNL#25WS3lzdii}TuQ3?CLnvQ1_n};2sT_;Y;#d3=+-(O% zMN$>O!3;ke(UuLR%h_&)N zs^!-@A>QR}4yB1bPp`9S19ikTbZ~O{&FF-yHK{En;mmShDUIEw03`j(DBIsM}Rjki2J#SQa3gFZTKBPDeIiLt9Z z%bL3(B@Qw%(B`wSMS~dPh$=R`(}lBoFXKy(s|*{#ru$wjsBc_O#zxNk9w+UUHmx(U zmJ8+M+ndtnZ<7|VU9Mbt61zpo9T&3%Wx&XII=#QJxjR`CZf22ac3d51Z?GD%LEe_&*t46Qf;4`bZ7p2K(Ab5>GfT^}4! zBT&HZD`^PEgWoI&{~o-ID0F?O`75sm(87x%A{(}Ch1)QlzdJ)1B-eqe5a(weg0`4lQIf1evjvbBY50DVbzO7CLf|vP z2#0(U-|jZ`H{y5N^o7%iK6H>_HEGN->U6^!)1{XpJV!!4(Ig7wzZQ*9WYF4X1rG0x z=1uA@i`rIAciubDC{;~b(|&|A@xkjRP5aRcvRU9tvIm}jDB6J eQ0-6-y)mpwdT=ayS0tBxKDA*~;EWmo literal 0 HcmV?d00001 diff --git a/problems/DTLZ/doc/html/tabs.css b/problems/DTLZ/doc/html/tabs.css new file mode 100644 index 000000000..95f00a91d --- /dev/null +++ b/problems/DTLZ/doc/html/tabs.css @@ -0,0 +1,102 @@ +/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ + +DIV.tabs +{ + float : left; + width : 100%; + background : url("tab_b.gif") repeat-x bottom; + margin-bottom : 4px; +} + +DIV.tabs UL +{ + margin : 0px; + padding-left : 10px; + list-style : none; +} + +DIV.tabs LI, DIV.tabs FORM +{ + display : inline; + margin : 0px; + padding : 0px; +} + +DIV.tabs FORM +{ + float : right; +} + +DIV.tabs A +{ + float : left; + background : url("tab_r.gif") no-repeat right top; + border-bottom : 1px solid #84B0C7; + font-size : x-small; + font-weight : bold; + text-decoration : none; +} + +DIV.tabs A:hover +{ + background-position: 100% -150px; +} + +DIV.tabs A:link, DIV.tabs A:visited, +DIV.tabs A:active, DIV.tabs A:hover +{ + color: #1A419D; +} + +DIV.tabs SPAN +{ + float : left; + display : block; + background : url("tab_l.gif") no-repeat left top; + padding : 5px 9px; + white-space : nowrap; +} + +DIV.tabs INPUT +{ + float : right; + display : inline; + font-size : 1em; +} + +DIV.tabs TD +{ + font-size : x-small; + font-weight : bold; + text-decoration : none; +} + + + +/* Commented Backslash Hack hides rule from IE5-Mac \*/ +DIV.tabs SPAN {float : none;} +/* End IE5-Mac hack */ + +DIV.tabs A:hover SPAN +{ + background-position: 0% -150px; +} + +DIV.tabs LI.current A +{ + background-position: 100% -150px; + border-width : 0px; +} + +DIV.tabs LI.current SPAN +{ + background-position: 0% -150px; + padding-bottom : 6px; +} + +DIV.navpath +{ + background : none; + border : none; + border-bottom : 1px solid #84B0C7; +} diff --git a/problems/DTLZ/doc/index.h b/problems/DTLZ/doc/index.h new file mode 100644 index 000000000..30d2abb71 --- /dev/null +++ b/problems/DTLZ/doc/index.h @@ -0,0 +1,57 @@ +/** @mainpage DTLZ for ParadisEO + +@section Introduction + +This package contains implementation of some DTLZ problems (1, 2, 3, 4, 5, 6, 7) + +@section Authors +Arnaud Liefooghe, Jérémie Humeau + +@section Installation + +The installation procedure of the package is detailed in the "README.txt" file located in the top-directory of the source-tree. + + +@section Design + +For an introduction to the design of ParadisEO, +you can look at the ParadisEO website. + + +@section LICENSE + + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can use, + 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". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + 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 + +*/ + +/** @page webpages Related webpages + +- ParadisEO homepage +- INRIA GForge project page +- Fore any questions, please contact paradiseo-help@lists.gforge.inria.fr +*/ diff --git a/problems/DTLZ/doc/moeo.doxyfile.cmake b/problems/DTLZ/doc/moeo.doxyfile.cmake new file mode 100644 index 000000000..3f56ae1a2 --- /dev/null +++ b/problems/DTLZ/doc/moeo.doxyfile.cmake @@ -0,0 +1,237 @@ +# Doxyfile 1.5.1 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = @PACKAGE_NAME@ +PROJECT_NUMBER = @PACKAGE_VERSION@ +OUTPUT_DIRECTORY = @CMAKE_BINARY_DIR@/doc +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = @CMAKE_SOURCE_DIR@ +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = YES +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_CLASSES = YES +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = NO +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = NO +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = YES +WARNINGS = NO +WARN_IF_UNDOCUMENTED = NO +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = @CMAKE_SOURCE_DIR@ +FILE_PATTERNS = *.cpp \ + *.h \ + NEWS README +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 3 +IGNORE_PREFIX = moeo +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = YES +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = @EO_BIN_DIR@/doc/eo.doxytag=http://eodev.sourceforge.net/eo/doc/html +GENERATE_TAGFILE = @CMAKE_BINARY_DIR@/doc/moeo.doxytag +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = YES diff --git a/problems/DTLZ/install.cmake b/problems/DTLZ/install.cmake new file mode 100644 index 000000000..dc32aaa0d --- /dev/null +++ b/problems/DTLZ/install.cmake @@ -0,0 +1,28 @@ +######################################################################################################### +# 1) ParadisEO install: SIMPLE Configuration +######################################################################################################### + +# Here, just specify PARADISEO_DIR : the directory where ParadisEO has been installed +SET(PARADISEO_DIR "/home/humeau/Bureau/paradiseo-1.3-beta2/" CACHE PATH "ParadisEO directory" FORCE) + +######################################################################################################### + + + +######################################################################################################### +# 2) ParadisEO install: ADVANCED Configuration +######################################################################################################### + +SET(PARADISEO_EO_SRC_DIR "${PARADISEO_DIR}/paradiseo-eo" CACHE PATH "ParadisEO-EO source directory" FORCE) +SET(PARADISEO_EO_BIN_DIR "${PARADISEO_DIR}/paradiseo-eo/build" CACHE PATH "ParadisEO-EO binary directory" FORCE) + +SET(PARADISEO_MO_SRC_DIR "${PARADISEO_DIR}/paradiseo-mo" CACHE PATH "ParadisEO-MO source directory" FORCE) +SET(PARADISEO_MO_BIN_DIR "${PARADISEO_DIR}/paradiseo-mo/build" CACHE PATH "ParadisEO-MO binary directory" FORCE) + +SET(PARADISEO_MOEO_SRC_DIR "${PARADISEO_DIR}/paradiseo-moeo" CACHE PATH "ParadisEO-MOEO source directory" FORCE) +SET(PARADISEO_MOEO_BIN_DIR "${PARADISEO_DIR}/paradiseo-moeo/build" CACHE PATH "ParadisEO-MOEO binary directory" FORCE) + +SET(PARADISEO_PEO_SRC_DIR "${PARADISEO_DIR}/paradiseo-peo" CACHE PATH "ParadisEO-PEO source directory" FORCE) +SET(PARADISEO_PEO_BIN_DIR "${PARADISEO_DIR}/paradiseo-peo/build" CACHE PATH "ParadisEO-PEO binary directory" FORCE) +######################################################################################################### + diff --git a/problems/DTLZ/run.sh b/problems/DTLZ/run.sh new file mode 100644 index 000000000..95f62e10c --- /dev/null +++ b/problems/DTLZ/run.sh @@ -0,0 +1,50 @@ +#population size +POP_SIZE=100 + +#ZDT number (1, 2, 3, 4 or 6) +EVAL=1 + +#vector Size +VEC_SIZE=30 + +#number of objectives +NB_OBJ=3 + +#PROBABIITY FOR SBXCROSSOVER +P_CROSS=1.0 + +#EXTERNAL PROBABILITY FOR POLYNOMIAL MUTATION +EXT_P_MUT=1.0 + +#INTERNAL PROBABILITY FOR POLYNOMIAL MUTATION +INT_P_MUT=0.083333 + +#ARCHIVE SIZE (ONLY FOR SPEA2) +ARC_SIZE=100 + +#K-TH DISTANCE (ONLY FOR SPEA2) +K=10 + +#number of evaluation +NB_EVAL=500 + +#Time +TIME=0 + +#seed +SEED=1 + +DTLZ4=100 + +SPEA2="SPEA2.out" + +IBEA="IBEA.out" + +NSGA="NSGAII.out" + +./build/application/DTLZ_SPEA2 --eval=$i --dtlz4_param=$DTLZ4 --vecSize=$VEC_SIZE --nbObj=$NB_OBJ --pCross=$P_CROSS --extPMut=$EXT_P_MUT --intPMut=$INT_P_MUT --arcSize=$ARC_SIZE --nbEval=$NB_EVAL --time=$TIME --k=$K -o=$SPEA2 + +./build/application/DTLZ_IBEA --eval=$i --dtlz4_param=$DTLZ4 --vecSize=$VEC_SIZE --nbObj=$NB_OBJ --pCross=$P_CROSS --extPMut=$EXT_P_MUT --intPMut=$INT_P_MUT --nbEval=$NB_EVAL --time=$TIME -o=$IBEA + +./build/application/DTLZ_NSGAII --eval=$i --dtlz4_param=$DTLZ4 --vecSize=$VEC_SIZE --nbObj=$NB_OBJ --pCross=$P_CROSS --extPMut=$EXT_P_MUT --intPMut=$INT_P_MUT --nbEval=$NB_EVAL --time=$TIME -o=$NSGA + diff --git a/problems/DTLZ/src/CMakeLists.txt b/problems/DTLZ/src/CMakeLists.txt new file mode 100644 index 000000000..ba815fe04 --- /dev/null +++ b/problems/DTLZ/src/CMakeLists.txt @@ -0,0 +1,33 @@ +###################################################################################### +### 1) Include the sources +###################################################################################### + +INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src) +INCLUDE_DIRECTORIES(${PARADISEO_MOEO_SRC_DIR}/src) +INCLUDE_DIRECTORIES(${PARADISEO_MO_SRC_DIR}/src) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +###################################################################################### + + +###################################################################################### +### 2) Define your target(s): just the flow-shop lib here +###################################################################################### + +SET(DTLZ_LIB_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) +SET(LIBRARY_OUTPUT_PATH ${DTLZ_LIB_OUTPUT_PATH}) + +SET (DTLZ_SOURCES + DTLZ.cpp + DTLZ1Eval.cpp + DTLZ2Eval.cpp + DTLZ3Eval.cpp + DTLZ4Eval.cpp + DTLZ5Eval.cpp + DTLZ6Eval.cpp + DTLZ7Eval.cpp) + +ADD_LIBRARY(lDTLZ STATIC ${DTLZ_SOURCES}) + +###################################################################################### + diff --git a/problems/DTLZ/src/DTLZ.cpp b/problems/DTLZ/src/DTLZ.cpp new file mode 100644 index 000000000..7a2606e51 --- /dev/null +++ b/problems/DTLZ/src/DTLZ.cpp @@ -0,0 +1,44 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include + +std::string DTLZ::className() const +{ + return "DTLZ"; +} diff --git a/problems/DTLZ/src/DTLZ.h b/problems/DTLZ/src/DTLZ.h new file mode 100644 index 000000000..0b20bc7d3 --- /dev/null +++ b/problems/DTLZ/src/DTLZ.h @@ -0,0 +1,58 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 DTLZ_H_ +#define DTLZ_H_ + +#include + +/** + * Structure of the genotype for DTLZ fonctions problem: a vector of double. + */ +class DTLZ : public moeoRealVector < DTLZObjectiveVector, double, double > +{ +public: + + /** + * class name + */ + std::string className() const; + +}; + +#endif /*DTLZ_H_*/ diff --git a/problems/DTLZ/src/DTLZ1Eval.cpp b/problems/DTLZ/src/DTLZ1Eval.cpp new file mode 100644 index 000000000..2edbf2ab8 --- /dev/null +++ b/problems/DTLZ/src/DTLZ1Eval.cpp @@ -0,0 +1,74 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include + +#define M_PI 3.14159265358979323846 +// Ce code est implémenté à partir de DEME:Dtlz1.cpp +void DTLZ1Eval::operator() (DTLZ & _element) +{ + if (_element.invalidObjectiveVector()) + { + int nbFun= DTLZ::ObjectiveVector::nObjectives(); + int nbVar= _element.size(); + int k; + double g; + DTLZObjectiveVector objVec(nbVar); + + k = nbVar - nbFun + 1; + g = 0.0; + for (unsigned i = nbVar - k + 1; i <= nbVar; i++) + g += pow(_element[i-1]-0.5,2) - cos(20 * M_PI * (_element[i-1]-0.5)); + + g = 100 *(k + g); + + for (unsigned i = 1; i <= nbFun; i++) { + double f = 0.5 * (1 + g); + for (unsigned j = nbFun - i; j >= 1; j--) + f *= _element[j-1]; + + if (i > 1) + f *= 1 - _element[(nbFun - i + 1) - 1]; + + objVec[i-1] = f; + } + + _element.objectiveVector(objVec); + } +} + diff --git a/problems/DTLZ/src/DTLZ1Eval.h b/problems/DTLZ/src/DTLZ1Eval.h new file mode 100644 index 000000000..37471612f --- /dev/null +++ b/problems/DTLZ/src/DTLZ1Eval.h @@ -0,0 +1,58 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 DSTLZ1EVAL_H_ +#define DSTLZ1EVAL_H_ + +#include + +/** + * DTLZ1 Evaluation Fonction + */ +class DTLZ1Eval : public moeoEvalFunc +{ +public: + + /** + * operator evaluates a genotype + */ + void operator () (DTLZ & _element); + +}; + +#endif /*DSTLZ1EVAL_H_*/ diff --git a/problems/DTLZ/src/DTLZ2Eval.cpp b/problems/DTLZ/src/DTLZ2Eval.cpp new file mode 100644 index 000000000..e9e8ca29b --- /dev/null +++ b/problems/DTLZ/src/DTLZ2Eval.cpp @@ -0,0 +1,73 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include + +#define M_PI 3.14159265358979323846 + +// Ce code est implémenté à partir de DEME:Dtlz1.cpp +void DTLZ2Eval::operator() (DTLZ & _element) +{ + if (_element.invalidObjectiveVector()) + { + int nbFun= DTLZ::ObjectiveVector::nObjectives(); + int nbVar= _element.size(); + int k; + double g; + DTLZObjectiveVector objVec; + + k = nbVar - nbFun + 1; + g = 0.0; + for (unsigned i = nbVar - k + 1; i <= nbVar; i++) + g += pow(_element[i-1]-0.5,2); + + for (unsigned i = 1; i <= nbFun; i++) { + double f = (1 + g); + for (unsigned j = nbFun - i; j >= 1; j--) + f *= cos(_element[j-1] * M_PI / 2); + + if (i > 1) + f *= sin(_element[(nbFun - i + 1) - 1] * M_PI / 2); + + objVec[i-1] = f; + } + + _element.objectiveVector(objVec); + } +} + diff --git a/problems/DTLZ/src/DTLZ2Eval.h b/problems/DTLZ/src/DTLZ2Eval.h new file mode 100644 index 000000000..806275548 --- /dev/null +++ b/problems/DTLZ/src/DTLZ2Eval.h @@ -0,0 +1,57 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 DTLZ2EVAL_H_ +#define DTLZ2EVAL_H_ + +#include + +/** + * DTLZ2 Evaluation Fonction + */ +class DTLZ2Eval : public moeoEvalFunc +{ +public: + /** + * operator evaluates a genotype + */ + void operator () (DTLZ & _element); + +}; + +#endif /*DTLZ2EVAL_H_*/ diff --git a/problems/DTLZ/src/DTLZ3Eval.cpp b/problems/DTLZ/src/DTLZ3Eval.cpp new file mode 100644 index 000000000..e856be289 --- /dev/null +++ b/problems/DTLZ/src/DTLZ3Eval.cpp @@ -0,0 +1,74 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include + +#define M_PI 3.14159265358979323846 + +// Ce code est implémenté à partir de DEME:Dtlz1.cpp +void DTLZ3Eval::operator() (DTLZ & _element) +{ + if (_element.invalidObjectiveVector()) + { + int nbFun= DTLZ::ObjectiveVector::nObjectives(); + int nbVar= _element.size(); + int k; + double g; + DTLZObjectiveVector objVec; + + k = nbVar - nbFun + 1; + g = 0.0; + for (unsigned i = nbVar - k + 1; i <= nbVar; i++) + g += pow(_element[i-1]-0.5,2) - cos( 20 * M_PI * (_element[i-1] - 0.5) ); + g = 100 * (k + g); + + for (unsigned i = 1; i <= nbFun; i++) { + double f = (1 + g); + for (unsigned j = nbFun - i; j >= 1; j--) + f *= cos(_element[j-1] * M_PI / 2); + + if (i > 1) + f *= sin(_element[(nbFun - i + 1) - 1] * M_PI / 2); + + objVec[i-1] = f; + } + + _element.objectiveVector(objVec); + } +} + diff --git a/problems/DTLZ/src/DTLZ3Eval.h b/problems/DTLZ/src/DTLZ3Eval.h new file mode 100644 index 000000000..3326e9ea8 --- /dev/null +++ b/problems/DTLZ/src/DTLZ3Eval.h @@ -0,0 +1,58 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 DTLZ3EVAL_H_ +#define DTLZ3EVAL_H_ + +#include + +/** + * DTLZ3 Evaluation Fonction + */ +class DTLZ3Eval : public moeoEvalFunc +{ +public: + + /** + * operator evaluates a genotype + */ + void operator () (DTLZ & _element); + +}; + +#endif /*DTLZ3EVAL_H_*/ diff --git a/problems/DTLZ/src/DTLZ4Eval.cpp b/problems/DTLZ/src/DTLZ4Eval.cpp new file mode 100644 index 000000000..36aef11a9 --- /dev/null +++ b/problems/DTLZ/src/DTLZ4Eval.cpp @@ -0,0 +1,75 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include + +#define M_PI 3.14159265358979323846 + +DTLZ4Eval::DTLZ4Eval(double _alpha = 100):alpha(_alpha) {} + +// Ce code est implémenté à partir de DEME:Dtlz1.cpp +void DTLZ4Eval::operator() (DTLZ & _element) +{ + if (_element.invalidObjectiveVector()) + { + int nbFun= DTLZ::ObjectiveVector::nObjectives(); + int nbVar= _element.size(); + int k; + double g; + DTLZObjectiveVector objVec; + + k = nbVar - nbFun + 1; + g = 0.0; + for (unsigned i = nbVar - k + 1; i <= nbVar; i++) + g += pow(_element[i-1]-0.5,2); + + for (unsigned i = 1; i <= nbFun; i++) { + double f = (1 + g); + for (unsigned j = nbFun - i; j >= 1; j--) + f *= cos( pow(_element[j-1], alpha) * M_PI / 2); + + if (i > 1) + f *= sin( pow(_element[(nbFun - i + 1) - 1], alpha) * M_PI / 2); + + objVec[i-1] = f; + } + + _element.objectiveVector(objVec); + } +} + diff --git a/problems/DTLZ/src/DTLZ4Eval.h b/problems/DTLZ/src/DTLZ4Eval.h new file mode 100644 index 000000000..49000f23f --- /dev/null +++ b/problems/DTLZ/src/DTLZ4Eval.h @@ -0,0 +1,68 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 DTLZ4EVAL_H_ +#define DTLZ4EVAL_H_ + +#include + +/** + * DTLZ4 Evaluation Fonction + */ +class DTLZ4Eval : public moeoEvalFunc +{ +public: + /** + * @param _alpha parameter used in DTLZ4 + */ + DTLZ4Eval(double _alpha); + + /** + * operator evaluates a genotype + */ + void operator () (DTLZ & _element); + +private: + /** parameter alpha */ + double alpha; + + +}; + +#endif /*DTLZ4EVAL_H_*/ + diff --git a/problems/DTLZ/src/DTLZ5Eval.cpp b/problems/DTLZ/src/DTLZ5Eval.cpp new file mode 100644 index 000000000..e7a788bb6 --- /dev/null +++ b/problems/DTLZ/src/DTLZ5Eval.cpp @@ -0,0 +1,82 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include + +#define M_PI 3.14159265358979323846 +#define M_PI_2 1.57079632679489661923 + +// Ce code est implémenté à partir de DEME:Dtlz1.cpp +void DTLZ5Eval::operator() (DTLZ & _element) +{ + if (_element.invalidObjectiveVector()) + { + int nbFun= DTLZ::ObjectiveVector::nObjectives(); + int nbVar= _element.size(); + int k; + double g, t; + DTLZObjectiveVector objVec; + + double theta[nbFun-1]; + + k = nbVar - nbFun + 1; + g = 0.0; + for (unsigned i = nbVar - k + 1; i <= nbVar; i++) + g += pow(_element[i-1]-0.5,2); + + t= M_PI /(4 * (1 + g)); + + theta[0]= M_PI_2 * _element[0]; + for (unsigned i = 1; i <= nbFun - 2 ; i++) + theta[i]= t * (1 + 2 * g * _element[i]); + + for (unsigned i = 1; i <= nbFun; i++) { + double f = (1 + g); + for (unsigned j = nbFun - i; j >= 1; j--) + f *= cos(theta[j-1]); + + if (i > 1) + f *= sin(theta[(nbFun - i + 1) - 1]); + + objVec[i-1] = f; + } + + _element.objectiveVector(objVec); + } +} + diff --git a/problems/DTLZ/src/DTLZ5Eval.h b/problems/DTLZ/src/DTLZ5Eval.h new file mode 100644 index 000000000..660e3e155 --- /dev/null +++ b/problems/DTLZ/src/DTLZ5Eval.h @@ -0,0 +1,59 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 DTLZ5EVAL_H_ +#define DTLZ5EVAL_H_ + +#include + +/** + * DTLZ5 Evaluation Fonction + */ +class DTLZ5Eval : public moeoEvalFunc +{ +public: + + /** + * operator evaluates a genotype + */ + void operator () (DTLZ & _element); + +}; + +#endif /*DTLZ5EVAL_H_*/ + diff --git a/problems/DTLZ/src/DTLZ6Eval.cpp b/problems/DTLZ/src/DTLZ6Eval.cpp new file mode 100644 index 000000000..5034d9374 --- /dev/null +++ b/problems/DTLZ/src/DTLZ6Eval.cpp @@ -0,0 +1,81 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include + +#define M_PI 3.14159265358979323846 + +// Ce code est implémenté à partir de DEME:Dtlz1.cpp +void DTLZ6Eval::operator() (DTLZ & _element) +{ + if (_element.invalidObjectiveVector()) + { + int nbFun= DTLZ::ObjectiveVector::nObjectives(); + int nbVar= _element.size(); + int k; + double g, t; + DTLZObjectiveVector objVec; + + double theta[nbFun-1]; + + k = nbVar - nbFun + 1; + g = 0.0; + for (unsigned i = nbVar - k + 1; i <= nbVar; i++) + g += pow(_element[i-1],0.1); + + t= M_PI /(4 * (1 + g)); + + theta[0]= M_PI * _element[0] / 2; + for (unsigned i = 1; i <= nbFun - 2 ; i++) + theta[i]= t * (1 + 2 * g * _element[i]); + + for (unsigned i = 1; i <= nbFun; i++) { + double f = (1 + g); + for (unsigned j = nbFun - i; j >= 1; j--) + f *= cos(theta[j-1]); + + if (i > 1) + f *= sin(theta[(nbFun - i + 1) - 1]); + + objVec[i-1] = f; + } + + _element.objectiveVector(objVec); + } +} + diff --git a/problems/DTLZ/src/DTLZ6Eval.h b/problems/DTLZ/src/DTLZ6Eval.h new file mode 100644 index 000000000..08e893c69 --- /dev/null +++ b/problems/DTLZ/src/DTLZ6Eval.h @@ -0,0 +1,60 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 DTLZ6EVAL_H_ +#define DTLZ6EVAL_H_ + +#include + +/** + * DTLZ6 Evaluation Fonction + */ +class DTLZ6Eval : public moeoEvalFunc +{ +public: + + /** + * operator evaluates a genotype + */ + void operator () (DTLZ & _element); + +}; + +#endif /*DTLZ6EVAL_H_*/ + + diff --git a/problems/DTLZ/src/DTLZ7Eval.cpp b/problems/DTLZ/src/DTLZ7Eval.cpp new file mode 100644 index 000000000..6f683d50b --- /dev/null +++ b/problems/DTLZ/src/DTLZ7Eval.cpp @@ -0,0 +1,74 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include + +#define M_PI 3.14159265358979323846 +// Ce code est implémenté à partir de DEME:Dtlz1.cpp +void DTLZ7Eval::operator() (DTLZ & _element) +{ + if (_element.invalidObjectiveVector()) + { + int nbFun= DTLZ::ObjectiveVector::nObjectives(); + int nbVar= _element.size(); + int k; + double f, g, h; + DTLZObjectiveVector objVec(nbVar); + + k = nbVar - nbFun + 1; + g = 0.0; + h = 0.0; + for (unsigned i = nbVar - k + 1; i <= nbVar; i++) + g += _element[i-1]; + g= 1 + (9 * g ) / k; + + + for (unsigned i = 1; i <= nbFun -1 ; i++) + objVec[i-1]=_element[i-1]; + + for (unsigned i = 1 ; i< nbFun; i++) + h += _element[i-1] / (1 + g) * (1 + sin(3 * M_PI * _element[i-1])); + h = nbFun - h; + + objVec[nbFun -1] = (1 + g) * h; + + + _element.objectiveVector(objVec); + } +} + diff --git a/problems/DTLZ/src/DTLZ7Eval.h b/problems/DTLZ/src/DTLZ7Eval.h new file mode 100644 index 000000000..6437523e1 --- /dev/null +++ b/problems/DTLZ/src/DTLZ7Eval.h @@ -0,0 +1,59 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 DTLZ7EVAL_H_ +#define DTLZ7EVAL_H_ + +#include + +/** + * DTLZ7 Evaluation Fonction + */ +class DTLZ7Eval : public moeoEvalFunc +{ +public: + + /** + * operator evaluates a genotype + */ + void operator () (DTLZ & _element); + +}; + +#endif /*DTLZ7EVAL_H_*/ + diff --git a/problems/DTLZ/src/DTLZObjectiveVector.h b/problems/DTLZ/src/DTLZObjectiveVector.h new file mode 100644 index 000000000..94f9ff1f2 --- /dev/null +++ b/problems/DTLZ/src/DTLZObjectiveVector.h @@ -0,0 +1,47 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 DTLZOBJECTIVEVECTOR_H_ +#define DTLZOBJECTIVEVECTOR_H_ + +#include + +/** define DTLZ Objective vector as a vector of double*/ +typedef moeoRealObjectiveVector DTLZObjectiveVector; + +#endif /*DTLZOBJECTIVEVECTOR_H_*/ diff --git a/problems/DTLZ/src/PolynomialMutation.h b/problems/DTLZ/src/PolynomialMutation.h new file mode 100644 index 000000000..871ed0b0f --- /dev/null +++ b/problems/DTLZ/src/PolynomialMutation.h @@ -0,0 +1,123 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 POLYNOMIALMUTATION_H_ +#define POLYNOMIALMUTATION_H_ + +#include + +template class PolynomialMutation: public eoMonOp +{ +public: + + PolynomialMutation(eoRealVectorBounds & _bounds, const double& _p_mut = 0.5, const double& _eta = 1.0): + p_mut(_p_mut), eta(_eta), bounds(_bounds) {} + + /// The class name. + virtual std::string className() const { + return "PolynomialMutation"; + } + + /** + * Do it! + * @param _eo The indi undergoing the mutation + */ + bool operator()(EOT& _eo) + { + bool hasChanged=false; + double rnd, delta1, delta2, mut_pow, deltaq, delta_max; + double y, yl, yu, val, xy; + + for (unsigned j=0; j<_eo.size(); j++) + { + if (rng.flip(p_mut)) + { + y = _eo[j]; + + yl = bounds.minimum(j); + yu = bounds.maximum(j); + delta1 = (y-yl)/(yu-yl); + delta2 = (yu-y)/(yu-yl); + + + //Ajout + if ( (y-yl) > (yu-y)) + delta_max = delta2; + else + delta_max= delta1; + //fin ajout + + rnd = rng.uniform(); + mut_pow = 1.0/(eta+1.0); + if (rnd <= 0.5) + { + xy = 1.0-delta_max;//delta_max au lieu de delta1 + val = 2.0*rnd+(1.0-2.0*rnd)*(pow(xy,(eta+1.0))); + deltaq = pow(val,mut_pow) - 1.0; + } + else + { + xy = 1.0-delta_max;//delta_max au lieu de delta2 + val = 2.0*(1.0-rnd)+2.0*(rnd-0.5)*(pow(xy,(eta+1.0))); + deltaq = 1.0 - (pow(val,mut_pow)); + } + //ajout + if (deltaq > delta_max) + deltaq = delta_max; + else if (deltaq < -delta_max) + deltaq= -delta_max; + //fin ajout + y = y + deltaq*(yu-yl); + + bounds.truncate(j, y); + _eo[j] = y; + + hasChanged = true; + } + } + + return hasChanged; + } + +private: + double p_mut; + double eta; + eoRealVectorBounds & bounds; +}; + +#endif /*POLYNOMIALMUTATION_H_*/ diff --git a/problems/DTLZ/src/SBXCrossover.h b/problems/DTLZ/src/SBXCrossover.h new file mode 100644 index 000000000..0001818ed --- /dev/null +++ b/problems/DTLZ/src/SBXCrossover.h @@ -0,0 +1,194 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 SBXCROSSOVER_H_ +#define SBXCROSSOVER_H_ + +#include // swap_ranges +#include +#include +#include +#include +#include + +template class SBXCrossover: public eoQuadOp +{ +public: + /**** + * (Default) Constructor. + * The bounds are initialized with the global object that says: no bounds. + * + * + */ + SBXCrossover(const double& _eta = 1.0) : + bounds(eoDummyVectorNoBounds), eta(_eta), range(1) {} + + + ////////////////////////////////////////////// + + /** + * Constructor with bounds + * @param _bounds an eoRealVectorBounds that contains the bounds + * @param _alphaMin the amount of exploration OUTSIDE the parents + * as in BLX-alpha notation (Eshelman and Schaffer) + * 0 == contractive application + * Must be positive + */ + + + + SBXCrossover(eoRealVectorBounds & _bounds, + const double& _eta = 1.0) : + bounds(_bounds), eta(_eta), range(1) {} + + /////////////////////////////////////////////// + + ////////////////////////////////////////////// + + /** + * Constructor from a parser. Will read from the argument parser + * eoRealVectorBounds that contains the bounds + * eta, the SBX parameter + */ + + SBXCrossover(eoParser & _parser) : + // First, decide whether the objective variables are bounded + // Warning, must be the same keywords than other possible objectBounds elsewhere + bounds (_parser.getORcreateParam(eoDummyVectorNoBounds, "objectBounds", "Bounds for variables", 'B', "Variation Operators").value()) , + // then get eta value + eta (_parser.getORcreateParam(1.0, "eta", "SBX eta parameter", '\0', "Variation Operators").value()) , + range(1) {} + +# define EPS 1.0e-14 + + /// The class name. + virtual std::string className() const { + return "SBXCrossover"; + } + + /***************************************** + * SBX crossover - modifies both parents * + * @param _eo1 The first parent * + * @param _eo2 The first parent * + *****************************************/ + bool operator()(EOT& _eo1, EOT& _eo2) + { + unsigned i; + double rand; + double y1, y2, yl, yu; + double c1, c2; + double alpha, beta, betaq; + bool changed = false; + + for (i=0; i<_eo1.size(); i++) + { + if (true) + { + if (fabs(_eo1[i] - _eo2[i]) > EPS) // pour éviter la division par 0 + { + // y2 doit être > à y1 + if (_eo1[i] < _eo2[i]) + { + y1 = _eo1[i]; + y2 = _eo2[i]; + } + else + { + y1 = _eo2[i]; + y2 = _eo1[i]; + } + yl = bounds.minimum(i); + yu = bounds.maximum(i); + + rand = rng.uniform(); + + beta = 1.0 + (2.0 * (y1 - yl) / (y2 - y1)); + alpha = 2.0 - pow( beta, -(eta + 1.0)); + if (rand <= (1.0/alpha)) + { + betaq = pow ( (rand * alpha), (1.0 / (eta + 1.0))); + } + else + { + betaq = pow ( (1.0 / (2.0 - rand * alpha)), (1.0 / (eta+1.0))); + } + c1 = 0.5 * ((y1 + y2) - betaq * (y2 - y1)); + + beta = 1.0 + (2.0 * (yu - y2) / (y2 - y1)); + alpha = 2.0 - pow( beta, -(eta + 1.0)); + if (rand <= (1.0/alpha)) + { + betaq = pow ( (rand * alpha), (1.0 / (eta + 1.0))); + } + else + { + betaq = pow ( (1.0 / (2.0 - rand * alpha)), (1.0 / (eta + 1.0))); + } + c2 = 0.5 * ((y1 + y2) + betaq * (y2 - y1)); + + bounds.truncate(i, c1); + bounds.truncate(i, c2); + + if (rng.flip()) + { + _eo1[i] = c2; + _eo2[i] = c1; + } + else + { + _eo1[i] = c1; + _eo2[i] = c2; + } + + changed = true; + } + } + } + + return changed; + } + + + +protected: + eoRealVectorBounds & bounds; + double eta; + double range; // == 1 +}; + +#endif /*SBXCROSSOVER_H_*/ diff --git a/problems/DTLZ/test/CMakeLists.txt b/problems/DTLZ/test/CMakeLists.txt new file mode 100644 index 000000000..900949952 --- /dev/null +++ b/problems/DTLZ/test/CMakeLists.txt @@ -0,0 +1,62 @@ +############################################################################### +## +## CMakeLists file for DTLZ/test +## +############################################################################### + + +###################################################################################### +### 1) Include the sources +###################################################################################### + +INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src + ${PARADISEO_MO_SRC_DIR}/src + ${PARADISEO_MOEO_SRC_DIR}/src + ${DTLZ_SOURCE_DIR}/src) + +###################################################################################### + + +###################################################################################### +### 2) Specify where CMake can find the libraries +###################################################################################### + +LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib) +LINK_DIRECTORIES(${PARADISEO_MOEO_BIN_DIR}/lib) +LINK_DIRECTORIES(${DTLZ_BINARY_DIR}/lib) +###################################################################################### + + + +###################################################################################### +### 3) Define your targets and link the librairies +###################################################################################### + +SET (TEST_LIST + t-DTLZ + t-DTLZ1Eval + t-DTLZ2Eval + t-DTLZ3Eval + t-DTLZ4Eval + t-DTLZ5Eval + t-DTLZ6Eval + t-DTLZ7Eval +) + +FOREACH (test ${TEST_LIST}) + SET ("T_${test}_SOURCES" "${test}.cpp") +ENDFOREACH (test) + + FOREACH (test ${TEST_LIST}) + ADD_EXECUTABLE(${test} ${T_${test}_SOURCES}) + ADD_TEST(${test} ${test}) + ENDFOREACH (test) + + # Link the librairies + FOREACH (test ${TEST_LIST}) + TARGET_LINK_LIBRARIES(${test} moeo eoutils eo lDTLZ) + ENDFOREACH (test) + + +###################################################################################### + diff --git a/problems/DTLZ/test/t-DTLZ.cpp b/problems/DTLZ/test/t-DTLZ.cpp new file mode 100644 index 000000000..b1d0b61d0 --- /dev/null +++ b/problems/DTLZ/test/t-DTLZ.cpp @@ -0,0 +1,62 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + std::cout << "Run test: t-DTLZ\n"; + + std::vector bObjectives(5); + for(unsigned int i=0; i<3 ; i++) + bObjectives[i]=true; + moeoObjectiveVectorTraits::setup(5,bObjectives); + DTLZ problem; + + assert(DTLZ::ObjectiveVector::nObjectives()==5); + std::cout << "\t> nObjectives OK\n"; + + assert(problem.className()=="DTLZ"); + std::cout << "\t> className OK\n"; + + return EXIT_SUCCESS; +} + diff --git a/problems/DTLZ/test/t-DTLZ1Eval.cpp b/problems/DTLZ/test/t-DTLZ1Eval.cpp new file mode 100644 index 000000000..e600d6204 --- /dev/null +++ b/problems/DTLZ/test/t-DTLZ1Eval.cpp @@ -0,0 +1,130 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + std::vector bObjectives(3); + for(unsigned int i=0; i<3 ; i++) + bObjectives[i]=true; + moeoObjectiveVectorTraits::setup(3,bObjectives); + + std::cout << "Run test: t-DTLZ1EVAL\n"; + DTLZ problem; + + double tolerance=1e-9; + + + //test1 :Verify evaluation of objective vectors with all variables are fixed at 1.0 + std::cout << "\t> test1:\n"; + problem.resize(7); + problem[0]=1; + problem[1]=1; + problem[2]=1; + problem[3]=1; + problem[4]=1; + problem[5]=1; + problem[6]=1; + + DTLZ1Eval eval; + eval(problem); + + double res = problem.objectiveVector()[0]; + assert( (res + tolerance > 63) && (res - tolerance < 63)); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test2 :Verify evaluation of objective vectors with all variables are fixed at 0.0 + std::cout << "\t> test2:\n"; + problem[0]=0; + problem[1]=0; + problem[2]=0; + problem[3]=0; + problem[4]=0; + problem[5]=0; + problem[6]=0; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > 63) && (res - tolerance < 63)); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test3 :Verify evaluation of objective vectors with all variables are fixed at 0.5 + std::cout << "\t> test3:\n"; + problem[0]=0.5; + problem[1]=0.5; + problem[2]=0.5; + problem[3]=0.5; + problem[4]=0.5; + problem[5]=0.5; + problem[6]=0.5; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( res == 0.125); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( res == 0.125); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( res == 0.25); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + return EXIT_SUCCESS; +} + diff --git a/problems/DTLZ/test/t-DTLZ2Eval.cpp b/problems/DTLZ/test/t-DTLZ2Eval.cpp new file mode 100644 index 000000000..03ecaff86 --- /dev/null +++ b/problems/DTLZ/test/t-DTLZ2Eval.cpp @@ -0,0 +1,131 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include +#include +#include +#include +#include + +#define M_PI 3.14159265358979323846 + +int main(int argc, char **argv) +{ + std::vector bObjectives(3); + for(unsigned int i=0; i<3 ; i++) + bObjectives[i]=true; + moeoObjectiveVectorTraits::setup(3,bObjectives); + + std::cout << "Run test: t-DTLZ2EVAL\n"; + DTLZ problem; + + double tolerance=1e-9; + + //test1 :Verify evaluation of objective vectors with all variables are fixed at 1.0 + std::cout << "\t> test1:\n"; + problem.resize(7); + problem[0]=1; + problem[1]=1; + problem[2]=1; + problem[3]=1; + problem[4]=1; + problem[5]=1; + problem[6]=1; + + DTLZ2Eval eval; + eval(problem); + + double res = problem.objectiveVector()[0]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( res == 2.25); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test2 :Verify evaluation of objective vectors with all variables are fixed at 0.0 + std::cout << "\t> test2:\n"; + problem[0]=0; + problem[1]=0; + problem[2]=0; + problem[3]=0; + problem[4]=0; + problem[5]=0; + problem[6]=0; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( res == 2.25); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test3 :Verify evaluation of objective vectors with all variables are fixed at 0.5 + std::cout << "\t> test3:\n"; + problem[0]=0.5; + problem[1]=0.5; + problem[2]=0.5; + problem[3]=0.5; + problem[4]=0.5; + problem[5]=0.5; + problem[6]=0.5; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( res == 0.5); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( res == 0.5); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > sin(M_PI/4)) && (res - tolerance < sin(M_PI/4))); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + return EXIT_SUCCESS; +} + diff --git a/problems/DTLZ/test/t-DTLZ3Eval.cpp b/problems/DTLZ/test/t-DTLZ3Eval.cpp new file mode 100644 index 000000000..36d60eca6 --- /dev/null +++ b/problems/DTLZ/test/t-DTLZ3Eval.cpp @@ -0,0 +1,131 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include +#include +#include +#include +#include + +#define M_PI 3.14159265358979323846 + +int main(int argc, char **argv) +{ + std::vector bObjectives(3); + for(unsigned int i=0; i<3 ; i++) + bObjectives[i]=true; + moeoObjectiveVectorTraits::setup(3,bObjectives); + + std::cout << "Run test: t-DTLZ3EVAL\n"; + DTLZ problem; + + double tolerance=1e-9; + + //test1 :Verify evaluation of objective vectors with all variables are fixed at 1.0 + std::cout << "\t> test1:\n"; + problem.resize(7); + problem[0]=1; + problem[1]=1; + problem[2]=1; + problem[3]=1; + problem[4]=1; + problem[5]=1; + problem[6]=1; + + DTLZ3Eval eval; + eval(problem); + + double res = problem.objectiveVector()[0]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > 126) && (res - tolerance < 126)); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test2 :Verify evaluation of objective vectors with all variables are fixed at 0.0 + std::cout << "\t> test2:\n"; + problem[0]=0; + problem[1]=0; + problem[2]=0; + problem[3]=0; + problem[4]=0; + problem[5]=0; + problem[6]=0; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( (res + tolerance > 126) && (res - tolerance < 126)); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test3 :Verify evaluation of objective vectors with all variables are fixed at 0.5 + std::cout << "\t> test3:\n"; + problem[0]=0.5; + problem[1]=0.5; + problem[2]=0.5; + problem[3]=0.5; + problem[4]=0.5; + problem[5]=0.5; + problem[6]=0.5; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( res == 0.5); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( res == 0.5); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > sin(M_PI/4)) && (res - tolerance < sin(M_PI/4))); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + return EXIT_SUCCESS; +} + diff --git a/problems/DTLZ/test/t-DTLZ4Eval.cpp b/problems/DTLZ/test/t-DTLZ4Eval.cpp new file mode 100644 index 000000000..7eeb9a7f0 --- /dev/null +++ b/problems/DTLZ/test/t-DTLZ4Eval.cpp @@ -0,0 +1,131 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include +#include +#include +#include +#include + +#define M_PI 3.14159265358979323846 + +int main(int argc, char **argv) +{ + std::vector bObjectives(3); + for(unsigned int i=0; i<3 ; i++) + bObjectives[i]=true; + moeoObjectiveVectorTraits::setup(3,bObjectives); + + std::cout << "Run test: t-DTLZ4EVAL\n"; + DTLZ problem; + + double tolerance=1e-9; + + //test1 :Verify evaluation of objective vectors with all variables are fixed at 1.0 + std::cout << "\t> test1:\n"; + problem.resize(7); + problem[0]=1; + problem[1]=1; + problem[2]=1; + problem[3]=1; + problem[4]=1; + problem[5]=1; + problem[6]=1; + + DTLZ4Eval eval(1); + eval(problem); + + double res = problem.objectiveVector()[0]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( res == 2.25); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test2 :Verify evaluation of objective vectors with all variables are fixed at 0.0 + std::cout << "\t> test2:\n"; + problem[0]=0; + problem[1]=0; + problem[2]=0; + problem[3]=0; + problem[4]=0; + problem[5]=0; + problem[6]=0; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( res == 2.25); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test3 :Verify evaluation of objective vectors with all variables are fixed at 0.5 + std::cout << "\t> test3:\n"; + problem[0]=0.5; + problem[1]=0.5; + problem[2]=0.5; + problem[3]=0.5; + problem[4]=0.5; + problem[5]=0.5; + problem[6]=0.5; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( res == 0.5); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( res == 0.5); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > sin(M_PI/4)) && (res - tolerance < sin(M_PI/4))); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + return EXIT_SUCCESS; +} + diff --git a/problems/DTLZ/test/t-DTLZ5Eval.cpp b/problems/DTLZ/test/t-DTLZ5Eval.cpp new file mode 100644 index 000000000..f258242fe --- /dev/null +++ b/problems/DTLZ/test/t-DTLZ5Eval.cpp @@ -0,0 +1,132 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include +#include +#include +#include +#include + +#define M_PI 3.14159265358979323846 + +int main(int argc, char **argv) +{ + std::vector bObjectives(3); + for(unsigned int i=0; i<3 ; i++) + bObjectives[i]=true; + moeoObjectiveVectorTraits::setup(3,bObjectives); + + std::cout << "Run test: t-DTLZ5EVAL\n"; + DTLZ problem; + + double tolerance=1e-9; + + + //test1 :Verify evaluation of objective vectors with all variables are fixed at 1.0 + std::cout << "\t> test1:\n"; + problem.resize(7); + problem[0]=1; + problem[1]=1; + problem[2]=1; + problem[3]=1; + problem[4]=1; + problem[5]=1; + problem[6]=1; + + DTLZ5Eval eval; + eval(problem); + + double res = problem.objectiveVector()[0]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( res == 2.25); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test2 :Verify evaluation of objective vectors with all variables are fixed at 0.0 + std::cout << "\t> test2:\n"; + problem[0]=0; + problem[1]=0; + problem[2]=0; + problem[3]=0; + problem[4]=0; + problem[5]=0; + problem[6]=0; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( (res + tolerance > 2.25 * cos(M_PI / 9)) && (res - tolerance < 2.25 * cos(M_PI / 9))); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 2.25 * sin(M_PI / 9)) && (res - tolerance < 2.25 * sin(M_PI / 9))); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > 0) && (res - tolerance < 0) ); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test3 :Verify evaluation of objective vectors with all variables are fixed at 0.5 + std::cout << "\t> test3:\n"; + problem[0]=0.5; + problem[1]=0.5; + problem[2]=0.5; + problem[3]=0.5; + problem[4]=0.5; + problem[5]=0.5; + problem[6]=0.5; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( res == 0.5); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( res == 0.5); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > sin(M_PI/4)) && (res - tolerance < sin(M_PI/4))); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + return EXIT_SUCCESS; +} + diff --git a/problems/DTLZ/test/t-DTLZ6Eval.cpp b/problems/DTLZ/test/t-DTLZ6Eval.cpp new file mode 100644 index 000000000..86c487909 --- /dev/null +++ b/problems/DTLZ/test/t-DTLZ6Eval.cpp @@ -0,0 +1,133 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include +#include +#include +#include +#include + +#define M_PI 3.14159265358979323846 + +int main(int argc, char **argv) +{ + std::vector bObjectives(3); + for(unsigned int i=0; i<3 ; i++) + bObjectives[i]=true; + moeoObjectiveVectorTraits::setup(3,bObjectives); + + std::cout << "Run test: t-DTLZ6EVAL\n"; + DTLZ problem; + + double tolerance=1e-9; + + //test1 :Verify evaluation of objective vectors with all variables are fixed at 1.0 + std::cout << "\t> test1:\n"; + problem.resize(7); + problem[0]=1; + problem[1]=1; + problem[2]=1; + problem[3]=1; + problem[4]=1; + problem[5]=1; + problem[6]=1; + + DTLZ6Eval eval; + eval(problem); + + double res = problem.objectiveVector()[0]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > 6) && (res - tolerance < 6)); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test2 :Verify evaluation of objective vectors with all variables are fixed at 0.0 + std::cout << "\t> test2:\n"; + problem[0]=0; + problem[1]=0; + problem[2]=0; + problem[3]=0; + problem[4]=0; + problem[5]=0; + problem[6]=0; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( (res + tolerance > sqrt(2)/2) && (res - tolerance < sqrt(2)/2)); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > sqrt(2)/2) && (res - tolerance < sqrt(2)/2)); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > 0) && (res - tolerance < 0)); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test3 :Verify evaluation of objective vectors with all variables are fixed at 0.5 + std::cout << "\t> test3:\n"; + problem[0]=0.5; + problem[1]=0.5; + problem[2]=0.5; + problem[3]=0.5; + problem[4]=0.5; + problem[5]=0.5; + problem[6]=0.5; + + problem.invalidate(); + eval(problem); + + double aux= 5 * pow(0.5,0.1); + + res = problem.objectiveVector()[0]; + assert( (res + tolerance > (1 + aux) / 2) && (res + tolerance > (res + tolerance > (1 + aux) / 2))); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( (res + tolerance > (1 + aux) / 2) && (res + tolerance > (res + tolerance > (1 + aux) / 2))); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( (res + tolerance > (1 + aux) * sqrt(2)/ 2) && (res + tolerance > (res + tolerance > (1 + aux) * sqrt(2)/ 2))); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + return EXIT_SUCCESS; +} + diff --git a/problems/DTLZ/test/t-DTLZ7Eval.cpp b/problems/DTLZ/test/t-DTLZ7Eval.cpp new file mode 100644 index 000000000..394a45f26 --- /dev/null +++ b/problems/DTLZ/test/t-DTLZ7Eval.cpp @@ -0,0 +1,131 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#include +#include +#include +#include +#include + +#define M_PI 3.14159265358979323846 + +int main(int argc, char **argv) +{ + std::vector bObjectives(3); + for(unsigned int i=0; i<3 ; i++) + bObjectives[i]=true; + moeoObjectiveVectorTraits::setup(3,bObjectives); + + std::cout << "Run test: t-DTLZ7EVAL\n"; + DTLZ problem; + + double tolerance=1e-9; + + //test1 :Verify evaluation of objective vectors with all variables are fixed at 1.0 + std::cout << "\t> test1:\n"; + problem.resize(7); + problem[0]=1; + problem[1]=1; + problem[2]=1; + problem[3]=1; + problem[4]=1; + problem[5]=1; + problem[6]=1; + + DTLZ7Eval eval; + eval(problem); + + double res = problem.objectiveVector()[0]; + assert( res == 1); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( res == 1); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( res == 31); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test2 :Verify evaluation of objective vectors with all variables are fixed at 0.0 + std::cout << "\t> test2:\n"; + problem[0]=0; + problem[1]=0; + problem[2]=0; + problem[3]=0; + problem[4]=0; + problem[5]=0; + problem[6]=0; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( res == 0); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( res == 0); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert( res == 6); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + //test3 :Verify evaluation of objective vectors with all variables are fixed at 0.5 + std::cout << "\t> test3:\n"; + problem[0]=0.5; + problem[1]=0.5; + problem[2]=0.5; + problem[3]=0.5; + problem[4]=0.5; + problem[5]=0.5; + problem[6]=0.5; + + problem.invalidate(); + eval(problem); + + res = problem.objectiveVector()[0]; + assert( res == 0.5); + std::cout << "\t\t- objectiveVector[0] OK\n"; + res = problem.objectiveVector()[1]; + assert( res == 0.5); + std::cout << "\t\t- objectiveVector[1] OK\n"; + res = problem.objectiveVector()[2]; + assert(res == 19.5); + std::cout << "\t\t- objectiveVector[2] OK\n"; + + return EXIT_SUCCESS; +} + From 217f11e33eccc471c605d57ae9bb34a0d4102974 Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 25 Sep 2014 17:49:44 +0200 Subject: [PATCH 100/419] * problems/DTLZ/src/: Do not build DTLZObjectiveVector using nbVar. --- problems/DTLZ/src/DTLZ1Eval.cpp | 2 +- problems/DTLZ/src/DTLZ7Eval.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/problems/DTLZ/src/DTLZ1Eval.cpp b/problems/DTLZ/src/DTLZ1Eval.cpp index 2edbf2ab8..9457f0390 100644 --- a/problems/DTLZ/src/DTLZ1Eval.cpp +++ b/problems/DTLZ/src/DTLZ1Eval.cpp @@ -48,7 +48,7 @@ void DTLZ1Eval::operator() (DTLZ & _element) int nbVar= _element.size(); int k; double g; - DTLZObjectiveVector objVec(nbVar); + DTLZObjectiveVector objVec; k = nbVar - nbFun + 1; g = 0.0; diff --git a/problems/DTLZ/src/DTLZ7Eval.cpp b/problems/DTLZ/src/DTLZ7Eval.cpp index 6f683d50b..4106d87ab 100644 --- a/problems/DTLZ/src/DTLZ7Eval.cpp +++ b/problems/DTLZ/src/DTLZ7Eval.cpp @@ -48,7 +48,7 @@ void DTLZ7Eval::operator() (DTLZ & _element) int nbVar= _element.size(); int k; double f, g, h; - DTLZObjectiveVector objVec(nbVar); + DTLZObjectiveVector objVec; k = nbVar - nbFun + 1; g = 0.0; From 749119070c66a0c8937648356cc8c554b0385d50 Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 25 Sep 2014 22:33:26 +0200 Subject: [PATCH 101/419] * Fixes in the build system to be able to build DTLZ from within the GIT repository. It seems the paths have changed since this library was developed. --- problems/DTLZ/CMakeLists.txt | 2 +- problems/DTLZ/application/CMakeLists.txt | 1 + problems/DTLZ/install.cmake | 32 ++++++++++++------------ problems/DTLZ/src/CMakeLists.txt | 3 +-- problems/DTLZ/test/CMakeLists.txt | 1 + 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/problems/DTLZ/CMakeLists.txt b/problems/DTLZ/CMakeLists.txt index d74bba102..30bbb14d3 100644 --- a/problems/DTLZ/CMakeLists.txt +++ b/problems/DTLZ/CMakeLists.txt @@ -94,7 +94,7 @@ IF(CMAKE_BUILD_TYPE MATCHES Debug) ENDIF(CMAKE_BUILD_TYPE MATCHES Debug) ###################################################################################### -### 3) Link the librairies for your executable +### 3) Link the libraries for your executable ###################################################################################### ADD_SUBDIRECTORY(doc) diff --git a/problems/DTLZ/application/CMakeLists.txt b/problems/DTLZ/application/CMakeLists.txt index a3e65fd72..583068779 100644 --- a/problems/DTLZ/application/CMakeLists.txt +++ b/problems/DTLZ/application/CMakeLists.txt @@ -14,6 +14,7 @@ INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src ### 2) Specify where CMake can find the libraries ###################################################################################### +LINK_DIRECTORIES(${PARADISEO_DIR}/build/lib) LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib) LINK_DIRECTORIES(${PARADISEO_MOEO_BIN_DIR}/lib) LINK_DIRECTORIES(${DTLZ_BINARY_DIR}/lib) diff --git a/problems/DTLZ/install.cmake b/problems/DTLZ/install.cmake index dc32aaa0d..bc2f13579 100644 --- a/problems/DTLZ/install.cmake +++ b/problems/DTLZ/install.cmake @@ -1,28 +1,28 @@ -######################################################################################################### +############################################################################### # 1) ParadisEO install: SIMPLE Configuration -######################################################################################################### +############################################################################### -# Here, just specify PARADISEO_DIR : the directory where ParadisEO has been installed -SET(PARADISEO_DIR "/home/humeau/Bureau/paradiseo-1.3-beta2/" CACHE PATH "ParadisEO directory" FORCE) -######################################################################################################### +# Here, just specify PARADISEO_DIR : the directory where ParadisEO has +# been installed +SET(PARADISEO_DIR "${CMAKE_BINARY_DIR}/../../../" CACHE PATH "ParadisEO directory" FORCE) + +############################################################################### -######################################################################################################### +############################################################################### # 2) ParadisEO install: ADVANCED Configuration -######################################################################################################### +############################################################################### -SET(PARADISEO_EO_SRC_DIR "${PARADISEO_DIR}/paradiseo-eo" CACHE PATH "ParadisEO-EO source directory" FORCE) -SET(PARADISEO_EO_BIN_DIR "${PARADISEO_DIR}/paradiseo-eo/build" CACHE PATH "ParadisEO-EO binary directory" FORCE) +SET(PARADISEO_EO_SRC_DIR "${PARADISEO_DIR}/eo" CACHE PATH "ParadisEO-EO source directory" FORCE) +SET(PARADISEO_EO_BIN_DIR "${PARADISEO_DIR}/build/eo" CACHE PATH "ParadisEO-EO binary directory" FORCE) -SET(PARADISEO_MO_SRC_DIR "${PARADISEO_DIR}/paradiseo-mo" CACHE PATH "ParadisEO-MO source directory" FORCE) -SET(PARADISEO_MO_BIN_DIR "${PARADISEO_DIR}/paradiseo-mo/build" CACHE PATH "ParadisEO-MO binary directory" FORCE) +SET(PARADISEO_MO_SRC_DIR "${PARADISEO_DIR}/mo" CACHE PATH "ParadisEO-MO source directory" FORCE) +SET(PARADISEO_MO_BIN_DIR "${PARADISEO_DIR}/build/mo" CACHE PATH "ParadisEO-MO binary directory" FORCE) -SET(PARADISEO_MOEO_SRC_DIR "${PARADISEO_DIR}/paradiseo-moeo" CACHE PATH "ParadisEO-MOEO source directory" FORCE) -SET(PARADISEO_MOEO_BIN_DIR "${PARADISEO_DIR}/paradiseo-moeo/build" CACHE PATH "ParadisEO-MOEO binary directory" FORCE) +SET(PARADISEO_MOEO_SRC_DIR "${PARADISEO_DIR}/moeo" CACHE PATH "ParadisEO-MOEO source directory" FORCE) +SET(PARADISEO_MOEO_BIN_DIR "${PARADISEO_DIR}/build/moeo" CACHE PATH "ParadisEO-MOEO binary directory" FORCE) -SET(PARADISEO_PEO_SRC_DIR "${PARADISEO_DIR}/paradiseo-peo" CACHE PATH "ParadisEO-PEO source directory" FORCE) -SET(PARADISEO_PEO_BIN_DIR "${PARADISEO_DIR}/paradiseo-peo/build" CACHE PATH "ParadisEO-PEO binary directory" FORCE) -######################################################################################################### +############################################################################### diff --git a/problems/DTLZ/src/CMakeLists.txt b/problems/DTLZ/src/CMakeLists.txt index ba815fe04..5075f296a 100644 --- a/problems/DTLZ/src/CMakeLists.txt +++ b/problems/DTLZ/src/CMakeLists.txt @@ -9,9 +9,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) ###################################################################################### - ###################################################################################### -### 2) Define your target(s): just the flow-shop lib here +### 2) Define your target(s) ###################################################################################### SET(DTLZ_LIB_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib) diff --git a/problems/DTLZ/test/CMakeLists.txt b/problems/DTLZ/test/CMakeLists.txt index 900949952..43e552333 100644 --- a/problems/DTLZ/test/CMakeLists.txt +++ b/problems/DTLZ/test/CMakeLists.txt @@ -21,6 +21,7 @@ INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src ### 2) Specify where CMake can find the libraries ###################################################################################### +LINK_DIRECTORIES(${PARADISEO_DIR}/build/lib) LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib) LINK_DIRECTORIES(${PARADISEO_MOEO_BIN_DIR}/lib) LINK_DIRECTORIES(${DTLZ_BINARY_DIR}/lib) From 5f9689fc2376603e6505c5ec2ac7d0b0dc81a576 Mon Sep 17 00:00:00 2001 From: Arnaud Liefooghe Date: Mon, 6 Oct 2014 14:51:37 +0200 Subject: [PATCH 102/419] hypervolume pointers + doc --- eo/src/es/eoNormalMutation.h | 2 +- eo/test/t-eoParallel.cpp | 2 ++ mo/src/problems/permutation/moTwoOptExNeighbor.h | 2 +- moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h | 4 ++-- moeo/src/metric/moeoHyperVolumeMetric.h | 4 ++-- moeo/src/moeo | 2 +- moeo/src/selection/moeoRouletteSelect.h | 2 +- moeo/test/t-moeo2DMinHypervolumeArchive.cpp | 2 ++ 8 files changed, 12 insertions(+), 8 deletions(-) diff --git a/eo/src/es/eoNormalMutation.h b/eo/src/es/eoNormalMutation.h index 96dcf54c2..fd3916c22 100644 --- a/eo/src/es/eoNormalMutation.h +++ b/eo/src/es/eoNormalMutation.h @@ -138,7 +138,7 @@ public: * @param _p_change the probability to change a given coordinate */ eoNormalMutation(eoRealVectorBounds & _bounds, - double _sigma, const double& _p_change = 1.0): + double & _sigma, const double& _p_change = 1.0): sigma(_sigma), bounds(_bounds), p_change(_p_change) {} /** The class name */ diff --git a/eo/test/t-eoParallel.cpp b/eo/test/t-eoParallel.cpp index ef03f0c30..1609c9924 100644 --- a/eo/test/t-eoParallel.cpp +++ b/eo/test/t-eoParallel.cpp @@ -2,7 +2,9 @@ // t-eoParallel.cpp //----------------------------------------------------------------------------- +#ifdef ENABLE_OPENMP #include +#endif #include #include diff --git a/mo/src/problems/permutation/moTwoOptExNeighbor.h b/mo/src/problems/permutation/moTwoOptExNeighbor.h index ed7198574..ae82fd45d 100755 --- a/mo/src/problems/permutation/moTwoOptExNeighbor.h +++ b/mo/src/problems/permutation/moTwoOptExNeighbor.h @@ -86,7 +86,7 @@ public: virtual bool equals(moTwoOptExNeighbor & _neighbor) { unsigned f, s; _neighbor.getIndices(f, s); - return ((indices.first == f) && (indices.second == s) || (indices.first == s) && (indices.second == f)); + return (((indices.first == f) && (indices.second == s)) || ((indices.first == s) && (indices.second == f))); } /** diff --git a/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h b/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h index 6aad16fe2..c781b9a92 100644 --- a/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h +++ b/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h @@ -211,7 +211,7 @@ private: std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp); - // + /* std::cout << std::endl << "sorted pop" << std::endl; std::cout << "====================" << std::endl; for(unsigned int i=0; i<_pop.size(); i++) @@ -219,7 +219,7 @@ private: std::cout << i << " : " << (*sortedptrpop[i]) << std::endl; } std::cout << "====================" << std::endl; - // + */ // compute an upper bound on the second objective (1) double max_obj1 = std::numeric_limits::min(); diff --git a/moeo/src/metric/moeoHyperVolumeMetric.h b/moeo/src/metric/moeoHyperVolumeMetric.h index 99f132131..b79dbc558 100644 --- a/moeo/src/metric/moeoHyperVolumeMetric.h +++ b/moeo/src/metric/moeoHyperVolumeMetric.h @@ -42,8 +42,8 @@ #include /** - * The contribution metric evaluates the proportion of non-dominated solutions given by a Pareto set relatively to another Pareto set - * (Meunier, Talbi, Reininger: 'A multiobjective genetic algorithm for radio network optimization', in Proc. of the 2000 Congress on Evolutionary Computation, IEEE Press, pp. 317-324) + * The hypervolume metric evaluates the multi-dimensional area (hypervolume) enclosed by set of objective vectors and a reference point + * (E. Zitzler and L. Thiele. Multiobjective evolutionary algorithms: A comparative case study and the strength pareto approach. IEEE Transactions on Evolutionary Computation, 3(4):257–271, 1999) */ template < class ObjectiveVector > class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , double > diff --git a/moeo/src/moeo b/moeo/src/moeo index 3b310d64f..4a7908913 100644 --- a/moeo/src/moeo +++ b/moeo/src/moeo @@ -57,7 +57,7 @@ #include #include -#include +//#include #include #include #include diff --git a/moeo/src/selection/moeoRouletteSelect.h b/moeo/src/selection/moeoRouletteSelect.h index fb34259e7..3a293b151 100644 --- a/moeo/src/selection/moeoRouletteSelect.h +++ b/moeo/src/selection/moeoRouletteSelect.h @@ -80,7 +80,7 @@ class moeoRouletteSelect:public moeoSelectOne < MOEOT > protected: /** size */ - unsigned int & tSize; + unsigned int tSize; }; diff --git a/moeo/test/t-moeo2DMinHypervolumeArchive.cpp b/moeo/test/t-moeo2DMinHypervolumeArchive.cpp index f90b9940b..994a9a4ea 100644 --- a/moeo/test/t-moeo2DMinHypervolumeArchive.cpp +++ b/moeo/test/t-moeo2DMinHypervolumeArchive.cpp @@ -41,6 +41,8 @@ #include #include +#include + //----------------------------------------------------------------------------- class ObjectiveVectorTraits : public moeoObjectiveVectorTraits From 54a229dfde7b667a97fe788a7d2285b1f6ab5f6c Mon Sep 17 00:00:00 2001 From: Arnaud Liefooghe Date: Mon, 6 Oct 2014 15:15:40 +0200 Subject: [PATCH 103/419] bug IBEA-hypervolume corrected --- moeo/src/metric/moeoHypervolumeBinaryMetric.h | 9 +- moeo/test/CMakeLists.txt | 1 + moeo/test/t-moeoHypervolumeBinaryMetric.cpp | 104 ++++++++++++++++++ 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 moeo/test/t-moeoHypervolumeBinaryMetric.cpp diff --git a/moeo/src/metric/moeoHypervolumeBinaryMetric.h b/moeo/src/metric/moeoHypervolumeBinaryMetric.h index bd6b1e606..af7fafcd8 100644 --- a/moeo/src/metric/moeoHypervolumeBinaryMetric.h +++ b/moeo/src/metric/moeoHypervolumeBinaryMetric.h @@ -3,7 +3,8 @@ * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 * (C) OPAC Team, LIFL, 2002-2007 * -* Arnaud Liefooghe +* July 2013: Bug fix in the recursive call of hypervolume (corrected thanks to Yann Semet and Dimo Brockhoff) +* * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -46,9 +47,13 @@ * Hypervolume binary metric allowing to compare two objective vectors as proposed in * Zitzler E., Künzli S.: Indicator-Based Selection in Multiobjective Search. In Parallel Problem Solving from Nature (PPSN VIII). * Lecture Notes in Computer Science 3242, Springer, Birmingham, UK pp.832–842 (2004). + * * This indicator is based on the hypervolume concept introduced in * Zitzler, E., Thiele, L.: Multiobjective Optimization Using Evolutionary Algorithms - A Comparative Case Study. * Parallel Problem Solving from Nature (PPSN-V), pp.292-301 (1998). + * + * This code is adapted from the PISA implementation of IBEA (http://www.tik.ee.ethz.ch/sop/pisa/) + * */ template < class ObjectiveVector > class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > @@ -155,7 +160,7 @@ class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinar } else { - result = hypervolume(_o1, _o2, _obj-1) * (max - v2) / range; + result = hypervolume(_o1, _o2, _obj-1) * (max - v1) / range; } } return result; diff --git a/moeo/test/CMakeLists.txt b/moeo/test/CMakeLists.txt index 49130ea3e..ce5b932e0 100644 --- a/moeo/test/CMakeLists.txt +++ b/moeo/test/CMakeLists.txt @@ -44,6 +44,7 @@ set(TEST_LIST t-moeoDominanceMatrix t-moeoVecVsVecAdditiveEpsilonBinaryMetric t-moeoVecVsVecMultiplicativeEpsilonBinaryMetric + t-moeoHypervolumeBinaryMetric t-moeoHyperVolumeMetric t-moeoHyperVolumeDifferenceMetric t-moeoIntVector diff --git a/moeo/test/t-moeoHypervolumeBinaryMetric.cpp b/moeo/test/t-moeoHypervolumeBinaryMetric.cpp new file mode 100644 index 000000000..083804537 --- /dev/null +++ b/moeo/test/t-moeoHypervolumeBinaryMetric.cpp @@ -0,0 +1,104 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2014 +* +* Suggested by Yann Semet +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// t-moeoHypervolumeBinaryMetric.cpp +//----------------------------------------------------------------------------- + +#include +#include + +//----------------------------------------------------------------------------- + +class ObjectiveVectorTraits : public moeoObjectiveVectorTraits +{ +public: + static bool minimizing (int i) + { + return true; + } + static bool maximizing (int i) + { + return false; + } + static unsigned int nObjectives () + { + return 2; + } +}; + +typedef moeoRealObjectiveVector < ObjectiveVectorTraits > ObjectiveVector; + +typedef MOEO < ObjectiveVector > Solution; + +//----------------------------------------------------------------------------- + +int main() +{ + std::cout << "[moeoHypervolumeBinaryMetric]\t=>\t"; + + // objective vectors + ObjectiveVector obj1; + obj1[0] = 133.0; + obj1[1] = 240.0; + ObjectiveVector obj2; + obj2[0] = 122.0; + obj2[1] = 290.0; + ObjectiveVector obj3; + obj3[0] = 145.0; + obj3[1] = 240.0; + + // indicator + moeoHypervolumeBinaryMetric indicator(1.1); + indicator.setup(122.0, 145.0, 0); + indicator.setup(240.0, 290.0, 1); + + + if ( (indicator(obj1, obj2) < 0.039525) || (indicator(obj1, obj2) > 0.039526)) + { + std::cout << "ERROR (indicator-value I(obj1,obj2))" << std::endl; + return EXIT_FAILURE; + } + + if ( (indicator(obj2, obj1) < 0.51383) || (indicator(obj2, obj1) > 0.51384)) + { + std::cout << "ERROR (indicator-value I(obj1,obj2))" << std::endl; + return EXIT_FAILURE; + } + + std::cout << "OK" << std::endl; + return EXIT_SUCCESS; +} + +//----------------------------------------------------------------------------- From c5e5af64d08e4d6ff5e1c7b4a91398a7d2d59642 Mon Sep 17 00:00:00 2001 From: Arnaud Liefooghe Date: Fri, 17 Oct 2014 15:04:32 +0200 Subject: [PATCH 104/419] some cleanup of memory consumption when using IBEA with a large population --- ...ExpBinaryIndicatorBasedFitnessAssignment.h | 250 ++++++++++-------- 1 file changed, 137 insertions(+), 113 deletions(-) diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h index fdc2f9240..41a3abd47 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedFitnessAssignment.h @@ -1,38 +1,43 @@ /* -* -* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 -* -* Arnaud Liefooghe -* -* This software is governed by the CeCILL license under French law and -* abiding by the rules of distribution of free software. You can use, -* 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". -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited liability. -* -* 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 -* -*/ + * + * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2014 + * (C) OPAC Team, LIFL, 2002-2014 + * + * Arnaud Liefooghe + * + * Oct 17, 2014 - Arnaud Liefooghe + * Modifications on the handling of the internal data structure (values) + * in order to avoid (too much/bad) memory consumptions, in particular + * when a very large population size is used + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * 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". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited liability. + * + * 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 MOEOEXPBINARYINDICATORBASEDFITNESSASSIGNMENT_H_ @@ -52,38 +57,49 @@ */ template < class MOEOT > class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorBasedFitnessAssignment < MOEOT > - { - public: - +{ +public: + /** The type of objective vector */ typedef typename MOEOT::ObjectiveVector ObjectiveVector; typedef typename ObjectiveVector::Type Type; typedef typename MOEOT::Fitness Fitness; - + + /** * Ctor. * @param _metric the quality indicator * @param _kappa the scaling factor */ - moeoExpBinaryIndicatorBasedFitnessAssignment(moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa = 0.05) : metric(_metric), kappa(_kappa) - {} - - + moeoExpBinaryIndicatorBasedFitnessAssignment(moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric, const double _kappa = 0.05) : metric(_metric), kappa(_kappa), values(0) {} + + + /** + * Dtor. + */ + ~moeoExpBinaryIndicatorBasedFitnessAssignment() + { + // clear "values" + for (unsigned int i=0; i & _pop) { - // 1 - setting of the bounds - setup(_pop); - // 2 - computing every indicator values - computeValues(_pop); - // 3 - setting fitnesses - setFitnesses(_pop); + // 1 - setting of the bounds + setup(_pop); + // 2 - computing every indicator values + computeValues(_pop); + // 3 - setting fitnesses + setFitnesses(_pop); } - - + + /** * Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account. * @param _pop the population @@ -91,19 +107,20 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB */ void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) { - std::vector < double > v; - v.resize(_pop.size()); - for (unsigned int i=0; i<_pop.size(); i++) + std::vector < double > v; + v.resize(_pop.size()); + for (unsigned int i=0; i<_pop.size(); i++) { - v[i] = metric(_objVec, _pop[i].objectiveVector()); + v[i] = metric(_objVec, _pop[i].objectiveVector()); } - for (unsigned int i=0; i<_pop.size(); i++) + for (unsigned int i=0; i<_pop.size(); i++) { - _pop[i].fitness( _pop[i].fitness() + exp(-v[i]/kappa) ); + _pop[i].fitness( _pop[i].fitness() + exp(-v[i]/kappa) ); } + v.clear(); } - - + + /** * Updates the fitness values of the whole population _pop by taking the adding of the objective vector _objVec into account * and returns the fitness value of _objVec. @@ -112,118 +129,125 @@ class moeoExpBinaryIndicatorBasedFitnessAssignment : public moeoBinaryIndicatorB */ double updateByAdding(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) { - std::vector < double > v; - // update every fitness values to take the new individual into account - v.resize(_pop.size()); - for (unsigned int i=0; i<_pop.size(); i++) + std::vector < double > v; + // update every fitness values to take the new individual into account + v.resize(_pop.size()); + for (unsigned int i=0; i<_pop.size(); i++) { - v[i] = metric(_objVec, _pop[i].objectiveVector()); + v[i] = metric(_objVec, _pop[i].objectiveVector()); } - for (unsigned int i=0; i<_pop.size(); i++) + for (unsigned int i=0; i<_pop.size(); i++) { - _pop[i].fitness( _pop[i].fitness() - exp(-v[i]/kappa) ); + _pop[i].fitness( _pop[i].fitness() - exp(-v[i]/kappa) ); } - // compute the fitness of the new individual - v.clear(); - v.resize(_pop.size()); - for (unsigned int i=0; i<_pop.size(); i++) + // compute the fitness of the new individual + for (unsigned int i=0; i<_pop.size(); i++) { - v[i] = metric(_pop[i].objectiveVector(), _objVec); + v[i] = metric(_pop[i].objectiveVector(), _objVec); } - double result = 0; - for (unsigned int i=0; i & metric; /** the scaling factor */ double kappa; /** the computed indicator values */ std::vector < std::vector > values; - - + + /** * Sets the bounds for every objective using the min and the max value for every objective vector of _pop * @param _pop the population */ void setup(const eoPop < MOEOT > & _pop) { - typename MOEOT::ObjectiveVector::Type min, max; - for (unsigned int i=0; i & _pop) { - values.clear(); - values.resize(_pop.size()); - for (unsigned int i=0; i<_pop.size(); i++) + // initialize the values structure (if it is used for the first time with such a population size) + if (values.size() < _pop.size()) { - values[i].resize(_pop.size()); - // the metric may not be symetric, thus neither is the matrix - for (unsigned int j=0; j<_pop.size(); j++) + values.resize(_pop.size()); + for (unsigned int i=0; i & _pop) { - for (unsigned int i=0; i<_pop.size(); i++) + for (unsigned int i=0; i<_pop.size(); i++) { - _pop[i].fitness(computeFitness(i)); + _pop[i].fitness(computeFitness(_pop, i)); } } - - + + /** * Returns the fitness value of the _idx th individual of the population + * @param _pop the population (only useful for its size here) * @param _idx the index */ - virtual Fitness computeFitness(const unsigned int _idx) + virtual Fitness computeFitness(const eoPop < MOEOT > & _pop, const unsigned int _idx) { - Fitness result(0.0); - for (unsigned int i=0; i Date: Fri, 17 Oct 2014 15:06:59 +0200 Subject: [PATCH 105/419] missing function in moBitsNeighborhood.h --- .../problems/bitString/moBitsNeighborhood.h | 212 +++++++++--------- 1 file changed, 110 insertions(+), 102 deletions(-) diff --git a/mo/src/problems/bitString/moBitsNeighborhood.h b/mo/src/problems/bitString/moBitsNeighborhood.h index 5bfb2576d..2d4557f2f 100644 --- a/mo/src/problems/bitString/moBitsNeighborhood.h +++ b/mo/src/problems/bitString/moBitsNeighborhood.h @@ -1,36 +1,36 @@ /* - - Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 - - Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau - - This software is governed by the CeCILL license under French law and - abiding by the rules of distribution of free software. You can use, - 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". - - As a counterpart to the access to the source code and rights to copy, - modify and redistribute granted by the license, users are provided only - with a limited warranty and the software's author, the holder of the - economic rights, and the successive licensors have only limited liability. - - 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 -*/ + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau + + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can use, + 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". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + 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 _moBitsNeighborhood_h #define _moBitsNeighborhood_h @@ -48,78 +48,86 @@ template< class Neighbor > class moBitsNeighborhood : public moNeighborhood { public: - - /** - * Define type of a solution corresponding to Neighbor - */ - typedef typename Neighbor::EOT EOT; - - /** - * Constructor - * @param _length bit string length - * @param _nBits maximum number of bits to flip (radius of the neighborhood) - * @param _exactDistance when true, only neighbor with exactly k bits flip are considered, other neighbor <= Hamming distance k - */ - moBitsNeighborhood(unsigned _length, unsigned _nBits, bool _exactDistance = false): moNeighborhood(), length(_length), nBits(_nBits) { - // neighborhood size : - // for distance == nBits : length \choose nBits = length! / ( (length - nBits)! * nBits!) - // for distance <= nBits : sum of previous distances - if (_exactDistance) { - neighborhoodSize = numberOfNeighbors(nBits); - } else { - neighborhoodSize = 0; - for(int d = 1; d <= nBits; d++) - neighborhoodSize += numberOfNeighbors(d); + + /** + * Define type of a solution corresponding to Neighbor + */ + typedef typename Neighbor::EOT EOT; + + /** + * Constructor + * @param _length bit string length + * @param _nBits maximum number of bits to flip (radius of the neighborhood) + * @param _exactDistance when true, only neighbor with exactly k bits flip are considered, other neighbor <= Hamming distance k + */ + moBitsNeighborhood(unsigned _length, unsigned _nBits, bool _exactDistance = false): moNeighborhood(), length(_length), nBits(_nBits) { + // neighborhood size : + // for distance == nBits : length \choose nBits = length! / ( (length - nBits)! * nBits!) + // for distance <= nBits : sum of previous distances + if (_exactDistance) { + neighborhoodSize = numberOfNeighbors(nBits); + } else { + neighborhoodSize = 0; + for(int d = 1; d <= nBits; d++) + neighborhoodSize += numberOfNeighbors(d); + } + } - - } - - /** - * Number fo neighbors at Hamming distance d - * - * @param d Hamming distance - */ - unsigned int numberOfNeighbors(unsigned d) { - unsigned int fact_nBits = 1; - - for(unsigned k = 1; k <= d; k++) - fact_nBits *= k; - - unsigned int fact_length = 1; - - for(unsigned k = length; k > length - d; k--) - fact_length *= k; - - return fact_length / fact_nBits; - } - - /** - * Test if it exist a neighbor - * @param _solution the solution to explore - * @return true if the neighborhood was not empty (bit string larger than 0) - */ - virtual bool hasNeighbor(EOT& _solution) { - return _solution.size() > 0; - } - - /** - * Return the class Name - * @return the class name as a std::string - */ - virtual std::string className() const { - return "moBitsNeighborhood"; - } - + + /** + * Number fo neighbors at Hamming distance d + * + * @param d Hamming distance + */ + unsigned int numberOfNeighbors(unsigned d) { + unsigned int fact_nBits = 1; + + for(unsigned k = 1; k <= d; k++) + fact_nBits *= k; + + unsigned int fact_length = 1; + + for(unsigned k = length; k > length - d; k--) + fact_length *= k; + + return fact_length / fact_nBits; + } + + /** + * Test if it exist a neighbor + * @param _solution the solution to explore + * @return true if the neighborhood was not empty (bit string larger than 0) + */ + virtual bool hasNeighbor(EOT& _solution) { + return _solution.size() > 0; + } + + /** + * Return the class Name + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moBitsNeighborhood"; + } + + /** + * The neighborhood is random here + * @return true, since the neighborhood is random + */ + bool isRandom() { + return true; + } + protected: - // length of the bit strings - unsigned int length; - - // radius of the neighborhood - unsigned int nBits; - - // size of the neighborhood - unsigned int neighborhoodSize; - + // length of the bit strings + unsigned int length; + + // radius of the neighborhood + unsigned int nBits; + + // size of the neighborhood + unsigned int neighborhoodSize; + }; #endif From 5a74f9a3c67c2dfc6fafe0d9499154de437ba028 Mon Sep 17 00:00:00 2001 From: Arnaud Liefooghe Date: Fri, 17 Oct 2014 15:27:43 +0200 Subject: [PATCH 106/419] trick to allow maximization --- moeo/src/metric/moeoHypervolumeBinaryMetric.h | 183 +++++++++--------- 1 file changed, 93 insertions(+), 90 deletions(-) diff --git a/moeo/src/metric/moeoHypervolumeBinaryMetric.h b/moeo/src/metric/moeoHypervolumeBinaryMetric.h index af7fafcd8..bf4fb7418 100644 --- a/moeo/src/metric/moeoHypervolumeBinaryMetric.h +++ b/moeo/src/metric/moeoHypervolumeBinaryMetric.h @@ -1,39 +1,39 @@ /* -* -* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 -* -* July 2013: Bug fix in the recursive call of hypervolume (corrected thanks to Yann Semet and Dimo Brockhoff) -* -* -* This software is governed by the CeCILL license under French law and -* abiding by the rules of distribution of free software. You can use, -* 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". -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited liability. -* -* 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 -* -*/ + * + * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 + * (C) OPAC Team, LIFL, 2002-2007 + * + * July 2013: Bug fix in the recursive call of hypervolume (corrected thanks to Yann Semet and Dimo Brockhoff) + * + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * 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". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited liability. + * + * 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 MOEOHYPERVOLUMEBINARYMETRIC_H_ @@ -57,32 +57,24 @@ */ template < class ObjectiveVector > class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > - { - public: - +{ +public: + /** * Ctor * @param _rho value used to compute the reference point from the worst values for each objective (default : 1.1) */ moeoHypervolumeBinaryMetric(double _rho = 1.1) : moeoNormalizedSolutionVsSolutionBinaryMetric(), rho(_rho) { - // not-a-maximization problem check - for (unsigned int i=0; i :: bounds; /** Functor to compare two objective vectors according to Pareto dominance relation */ moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; - - + + /** * Returns the volume of the space that is dominated by _o2 but not by _o1 with respect to a reference point computed using rho for the objective _obj. * @param _o1 the first objective vector @@ -124,48 +127,48 @@ class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinar */ double hypervolume(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned int _obj, const bool _flag = false) { - double result; - double range = rho * bounds[_obj].range(); - double max = bounds[_obj].minimum() + range; - - // value of _1 for the objective _obj - double v1 = _o1[_obj]; - // value of _2 for the objective _obj (if _flag=true, v2=max) - double v2; - if (_flag) + double result; + double range = rho * bounds[_obj].range(); + double max = bounds[_obj].minimum() + range; + + // value of _1 for the objective _obj + double v1 = _o1[_obj]; + // value of _2 for the objective _obj (if _flag=true, v2=max) + double v2; + if (_flag) { - v2 = max; + v2 = max; } - else + else { - v2 = _o2[_obj]; + v2 = _o2[_obj]; } - // computation of the volume - if (_obj == 0) + // computation of the volume + if (_obj == 0) { - if (v1 < v2) + if (v1 < v2) { - result = (v2 - v1) / range; + result = (v2 - v1) / range; } - else + else { - result = 0; + result = 0; } } - else + else { - if (v1 < v2) + if (v1 < v2) { - result = ( hypervolume(_o1, _o2, _obj-1, true) * (v2 - v1) / range ) + ( hypervolume(_o1, _o2, _obj-1) * (max - v2) / range ); + result = ( hypervolume(_o1, _o2, _obj-1, true) * (v2 - v1) / range ) + ( hypervolume(_o1, _o2, _obj-1) * (max - v2) / range ); } - else + else { - result = hypervolume(_o1, _o2, _obj-1) * (max - v1) / range; + result = hypervolume(_o1, _o2, _obj-1) * (max - v1) / range; } } - return result; + return result; } - - }; + +}; #endif /*MOEOHYPERVOLUMEBINARYMETRIC_H_*/ From a3288caf6d1ffa71864d24217f603a1127ef0cd2 Mon Sep 17 00:00:00 2001 From: verel Date: Sat, 18 Oct 2014 16:15:49 +0200 Subject: [PATCH 107/419] Add the number of neighbor evaluations in moAdaptiveWalk --- mo/src/continuator/moValueStat.h | 19 ++- mo/src/eval/moEvalCounter.h | 4 +- mo/src/sampling/moAdaptiveWalkSampling.h | 31 ++++- mo/src/sampling/moNeutralWalkSampling.h | 161 ++++++++++++++--------- problems/eval/qapEval.h | 8 +- 5 files changed, 148 insertions(+), 75 deletions(-) diff --git a/mo/src/continuator/moValueStat.h b/mo/src/continuator/moValueStat.h index 6c8806e87..0d8d8877d 100644 --- a/mo/src/continuator/moValueStat.h +++ b/mo/src/continuator/moValueStat.h @@ -45,12 +45,15 @@ template class moValueStat : public moStat { public : - using moStat< EOT, double>::value; + using moStat::value; /** * Default Constructor + * + * @param _valueParam the value to report in the statistic + * @param _restart if true, the value is initialized at 0 for each init (restart) */ - moValueStat(eoValueParam & _valueParam): moStat(0, "value"), valueParam(_valueParam) { + moValueStat(eoValueParam & _valueParam, bool _restart = false): moStat(0, "value"), valueParam(_valueParam), restart(_restart) { } /** @@ -58,7 +61,12 @@ public : * @param _sol a solution */ virtual void init(EOT & _sol) { - value() = (double) valueParam.value(); + if (restart) + value_start = valueParam.value(); + else + value_start = 0; + + value() = (double) (valueParam.value() - value_start); } /** @@ -66,7 +74,7 @@ public : * @param _sol a solution */ virtual void operator()(EOT & _sol) { - value() = (double) valueParam.value() ; + value() = (double) (valueParam.value() - value_start); } /** @@ -79,6 +87,9 @@ public : private: eoValueParam & valueParam; + bool restart; + ValueType value_start ; + }; #endif diff --git a/mo/src/eval/moEvalCounter.h b/mo/src/eval/moEvalCounter.h index e795f4384..e12949b1f 100644 --- a/mo/src/eval/moEvalCounter.h +++ b/mo/src/eval/moEvalCounter.h @@ -34,8 +34,8 @@ Contact: paradiseo-help@lists.gforge.inria.fr #include /** - Counts the number of neighbor evaluations actually performed, thus checks first - if it has to evaluate.. etc. + Counts the number of neighbor evaluations actually performed, + thus checks first if it has to be evaluated.. etc. */ template class moEvalCounter : public moEval, public eoValueParam diff --git a/mo/src/sampling/moAdaptiveWalkSampling.h b/mo/src/sampling/moAdaptiveWalkSampling.h index 14d99ac44..0dae8633c 100644 --- a/mo/src/sampling/moAdaptiveWalkSampling.h +++ b/mo/src/sampling/moAdaptiveWalkSampling.h @@ -46,12 +46,19 @@ #include #include #include +#include +#include +#include /** * To compute the length and final solution of an adaptive walk: * Perform a first improvement Hill-climber based on the neighborhood (adaptive walk), - * The lengths of HC are collected and the final solution which are local optima - * The adaptive walk is repeated several times + * The adaptive walk is repeated several times (defined by a parameter) + * + * Statistics are: + * - the length of the adaptive walk + * - the number of neighbor evaluaitons + * - the final solution which are local optimum * */ template @@ -64,11 +71,12 @@ public: /** * Constructor + * * @param _init initialisation method of the solution * @param _neighborhood neighborhood giving neighbor in random order * @param _fullEval a full evaluation function * @param _eval an incremental evaluation of neighbors - * @param _nbAdaptWalk Number of adaptive walks + * @param _nbAdaptWalk Number of adaptive walks (minimum value = 2) */ moAdaptiveWalkSampling(eoInit & _init, moNeighborhood & _neighborhood, @@ -76,15 +84,22 @@ public: moEval& _eval, unsigned int _nbAdaptWalk) : moSampling(initHC, * new moRandomSearch(initHC, _fullEval, _nbAdaptWalk), copyStat), - copyStat(lengthStat), + neighborEvalCount(_eval), + nEvalStat(neighborEvalCount, true), + copyStat(lengthStat), // copy is used to report the statistic of the first walk + copyEvalStat(nEvalStat), checkpoint(trueCont), - hc(_neighborhood, _fullEval, _eval, checkpoint), + hc(_neighborhood, _fullEval, neighborEvalCount, checkpoint), initHC(_init, hc) { // to count the number of step in the HC checkpoint.add(lengthStat); + // to count the number of evaluations + checkpoint.add(nEvalStat); + // add the solution into statistics + this->add(copyEvalStat); this->add(solStat); } @@ -97,6 +112,11 @@ public: } protected: + /* count the number of evaluations */ + moEvalCounter neighborEvalCount; + moValueStat nEvalStat; + moStatFromStat copyEvalStat; + moSolutionStat solStat; moMinusOneCounterStat lengthStat; moTrueContinuator trueCont; @@ -104,6 +124,7 @@ protected: moCheckpoint checkpoint; moFirstImprHC hc; moLocalSearchInit initHC; + }; diff --git a/mo/src/sampling/moNeutralWalkSampling.h b/mo/src/sampling/moNeutralWalkSampling.h index 789dd8fed..708f0ac14 100644 --- a/mo/src/sampling/moNeutralWalkSampling.h +++ b/mo/src/sampling/moNeutralWalkSampling.h @@ -76,71 +76,112 @@ template class moNeutralWalkSampling : public moSampling { public: - typedef typename Neighbor::EOT EOT ; + typedef typename Neighbor::EOT EOT ; - using moSampling::localSearch; + using moSampling::localSearch; - /** - * Constructor - * @param _initSol the first solution of the walk - * @param _neighborhood neighborhood giving neighbor in random order - * @param _fullEval Fitness function, full evaluation function - * @param _eval neighbor evaluation, incremental evaluation function - * @param _distance component to measure the distance from the initial solution - * @param _nbStep Number of steps of the random walk - */ - moNeutralWalkSampling(EOT & _initSol, - moNeighborhood & _neighborhood, - eoEvalFunc& _fullEval, - moEval& _eval, - eoDistance & _distance, - unsigned int _nbStep) : - moSampling(init, * new moRandomNeutralWalk(_neighborhood, _fullEval, _eval, _nbStep), solutionStat), - init(_initSol), - distStat(_distance, _initSol), - neighborhoodStat(_neighborhood, _eval), - minStat(neighborhoodStat), - averageStat(neighborhoodStat), - stdStat(neighborhoodStat), - maxStat(neighborhoodStat), - nbSupStat(neighborhoodStat), - nbInfStat(neighborhoodStat), - sizeStat(neighborhoodStat), - ndStat(neighborhoodStat) - { - this->add(neighborhoodStat, false); - this->add(distStat); - this->add(minStat); - this->add(averageStat); - this->add(stdStat); - this->add(maxStat); - this->add(sizeStat); - this->add(nbInfStat); - this->add(ndStat); - this->add(nbSupStat); - } + /** + * Constructor + * @param _initSol the first solution of the walk + * @param _neighborhood neighborhood giving neighbor in random order + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _distance component to measure the distance from the initial solution + * @param _nbStep Number of steps of the random walk + */ + moNeutralWalkSampling(EOT & _initSol, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + eoDistance & _distance, + unsigned int _nbStep) : + moSampling(init, * new moRandomNeutralWalk(_neighborhood, _fullEval, _eval, _nbStep), solutionStat), + init(_initSol), + distStat(_distance, _initSol), + neighborhoodStat(_neighborhood, _eval), + minStat(neighborhoodStat), + averageStat(neighborhoodStat), + stdStat(neighborhoodStat), + maxStat(neighborhoodStat), + nbSupStat(neighborhoodStat), + nbInfStat(neighborhoodStat), + sizeStat(neighborhoodStat), + ndStat(neighborhoodStat) + { + this->add(neighborhoodStat, false); + this->add(distStat); + this->add(minStat); + this->add(averageStat); + this->add(stdStat); + this->add(maxStat); + this->add(sizeStat); + this->add(nbInfStat); + this->add(ndStat); + this->add(nbSupStat); + } - /** - * default destructor - */ - ~moNeutralWalkSampling() { - // delete the pointer on the local search which has been constructed in the constructor - delete localSearch; - } + /** + * Constructor + * @param _initSol the first solution of the walk + * @param _neighborhood neighborhood giving neighbor in random order + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _distance component to measure the distance from the initial solution + * @param _nbStep Number of steps of the random walk + */ + moNeutralWalkSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbStep) : + moSampling(_init, * new moRandomNeutralWalk(_neighborhood, _fullEval, _eval, _nbStep), solutionStat), + init(initialSol), + distStat(dummyDistance, initialSol), + neighborhoodStat(_neighborhood, _eval), + minStat(neighborhoodStat), + averageStat(neighborhoodStat), + stdStat(neighborhoodStat), + maxStat(neighborhoodStat), + nbSupStat(neighborhoodStat), + nbInfStat(neighborhoodStat), + sizeStat(neighborhoodStat), + ndStat(neighborhoodStat) + { + this->add(neighborhoodStat, false); + // this->add(distStat); + this->add(minStat); + this->add(averageStat); + this->add(stdStat); + this->add(maxStat); + this->add(sizeStat); + this->add(nbInfStat); + this->add(ndStat); + this->add(nbSupStat); + } + + /** + * default destructor + */ + ~moNeutralWalkSampling() { + // delete the pointer on the local search which has been constructed in the constructor + delete localSearch; + } protected: - moSolInit init; - moSolutionStat solutionStat; - moDistanceStat distStat; - moNeighborhoodStat< Neighbor > neighborhoodStat; - moMinNeighborStat< Neighbor > minStat; - moAverageFitnessNeighborStat< Neighbor > averageStat; - moStdFitnessNeighborStat< Neighbor > stdStat; - moMaxNeighborStat< Neighbor > maxStat; - moNbSupNeighborStat< Neighbor > nbSupStat; - moNbInfNeighborStat< Neighbor > nbInfStat; - moSizeNeighborStat< Neighbor > sizeStat; - moNeutralDegreeNeighborStat< Neighbor > ndStat; + EOT initialSol; + eoHammingDistance dummyDistance; + moSolInit init; + moSolutionStat solutionStat; + moDistanceStat distStat; + moNeighborhoodStat< Neighbor > neighborhoodStat; + moMinNeighborStat< Neighbor > minStat; + moAverageFitnessNeighborStat< Neighbor > averageStat; + moStdFitnessNeighborStat< Neighbor > stdStat; + moMaxNeighborStat< Neighbor > maxStat; + moNbSupNeighborStat< Neighbor > nbSupStat; + moNbInfNeighborStat< Neighbor > nbInfStat; + moSizeNeighborStat< Neighbor > sizeStat; + moNeutralDegreeNeighborStat< Neighbor > ndStat; }; diff --git a/problems/eval/qapEval.h b/problems/eval/qapEval.h index 0915a8886..3236dae60 100644 --- a/problems/eval/qapEval.h +++ b/problems/eval/qapEval.h @@ -45,12 +45,12 @@ public: * * @param _fileData the file name which contains the instance of QAP from QAPlib */ - QAPeval(string & _fileData) { - fstream file(_fileData.c_str(), ios::in); + QAPeval(std::string _fileData) { + std::fstream file(_fileData.c_str(), std::ios::in); if (!file) { - string str = "QAPeval: Could not open file [" + _fileData + "]." ; - throw runtime_error(str); + std::string str = "QAPeval: Could not open file [" + _fileData + "]." ; + throw std::runtime_error(str); } unsigned i, j; From c876f0b58bf4e3d04b2ef56cd868cb7cfbd55958 Mon Sep 17 00:00:00 2001 From: Arnaud Liefooghe Date: Wed, 22 Oct 2014 12:35:00 +0200 Subject: [PATCH 108/419] maximizing objectives --- moeo/src/metric/moeoHypervolumeBinaryMetric.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moeo/src/metric/moeoHypervolumeBinaryMetric.h b/moeo/src/metric/moeoHypervolumeBinaryMetric.h index bf4fb7418..3fbc42031 100644 --- a/moeo/src/metric/moeoHypervolumeBinaryMetric.h +++ b/moeo/src/metric/moeoHypervolumeBinaryMetric.h @@ -98,11 +98,11 @@ public: // if _o2 is dominated by _o1 if ( paretoComparator(_o2,_o1) ) { - result = - hypervolume(_o1, _o2, ObjectiveVector::Traits::nObjectives()-1); + result = - hypervolume(o1, o2, ObjectiveVector::Traits::nObjectives()-1); } else { - result = hypervolume(_o2, _o1, ObjectiveVector::Traits::nObjectives()-1); + result = hypervolume(o2, o1, ObjectiveVector::Traits::nObjectives()-1); } return result; } From b2b092bdd41be6eb0259b8b9c86eb701079b987d Mon Sep 17 00:00:00 2001 From: Arnaud Liefooghe Date: Wed, 22 Oct 2014 12:42:04 +0200 Subject: [PATCH 109/419] Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/paradiseo/paradiseo # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit. --- mo/src/continuator/moValueStat.h | 19 ++- mo/src/eval/moEvalCounter.h | 4 +- mo/src/sampling/moAdaptiveWalkSampling.h | 31 ++++- mo/src/sampling/moNeutralWalkSampling.h | 161 ++++++++++++++--------- problems/eval/qapEval.h | 8 +- 5 files changed, 148 insertions(+), 75 deletions(-) diff --git a/mo/src/continuator/moValueStat.h b/mo/src/continuator/moValueStat.h index 6c8806e87..0d8d8877d 100644 --- a/mo/src/continuator/moValueStat.h +++ b/mo/src/continuator/moValueStat.h @@ -45,12 +45,15 @@ template class moValueStat : public moStat { public : - using moStat< EOT, double>::value; + using moStat::value; /** * Default Constructor + * + * @param _valueParam the value to report in the statistic + * @param _restart if true, the value is initialized at 0 for each init (restart) */ - moValueStat(eoValueParam & _valueParam): moStat(0, "value"), valueParam(_valueParam) { + moValueStat(eoValueParam & _valueParam, bool _restart = false): moStat(0, "value"), valueParam(_valueParam), restart(_restart) { } /** @@ -58,7 +61,12 @@ public : * @param _sol a solution */ virtual void init(EOT & _sol) { - value() = (double) valueParam.value(); + if (restart) + value_start = valueParam.value(); + else + value_start = 0; + + value() = (double) (valueParam.value() - value_start); } /** @@ -66,7 +74,7 @@ public : * @param _sol a solution */ virtual void operator()(EOT & _sol) { - value() = (double) valueParam.value() ; + value() = (double) (valueParam.value() - value_start); } /** @@ -79,6 +87,9 @@ public : private: eoValueParam & valueParam; + bool restart; + ValueType value_start ; + }; #endif diff --git a/mo/src/eval/moEvalCounter.h b/mo/src/eval/moEvalCounter.h index e795f4384..e12949b1f 100644 --- a/mo/src/eval/moEvalCounter.h +++ b/mo/src/eval/moEvalCounter.h @@ -34,8 +34,8 @@ Contact: paradiseo-help@lists.gforge.inria.fr #include /** - Counts the number of neighbor evaluations actually performed, thus checks first - if it has to evaluate.. etc. + Counts the number of neighbor evaluations actually performed, + thus checks first if it has to be evaluated.. etc. */ template class moEvalCounter : public moEval, public eoValueParam diff --git a/mo/src/sampling/moAdaptiveWalkSampling.h b/mo/src/sampling/moAdaptiveWalkSampling.h index 14d99ac44..0dae8633c 100644 --- a/mo/src/sampling/moAdaptiveWalkSampling.h +++ b/mo/src/sampling/moAdaptiveWalkSampling.h @@ -46,12 +46,19 @@ #include #include #include +#include +#include +#include /** * To compute the length and final solution of an adaptive walk: * Perform a first improvement Hill-climber based on the neighborhood (adaptive walk), - * The lengths of HC are collected and the final solution which are local optima - * The adaptive walk is repeated several times + * The adaptive walk is repeated several times (defined by a parameter) + * + * Statistics are: + * - the length of the adaptive walk + * - the number of neighbor evaluaitons + * - the final solution which are local optimum * */ template @@ -64,11 +71,12 @@ public: /** * Constructor + * * @param _init initialisation method of the solution * @param _neighborhood neighborhood giving neighbor in random order * @param _fullEval a full evaluation function * @param _eval an incremental evaluation of neighbors - * @param _nbAdaptWalk Number of adaptive walks + * @param _nbAdaptWalk Number of adaptive walks (minimum value = 2) */ moAdaptiveWalkSampling(eoInit & _init, moNeighborhood & _neighborhood, @@ -76,15 +84,22 @@ public: moEval& _eval, unsigned int _nbAdaptWalk) : moSampling(initHC, * new moRandomSearch(initHC, _fullEval, _nbAdaptWalk), copyStat), - copyStat(lengthStat), + neighborEvalCount(_eval), + nEvalStat(neighborEvalCount, true), + copyStat(lengthStat), // copy is used to report the statistic of the first walk + copyEvalStat(nEvalStat), checkpoint(trueCont), - hc(_neighborhood, _fullEval, _eval, checkpoint), + hc(_neighborhood, _fullEval, neighborEvalCount, checkpoint), initHC(_init, hc) { // to count the number of step in the HC checkpoint.add(lengthStat); + // to count the number of evaluations + checkpoint.add(nEvalStat); + // add the solution into statistics + this->add(copyEvalStat); this->add(solStat); } @@ -97,6 +112,11 @@ public: } protected: + /* count the number of evaluations */ + moEvalCounter neighborEvalCount; + moValueStat nEvalStat; + moStatFromStat copyEvalStat; + moSolutionStat solStat; moMinusOneCounterStat lengthStat; moTrueContinuator trueCont; @@ -104,6 +124,7 @@ protected: moCheckpoint checkpoint; moFirstImprHC hc; moLocalSearchInit initHC; + }; diff --git a/mo/src/sampling/moNeutralWalkSampling.h b/mo/src/sampling/moNeutralWalkSampling.h index 789dd8fed..708f0ac14 100644 --- a/mo/src/sampling/moNeutralWalkSampling.h +++ b/mo/src/sampling/moNeutralWalkSampling.h @@ -76,71 +76,112 @@ template class moNeutralWalkSampling : public moSampling { public: - typedef typename Neighbor::EOT EOT ; + typedef typename Neighbor::EOT EOT ; - using moSampling::localSearch; + using moSampling::localSearch; - /** - * Constructor - * @param _initSol the first solution of the walk - * @param _neighborhood neighborhood giving neighbor in random order - * @param _fullEval Fitness function, full evaluation function - * @param _eval neighbor evaluation, incremental evaluation function - * @param _distance component to measure the distance from the initial solution - * @param _nbStep Number of steps of the random walk - */ - moNeutralWalkSampling(EOT & _initSol, - moNeighborhood & _neighborhood, - eoEvalFunc& _fullEval, - moEval& _eval, - eoDistance & _distance, - unsigned int _nbStep) : - moSampling(init, * new moRandomNeutralWalk(_neighborhood, _fullEval, _eval, _nbStep), solutionStat), - init(_initSol), - distStat(_distance, _initSol), - neighborhoodStat(_neighborhood, _eval), - minStat(neighborhoodStat), - averageStat(neighborhoodStat), - stdStat(neighborhoodStat), - maxStat(neighborhoodStat), - nbSupStat(neighborhoodStat), - nbInfStat(neighborhoodStat), - sizeStat(neighborhoodStat), - ndStat(neighborhoodStat) - { - this->add(neighborhoodStat, false); - this->add(distStat); - this->add(minStat); - this->add(averageStat); - this->add(stdStat); - this->add(maxStat); - this->add(sizeStat); - this->add(nbInfStat); - this->add(ndStat); - this->add(nbSupStat); - } + /** + * Constructor + * @param _initSol the first solution of the walk + * @param _neighborhood neighborhood giving neighbor in random order + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _distance component to measure the distance from the initial solution + * @param _nbStep Number of steps of the random walk + */ + moNeutralWalkSampling(EOT & _initSol, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + eoDistance & _distance, + unsigned int _nbStep) : + moSampling(init, * new moRandomNeutralWalk(_neighborhood, _fullEval, _eval, _nbStep), solutionStat), + init(_initSol), + distStat(_distance, _initSol), + neighborhoodStat(_neighborhood, _eval), + minStat(neighborhoodStat), + averageStat(neighborhoodStat), + stdStat(neighborhoodStat), + maxStat(neighborhoodStat), + nbSupStat(neighborhoodStat), + nbInfStat(neighborhoodStat), + sizeStat(neighborhoodStat), + ndStat(neighborhoodStat) + { + this->add(neighborhoodStat, false); + this->add(distStat); + this->add(minStat); + this->add(averageStat); + this->add(stdStat); + this->add(maxStat); + this->add(sizeStat); + this->add(nbInfStat); + this->add(ndStat); + this->add(nbSupStat); + } - /** - * default destructor - */ - ~moNeutralWalkSampling() { - // delete the pointer on the local search which has been constructed in the constructor - delete localSearch; - } + /** + * Constructor + * @param _initSol the first solution of the walk + * @param _neighborhood neighborhood giving neighbor in random order + * @param _fullEval Fitness function, full evaluation function + * @param _eval neighbor evaluation, incremental evaluation function + * @param _distance component to measure the distance from the initial solution + * @param _nbStep Number of steps of the random walk + */ + moNeutralWalkSampling(eoInit & _init, + moNeighborhood & _neighborhood, + eoEvalFunc& _fullEval, + moEval& _eval, + unsigned int _nbStep) : + moSampling(_init, * new moRandomNeutralWalk(_neighborhood, _fullEval, _eval, _nbStep), solutionStat), + init(initialSol), + distStat(dummyDistance, initialSol), + neighborhoodStat(_neighborhood, _eval), + minStat(neighborhoodStat), + averageStat(neighborhoodStat), + stdStat(neighborhoodStat), + maxStat(neighborhoodStat), + nbSupStat(neighborhoodStat), + nbInfStat(neighborhoodStat), + sizeStat(neighborhoodStat), + ndStat(neighborhoodStat) + { + this->add(neighborhoodStat, false); + // this->add(distStat); + this->add(minStat); + this->add(averageStat); + this->add(stdStat); + this->add(maxStat); + this->add(sizeStat); + this->add(nbInfStat); + this->add(ndStat); + this->add(nbSupStat); + } + + /** + * default destructor + */ + ~moNeutralWalkSampling() { + // delete the pointer on the local search which has been constructed in the constructor + delete localSearch; + } protected: - moSolInit init; - moSolutionStat solutionStat; - moDistanceStat distStat; - moNeighborhoodStat< Neighbor > neighborhoodStat; - moMinNeighborStat< Neighbor > minStat; - moAverageFitnessNeighborStat< Neighbor > averageStat; - moStdFitnessNeighborStat< Neighbor > stdStat; - moMaxNeighborStat< Neighbor > maxStat; - moNbSupNeighborStat< Neighbor > nbSupStat; - moNbInfNeighborStat< Neighbor > nbInfStat; - moSizeNeighborStat< Neighbor > sizeStat; - moNeutralDegreeNeighborStat< Neighbor > ndStat; + EOT initialSol; + eoHammingDistance dummyDistance; + moSolInit init; + moSolutionStat solutionStat; + moDistanceStat distStat; + moNeighborhoodStat< Neighbor > neighborhoodStat; + moMinNeighborStat< Neighbor > minStat; + moAverageFitnessNeighborStat< Neighbor > averageStat; + moStdFitnessNeighborStat< Neighbor > stdStat; + moMaxNeighborStat< Neighbor > maxStat; + moNbSupNeighborStat< Neighbor > nbSupStat; + moNbInfNeighborStat< Neighbor > nbInfStat; + moSizeNeighborStat< Neighbor > sizeStat; + moNeutralDegreeNeighborStat< Neighbor > ndStat; }; diff --git a/problems/eval/qapEval.h b/problems/eval/qapEval.h index 0915a8886..3236dae60 100644 --- a/problems/eval/qapEval.h +++ b/problems/eval/qapEval.h @@ -45,12 +45,12 @@ public: * * @param _fileData the file name which contains the instance of QAP from QAPlib */ - QAPeval(string & _fileData) { - fstream file(_fileData.c_str(), ios::in); + QAPeval(std::string _fileData) { + std::fstream file(_fileData.c_str(), std::ios::in); if (!file) { - string str = "QAPeval: Could not open file [" + _fileData + "]." ; - throw runtime_error(str); + std::string str = "QAPeval: Could not open file [" + _fileData + "]." ; + throw std::runtime_error(str); } unsigned i, j; From 25850272c343b5f85e7a5f48753e3b23a2f793a5 Mon Sep 17 00:00:00 2001 From: verel Date: Thu, 23 Oct 2014 14:00:17 +0200 Subject: [PATCH 110/419] Add quartiles statistics of the moNeighborhoodStat. Add metho longName in moVectorMonitor. --- .../moAverageFitnessNeighborStat.h | 2 +- mo/src/continuator/moMaxNeighborStat.h | 2 +- mo/src/continuator/moMedianNeighborStat.h | 90 ++++++++++++++++++ mo/src/continuator/moNbInfNeighborStat.h | 2 +- mo/src/continuator/moNbSupNeighborStat.h | 2 +- mo/src/continuator/moNeighborhoodStat.h | 60 ++++++++++-- .../continuator/moNeutralDegreeNeighborStat.h | 2 +- mo/src/continuator/moQ1NeighborStat.h | 90 ++++++++++++++++++ mo/src/continuator/moQ3NeighborStat.h | 90 ++++++++++++++++++ mo/src/continuator/moQuartilesNeighborStat.h | 91 +++++++++++++++++++ .../continuator/moSecondMomentNeighborStat.h | 2 +- mo/src/continuator/moSizeNeighborStat.h | 2 +- mo/src/continuator/moSolutionStat.h | 2 +- mo/src/continuator/moStatFromStat.h | 2 +- mo/src/continuator/moStdFitnessNeighborStat.h | 2 +- mo/src/continuator/moVectorMonitor.h | 18 ++++ mo/src/sampling/moAdaptiveWalkSampling.h | 6 ++ mo/src/sampling/moHillClimberSampling.h | 3 + mo/src/sampling/moNeutralWalkSampling.h | 33 +++++-- mo/src/sampling/moSampling.h | 17 +++- mo/test/t-moAdaptiveWalkSampling.cpp | 2 +- mo/test/t-moNeighborhoodStat.cpp | 41 +++++++++ 22 files changed, 533 insertions(+), 28 deletions(-) create mode 100644 mo/src/continuator/moMedianNeighborStat.h create mode 100644 mo/src/continuator/moQ1NeighborStat.h create mode 100644 mo/src/continuator/moQ3NeighborStat.h create mode 100644 mo/src/continuator/moQuartilesNeighborStat.h diff --git a/mo/src/continuator/moAverageFitnessNeighborStat.h b/mo/src/continuator/moAverageFitnessNeighborStat.h index 4c268d6d3..7d12abc0a 100644 --- a/mo/src/continuator/moAverageFitnessNeighborStat.h +++ b/mo/src/continuator/moAverageFitnessNeighborStat.h @@ -55,7 +55,7 @@ public : * @param _nhStat a neighborhoodStat */ moAverageFitnessNeighborStat(moNeighborhoodStat & _nhStat): - moStat(0.0, "average"), nhStat(_nhStat) {} + moStat(0.0, "mean"), nhStat(_nhStat) {} /** * Set the average of fitness in the neighborhood diff --git a/mo/src/continuator/moMaxNeighborStat.h b/mo/src/continuator/moMaxNeighborStat.h index d0dbd8136..f0b165d72 100644 --- a/mo/src/continuator/moMaxNeighborStat.h +++ b/mo/src/continuator/moMaxNeighborStat.h @@ -56,7 +56,7 @@ public : * @param _nhStat a neighborhoodStat */ moMaxNeighborStat(moNeighborhoodStat & _nhStat): - moStat(Fitness(), "min"), nhStat(_nhStat) {} + moStat(Fitness(), "max"), nhStat(_nhStat) {} /** * Set the max fitness in the neighborhood diff --git a/mo/src/continuator/moMedianNeighborStat.h b/mo/src/continuator/moMedianNeighborStat.h new file mode 100644 index 000000000..4c3cfb8f2 --- /dev/null +++ b/mo/src/continuator/moMedianNeighborStat.h @@ -0,0 +1,90 @@ +/* + + 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 use, + 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". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + 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 moMedianNeighborStat_h +#define moMedianNeighborStat_h + +#include +#include +#include + +/** + * From moNeighborhoodStat, + * to compute the meadian fitness in the neighborhood + */ +template< class Neighbor > +class moMedianNeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, Fitness >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moMedianNeighborStat(moNeighborhoodStat & _nhStat): + moStat(Fitness(), "median"), nhStat(_nhStat) {} + + /** + * Set the median fitness in the neighborhood + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getMedian(); + } + + /** + * Set the median fitness in the neighborhood + * @param _sol the corresponding solution + */ + virtual void operator()(EOT & _sol) { + value() = nhStat.getMedian(); + } + + /** + * @return the class name + */ + virtual std::string className(void) const { + return "moMedianNeighborStat"; + } + +private: + /** moNeighborhoodStat */ + moNeighborhoodStat & nhStat; +}; + +#endif diff --git a/mo/src/continuator/moNbInfNeighborStat.h b/mo/src/continuator/moNbInfNeighborStat.h index 1fa6783bb..e3bc27bb7 100644 --- a/mo/src/continuator/moNbInfNeighborStat.h +++ b/mo/src/continuator/moNbInfNeighborStat.h @@ -57,7 +57,7 @@ public : * @param _nhStat a neighborhoodStat */ moNbInfNeighborStat(moNeighborhoodStat & _nhStat): - moStat(0, "nb inf"), nhStat(_nhStat) {} + moStat(0, "inf"), nhStat(_nhStat) {} /** * Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution diff --git a/mo/src/continuator/moNbSupNeighborStat.h b/mo/src/continuator/moNbSupNeighborStat.h index 027d8f1e8..8febf94f8 100644 --- a/mo/src/continuator/moNbSupNeighborStat.h +++ b/mo/src/continuator/moNbSupNeighborStat.h @@ -57,7 +57,7 @@ public : * @param _nhStat a neighborhoodStat */ moNbSupNeighborStat(moNeighborhoodStat & _nhStat): - moStat(0, "nb sup"), nhStat(_nhStat) {} + moStat(0, "sup"), nhStat(_nhStat) {} /** * Set the number of solutions in the neighborhood with better fitness than the current solution diff --git a/mo/src/continuator/moNeighborhoodStat.h b/mo/src/continuator/moNeighborhoodStat.h index 6dfe4fde9..3ce7d3757 100644 --- a/mo/src/continuator/moNeighborhoodStat.h +++ b/mo/src/continuator/moNeighborhoodStat.h @@ -41,6 +41,8 @@ #include #include #include +#include +#include // std::sort /** * All possible statitic on the neighborhood fitness @@ -102,8 +104,11 @@ public : Neighbor lowest ; if (neighborhood.hasNeighbor(_solution)) { - //init the first neighbor - neighborhood.init(_solution, current); + // to save the fitness values of the neighbors + std::vector neighborFitness; + + //init the first neighbor + neighborhood.init(_solution, current); //eval the _solution moved with the neighbor and stock the result in the neighbor eval(_solution, current); @@ -112,7 +117,7 @@ public : value() = true; mean = current.fitness(); - sd = mean * mean; + neighborFitness.push_back( (double) current.fitness() ); nb = 1; nbInf = 0; nbEqual = 0; @@ -137,7 +142,7 @@ public : eval(_solution, current); mean += current.fitness(); - sd += current.fitness() * current.fitness(); + neighborFitness.push_back( (double) current.fitness() ); nb++; if (solNeighborComparator.equals(_solution, current)) @@ -159,10 +164,24 @@ public : min = lowest.fitness(); mean /= nb; - if (nb > 1) - sd = sqrt( (sd - nb * mean * mean) / (nb - 1.0) ); - else + + if (nb > 1) { + sd = 0; + for(int i = 0; i < nb; i++) + sd += (neighborFitness[i] - mean) * (neighborFitness[i] - mean) ; + sd = sqrt( sd / (nb - 1.0) ); // becareful: could be infinite when large values + //sd = sqrt( (sd - nb * mean * mean) / (nb - 1.0) ); // becareful: could be negative due to approximation of large values + + std::sort(neighborFitness.begin(), neighborFitness.end()); // to compute the quartiles + q1 = neighborFitness[nb / 4]; + q2 = neighborFitness[nb / 2]; + q3 = neighborFitness[3 * nb / 4]; + } else { sd = 0.0; + q1 = max; + q2 = q1; + q3 = q1; + } } else { //if _solution hasn't neighbor, @@ -198,6 +217,27 @@ public : return sd; } + /** + * @return the first quartile of fitness in the neighborhood + */ + Fitness getQ1() { + return q1; + } + + /** + * @return the third quartile of fitness in the neighborhood + */ + Fitness getQ3() { + return q3; + } + + /** + * @return the median fitness value of the neighborhood + */ + Fitness getMedian() { + return q2; + } + /** * @return the size of the neighborhood */ @@ -251,9 +291,13 @@ protected: // the stastics of the fitness Fitness max, min; - //mean and standard deviation + + // mean and standard deviation double mean, sd ; + // quartiles + Fitness q1, q2, q3; + // number of neighbors in the neighborhood; unsigned int nb; diff --git a/mo/src/continuator/moNeutralDegreeNeighborStat.h b/mo/src/continuator/moNeutralDegreeNeighborStat.h index 88ab663b4..d46e99475 100644 --- a/mo/src/continuator/moNeutralDegreeNeighborStat.h +++ b/mo/src/continuator/moNeutralDegreeNeighborStat.h @@ -57,7 +57,7 @@ public : * @param _nhStat a neighborhoodStat */ moNeutralDegreeNeighborStat(moNeighborhoodStat & _nhStat): - moStat(0, "neutral degree"), nhStat(_nhStat) {} + moStat(0, "nd"), nhStat(_nhStat) {} /** * Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness diff --git a/mo/src/continuator/moQ1NeighborStat.h b/mo/src/continuator/moQ1NeighborStat.h new file mode 100644 index 000000000..4d74be68d --- /dev/null +++ b/mo/src/continuator/moQ1NeighborStat.h @@ -0,0 +1,90 @@ +/* + + 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 use, + 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". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + 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 moQ1NeighborStat_h +#define moQ1NeighborStat_h + +#include +#include +#include + +/** + * From moNeighborhoodStat, + * to compute the first quartile of fitness in the neighborhood + */ +template< class Neighbor > +class moQ1NeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, Fitness >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moQ1NeighborStat(moNeighborhoodStat & _nhStat): + moStat(Fitness(), "q1"), nhStat(_nhStat) {} + + /** + * Set the first quartile of fitness in the neighborhood + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getQ1(); + } + + /** + * Set the first quartile of fitness in the neighborhood + * @param _sol the corresponding solution + */ + virtual void operator()(EOT & _sol) { + value() = nhStat.getQ1(); + } + + /** + * @return the class name + */ + virtual std::string className(void) const { + return "moQ1NeighborStat"; + } + +private: + /** moNeighborhoodStat */ + moNeighborhoodStat & nhStat; +}; + +#endif diff --git a/mo/src/continuator/moQ3NeighborStat.h b/mo/src/continuator/moQ3NeighborStat.h new file mode 100644 index 000000000..50426e65f --- /dev/null +++ b/mo/src/continuator/moQ3NeighborStat.h @@ -0,0 +1,90 @@ +/* + + 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 use, + 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". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + 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 moQ3NeighborStat_h +#define moQ3NeighborStat_h + +#include +#include +#include + +/** + * From moNeighborhoodStat, + * to compute the third quartile of fitness in the neighborhood + */ +template< class Neighbor > +class moQ3NeighborStat : public moStat +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, Fitness >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moQ3NeighborStat(moNeighborhoodStat & _nhStat): + moStat(Fitness(), "q3"), nhStat(_nhStat) {} + + /** + * Set the third quartile of fitness in the neighborhood + * @param _sol the third solution + */ + virtual void init(EOT & _sol) { + value() = nhStat.getQ3(); + } + + /** + * Set the third quartile of fitness in the neighborhood + * @param _sol the corresponding solution + */ + virtual void operator()(EOT & _sol) { + value() = nhStat.getQ3(); + } + + /** + * @return the class name + */ + virtual std::string className(void) const { + return "moQ3NeighborStat"; + } + +private: + /** moNeighborhoodStat */ + moNeighborhoodStat & nhStat; +}; + +#endif diff --git a/mo/src/continuator/moQuartilesNeighborStat.h b/mo/src/continuator/moQuartilesNeighborStat.h new file mode 100644 index 000000000..69f6af68a --- /dev/null +++ b/mo/src/continuator/moQuartilesNeighborStat.h @@ -0,0 +1,91 @@ +/* + + 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 use, + 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". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + 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 moQuartilesNeighborStat_h +#define moQuartilesNeighborStat_h + +#include +#include + +/** + * From moNeighborhoodStat, + * to compute the first and the third quartile of fitness in the neighborhood + */ +template< class Neighbor > +class moQuartilesNeighborStat : public moStat > +{ +public : + typedef typename Neighbor::EOT EOT ; + typedef typename EOT::Fitness Fitness ; + + using moStat< EOT, std::pair >::value; + + /** + * Constructor + * @param _nhStat a neighborhoodStat + */ + moQuartilesNeighborStat(moNeighborhoodStat & _nhStat): + moStat >(std::make_pair(0.0,0.0), "first and third quartile"), nhStat(_nhStat) {} + + /** + * Set the first and the third quartile of fitness in the neighborhood + * @param _sol the first solution + */ + virtual void init(EOT & _sol) { + value().first = nhStat.getQ1(); + value().second = nhStat.getQ3(); + } + + /** + * Set the first and the third quartile fitness in the neighborhood + * @param _sol the corresponding solution + */ + virtual void operator()(EOT & _sol) { + value().first = nhStat.getQ1(); + value().second = nhStat.getQ3(); + } + + /** + * @return the class name + */ + virtual std::string className(void) const { + return "moQuartilesNeighborStat"; + } + +private: + /** moNeighborhoodStat */ + moNeighborhoodStat & nhStat; +}; + +#endif diff --git a/mo/src/continuator/moSecondMomentNeighborStat.h b/mo/src/continuator/moSecondMomentNeighborStat.h index c5b1009f7..7c3a08fff 100644 --- a/mo/src/continuator/moSecondMomentNeighborStat.h +++ b/mo/src/continuator/moSecondMomentNeighborStat.h @@ -55,7 +55,7 @@ public : * @param _nhStat a neighborhoodStat */ moSecondMomentNeighborStat(moNeighborhoodStat & _nhStat): - moStat >(std::make_pair(0.0,0.0), "average and stdev"), nhStat(_nhStat) {} + moStat >(std::make_pair(0.0,0.0), "mean sd"), nhStat(_nhStat) {} /** * Set the average and the standard deviation of fitness in the neighborhood diff --git a/mo/src/continuator/moSizeNeighborStat.h b/mo/src/continuator/moSizeNeighborStat.h index 6e7ae60f1..1a5b5b123 100644 --- a/mo/src/continuator/moSizeNeighborStat.h +++ b/mo/src/continuator/moSizeNeighborStat.h @@ -56,7 +56,7 @@ public : * @param _nhStat a neighborhoodStat */ moSizeNeighborStat(moNeighborhoodStat & _nhStat): - moStat(0, "size"), nhStat(_nhStat) {} + moStat(0, "nghsize"), nhStat(_nhStat) {} /** * Set the number of solutions in the neighborhood diff --git a/mo/src/continuator/moSolutionStat.h b/mo/src/continuator/moSolutionStat.h index 17a997e25..93c4f57f5 100644 --- a/mo/src/continuator/moSolutionStat.h +++ b/mo/src/continuator/moSolutionStat.h @@ -53,7 +53,7 @@ public : * @param _description a description of the parameter */ moSolutionStat(std::string _description = "solution"): - moStat(EOT(), _description) { } + moStat(EOT(), "fitness solution") { } /** * Initialization the solution by copy diff --git a/mo/src/continuator/moStatFromStat.h b/mo/src/continuator/moStatFromStat.h index e8da634ad..962106eb0 100644 --- a/mo/src/continuator/moStatFromStat.h +++ b/mo/src/continuator/moStatFromStat.h @@ -50,7 +50,7 @@ public : * Constructor * @param _stat a stat */ - moStatFromStat(moStat & _stat): moStat(0, _stat.description()), stat(_stat) { + moStatFromStat(moStat & _stat): moStat(0, _stat.longName()), stat(_stat) { } /** diff --git a/mo/src/continuator/moStdFitnessNeighborStat.h b/mo/src/continuator/moStdFitnessNeighborStat.h index b9a547954..649308f74 100644 --- a/mo/src/continuator/moStdFitnessNeighborStat.h +++ b/mo/src/continuator/moStdFitnessNeighborStat.h @@ -55,7 +55,7 @@ public : * @param _nhStat a neighborhoodStat */ moStdFitnessNeighborStat(moNeighborhoodStat & _nhStat): - moStat(0.0, "stdev"), nhStat(_nhStat) {} + moStat(0.0, "sd"), nhStat(_nhStat) {} /** * Set the average and the standard deviation of fitness in the neighborhood diff --git a/mo/src/continuator/moVectorMonitor.h b/mo/src/continuator/moVectorMonitor.h index d6870bb80..cd2b6c4e0 100644 --- a/mo/src/continuator/moVectorMonitor.h +++ b/mo/src/continuator/moVectorMonitor.h @@ -174,6 +174,24 @@ public: return os.str(); } + /** + * Returns the long name of the statistic (which is a eoParam) + * + * @return longName of the statistic + */ + const std::string& longName() const { + if (doubleParam != NULL) + return doubleParam->longName(); + else + if (intParam != NULL) + return intParam->longName(); + else + if (intLongParam != NULL) + return intLongParam->longName(); + else + return eotParam->longName(); + } + /** * clear the vector */ diff --git a/mo/src/sampling/moAdaptiveWalkSampling.h b/mo/src/sampling/moAdaptiveWalkSampling.h index 0dae8633c..04dafe876 100644 --- a/mo/src/sampling/moAdaptiveWalkSampling.h +++ b/mo/src/sampling/moAdaptiveWalkSampling.h @@ -95,8 +95,14 @@ public: // to count the number of step in the HC checkpoint.add(lengthStat); + // set the long name of this statistic which is the length of the walk + copyStat.setLongName("length"); + // to count the number of evaluations checkpoint.add(nEvalStat); + + // set the long name of this statistic which is the number of neighbor evaluation + copyEvalStat.setLongName("ngheval"); // add the solution into statistics this->add(copyEvalStat); diff --git a/mo/src/sampling/moHillClimberSampling.h b/mo/src/sampling/moHillClimberSampling.h index 7ca2fb538..d6bc45a28 100644 --- a/mo/src/sampling/moHillClimberSampling.h +++ b/mo/src/sampling/moHillClimberSampling.h @@ -84,6 +84,9 @@ public: // to count the number of step in the HC checkpoint.add(lengthStat); + // set the long name of this statistic which is the length of the walk + copyStat.setLongName("length"); + // add the solution into statistics this->add(solStat); } diff --git a/mo/src/sampling/moNeutralWalkSampling.h b/mo/src/sampling/moNeutralWalkSampling.h index 708f0ac14..0db5f6c06 100644 --- a/mo/src/sampling/moNeutralWalkSampling.h +++ b/mo/src/sampling/moNeutralWalkSampling.h @@ -47,6 +47,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -63,9 +66,12 @@ * Informations collected: * - the current solution of the walk * - the distance from the starting solution - * - the minimal fitness in the neighborhood * - the average fitness * - the standard deviation of the fitness + * - the minimal fitness in the neighborhood + * - the first quartile of fitness in the neighborhood + * - the median fitness in the neighborhood + * - the third quartile of fitness in the neighborhood * - the maximal fitness * - the size of the neighborhood * - the number of neighbors with lower fitness @@ -99,20 +105,26 @@ public: init(_initSol), distStat(_distance, _initSol), neighborhoodStat(_neighborhood, _eval), - minStat(neighborhoodStat), averageStat(neighborhoodStat), stdStat(neighborhoodStat), + minStat(neighborhoodStat), maxStat(neighborhoodStat), nbSupStat(neighborhoodStat), nbInfStat(neighborhoodStat), sizeStat(neighborhoodStat), - ndStat(neighborhoodStat) + ndStat(neighborhoodStat), + q1Stat(neighborhoodStat), + medianStat(neighborhoodStat), + q3Stat(neighborhoodStat) { this->add(neighborhoodStat, false); this->add(distStat); - this->add(minStat); this->add(averageStat); this->add(stdStat); + this->add(minStat); + this->add(q1Stat); + this->add(medianStat); + this->add(q3Stat); this->add(maxStat); this->add(sizeStat); this->add(nbInfStat); @@ -145,13 +157,19 @@ public: nbSupStat(neighborhoodStat), nbInfStat(neighborhoodStat), sizeStat(neighborhoodStat), - ndStat(neighborhoodStat) + ndStat(neighborhoodStat), + q1Stat(neighborhoodStat), + medianStat(neighborhoodStat), + q3Stat(neighborhoodStat) { this->add(neighborhoodStat, false); // this->add(distStat); - this->add(minStat); this->add(averageStat); this->add(stdStat); + this->add(minStat); + this->add(q1Stat); + this->add(medianStat); + this->add(q3Stat); this->add(maxStat); this->add(sizeStat); this->add(nbInfStat); @@ -182,6 +200,9 @@ protected: moNbInfNeighborStat< Neighbor > nbInfStat; moSizeNeighborStat< Neighbor > sizeStat; moNeutralDegreeNeighborStat< Neighbor > ndStat; + moQ1NeighborStat< Neighbor > q1Stat; + moMedianNeighborStat< Neighbor > medianStat; + moQ3NeighborStat< Neighbor > q3Stat; }; diff --git a/mo/src/sampling/moSampling.h b/mo/src/sampling/moSampling.h index b118b9d48..c2db1fa73 100644 --- a/mo/src/sampling/moSampling.h +++ b/mo/src/sampling/moSampling.h @@ -140,19 +140,20 @@ public: /** * to export the vectors of values into one file + * * @param _filename file name * @param _delim delimiter between statistics * @param _openFile to specify if it writes at the following of the file + * @param _header if true, print the headers which are the name of the statistic */ - void fileExport(std::string _filename, std::string _delim = " ", bool _openFile=false) { + void fileExport(std::string _filename, std::string _delim = " ", bool _openFile = false, bool _header = false) { // create file std::ofstream os; if(! _openFile) os.open(_filename.c_str()); - else - os.open(_filename.c_str(),std::ios::app); + os.open(_filename.c_str(), std::ios::app); if (!os) { std::string str = "moSampling: Could not open " + _filename; @@ -164,6 +165,16 @@ public: for (unsigned int j = 0; j < monitorVec.size(); j++) monitorVec[j]->precision(precisionOutput); + if (!_openFile && _header) { + os << monitorVec[0]->longName(); + + for (unsigned int j = 1; j < monitorVec.size(); j++) { + os << _delim.c_str() << monitorVec[j]->longName(); + } + + os << std::endl ; + } + // all vector have the same size unsigned vecSize = monitorVec[0]->size(); diff --git a/mo/test/t-moAdaptiveWalkSampling.cpp b/mo/test/t-moAdaptiveWalkSampling.cpp index 586624246..3bc232096 100755 --- a/mo/test/t-moAdaptiveWalkSampling.cpp +++ b/mo/test/t-moAdaptiveWalkSampling.cpp @@ -57,7 +57,7 @@ int main() { std::vector res; std::vector res2; - res = test.getValues(1); + res = test.getValues(2); res2= test.getSolutions(0); for (unsigned int i=0; i #include #include +#include +#include +#include +#include #include "moTestClass.h" @@ -85,6 +89,9 @@ int main() { assert(test.getMean()==6.6); double sd=test.getSD(); assert(sd>0.966 && sd<0.967); + assert(test.getMedian()==6); + assert(test.getQ1()==6); + assert(test.getQ3()==8); assert(test.getSize()==10); assert(test.getNbSup()==7); assert(test.getNbInf()==3); @@ -167,6 +174,40 @@ int main() { assert(test10.className()=="moStdFitnessNeighborStat"); std::cout << "[t-moStdFitnessNeighborStat] => OK" << std::endl; + //test of moQuartilesNeighborStat.h + std::cout << "[t-moQuartilesNeighborStat] => START" << std::endl; + moQuartilesNeighborStat test11(test); + test11.init(sol); + test11(sol); + assert(test11.value().first==6); + assert(test11.value().second==8); + assert(test11.className()=="moQuartilesNeighborStat"); + std::cout << "[t-moQuartilesNeighborStat] => OK" << std::endl; + + //test of moMedianNeighborStat.h + std::cout << "[t-moMedianNeighborStat] => START" << std::endl; + moMedianNeighborStat test12(test); + test12(sol); + assert(test12.value()==6); + assert(test12.className()=="moMedianNeighborStat"); + std::cout << "[t-moMedianNeighborStat] => OK" << std::endl; + + //test of moQ1NeighborStat.h + std::cout << "[t-moQ1NeighborStat] => START" << std::endl; + moQ1NeighborStat test13(test); + test13(sol); + assert(test13.value()==6); + assert(test13.className()=="moQ1NeighborStat"); + std::cout << "[t-moQ1NeighborStat] => OK" << std::endl; + + //test of moQ3NeighborStat.h + std::cout << "[t-moQ3NeighborStat] => START" << std::endl; + moQ3NeighborStat test14(test); + test14(sol); + assert(test14.value()==8); + assert(test14.className()=="moQ3NeighborStat"); + std::cout << "[t-moQ3NeighborStat] => OK" << std::endl; + return EXIT_SUCCESS; } From be231d9129164937e226c397950037a81d3a3cb2 Mon Sep 17 00:00:00 2001 From: verel Date: Tue, 28 Oct 2014 14:09:19 +0100 Subject: [PATCH 111/419] Correction eo/tutorial/Lesson3 --- eo/tutorial/Lesson3/SecondBitEA.cpp | 2 +- eo/tutorial/Lesson3/SecondRealEA.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eo/tutorial/Lesson3/SecondBitEA.cpp b/eo/tutorial/Lesson3/SecondBitEA.cpp index cb7ac9c9d..b604472ce 100644 --- a/eo/tutorial/Lesson3/SecondBitEA.cpp +++ b/eo/tutorial/Lesson3/SecondBitEA.cpp @@ -273,7 +273,7 @@ void main_function(int argc, char **argv) checkpoint.add(SecondStat); // The Stdout monitor will print parameters to the screen ... - eoStdoutMonitor monitor(false); + eoStdoutMonitor monitor; // when called by the checkpoint (i.e. at every generation) checkpoint.add(monitor); diff --git a/eo/tutorial/Lesson3/SecondRealEA.cpp b/eo/tutorial/Lesson3/SecondRealEA.cpp index 1116682f3..f74411be4 100644 --- a/eo/tutorial/Lesson3/SecondRealEA.cpp +++ b/eo/tutorial/Lesson3/SecondRealEA.cpp @@ -253,7 +253,7 @@ void main_function(int argc, char **argv) checkpoint.add(SecondStat); // The Stdout monitor will print parameters to the screen ... - eoStdoutMonitor monitor(false); + eoStdoutMonitor monitor; // when called by the checkpoint (i.e. at every generation) checkpoint.add(monitor); From eb8f1e99a9a951f924e67980bfd4674d49426efc Mon Sep 17 00:00:00 2001 From: verel Date: Sun, 9 Nov 2014 15:17:41 +0100 Subject: [PATCH 112/419] Add precision in the output of the eoValueParam.h --- eo/src/utils/eoFileMonitor.cpp | 3 +-- eo/src/utils/eoFileMonitor.h | 2 ++ eo/src/utils/eoParam.h | 15 +++++++++++++++ mo/src/explorer/moFirstImprHCexplorer.h | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/eo/src/utils/eoFileMonitor.cpp b/eo/src/utils/eoFileMonitor.cpp index 3cc96deb1..80b7afaff 100644 --- a/eo/src/utils/eoFileMonitor.cpp +++ b/eo/src/utils/eoFileMonitor.cpp @@ -67,13 +67,12 @@ eoMonitor& eoFileMonitor::operator()(void) printHeader(); firstcall = false; } - + return operator()(os); } eoMonitor& eoFileMonitor::operator()(std::ostream& os) { - iterator it = vec.begin(); os << (*it)->getValue(); diff --git a/eo/src/utils/eoFileMonitor.h b/eo/src/utils/eoFileMonitor.h index 9438d25c3..dcd48e4c4 100644 --- a/eo/src/utils/eoFileMonitor.h +++ b/eo/src/utils/eoFileMonitor.h @@ -96,6 +96,7 @@ public : virtual void printHeader(std::ostream& os); virtual std::string getFileName() { return filename;} + private : @@ -116,6 +117,7 @@ private : //! erase the entire file prior to writing in it (mode eos_base:: bool overwrite; + }; #endif diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index 948092c93..d6e794ca9 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -167,6 +167,8 @@ public : repValue(_defaultValue) { eoParam::defValue(getValue()); + // default precision + numOfDigits = std::cout.precision(); } /** Get a reference on the parameter value @@ -203,6 +205,7 @@ public : std::string getValue(void) const { std::ostringstream os; + os.precision(numOfDigits); os << repValue; return os.str(); } @@ -227,9 +230,21 @@ public : is >> repValue; } + /** + set the precision of the output + + @param _numOfDigits the precision of the output + */ + void setPrecision(unsigned _numOfDigits) { + numOfDigits = _numOfDigits; + } + protected: ValueType repValue; + + //! precision of the output + unsigned numOfDigits; }; /* diff --git a/mo/src/explorer/moFirstImprHCexplorer.h b/mo/src/explorer/moFirstImprHCexplorer.h index 8edf9f976..e341908d3 100644 --- a/mo/src/explorer/moFirstImprHCexplorer.h +++ b/mo/src/explorer/moFirstImprHCexplorer.h @@ -162,7 +162,7 @@ private: // true if the move is accepted bool isAccept ; - // if true the HC stop when to improving solution is found + // if true : the HC stop when no improving solution is found // if false : never stop, always continue (external continuator) bool stop ; }; From b151ca140d7032bff9cebfecac5145ad40de29f2 Mon Sep 17 00:00:00 2001 From: verel Date: Mon, 10 Nov 2014 15:58:56 +0100 Subject: [PATCH 113/419] Add incremental evaluation of NK landscape when several bits could be modified --- .../eval/moNKlandscapesBitsIncrEval.h | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 mo/src/problems/eval/moNKlandscapesBitsIncrEval.h diff --git a/mo/src/problems/eval/moNKlandscapesBitsIncrEval.h b/mo/src/problems/eval/moNKlandscapesBitsIncrEval.h new file mode 100644 index 000000000..c9a0ff0f3 --- /dev/null +++ b/mo/src/problems/eval/moNKlandscapesBitsIncrEval.h @@ -0,0 +1,146 @@ +/* + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Sebastien Verel, Arnaud Liefooghe, Jeremie 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 _moNKlandscapesBitsIncrEval_H +#define _moNKlandscapesBitsIncrEval_H + +#include +#include +#include + +/** + * + * Incremental evaluation function (1 bit flip, Hamming distance 1) + * for the NK-landscapes problem + * + * + */ +template< class Neighbor > +class moNKlandscapesBitsIncrEval : public moEval +{ +public: + typedef typename Neighbor::EOT EOT; + + /* + * Constructor + * + * @param _nk fitness function of the NK landscapes + */ + moNKlandscapesBitsIncrEval(nkLandscapesEval & _nk) : nk(_nk) { + inverseLinks = new std::vector[ nk.N ]; + + // compute the contributions which are modified by flipping one bit + for(unsigned int i = 0; i < nk.N; i++) + for(unsigned int j = 0; j < nk.K + 1; j++) { + inverseLinks[ nk.links[i][j] ].push_back(i); + } + } + + /* + * Destructor + * + */ + ~moNKlandscapesBitsIncrEval() { + delete [] inverseLinks; + } + + /* + * incremental evaluation of the neighbor for the oneMax problem + * @param _solution the solution to move (bit string) + * @param _neighbor the neighbor to consider (of type moBitNeigbor) + */ + virtual void operator()(EOT & _solution, Neighbor & _neighbor) { + unsigned int b; + + unsigned sig, nonSig; + unsigned i; + + double delta = 0 ; + + for(unsigned k = 0; k < _neighbor.nBits; k++) { + b = _neighbor.bits[k]; + + for(unsigned int j = 0; j < inverseLinks[b].size(); j++) { + i = inverseLinks[b][j]; + sigma(_solution, i, b, sig, nonSig); + delta += nk.tables[i][nonSig] - nk.tables[i][sig]; + } + + // move the solution on this bit + _solution[b] = !_solution[b]; + } + + // move back the solution + for(unsigned k = 0; k < _neighbor.nBits; k++) { + b = _neighbor.bits[k]; + _solution[b] = !_solution[b]; + } + //std::cout << delta << std::endl; + + _neighbor.fitness(_solution.fitness() + delta / (double) nk.N); + } + +private: + // Original nk fitness function + nkLandscapesEval & nk; + + // give the list of contributions which are modified when the corresponding bit is flipped + std::vector * inverseLinks; + + /** + * Compute the mask of the linked bits, and the mask when the bit is flipped + * + * @param _solution the solution to evaluate + * @param i the bit of the contribution + * @param _bit the bit to flip + * @param sig value of the mask of contribution i + * @param nonSig value of the mask of contribution i when the bit _bit is flipped + */ + void sigma(EOT & _solution, int i, unsigned _bit, unsigned & sig, unsigned & nonSig) { + sig = 0; + nonSig = 0; + + unsigned int n = 1; + for(int j = 0; j < nk.K + 1; j++) { + if (_solution[ nk.links[i][j] ] == 1) + sig = sig | n; + + if (nk.links[i][j] == _bit) + nonSig = n; + + n = n << 1; + } + + nonSig = sig ^ nonSig; + } + +}; + +#endif + From bf7f395115d1e4fa04cebd979386ec37b100d899 Mon Sep 17 00:00:00 2001 From: Arnaud Liefooghe Date: Wed, 19 Nov 2014 09:39:10 +0100 Subject: [PATCH 114/419] SPEA2 archive internal comparator updated on how to order ties in order to avoid some segfault with some compilers --- moeo/src/archive/moeoSPEA2Archive.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moeo/src/archive/moeoSPEA2Archive.h b/moeo/src/archive/moeoSPEA2Archive.h index f7ea9927d..f5b60e63f 100644 --- a/moeo/src/archive/moeoSPEA2Archive.h +++ b/moeo/src/archive/moeoSPEA2Archive.h @@ -364,7 +364,7 @@ private: it1++; it2++; } - return true; + return false; } }; From dbb8fbe9a786efd4d1c26408ac1883442e7643a6 Mon Sep 17 00:00:00 2001 From: verel Date: Wed, 31 Dec 2014 10:36:20 +0100 Subject: [PATCH 115/419] Correction of the bug in the constructor of eoValueParam l170: numOfDigits is set before reading the value with getValue(). --- eo/src/utils/eoParam.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index d6e794ca9..e3a09f215 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -166,9 +166,9 @@ public : : eoParam(_longName, "", _description, _shortHand, _required), repValue(_defaultValue) { - eoParam::defValue(getValue()); // default precision numOfDigits = std::cout.precision(); + eoParam::defValue(getValue()); } /** Get a reference on the parameter value From c9475c4ed064e856381e68636bbb916526b38b1b Mon Sep 17 00:00:00 2001 From: verel Date: Tue, 9 Jun 2015 11:08:41 +0200 Subject: [PATCH 116/419] Update type of elements in QAP eval and QAP incrEval --- mo/src/continuator/moVectorMonitor.h | 46 ++++++++++++++++++++++------ mo/src/problems/eval/moQAPIncrEval.h | 12 +++++--- problems/eval/nkLandscapesEval.h | 24 ++++++++++----- problems/eval/nkpLandscapesEval.h | 3 ++ problems/eval/nkqLandscapesEval.h | 3 ++ problems/eval/qapEval.h | 23 ++++++++------ 6 files changed, 79 insertions(+), 32 deletions(-) diff --git a/mo/src/continuator/moVectorMonitor.h b/mo/src/continuator/moVectorMonitor.h index cd2b6c4e0..853096448 100644 --- a/mo/src/continuator/moVectorMonitor.h +++ b/mo/src/continuator/moVectorMonitor.h @@ -53,7 +53,7 @@ public: * Constructor * @param _param the parameter of type double to save in the vector */ - moVectorMonitor(eoValueParam & _param) : doubleParam(&_param), intParam(NULL), intLongParam(NULL), eotParam(NULL) + moVectorMonitor(eoValueParam & _param) : doubleParam(&_param), intParam(NULL), intLongParam(NULL), intLongLongParam(NULL), eotParam(NULL) { // precision of the output by default precisionOutput = std::cout.precision(); @@ -63,7 +63,7 @@ public: * Default Constructor * @param _param the parameter of type unsigned int to save in the vector */ - moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(&_param), intLongParam(NULL), eotParam(NULL) + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(&_param), intLongParam(NULL), intLongLongParam(NULL), eotParam(NULL) { // precision of the output by default precisionOutput = std::cout.precision(); @@ -73,7 +73,17 @@ public: * Default Constructor * @param _param the parameter of type unsigned int to save in the vector */ - moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(&_param), eotParam(NULL) + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(&_param), intLongLongParam(NULL), eotParam(NULL) + { + // precision of the output by default + precisionOutput = std::cout.precision(); + } + + /** + * Default Constructor + * @param _param the parameter of type unsigned int to save in the vector + */ + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(NULL), intLongLongParam(&_param), eotParam(NULL) { // precision of the output by default precisionOutput = std::cout.precision(); @@ -83,7 +93,18 @@ public: * Default Constructor * @param _param the parameter of type EOT to save in the vector */ - moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(NULL), eotParam(&_param) + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(NULL), intLongLongParam(NULL), eotParam(&_param) + { + // precision of the output by default + precisionOutput = std::cout.precision(); + } + + /** + * Default Constructor + * @param _param the parameter of type eoScalarFitness to save in the vector + */ + template + moVectorMonitor(eoValueParam > & _param) : doubleParam(NULL), intParam(NULL), intLongParam(NULL), intLongLongParam(& (eoValueParam&)_param), eotParam(NULL) { // precision of the output by default precisionOutput = std::cout.precision(); @@ -94,7 +115,7 @@ public: * @param _param the parameter of type eoScalarFitness to save in the vector */ template - moVectorMonitor(eoValueParam > & _param) : doubleParam( & (eoValueParam&)_param), intParam(NULL), intLongParam(NULL), eotParam(NULL) + moVectorMonitor(eoValueParam > & _param) : doubleParam( & (eoValueParam&)_param), intParam(NULL), intLongParam(NULL), intLongLongParam(NULL), eotParam(NULL) { // precision of the output by default precisionOutput = std::cout.precision(); @@ -105,7 +126,7 @@ public: * @param _param unvalid Parameter */ template - moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(NULL), eotParam(NULL) + moVectorMonitor(eoValueParam & _param) : doubleParam(NULL), intParam(NULL), intLongParam(NULL), intLongLongParam(NULL), eotParam(NULL) { std::cerr << "Sorry the type can not be in a vector of moVectorMonitor" << std::endl; } @@ -133,8 +154,11 @@ public: else if (intLongParam != NULL) valueVec.push_back((double) intLongParam->value()); - else - eotVec.push_back(eotParam->value()); + else + if (intLongLongParam != NULL) + valueVec.push_back((double) intLongLongParam->value()); + else + eotVec.push_back(eotParam->value()); return *this ; } @@ -189,7 +213,10 @@ public: if (intLongParam != NULL) return intLongParam->longName(); else - return eotParam->longName(); + if (intLongLongParam != NULL) + return intLongLongParam->longName(); + else + return eotParam->longName(); } /** @@ -259,6 +286,7 @@ protected: eoValueParam * doubleParam ; eoValueParam * intParam ; eoValueParam * intLongParam ; + eoValueParam * intLongLongParam ; eoValueParam * eotParam ; std::vector valueVec; diff --git a/mo/src/problems/eval/moQAPIncrEval.h b/mo/src/problems/eval/moQAPIncrEval.h index 5c47623d9..16494e4b0 100644 --- a/mo/src/problems/eval/moQAPIncrEval.h +++ b/mo/src/problems/eval/moQAPIncrEval.h @@ -35,8 +35,10 @@ Contact: paradiseo-help@lists.gforge.inria.fr /** * Incremental evaluation Function for the QAP problem + * + * ElemType is the type of elements in the matrix. This type must be signed and not unsigned. */ -template< class Neighbor > +template< class Neighbor, typename ElemType = long int > class moQAPIncrEval : public moEval { public: @@ -46,7 +48,7 @@ public: * default constructor * @param _qapEval full evaluation of the QAP problem */ - moQAPIncrEval(QAPeval & _qapEval) { + moQAPIncrEval(QAPeval & _qapEval) { n = _qapEval.getNbVar(); A = _qapEval.getA(); B = _qapEval.getB(); @@ -58,7 +60,7 @@ public: * @param _neighbor the neighbor to consider (of type moSwapNeigbor) */ virtual void operator()(EOT & _solution, Neighbor & _neighbor) { - int d; + ElemType d; int k; unsigned i = _neighbor.first(); @@ -81,10 +83,10 @@ private: int n; // matrix A - int ** A; + ElemType ** A; // matrix B - int ** B; + ElemType ** B; }; diff --git a/problems/eval/nkLandscapesEval.h b/problems/eval/nkLandscapesEval.h index 070fb1b43..f2e243021 100644 --- a/problems/eval/nkLandscapesEval.h +++ b/problems/eval/nkLandscapesEval.h @@ -71,6 +71,8 @@ public: consecutiveTables(); else randomTables(); + + generateTables(); }; /** @@ -365,6 +367,20 @@ protected: } } + /** + * To generate the tables: + * The component function is random + * each contribution is independent from the others ones + * and drawn from the distribution given by contribution() + * + */ + virtual void generateTables() { + for(int i = 0; i < N; i++) { + for(int j = 0; j < (1<<(K+1)); j++) + tables[i][j] = contribution(); + } + } + /** * To generate a contribution in the table f_i * @@ -386,10 +402,6 @@ protected: for(int i = 0; i < N; i++) { // random links to the bit choose(i, tabTirage); - - // table of contribution with random numbers from [0,1) - for(int j = 0; j < (1<<(K+1)); j++) - tables[i][j] = contribution(); } } @@ -403,10 +415,6 @@ protected: for(int i = 0; i < N; i++) { // consecutive link to bit i consecutiveLinks(i); - - // table of contribution with random numbers from [0,1) - for(int j = 0; j < (1<<(K+1)); j++) - tables[i][j] = contribution(); } } diff --git a/problems/eval/nkpLandscapesEval.h b/problems/eval/nkpLandscapesEval.h index 9be4f47e2..5f2a5e932 100644 --- a/problems/eval/nkpLandscapesEval.h +++ b/problems/eval/nkpLandscapesEval.h @@ -53,6 +53,7 @@ public: using nkLandscapesEval::loadTables; using nkLandscapesEval::consecutiveTables; using nkLandscapesEval::randomTables; + using nkLandscapesEval::generateTables; // parameter p : probability to have the contribution to zero, otherwise random number from [0,1) double p; @@ -79,6 +80,8 @@ public: consecutiveTables(); else randomTables(); + + generateTables(); } /** diff --git a/problems/eval/nkqLandscapesEval.h b/problems/eval/nkqLandscapesEval.h index 720143566..d40bf3955 100644 --- a/problems/eval/nkqLandscapesEval.h +++ b/problems/eval/nkqLandscapesEval.h @@ -53,6 +53,7 @@ public: using nkLandscapesEval::loadTables; using nkLandscapesEval::consecutiveTables; using nkLandscapesEval::randomTables; + using nkLandscapesEval::generateTables; // parameter q : number of different integer values in the table: [0..q[ unsigned q; @@ -78,6 +79,8 @@ public: consecutiveTables(); else randomTables(); + + generateTables(); } /** diff --git a/problems/eval/qapEval.h b/problems/eval/qapEval.h index 3236dae60..40d763c9f 100644 --- a/problems/eval/qapEval.h +++ b/problems/eval/qapEval.h @@ -34,11 +34,14 @@ Contact: paradiseo-help@lists.gforge.inria.fr /** * Full evaluation Function for QAP problem + * + * ElemType is the type of elements in the matrix. This type must be signed and not unsigned. */ -template< class EOT > +template< class EOT, typename ElemType = long int > class QAPeval : public eoEvalFunc { public: + //typedef typename EOT::Fitness ElemType ; /* * Constructor from instance file @@ -56,18 +59,18 @@ public: unsigned i, j; file >> n; - A = new int *[n]; - B = new int *[n]; + A = new ElemType *[n]; + B = new ElemType *[n]; for(i = 0; i < n; i++) { - A[i] = new int[n]; + A[i] = new ElemType[n]; for(j = 0; j < n; j++) { file >> A[i][j]; } } for(i = 0; i < n; i++) { - B[i] = new int[n]; + B[i] = new ElemType[n]; for(j = 0; j < n; j++) file >> B[i][j]; } @@ -100,7 +103,7 @@ public: * @param _solution the solution to evaluate */ void operator()(EOT & _solution) { - int cost = 0; + ElemType cost = 0; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) @@ -114,7 +117,7 @@ public: * * @return matrix A */ - int** getA() { + ElemType** getA() { return A; } @@ -123,7 +126,7 @@ public: * * @return matrix B */ - int** getB() { + ElemType** getB() { return B; } @@ -141,10 +144,10 @@ private: int n; // matrix A - int ** A; + ElemType ** A; // matrix B - int ** B; + ElemType ** B; }; From c0bf207fc17632814d9f0ca864f193f055d35a0e Mon Sep 17 00:00:00 2001 From: Arnaud Liefooghe Date: Tue, 19 Apr 2016 17:34:39 +0200 Subject: [PATCH 117/419] diversity assignment corrected in moeoFrontByFrontCrowdingDiversityAssignment.h --- ...oFrontByFrontCrowdingDiversityAssignment.h | 217 +++++++++--------- 1 file changed, 111 insertions(+), 106 deletions(-) diff --git a/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h b/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h index c4909d504..c90a7ac91 100644 --- a/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h +++ b/moeo/src/diversity/moeoFrontByFrontCrowdingDiversityAssignment.h @@ -1,38 +1,40 @@ /* -* -* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2009 -* (C) OPAC Team, LIFL, 2002-2009 -* -* Arnaud Liefooghe, Waldo Cancino -* -* This software is governed by the CeCILL license under French law and -* abiding by the rules of distribution of free software. You can use, -* 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". -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited liability. -* -* 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 -* -*/ + * + * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2009 + * (C) OPAC Team, LIFL, 2002-2009 + * + * Arnaud Liefooghe, Waldo Cancino + * + * April 2016: Bug fix in the sorting of population (corrected thanks to Martin Stehlik) + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * 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". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited liability. + * + * 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 MOEOFRONTBYFRONTCROWDINGDIVERSITYASSIGNMENT2_H_ @@ -50,13 +52,13 @@ */ template < class MOEOT > class moeoFrontByFrontCrowdingDiversityAssignment : public moeoCrowdingDiversityAssignment < MOEOT > - { - public: - +{ +public: + /** the objective vector type of the solutions */ typedef typename MOEOT::ObjectiveVector ObjectiveVector; - - + + /** * @warning NOT IMPLEMENTED, DO NOTHING ! * Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account. @@ -66,110 +68,113 @@ class moeoFrontByFrontCrowdingDiversityAssignment : public moeoCrowdingDiversity */ void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) { - std::cout << "WARNING : updateByDeleting not implemented in moeoFrontByFrontCrowdingDistanceDiversityAssignment" << std::endl; + std::cout << "WARNING : updateByDeleting not implemented in moeoFrontByFrontCrowdingDistanceDiversityAssignment" << std::endl; } - - private: - + +private: + using moeoCrowdingDiversityAssignment < MOEOT >::inf; using moeoCrowdingDiversityAssignment < MOEOT >::tiny; - + /** * Sets the distance values * @param _pop the population */ - + void setDistances (eoPop & _pop) { - unsigned int a,b; - double min, max, distance; - unsigned int nObjectives = MOEOT::ObjectiveVector::nObjectives(); - // set diversity to 0 for every individual - for (unsigned int i=0; i<_pop.size(); i++) + unsigned int a,b; + double min, max, distance; + unsigned int nObjectives = MOEOT::ObjectiveVector::nObjectives(); + // set diversity to 0 for every individual + for (unsigned int i=0; i<_pop.size(); i++) { - _pop[i].diversity(0.0); + _pop[i].diversity(0.0); } - // sort the whole pop according to fitness values - moeoFitnessThenDiversityComparator < MOEOT > fitnessComparator; - std::vector sortedptrpop; - sortedptrpop.resize(_pop.size()); - // due to intensive sort operations for this diversity assignment, - // it is more efficient to perform sorts using only pointers to the - // population members in order to avoid copy of individuals - for(unsigned int i=0; i< _pop.size(); i++) sortedptrpop[i] = & (_pop[i]); - //sort the pointers to population members - moeoPtrComparator cmp2( fitnessComparator); - std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp2); - // compute the crowding distance values for every individual "front" by "front" (front : from a to b) - a = 0; // the front starts at a - while (a < _pop.size()) + // sort the whole pop according to fitness values + moeoFitnessThenDiversityComparator < MOEOT > fitnessComparator; + std::vector sortedptrpop; + sortedptrpop.resize(_pop.size()); + // due to intensive sort operations for this diversity assignment, + // it is more efficient to perform sorts using only pointers to the + // population members in order to avoid copy of individuals + for(unsigned int i=0; i< _pop.size(); i++) sortedptrpop[i] = & (_pop[i]); + //sort the pointers to population members + moeoPtrComparator cmp2( fitnessComparator); + std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp2); + // compute the crowding distance values for every individual "front" by "front" (front : from a to b) + a = 0; // the front starts at a + while (a < _pop.size()) { - b = lastIndex(sortedptrpop,a); // the front ends at b - //b = lastIndex(_pop,a); // the front ends at b - // if there is less than 2 individuals in the front... - if ((b-a) < 2) + b = lastIndex(sortedptrpop,a); // the front ends at b + //b = lastIndex(_pop,a); // the front ends at b + // if there is less than 2 individuals in the front... + if ((b-a) < 2) { - for (unsigned int i=a; i<=b; i++) + for (unsigned int i=a; i<=b; i++) { - sortedptrpop[i]->diversity(inf()); - //_pop[i].diversity(inf()); + sortedptrpop[i]->diversity(inf()); + //_pop[i].diversity(inf()); } } - // else... - else + // else... + else { - // for each objective - for (unsigned int obj=0; obj objComp(obj); - moeoPtrComparator cmp2( objComp ); - std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp2); - // min & max - min = (sortedptrpop[b])->objectiveVector()[obj]; - max = (sortedptrpop[a])->objectiveVector()[obj]; - - // avoid extreme case - if (min == max) + // sort in the descending order using the values of the objective 'obj' + moeoOneObjectiveComparator < MOEOT > objComp(obj); + moeoPtrComparator cmp2( objComp ); + // erroneous part + // std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp2); + // correct version + std::sort(sortedptrpop.begin()+a, sortedptrpop.begin()+b+1, cmp2); + // min & max + min = (sortedptrpop[b])->objectiveVector()[obj]; + max = (sortedptrpop[a])->objectiveVector()[obj]; + + // avoid extreme case + if (min == max) { - min -= tiny(); - max += tiny(); + min -= tiny(); + max += tiny(); } - // set the diversity value to infiny for min and max - sortedptrpop[a]->diversity(inf()); - sortedptrpop[b]->diversity(inf()); - // set the diversity values for the other individuals - for (unsigned int i=a+1; idiversity(inf()); + sortedptrpop[b]->diversity(inf()); + // set the diversity values for the other individuals + for (unsigned int i=a+1; iobjectiveVector()[obj] - sortedptrpop[i+1]->objectiveVector()[obj] ) / (max-min); sortedptrpop[i]->diversity(sortedptrpop[i]->diversity() + distance); } } } - // go to the next front - a = b+1; + // go to the next front + a = b+1; } } - - - + + + /** * Returns the index of the last individual having the same fitness value than _pop[_start] * @param _pop the vector of pointers to population individuals * @param _start the index to start from */ - + unsigned int lastIndex (std::vector & _pop, unsigned int _start) { - unsigned int i=_start; - while ( (i<_pop.size()-1) && (_pop[i]->fitness()==_pop[i+1]->fitness()) ) + unsigned int i=_start; + while ( (i<_pop.size()-1) && (_pop[i]->fitness()==_pop[i+1]->fitness()) ) { - i++; + i++; } - return i; + return i; } - - - }; + + +}; #endif /*MOEOFRONTBYFRONTCROWDINGDIVERSITYASSIGNMENT_H_*/ From fc4a398459d4e1f17a6391568b3e77612d3e3a84 Mon Sep 17 00:00:00 2001 From: SV Date: Wed, 18 May 2016 11:55:56 +0200 Subject: [PATCH 118/419] comment for the include of moNKlandscapesIncrEval in mo.h --- mo/src/mo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mo/src/mo.h b/mo/src/mo.h index 2ba411388..8a6343aeb 100755 --- a/mo/src/mo.h +++ b/mo/src/mo.h @@ -190,7 +190,7 @@ //#include //#include //#include -#include +//#include #include From ee71ea24779f06fba1db895255e1e17082344bb7 Mon Sep 17 00:00:00 2001 From: Arnaud Liefooghe Date: Thu, 7 Jul 2016 11:28:07 +0200 Subject: [PATCH 119/419] minor update on permutation hoods --- .../permutation/moIndexedSwapNeighbor.h | 19 ++++++++++--------- mo/src/problems/permutation/moShiftNeighbor.h | 8 ++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/mo/src/problems/permutation/moIndexedSwapNeighbor.h b/mo/src/problems/permutation/moIndexedSwapNeighbor.h index d3ddababf..4706305f6 100644 --- a/mo/src/problems/permutation/moIndexedSwapNeighbor.h +++ b/mo/src/problems/permutation/moIndexedSwapNeighbor.h @@ -37,13 +37,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr * Indexed Swap Neighbor: the position of the swap are computed according to the index */ template -class moIndexedSwapNeighbor: public moBackableNeighbor, public moIndexNeighbor +class moIndexedSwapNeighbor: public moBackableNeighbor, public moIndexNeighbor { public: - using moBackableNeighbor::fitness; - using moIndexNeighbor::key; - using moIndexNeighbor::index; + using moBackableNeighbor::fitness; + using moIndexNeighbor::key; + using moIndexNeighbor::index; /** * Default Constructor @@ -78,11 +78,12 @@ public: */ virtual void move(EOT& _solution) { // bof utiliser plutot le template du vector : to do - EOT tmp(1); - - tmp[0] = _solution[indices.first]; - _solution[indices.first] = _solution[indices.second]; - _solution[indices.second] = tmp[0]; +// EOT tmp(1); +// +// tmp[0] = _solution[indices.first]; +// _solution[indices.first] = _solution[indices.second]; +// _solution[indices.second] = tmp[0]; + std::swap(_solution[indices.first], _solution[indices.second]); _solution.invalidate(); } diff --git a/mo/src/problems/permutation/moShiftNeighbor.h b/mo/src/problems/permutation/moShiftNeighbor.h index 87dfb9265..13eba1849 100644 --- a/mo/src/problems/permutation/moShiftNeighbor.h +++ b/mo/src/problems/permutation/moShiftNeighbor.h @@ -151,6 +151,14 @@ public: void print() { std::cout << key << ": [" << indices.first << ", " << indices.second << "] -> " << (*this).fitness() << std::endl; } + + /** + * Return the class Name + * @return the class name as a std::string + */ + virtual std::string className() const { + return "moShiftNeighbor"; + } private: std::pair indices; From a71a273a153ef30598f7f31e9b55a83d4fd0abcb Mon Sep 17 00:00:00 2001 From: Mammar AMARA Date: Mon, 17 Apr 2017 23:46:53 +0200 Subject: [PATCH 120/419] add new class fuzzy distance --- moeo/src/distance/BertDistance.h | 95 ++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 moeo/src/distance/BertDistance.h diff --git a/moeo/src/distance/BertDistance.h b/moeo/src/distance/BertDistance.h new file mode 100644 index 000000000..949c66d8c --- /dev/null +++ b/moeo/src/distance/BertDistance.h @@ -0,0 +1,95 @@ +/* + + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- + +#ifndef BERTDISTANCE_H_ +#define BERTDISTANCE_H_ + +#include +#include +#include "ObjectiveVectorNormalizer.h" + +/** + * A class allowing to compute an Bert distance between two fuzzy solutions in the objective space + with normalized objective values (i.e. between 0 and 1). + * A distance value then lies between 0 and sqrt(nObjectives). + */ +template < class MOEOT> +class BertDistance : public moeoObjSpaceDistance < MOEOT > + { + public: + + /** the objective vector type of the solutions */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + /** the fitness type of the solutions */ + typedef typename MOEOT::Fitness Fitness; + + /** + default ctr + */ + /* BertDistance () + {}*/ + /** + ctr with a normalizer + @param _normalizer the normalizer used for every ObjectiveVector + */ + /** + default ctr + */ + BertDistance ():normalizer(defaultNormalizer) + {} + + + double calculateBertDistance(std::triple A, std::triple B) + { + double midA = 0.5 * (A.first + A.third); + double midB = 0.5 * (B.first + B.third); + double sprA = 0.5 * (A.first - A.third); + double sprB = 0.5 * (B.first - B.third); + + double theta = 0.5; + + return sqrt((midA -midB) * (midA -midB) + theta * (sprA - sprB) * (sprA - sprB)); + } + + + /** + * tmp1 and tmp2 take the Expected values of Objective vectors + * Returns the Bert distance between _obj1 and _obj2 in the objective space + * @param _obj1 the first objective vector + * @param _obj2 the second objective vector + */ +const Fitness operator()(const ObjectiveVector & _obj1, const ObjectiveVector & _obj2) + { + vector v_BD; + double dist=0.0; + + for (unsigned int i=0; i Normalizer; + + + + }; + +#endif /*BERTDISTANCE_H_*/ From 286dd256deb6ea29b2cf9acc5a1e43b7e3767090 Mon Sep 17 00:00:00 2001 From: bahri Date: Wed, 26 Apr 2017 11:36:00 +0200 Subject: [PATCH 121/419] Correct the last commit of Fuzzy distance --- moeo/src/distance/moeoBertDistance.h | 95 ++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 moeo/src/distance/moeoBertDistance.h diff --git a/moeo/src/distance/moeoBertDistance.h b/moeo/src/distance/moeoBertDistance.h new file mode 100644 index 000000000..5d2d60e4c --- /dev/null +++ b/moeo/src/distance/moeoBertDistance.h @@ -0,0 +1,95 @@ +/* + + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEOBERTDISTANCE_H_ +#define MOEOBERTDISTANCE_H_ + +#include +#include +#include "ObjectiveVectorNormalizer.h" + +/** + * A class allowing to compute an Bert distance between two fuzzy solutions in the objective space + with normalized objective values (i.e. between 0 and 1). + * A distance value then lies between 0 and sqrt(nObjectives). + */ +template < class MOEOT> +class moeoBertDistance : public moeoObjSpaceDistance < MOEOT > + { + public: + + /** the objective vector type of the solutions */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + /** the fitness type of the solutions */ + typedef typename MOEOT::Fitness Fitness; + + /** + default ctr + */ + /* moeoBertDistance () + {}*/ + /** + ctr with a normalizer + @param _normalizer the normalizer used for every ObjectiveVector + */ + /** + default ctr + */ + moeoBertDistance ():normalizer(defaultNormalizer) + {} + + + double calculateBertDistance(std::triple A, std::triple B) + { + double midA = 0.5 * (A.first + A.third); + double midB = 0.5 * (B.first + B.third); + double sprA = 0.5 * (A.first - A.third); + double sprB = 0.5 * (B.first - B.third); + + double theta = 0.5; + + return sqrt((midA -midB) * (midA -midB) + theta * (sprA - sprB) * (sprA - sprB)); + } + + + /** + * tmp1 and tmp2 take the Expected values of Objective vectors + * Returns the Bert distance between _obj1 and _obj2 in the objective space + * @param _obj1 the first objective vector + * @param _obj2 the second objective vector + */ +const Fitness operator()(const ObjectiveVector & _obj1, const ObjectiveVector & _obj2) + { + vector v_BD; + double dist=0.0; + + for (unsigned int i=0; i Normalizer; + + + + }; + +#endif /*MOEOBERTDISTANCE_H_*/ From bc686f70236010fd879bafcebb22eea7ac110646 Mon Sep 17 00:00:00 2001 From: bahri Date: Wed, 3 May 2017 13:34:39 +0200 Subject: [PATCH 122/419] Fuzzy Extension of some classical concepts --- moeo/src/algo/moeoExtendedNSGAII.h | 137 +++++++++++++ moeo/src/algo/moeoExtendedSPEA2.h | 156 ++++++++++++++ moeo/src/archive/moeoFuzzyArchive.h | 194 ++++++++++++++++++ .../comparator/moeoFuzzyParetoComparator.h | 118 +++++++++++ moeo/src/core/moeoFuzzyRealObjectiveVector.h | 125 +++++++++++ moeo/src/distance/BertDistance.h | 95 --------- moeo/src/distance/moeoBertDistance.h | 9 +- moeo/src/distance/moeoExpectedFuzzyDistance.h | 66 ++++++ .../diversity/moeoFuzzyCrowdingDiversity.h | 152 ++++++++++++++ .../moeoFuzzyNearestNeighborDiversity.h | 116 +++++++++++ .../moeoFuzzyObjectiveVectorNormalizer.h | 75 +++++++ 11 files changed, 1143 insertions(+), 100 deletions(-) create mode 100644 moeo/src/algo/moeoExtendedNSGAII.h create mode 100644 moeo/src/algo/moeoExtendedSPEA2.h create mode 100644 moeo/src/archive/moeoFuzzyArchive.h create mode 100644 moeo/src/comparator/moeoFuzzyParetoComparator.h create mode 100644 moeo/src/core/moeoFuzzyRealObjectiveVector.h delete mode 100644 moeo/src/distance/BertDistance.h create mode 100644 moeo/src/distance/moeoExpectedFuzzyDistance.h create mode 100644 moeo/src/diversity/moeoFuzzyCrowdingDiversity.h create mode 100644 moeo/src/diversity/moeoFuzzyNearestNeighborDiversity.h create mode 100644 moeo/src/utils/moeoFuzzyObjectiveVectorNormalizer.h diff --git a/moeo/src/algo/moeoExtendedNSGAII.h b/moeo/src/algo/moeoExtendedNSGAII.h new file mode 100644 index 000000000..768ad4d62 --- /dev/null +++ b/moeo/src/algo/moeoExtendedNSGAII.h @@ -0,0 +1,137 @@ +/* + + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEOEXTENDEDNSGAII_H_ +#define MOEOEXTENDEDNSGAII_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +/** + * Extended NSGAII is an extension of classical algorithm NSGAII for incorporating the aspect of fuzziness in diversity assignement + */ +template < class MOEOT > +class moeoExtendedNSGAII: public moeoEA < MOEOT > +{ +public: + + + /** + * Ctor with a eoContinue, a eoPopEval and a eoGenOp. + * @param _continuator stopping criteria + * @param _popEval population evaluation function + * @param _op variation operators + */ + moeoExtendedNSGAII (eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoGenOp < MOEOT > & _op) : + defaultGenContinuator(0), continuator(_continuator), eval(defaultEval), defaultPopEval(eval), popEval(_popEval), select(2), + selectMany(select,0.0), selectTransform(defaultSelect, defaultTransform), defaultSGAGenOp(defaultQuadOp, 1.0, defaultMonOp, 1.0), + enBreed(select, _op), breed(genBreed), replace (fitnessAssignment, diversityAssignment) + {} + + + + /** + * Apply a the algorithm to the population _pop until the stopping criteria is satified. + * @param _pop the population + */ + virtual void operator () (eoPop < MOEOT > &_pop) + { + eoPop < MOEOT > offspring, empty_pop; + popEval (empty_pop, _pop); // a first eval of _pop + // evaluate fitness and diversity + fitnessAssignment(_pop); + diversityAssignment(_pop); + do + { + // generate offspring, worths are recalculated if necessary + breed (_pop, offspring); + // eval of offspring + popEval (_pop, offspring); + // after replace, the new pop is in _pop. Worths are recalculated if necessary + replace (_pop, offspring); + } + while (continuator (_pop)); + } + + +protected: + + /** a continuator based on the number of generations (used as default) */ + eoGenContinue < MOEOT > defaultGenContinuator; + /** stopping criteria */ + eoContinue < MOEOT > & continuator; + /** default eval */ + class DummyEval : public eoEvalFunc < MOEOT > + { + public: + void operator()(MOEOT &) {} + } + defaultEval; + /** evaluation function */ + eoEvalFunc < MOEOT > & eval; + /** default popEval */ + eoPopLoopEval < MOEOT > defaultPopEval; + /** evaluation function used to evaluate the whole population */ + eoPopEvalFunc < MOEOT > & popEval; + /** default select */ + class DummySelect : public eoSelect < MOEOT > + { + public : + void operator()(const eoPop&, eoPop&) {} + } + defaultSelect; + /** binary tournament selection */ + moeoDetTournamentSelect < MOEOT > select; + /** default select many */ + eoSelectMany < MOEOT > selectMany; + /** select transform */ + eoSelectTransform < MOEOT > selectTransform; + /** a default crossover */ + eoQuadCloneOp < MOEOT > defaultQuadOp; + /** a default mutation */ + eoMonCloneOp < MOEOT > defaultMonOp; + /** an object for genetic operators (used as default) */ + eoSGAGenOp < MOEOT > defaultSGAGenOp; + /** default transform */ + class DummyTransform : public eoTransform < MOEOT > + { + public : + void operator()(eoPop&) {} + } + defaultTransform; + /** general breeder */ + eoGeneralBreeder < MOEOT > genBreed; + /** breeder */ + eoBreed < MOEOT > & breed; + /** fitness assignment*/ + FitnessAssignment < MOEOT > fitnessAssignment; + /** diversity assignment */ + moeoFuzzyCrowdingDiversity < MOEOT > diversityAssignment; + /** elitist replacement */ + ElitistReplacement < MOEOT > replace; + +}; + +#endif /*MOEOEXTENDEDNSGAII_H_*/ diff --git a/moeo/src/algo/moeoExtendedSPEA2.h b/moeo/src/algo/moeoExtendedSPEA2.h new file mode 100644 index 000000000..44a999a3e --- /dev/null +++ b/moeo/src/algo/moeoExtendedSPEA2.h @@ -0,0 +1,156 @@ +/* + + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEOEXTENDEDSPEA2_H_ +#define MOEOEXTENDEDSPEA2_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/** + * Extended SPEA2 is an extension of classical algorithm SPEA2 for incorporating the aspect of fuzziness in diversity assignment + */ +template < class MOEOT > +class moeoExtendedSPEA2: public moeoEA < MOEOT > +{ +public: + + /** + * Ctor with a crossover, a mutation and their corresponding rates. + * @param _maxGen number of generations before stopping + * @param _eval evaluation function + * @param _crossover crossover + * @param _pCross crossover probability + * @param _mutation mutation + * @param _pMut mutation probability + * @param _archive archive + * @param _k the k-ieme distance used to fixe diversity + * @param _nocopy boolean allow to consider copies and doublons as bad elements whose were dominated by all other MOEOT in fitness assignment. + */ + moeoExtendedSPEA2 (unsigned int _maxGen, eoEvalFunc < MOEOT > & _eval, eoQuadOp < MOEOT > & _crossover, + double _pCross, eoMonOp < MOEOT > & _mutation, double _pMut, moeoFuzzyArchive < MOEOT >& _archive, + unsigned int _k=1, bool _nocopy=false) : + defaultGenContinuator(_maxGen), continuator(defaultGenContinuator), eval(_eval), loopEval(_eval), + popEval(loopEval), archive(_archive),defaultSelect(2),select(defaultSelect, defaultSelect, _archive, 0.0), + defaultSGAGenOp(_crossover, _pCross, _mutation, _pMut), fitnessAssignment(_archive, _nocopy), + genBreed(defaultSelect, defaultSGAGenOp),selectMany(defaultSelect,0.0), selectTransform(selectMany, dummyTransform), + breed(genBreed), FuzzydiversityAssignment(dist,_archive, _k) + {} + + + + /** + * Apply a few generation of evolution to the population _pop until the stopping criteria is verified. + * @param _pop the population + */ + virtual void operator () (eoPop < MOEOT > &_pop) + { + eoPop < MOEOT >empty_pop, offspring; + + popEval (empty_pop, _pop);// a first eval of _pop + fitnessAssignment(_pop); //a first fitness assignment of _pop + + diversityAssignment(_pop);//a first diversity assignment of _pop + archive(_pop);//a first filling of archive + while (continuator (_pop)) + { + // generate offspring, worths are recalculated if necessary + breed (_pop, offspring); + popEval (_pop, offspring); // eval of offspring + // after replace, the new pop is in _pop. Worths are recalculated if necessary + replace (_pop, offspring); + fitnessAssignment(_pop); //fitness assignment of _pop + diversityAssignment(_pop); //diversity assignment of _pop + archive(_pop); //control of archive + } + } + + +protected: + + /** dummy evaluation */ + class eoDummyEval : public eoEvalFunc< MOEOT > + { + public: + void operator()(MOEOT &) {} + } + dummyEval; + + /** dummy transform */ + class eoDummyTransform : public eoTransform + { + public : + void operator()(eoPop&) {} + } + dummyTransform; + + /** a continuator based on the number of generations (used as default) */ + eoGenContinue < MOEOT > defaultGenContinuator; + /** stopping criteria */ + eoContinue < MOEOT > & continuator; + /** evaluation function */ + eoEvalFunc < MOEOT > & eval; + /** loop eval */ + eoPopLoopEval < MOEOT > loopEval; + /** evaluation function used to evaluate the whole population */ + eoPopEvalFunc < MOEOT > & popEval; + + /**SelectOne*/ + moeoDetTournamentSelect < MOEOT > defaultSelect; + /** binary tournament selection */ + SelectFromPopAndArch < MOEOT > select; + /** a default mutation */ + eoMonCloneOp < MOEOT > defaultMonOp; + /** a default crossover */ + eoQuadCloneOp < MOEOT > defaultQuadOp; + /** an object for genetic operators (used as default) */ + eoSGAGenOp < MOEOT > defaultSGAGenOp; + + /** general breeder */ + eoGeneralBreeder < MOEOT > genBreed; + /** selectMany */ + eoSelectMany selectMany; + /** select Transform*/ + eoSelectTransform selectTransform; + /** breeder */ + eoBreed < MOEOT > & breed; + + /** Fuzzy archive*/ + moeoFuzzyArchive < MOEOT >& archive; + /** diversity assignment used in E-SPEA2 */ + moeoFuzzyNearestNeighborDiversity < MOEOT > diversityAssignment; + /** elitist replacement */ + moeoGenerationalReplacement < MOEOT > replace; + /**Bert distance*/ + moeoBertDistance < MOEOT > dist; + + + +}; + +#endif /*MOEOEXTENDEDSPEA2_H_*/ diff --git a/moeo/src/archive/moeoFuzzyArchive.h b/moeo/src/archive/moeoFuzzyArchive.h new file mode 100644 index 000000000..c0c4e4f49 --- /dev/null +++ b/moeo/src/archive/moeoFuzzyArchive.h @@ -0,0 +1,194 @@ +/* + + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- +#ifndef MOEOFUZZYARCHIVE_H_ +#define MOEOFUZZYARCHIVE_H_ + +#include +#include + + +/** + * Abstract class for representing an archive in a fuzzy space of solutions; + * an archive is a secondary population that stores non-dominated fuzzy solutions. + */ +template < class MOEOT > +class moeoFuzzyArchive : public eoPop < MOEOT >, public eoUF < const MOEOT &, bool>, public eoUF < const eoPop < MOEOT > &, bool> +{ +public: + + using eoPop < MOEOT > :: size; + using eoPop < MOEOT > :: operator[]; + using eoPop < MOEOT > :: back; + using eoPop < MOEOT > :: pop_back; + + + /** + * The type of an objective vector for a solution + */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + + /** + * ctor. + * The FuzzyComparator is used to compare fuzzy solutions based on Pareto dominance + * @param _replace boolean which determine if a solution with the same objectiveVector than another one, can replace it or not + */ + moeoFuzzyArchive(FuzzyComparator< ObjectiveVector > & _comparator, bool _replace=true) : eoPop < MOEOT >(), comparator(_comparator), replace(_replace) + {} + + + /** + * Returns true if the current archive dominates _objectiveVector according to the moeoObjectiveVectorComparator given in the constructor + * @param _objectiveVector the objective vector to compare with the current archive + */ + bool dominates (const ObjectiveVector & _objectiveVector) const + { + for (unsigned int i = 0; i & _pop) = 0; + + + /** + * Returns true if the current archive contains the same objective vectors than the given archive _arch + * @param _arch the given archive + */ + bool equals (const moeoFuzzyArchive < MOEOT > & _arch) + { + for (unsigned int i=0; i & _pop) + { + bool res = false; + bool tmp = false; + for (unsigned int i=0; i<_pop.size(); i++) + { + tmp = (*this).update(_pop[i]); + res = tmp || res; + } + return res; + } + + /** A comparator based on fuzzy Pareto dominance (used as default) */ + moeoFuzzyParetoComparator < ObjectiveVector > FuzzyComparator; + /** boolean */ + bool replace; +}; + +#endif /*MOEOFUZZYARCHIVE_H_ */ diff --git a/moeo/src/comparator/moeoFuzzyParetoComparator.h b/moeo/src/comparator/moeoFuzzyParetoComparator.h new file mode 100644 index 000000000..c74f643e6 --- /dev/null +++ b/moeo/src/comparator/moeoFuzzyParetoComparator.h @@ -0,0 +1,118 @@ +/* + + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- + + +#ifndef MOEOFUZZYPARETOCOMPARATOR_H_ +#define MOEOFUZZYPARETOCOMPARATOR_H_ + +#include +//#include "triple.h" + +/** + * This class allows ranking fuzzy-valued objectives according to new dominance relations. + The dominance is defined between vectors of triangular fuzzy numbers (each number is expressed by a triplet of values [first, second, third]. + */ +template < class ObjectiveVector > +class moeoFuzzyParetoObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector > + { + int compareTriangNum (std::triple A, std::triple B) +{ + // Total dominance + if (A.third < B.first) return TNCR_TOTAL_DOMINANCE; + + + // Partial Strong dominance + if (A.third >= B.first && A.second <= B.first && A.third <= B.second) return TNCR_PARTIAL_STRONG_DOMINANCE; + + + + // Partial Weak dominance + if ((A.first B.second) || (A.second > B.first && A.third <= B.second ) || (A.second > B.first && A.third > B.second ))) + + return TNCR_PARTIAL_WEAK_DOMINANCE; + + if (A.first < B.first && A.third >= B.third && A.second < B.second) + return TNCR_PARTIAL_WEAK_DOMINANCE; + else if (A.first < B.first && A.third >= B.third && A.second >= B.second && (B.first - A.first) > (B.third - A.third)) + return TNCR_PARTIAL_WEAK_DOMINANCE; + + return 0; +} + public: + + /** + * Returns true if _objectiveVector1 V1 is dominated by _objectiveVector2 V2 means V2 dominates V1 + * @param _objectiveVector1 the first objective vector + * @param _objectiveVector2 the second objective vector + */ + /*const*/ bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2) +{ + bool dom = false; + int nb_Different_Objective_Values = 0, + nb_Total_Dominance = 0, + nb_Partial_Strong_Dominance = 0, + nb_Partial_Weak_Dominance = 0, + nb_Other = 0; + + //nObjective= 2 + for (unsigned int i=0; i ObjectiveVector::Traits::tolerance())|| + ( fabs(_objectiveVector1[i].second - _objectiveVector2[i].second) > ObjectiveVector::Traits::tolerance())|| + ( fabs(_objectiveVector1[i].third - _objectiveVector2[i].third) > ObjectiveVector::Traits::tolerance())) + { + nb_Different_Objective_Values++; + + // if the ith objective have to be minimized... + if (ObjectiveVector::minimizing(i)) + { + if ( compareTriangNum(_objectiveVector2[i], _objectiveVector1[i] ) == TNCR_TOTAL_DOMINANCE ) nb_Total_Dominance++; + else if ( compareTriangNum(_objectiveVector2[i], _objectiveVector1[i] ) == TNCR_PARTIAL_STRONG_DOMINANCE ) nb_Partial_Strong_Dominance++; + else if ( compareTriangNum(_objectiveVector2[i], _objectiveVector1[i] ) == TNCR_PARTIAL_WEAK_DOMINANCE ) nb_Partial_Weak_Dominance++; + else nb_Other++; + } + else + { + // Develop the maximizing compareTriangNum version + } + } + } + + // Strong Pareto Dominance + if ( nb_Different_Objective_Values == nb_Total_Dominance || + nb_Different_Objective_Values == nb_Partial_Strong_Dominance || + nb_Total_Dominance >= 1 && nb_Partial_Strong_Dominance > 0 || + nb_Total_Dominance >= 1 || nb_Partial_Strong_Dominance >= 1 && nb_Partial_Weak_Dominance > 0) + { dom = true; + } + + + else if ( nb_Different_Objective_Values == nb_Partial_Weak_Dominance ) { dom = true; } + else {return false; + } + + return dom; +} + +enum TriangularNumberComparaisonResult +{ + TNCR_TOTAL_DOMINANCE, + TNCR_PARTIAL_STRONG_DOMINANCE, + TNCR_PARTIAL_WEAK_DOMINANCE +}; + + + }; +#endif /*MOEOFUZZYPARETOCOMPARATOR_H_*/ diff --git a/moeo/src/core/moeoFuzzyRealObjectiveVector.h b/moeo/src/core/moeoFuzzyRealObjectiveVector.h new file mode 100644 index 000000000..2fa7367ae --- /dev/null +++ b/moeo/src/core/moeoFuzzyRealObjectiveVector.h @@ -0,0 +1,125 @@ +/* + + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEOFUZZYREALOBJECTIVEVECTOR_H_ +#define MOEOFUZZYREALOBJECTIVEVECTOR_H_ + +#include +#include +#include + +#include +//#include "triple.h" + +/* + *This class allows to represent a solution in the objective space (phenotypic representation) by a std::vector of triangles, + * i.e. that an objective value is represented using a triangle of double, and this for any objective. + */ +template < class ObjectiveVectorTraits > +class moeoFuzzyRealObjectiveVector : public moeoObjectiveVector < ObjectiveVectorTraits, std::triple > + { + public: + + using moeoObjectiveVector < ObjectiveVectorTraits, std::triple >::size; + using moeoObjectiveVector < ObjectiveVectorTraits, std::triple >::operator[]; + + /** + * Ctor + */ + moeoFuzzyRealObjectiveVector() + {} + + + /** + * Ctor from a vector of triangles of doubles + * @param _v the std::vector < std::triple > + */ + moeoFuzzyRealObjectiveVector(std::vector < std::triple > & _v) : moeoObjectiveVector < ObjectiveVectorTraits, std::triple > (_v) + {} + + + /** + * Returns true if the current objective vector dominates _other according to the Fuzzy Preto dominance relation + * (but it's better to use a moeoObjectiveVectorComparator object to compare solutions) + * @param _other the other FuzzyRealObjectiveVector object to compare with + */ + bool dominates(const moeoFuzzyRealObjectiveVector < ObjectiveVectorTraits > & _other) const + { + moeoFuzzyParetoComparator < moeoFuzzyRealObjectiveVector > comparator; + return comparator(_other, *this); + } + + + /** + * Returns true if the current objective vector is equal to _other (according to a tolerance value) + * @param _other the other FuzzyRealObjectiveVector object to compare with + */ + bool operator==(const moeoFuzzyRealObjectiveVector < ObjectiveVectorTraits > & _other) const + { + for (unsigned int i=0; i < size(); i++) + { + if ( (fabs((operator[](i)).first - _other[i].first) > ObjectiveVectorTraits::tolerance()) && + (fabs((operator[](i)).second - _other[i].second) > ObjectiveVectorTraits::tolerance()) && + (fabs((operator[](i)).third - _other[i].third) > ObjectiveVectorTraits::tolerance()) ) + { + return false; + } + } + return true; + } + + /** + * Returns true if the current objective vector is different than _other (according to a tolerance value) + * @param _other the other FuzzyRealObjectiveVector object to compare with + */ + bool operator!=(const moeoFuzzyRealObjectiveVector < ObjectiveVectorTraits > & _other) const + { + return ! operator==(_other); + } + +}; + +/** + * Output for a FuzzyRealObjectiveVector object + * @param _os output stream + * @param _objectiveVector the objective vector to write + */ + +template < class ObjectiveVectorTraits > +std::ostream & operator<<(std::ostream & _os, const moeoFuzzyRealObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) +{ + for (unsigned int i=0; i<_objectiveVector.size()-1; i++) + _os << "[" << _objectiveVector[i].first << " " << _objectiveVector[i].second << " " << _objectiveVector[i].third << "]" <<" "; + _os << "[" <<_objectiveVector[_objectiveVector.size()-1].first << " " << _objectiveVector[_objectiveVector.size()-1].second + << " " << _objectiveVector[_objectiveVector.size()-1].third << "]" << " "; + return _os; +} + + +/** + * Input for a FuzzyRealObjectiveVector object + * @param _is input stream + * @param _objectiveVector the objective vector to read + */ +template < class ObjectiveVectorTraits > +std::istream & operator>>(std::istream & _is, moeoFuzzyRealObjectiveVector < ObjectiveVectorTraits > & _objectiveVector) +{ + + for (unsigned int i=0; i<_objectiveVector.size(); i++) + { + _is >> _objectiveVector[i].first >> _objectiveVector[i].second >> _objectiveVector[i].third; + } + return _is; +} + +#endif /*MOEOFUZZYREALOBJECTIVEVECTOR_H_*/ diff --git a/moeo/src/distance/BertDistance.h b/moeo/src/distance/BertDistance.h deleted file mode 100644 index 949c66d8c..000000000 --- a/moeo/src/distance/BertDistance.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - - Oumayma BAHRI - -Author: - Oumayma BAHRI - -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr - -*/ -//----------------------------------------------------------------------------- - -#ifndef BERTDISTANCE_H_ -#define BERTDISTANCE_H_ - -#include -#include -#include "ObjectiveVectorNormalizer.h" - -/** - * A class allowing to compute an Bert distance between two fuzzy solutions in the objective space - with normalized objective values (i.e. between 0 and 1). - * A distance value then lies between 0 and sqrt(nObjectives). - */ -template < class MOEOT> -class BertDistance : public moeoObjSpaceDistance < MOEOT > - { - public: - - /** the objective vector type of the solutions */ - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - /** the fitness type of the solutions */ - typedef typename MOEOT::Fitness Fitness; - - /** - default ctr - */ - /* BertDistance () - {}*/ - /** - ctr with a normalizer - @param _normalizer the normalizer used for every ObjectiveVector - */ - /** - default ctr - */ - BertDistance ():normalizer(defaultNormalizer) - {} - - - double calculateBertDistance(std::triple A, std::triple B) - { - double midA = 0.5 * (A.first + A.third); - double midB = 0.5 * (B.first + B.third); - double sprA = 0.5 * (A.first - A.third); - double sprB = 0.5 * (B.first - B.third); - - double theta = 0.5; - - return sqrt((midA -midB) * (midA -midB) + theta * (sprA - sprB) * (sprA - sprB)); - } - - - /** - * tmp1 and tmp2 take the Expected values of Objective vectors - * Returns the Bert distance between _obj1 and _obj2 in the objective space - * @param _obj1 the first objective vector - * @param _obj2 the second objective vector - */ -const Fitness operator()(const ObjectiveVector & _obj1, const ObjectiveVector & _obj2) - { - vector v_BD; - double dist=0.0; - - for (unsigned int i=0; i Normalizer; - - - - }; - -#endif /*BERTDISTANCE_H_*/ diff --git a/moeo/src/distance/moeoBertDistance.h b/moeo/src/distance/moeoBertDistance.h index 5d2d60e4c..24aa2af51 100644 --- a/moeo/src/distance/moeoBertDistance.h +++ b/moeo/src/distance/moeoBertDistance.h @@ -16,12 +16,11 @@ Contact: paradiseo-help@lists.gforge.inria.fr #include #include -#include "ObjectiveVectorNormalizer.h" +#include /** - * A class allowing to compute an Bert distance between two fuzzy solutions in the objective space - with normalized objective values (i.e. between 0 and 1). - * A distance value then lies between 0 and sqrt(nObjectives). + * A class allowing to compute the bertoluzza distance between two fuzzy solutions in the objective space with normalized objective values. + * A distance value lies between 0 and sqrt(nObjectives). */ template < class MOEOT> class moeoBertDistance : public moeoObjSpaceDistance < MOEOT > @@ -86,7 +85,7 @@ const Fitness operator()(const ObjectiveVector & _obj1, const ObjectiveVector & private: - ObjectiveVectorNormalizer Normalizer; + moeoFuzzyObjectiveVectorNormalizer Normalizer; diff --git a/moeo/src/distance/moeoExpectedFuzzyDistance.h b/moeo/src/distance/moeoExpectedFuzzyDistance.h new file mode 100644 index 000000000..9447fe5f4 --- /dev/null +++ b/moeo/src/distance/moeoExpectedFuzzyDistance.h @@ -0,0 +1,66 @@ +/* + + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEOEXPECTEDFUZZYDISTANCE_H_ +#define MOEOEXPECTEDFUZZYDISTANCE_H_ + +#include +#include +#include + +/** + * An expected euclidian distance between two fuzzy solutions in the objective space + * Every solution value is expressed by a triangular fuzzy number + */ +template < class MOEOT> +class moeoExpectedFuzzyDistance : public moeoObjSpaceDistance < MOEOT > + { + public: + + /** the objective vector type of the solutions */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + /** the fitness type of the solutions */ + typedef typename MOEOT::Fitness Fitness; + + /** + default ctr + */ + moeoExpectedFuzzyDistance () + {} + + /** + * tmp1 and tmp2 take the Expected values of Objective vectors + * Returns the expected distance between _obj1 and _obj2 in the objective space + * @param _obj1 the first objective vector + * @param _obj2 the second objective vector + */ +const Fitness operator()(const ObjectiveVector & _obj1, const ObjectiveVector & _obj2) + { + Fitness result = 0.0; + Fitness tmp1, tmp2; + for (unsigned int i=0; i + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- +#ifndef MOEOFUZZYCROWDINGDIVERSITY_H_ +#define MOEOFUZZYCROWDINGDIVERSITY_H_ + +#include +#include +#include + +#include +#include + + + +/** + * Diversity assignment sheme based on crowding proposed in: + * K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002). + * Tis strategy assigns diversity values FRONT BY FRONT. It is, for instance, used in NSGA-II. + */ +template < class MOEOT > +class moeoFuzzyCrowdingDiversity : public CrowdingDiversityAssignment < MOEOT > + { + public: + + /** the objective vector type of the solutions */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + + /** + * Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account. + * @param _pop the population + * @param _objVec the objective vector + */ + void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) + { + std::cout << "WARNING : updateByDeleting not implemented in FrontByFrontCrowdingDistanceDiversityAssignment" << std::endl; + } + + private: + + using CrowdingDiversityAssignment < MOEOT >::inf; + using CrowdingDiversityAssignment < MOEOT >::tiny; + + /** + * Sets the distance values + * @param _pop the population + */ + + void setDistances (eoPop & _pop) + { + unsigned int a,b; + double min, max, distance; + unsigned int nObjectives = MOEOT::ObjectiveVector::nObjectives(); + // set diversity to 0 for every individual + for (unsigned int i=0; i<_pop.size(); i++) + { + _pop[i].diversity(0.0); + } + // sort the whole pop according to fitness values + moeoFitnessThenDiversityComparator < MOEOT > fitnessComparator; + std::vector sortedptrpop; + sortedptrpop.resize(_pop.size()); + // due to intensive sort operations for this diversity assignment, + // it is more efficient to perform sorts using only pointers to the + // population members in order to avoid copy of individuals + for(unsigned int i=0; i< _pop.size(); i++) sortedptrpop[i] = & (_pop[i]); + //sort the pointers to population members + moeoFuzzyParetoComparator comp( fitnessComparator); + std::sort(sortedptrpop.begin(), sortedptrpop.end(), comp); + // compute the expected crowding distance values for every individual "front" by "front" (front : from a to b) + a = 0; // the front starts at a + while (a < _pop.size()) + { + b = lastIndex(sortedptrpop,a); // the front ends at b + //b = lastIndex(_pop,a); // the front ends at b + // if there is less than 2 individuals in the front... + if ((b-a) < 2) + { + for (unsigned int i=a; i<=b; i++) + { + sortedptrpop[i]->diversity(inf()); + //_pop[i].diversity(inf()); + } + } + // else... + else + { + // for each objective + for (unsigned int obj=0; obj objComp(obj); + moeoFuzzyParetoComparator comp( objComp ); + std::sort(sortedptrpop.begin(), sortedptrpop.end(), comp); + // min & max + min = (sortedptrpop[b])->objectiveVector()[obj].second; + max = (sortedptrpop[a])->objectiveVector()[obj].second; + + // avoid extreme case + if (min == max) + { + min -= tiny(); + max += tiny(); + } + // set the diversity value to infiny for min and max + sortedptrpop[a]->diversity(inf()); + sortedptrpop[b]->diversity(inf()); + // set the diversity values for the other individuals + for (unsigned int i=a+1; imoeoExpectedFuzzyDistance(objectiveVector()[obj]) - sortedptrpop[i+1]->moeoExpectedFuzzyDistance(objectiveVector()[obj] )) / (max-min); + sortedptrpop[i]->diversity(sortedptrpop[i]->diversity() + distance); + } + } + } + // go to the next front + a = b+1; + } + } + + + + /** + * Returns the index of the last individual having the same fitness value than _pop[_start] + * @param _pop the vector of pointers to population individuals + * @param _start the index to start from + */ + + unsigned int lastIndex (std::vector & _pop, unsigned int _start) + { + unsigned int i=_start; + while ( (i<_pop.size()-1) && (_pop[i]->fitness()==_pop[i+1]->fitness()) ) + { + i++; + } + return i; + } + + + }; + +#endif /*MOEOFUZZYCROWDINGDIVERSITY_H_*/ diff --git a/moeo/src/diversity/moeoFuzzyNearestNeighborDiversity.h b/moeo/src/diversity/moeoFuzzyNearestNeighborDiversity.h new file mode 100644 index 000000000..5be53c393 --- /dev/null +++ b/moeo/src/diversity/moeoFuzzyNearestNeighborDiversity.h @@ -0,0 +1,116 @@ +/* + + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEOFUZZYNEARESTNEIGHBORDIVERSITY_H_ +#define MOEOFUZZYNEARESTNEIGHBORDIVERSITY_H_ + +#include +#include +#include +#include + +/** + * moeoFuzzyNearestNeighborDiversity is a moeoDiversityAssignment using the fuzzy "Bert" distance between individuals to assign diversity. + */ +template < class MOEOT > +class moeoFuzzyNearestNeighborDiversity : public moeoDiversityAssignment < MOEOT > +{ +public: + + /** The type for objective vector */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + + /** + * Ctor where you can choose your own distance and archive + * @param _dist the distance used + * @param _archive the archive used + * @param _index index for find the k-ieme nearest neighbor, _index correspond to k + */ + moeoFuzzyNearestNeighborDiversity(moeoBertDistance & _dist, moeoFuzzyArchive & _archive, unsigned int _index=1) : distance(_dist), archive(_archive), index(_index) + {} + + + /** + * Affect the diversity to the pop, diversity corresponding to the k-ieme nearest neighbor. + * @param _pop the population + */ + void operator () (eoPop < MOEOT > & _pop) + { + unsigned int i = _pop.size(); + unsigned int j = archive.size(); + double tmp=0; + std::vector< std::list > matrice(i+j); + if (i+j>0) + { + for (unsigned k=0; k=i) ) + tmp=distance(_pop[k], archive[l-i]); + else + tmp=distance(archive[k-i], archive[l-i]); + matrice[k].push_back(tmp); + matrice[l].push_back(tmp); + } + } + } + for (unsigned int k=0; k & _pop, ObjectiveVector & _objVec) + { + std::cout << "WARNING : updateByDeleting not implemented in moeoNearestNeighborDiversityAssignment" << std::endl; + } + + +private: + + + /** Default distance */ + moeoBertDistance < MOEOT > Distance; + /** Default archive */ + moeoFuzzyArchive < MOEOT > Archive; + /** the index corresponding to k for search the k-ieme nearest neighbor */ + unsigned int index; + + + /** + * Return the index-th element of the list _myList + * @param _myList the list which contains distances + */ + double getElement(std::list _myList) + { + std::list::iterator it= _myList.begin(); + for (unsigned int i=1; i< std::min((unsigned int)_myList.size(),index); i++) + it++; + return *it; + } + +}; + +#endif /*MOEOFUZZYNEARESTNEIGHBORDIVERSITY_H_*/ diff --git a/moeo/src/utils/moeoFuzzyObjectiveVectorNormalizer.h b/moeo/src/utils/moeoFuzzyObjectiveVectorNormalizer.h new file mode 100644 index 000000000..2ab71c83b --- /dev/null +++ b/moeo/src/utils/moeoFuzzyObjectiveVectorNormalizer.h @@ -0,0 +1,75 @@ +/* + + Oumayma BAHRI + +Author: + Oumayma BAHRI + +ParadisEO WebSite : http://paradiseo.gforge.inria.fr +Contact: paradiseo-help@lists.gforge.inria.fr + +*/ +//----------------------------------------------------------------------------- + +#ifndef MOEOFUZZYOBJECTIVEVECTORNORMALIZER_H_ +#define MOEOFUZZYOBJECTIVEVECTORNORMALIZER_H_ +#include +#include +/** + Adaptation of classical class "moeoObjectiveVectorNormalizer" to normalize fuzzy objective Vectors + */ +template +class moeoFuzzyObjectiveVectorNormalizer +{ + public: + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + typedef typename MOEOT::ObjectiveVector::Type Type; + typedef typename std::vector > Scale; + typedef eoRealInterval Bounds; + + + + /** + constructor with a supplied scale, usefull if you tweak your scale + @param _scale the scale for noramlzation + @param max_param the returned values will be between 0 and max + */ + moeoFuzzyObjectiveVectorNormalizer(Scale _scale=make_dummy_scale(),Type max_param=100):scale(_scale),max(max_param) + {} + + /** + * main fonction, normalize a triangular fuzzy vector defined with a triplet [first, second, third]. + * @param _vec the vector + * @return the normalized vector + */ + virtual ObjectiveVector operator()(const ObjectiveVector &_vec){ + unsigned int dim=_vec.nObjectives(); + ObjectiveVector res; + for (unsigned int i=0;i normalize(const eoPop &pop, Type &max){ + moeoFuzzyObjectiveVectorNormalizer normalizer(pop,true, max); + return normalizer(pop); + } + + + + private: + Scale scale; + Type max; + + +}; +#endif From 4f726f482d4e88c3840e00a2b82111a614f1e739 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sat, 8 Dec 2018 21:11:41 +0100 Subject: [PATCH 123/419] Fix the doc build. - Fix the doc target management: now working whatever the combination of modules that is asked. - Add edo to the doc targets. - Add a warning when doxygen is not found. --- CMakeLists.txt | 5 ++ cmake/Target.cmake | 121 ++++++++++++++++++++++++++++++++++++++++----- edo/CMakeLists.txt | 2 +- 3 files changed, 115 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f279e5a3e..3bbb8de3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,11 @@ SET(GLOBAL_VERSION "${VERSION}") ## Optional set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/module" CACHE INTERNAL "Cmake module" FORCE) include(FindDoxygen OPTIONAL) +if(NOT DOXYGEN_FOUND) + message(WARNING "Doxygen was not found, install it if you want to generate the documentation.") +else() + message(STATUS "Doxygen found, use the target `doc` to generate the documentation.") +endif() ###################################################################################### ### 3) Include CMake files diff --git a/cmake/Target.cmake b/cmake/Target.cmake index 06fc26162..30d60f531 100644 --- a/cmake/Target.cmake +++ b/cmake/Target.cmake @@ -11,22 +11,119 @@ endif(UNIX) ###################################################################################### if(DOXYGEN_FOUND AND DOXYGEN_EXECUTABLE) - if(SMP) + # FIXME this would work in cmake 3.13 + # set(DOC_EO "make doc-eo") + # if(NOT EO_ONLY) + # set(DOC_MO "make doc-mo") + # set(DOC_MOEO "make doc-moeo") + # if(EDO) + # set(DOC_EDO "make doc-edo") + # else() + # set(DOC_EDO "") + # endif() + # if(SMP) + # set(DOC_SMP "make doc-smp") + # else() + # set(DOC_SMP "") + # endif() + # if(MPI) + # set(DOC_MPI "make doc-mpi") + # else() + # set(DOC_MPI "") + # endif() + # endif() + # + # add_custom_target(doc + # COMMAND ${DOC_EO} + # COMMAND ${DOC_MO} + # COMMAND ${DOC_MOEO} + # COMMAND ${DOC_EDO} + # COMMAND ${DOC_SMP} + # COMMAND ${DOC_MPI} + # ) + # FIXME in the meantime, we must enumerate... + if(EO_ONLY) add_custom_target(doc COMMAND make doc-eo - COMMAND make doc-edo - COMMAND make doc-mo - COMMAND make doc-moeo - COMMAND make doc-smp ) else() - add_custom_target(doc - COMMAND make doc-eo - COMMAND make doc-edo - COMMAND make doc-mo - COMMAND make doc-moeo - ) - endif() + # No optional module. + if(NOT EDO AND NOT SMP AND NOT MPI) + add_custom_target(doc + COMMAND make doc-eo + COMMAND make doc-mo + COMMAND make doc-moeo + ) + endif() + + # One optional module. + if(EDO AND NOT SMP AND NOT MPI) + add_custom_target(doc + COMMAND make doc-eo + COMMAND make doc-mo + COMMAND make doc-moeo + COMMAND make doc-edo + ) + endif() + if(NOT EDO AND SMP AND NOT MPI) + add_custom_target(doc + COMMAND make doc-eo + COMMAND make doc-mo + COMMAND make doc-moeo + COMMAND make doc-smp + ) + endif() + if(NOT EDO AND NOT SMP AND MPI) + add_custom_target(doc + COMMAND make doc-eo + COMMAND make doc-mo + COMMAND make doc-moeo + COMMAND make doc-mpi + ) + endif() + + # Two optional modules. + if(NOT EDO AND SMP AND MPI) + add_custom_target(doc + COMMAND make doc-eo + COMMAND make doc-mo + COMMAND make doc-moeo + COMMAND make doc-smp + COMMAND make doc-mpi + ) + endif() + if(EDO AND NOT SMP AND MPI) + add_custom_target(doc + COMMAND make doc-eo + COMMAND make doc-mo + COMMAND make doc-moeo + COMMAND make doc-edo + COMMAND make doc-mpi + ) + endif() + if(EDO AND SMP AND NOT MPI) + add_custom_target(doc + COMMAND make doc-eo + COMMAND make doc-mo + COMMAND make doc-moeo + COMMAND make doc-edo + COMMAND make doc-smp + ) + endif() + + # Three optional modules + if(EDO AND SMP AND MPI) + add_custom_target(doc + COMMAND make doc-eo + COMMAND make doc-mo + COMMAND make doc-moeo + COMMAND make doc-edo + COMMAND make doc-smp + COMMAND make doc-mpi + ) + endif() + + endif(EO_ONLY) endif(DOXYGEN_FOUND AND DOXYGEN_EXECUTABLE) ###################################################################################### diff --git a/edo/CMakeLists.txt b/edo/CMakeLists.txt index 50424db45..b32c874cb 100644 --- a/edo/CMakeLists.txt +++ b/edo/CMakeLists.txt @@ -26,8 +26,8 @@ endif() ### Include subdirectories ###################################################################################### -add_subdirectory(doc) add_subdirectory(src) +add_subdirectory(doc) if(ENABLE_CMAKE_TESTING AND EIGEN3_FOUND) # see edoNormalAdaptive add_subdirectory(test) From 85fded52a5dc82b650de518150125675c553f155 Mon Sep 17 00:00:00 2001 From: Ronaldd Pinho Date: Fri, 12 Apr 2019 22:56:50 -0300 Subject: [PATCH 124/419] Add README.md --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..d7487ae83 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# ParadisEO: A C++ evolutionary computation framework to build parallel stochastic optimization solvers + +## Release + +The actual release is paradiseo-2.0 + +## Installation + +The basic installation procedure must be done in a separatly folder in order to keep your file tree clean. + +Create a directory to build and access it: + +``` +$ mkdir build && cd build +``` + +Compile the project into the directory with ```cmake```: +``` +$ cmake .. +$ make +``` + +Take a coffee ;) + +**Congratulations!! ParadiseEO is installed!** + +Please refer to paradisEO website or INSTALL file for further information about installation types and options. + +--- + +## Directory Structure + From 71c51139d21e8bab7d63a5c01892bbce794501fb Mon Sep 17 00:00:00 2001 From: Ronaldd Pinho Date: Fri, 12 Apr 2019 23:11:09 -0300 Subject: [PATCH 125/419] Replace README file with a Markdown file README.md --- README | 83 ------------------------------------------------------- README.md | 19 +++++++++++++ 2 files changed, 19 insertions(+), 83 deletions(-) delete mode 100644 README diff --git a/README b/README deleted file mode 100644 index c989a97b5..000000000 --- a/README +++ /dev/null @@ -1,83 +0,0 @@ - -========================================================================================== - RELEASE -========================================================================================== - -The current release is paradisEO-2.0 - -========================================================================================== - INSTALLATION -========================================================================================== -The basic installation procedure must be done in a separatly folder in order to keep -your file tree clean. - -1) mkdir build -2) cd build -3) cmake .. -4) make -5) Take a cofee. -6) Congratulation, ParadiseEO is installed ! - -Please refer to paradisEO website or INSTALL file for further information about -installation types and options. - -========================================================================================== - DIRECTORY STRUCTURE -========================================================================================== -After unpacking the archive file, you should end up with the following -structure: - -.../ - | - | - +-- AUTHORS Author list - | - | - +-- cmake/ CMake dir - | - | - +-- CMakeLists.txt For building process - | - | - +-- CTestConfig.cmake For testing process - | - | - +-- INSTALL INSTALL file - | - | - +-- LICENCE Licence contents - | - | - +-- paradiseo-eo paradiseo-eo dir - | - | - +-- paradiseo-mo paradiseo-mo dir - | - | - +-- paradiseo-moeo paradiseo-moeo dir - | - | - +-- problems classical problems evaluation functions - | - | - +-- README README file - -========================================================================================== - NOTES -========================================================================================== - -ParadisEO uses EO, a templates-based, ANSI-C++ compliant evolutionary computation library. -It contains classes for almost any kind of evolutionary computation you might come up to - at -least for the ones we could think of. -EO Website: http://eodev.sourceforge.net/. -EO is distributed under the GNU Lesser General Public License: http://www.gnu.org/copyleft/lesser.html - -Please read README file of each extracted directory if you have -problems for the installation. - -========================================================================================== - CONTACT -========================================================================================== -For further information about ParadisEO, help or to report any -problem : paradiseo-help@lists.gforge.inria.fr - diff --git a/README.md b/README.md index d7487ae83..ee2ec7198 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,22 @@ Please refer to paradisEO website or INSTALL file for further information about ## Directory Structure +* __AUTHORS__: Authors list; + +* __cmake__: Directory of cmake files; + +* __CMakeLists.txt__: Definitions for building process; + +* __CTestConfig.cmake__: Definitions for testing process; + +* __INSTALL__: Steps and options of the installation process; + +* __LICENSE__: License contents; + +* __eo__: Specific directory of the EO (Evolving Objects) module; + +* __mo__: Specific directory of the MO (Moving Objects) module; + +* __moeo__: Specific directory of the MOEO (Multi-Objective Optimization) module; + +* __problems__: classical problems evaluation functions; \ No newline at end of file From bedb18ff3ede40a95abbfd256f1b8ca2125382fc Mon Sep 17 00:00:00 2001 From: Ronaldd Pinho Date: Fri, 12 Apr 2019 23:20:34 -0300 Subject: [PATCH 126/419] README file adapted to Markdown file README.md finished --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee2ec7198..cdba1774b 100644 --- a/README.md +++ b/README.md @@ -48,4 +48,22 @@ Please refer to paradisEO website or INSTALL file for further information about * __moeo__: Specific directory of the MOEO (Multi-Objective Optimization) module; -* __problems__: classical problems evaluation functions; \ No newline at end of file +* __problems__: classical problems evaluation functions. + +--- +## Notes + +ParadisEO uses EO, a templates-based, ANSI-C++ compliant evolutionary computation library. It contains classes for almost any kind of evolutionary computation you might come up to - at least for the ones we could think of. + +EO Website: http://eodev.sourceforge.net/. + +ParadisEO Website: http://paradiseo.gforge.inria.fr/ + +EO is distributed under the GNU Lesser General Public License: http://www.gnu.org/copyleft/lesser.html + +Please read README file of each extracted directory if you have problems for the installation. + +--- +**Contact** + +For further information about ParadisEO, help or to report any problem : paradiseo-help@lists.gforge.inria.fr \ No newline at end of file From f88edf0dabaefa6501ab56bde7f449a259969b60 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 19 Apr 2019 06:52:15 +0200 Subject: [PATCH 127/419] deactivate moeo2DMinHypervolumeArchive which has a missing header --- moeo/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moeo/test/CMakeLists.txt b/moeo/test/CMakeLists.txt index ce5b932e0..3c1d5af28 100644 --- a/moeo/test/CMakeLists.txt +++ b/moeo/test/CMakeLists.txt @@ -71,7 +71,7 @@ set(TEST_LIST t-moeoNumberUnvisitedSelect t-moeoDMLSMonOp t-moeoDMLSGenUpdater - t-moeo2DMinHypervolumeArchive + # t-moeo2DMinHypervolumeArchive ) ###################################################################################### From ff322ba27bd0f698fe57c1c676a043e11d7917e0 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 19 Apr 2019 06:52:38 +0200 Subject: [PATCH 128/419] fix missing API update - tutorial/Lesson3 was still using the old eoStdoutMonitor interface --- eo/tutorial/Lesson3/exercise3.1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo/tutorial/Lesson3/exercise3.1.cpp b/eo/tutorial/Lesson3/exercise3.1.cpp index dc37479d4..d178941c5 100644 --- a/eo/tutorial/Lesson3/exercise3.1.cpp +++ b/eo/tutorial/Lesson3/exercise3.1.cpp @@ -289,7 +289,7 @@ void main_function(int argc, char **argv) checkpoint.add(fdcStat); // The Stdout monitor will print parameters to the screen ... - eoStdoutMonitor monitor(false); + eoStdoutMonitor monitor; // when called by the checkpoint (i.e. at every generation) checkpoint.add(monitor); From d83681d6facb0c504af15dd2ef83a0cd90e8f32e Mon Sep 17 00:00:00 2001 From: nojhan Date: Sun, 29 Sep 2019 21:14:30 +0200 Subject: [PATCH 129/419] add cmake export to all targets & bugfix Find module - Add "EXPORT paradiseo-targets" to cmake's "install" commands. - Export those targets in "paradiseo-config.cmake", which is needed by FindParadiseo.cmake script. - Bugfix "FindParadiseo.cmake" script: - document PARADISEO_ROOT input, - add PARADISEO_DIR to specify a bin dir (try build, debug and release as defaults), - bugfix bad copy pastes involving edo and peo, - default messages only for eo, mo and meo. --- CMakeLists.txt | 9 +++++ cmake/module/FindParadiseo.cmake | 61 +++++++++++++++++++++----------- edo/src/utils/CMakeLists.txt | 2 +- eo/src/CMakeLists.txt | 2 +- eo/src/es/CMakeLists.txt | 4 +-- eo/src/ga/CMakeLists.txt | 2 +- eo/src/mpi/CMakeLists.txt | 2 +- eo/src/pyeo/CMakeLists.txt | 2 +- eo/src/serial/CMakeLists.txt | 2 +- eo/src/utils/CMakeLists.txt | 2 +- moeo/src/CMakeLists.txt | 2 +- smp/src/CMakeLists.txt | 2 +- 12 files changed, 61 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bbb8de3e..8bb3a2c4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,3 +137,12 @@ endif() if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Package.cmake) endif() + + +# Add all targets to the build-tree export set +export(TARGETS eo FILE "${PROJECT_BINARY_DIR}/paradiseo-config.cmake") + +# Export the package for use from the build-tree +# (this registers the build-tree with a global CMake-registry) +export(PACKAGE paradiseo) + diff --git a/cmake/module/FindParadiseo.cmake b/cmake/module/FindParadiseo.cmake index 59b85a864..ecbd9ab79 100644 --- a/cmake/module/FindParadiseo.cmake +++ b/cmake/module/FindParadiseo.cmake @@ -1,3 +1,6 @@ +# The script use the following variables as search paths, if they are defined: +# - PARADISEO_ROOT : the project root +# - PARADISEO_DIR : the build/install directory with libraries binaries # # The following variables are filled out: # - PARADISEO_INCLUDE_DIR : EO, MO and MOEO source dir @@ -36,15 +39,21 @@ if(UNIX) set(INSTALL_SUB_DIR /paradiseo) endif() +if(PARADISEO_DIR) + # CMake config module is case sensitive + set(Paradiseo_DIR ${PARADISEO_DIR}) +endif() + # enabled components -if ("${Paradiseo_FIND_COMPONENTS}" STREQUAL "") +if (Paradiseo_FIND_COMPONENTS STREQUAL "") set(PARADISEO_LIBRARIES_TO_FIND eo eoutils cma es flowshop ga moeo) else() set(PARADISEO_LIBRARIES_TO_FIND ${Paradiseo_FIND_COMPONENTS}) endif() +message(STATUS "${PARADISEO_LIBRARIES_TO_FIND}") #set the build directory -set(BUILD_DIR build) +#set(BUILD_DIR build) # Path set(PARADISEO_SRC_PATHS @@ -72,32 +81,36 @@ find_path(MOEO_INCLUDE_DIR moeo PATH_SUFFIXES include${INSTALL_SUB_DIR}/moeo moeo/src PATHS ${PARADISEO_SRC_PATHS}) -# Specific for SMP and PEO +set(PARADISEO_INCLUDE_DIR ${EO_INCLUDE_DIR} ${MO_INCLUDE_DIR} ${MOEO_INCLUDE_DIR}) + +# Specific for SMP, EDO and PEO foreach(COMP ${PARADISEO_LIBRARIES_TO_FIND}) if(${COMP} STREQUAL "smp") set(SMP_FOUND true) find_path(SMP_INCLUDE_DIR smp PATH_SUFFIXES include${INSTALL_SUB_DIR}/smp smp/src PATHS ${PARADISEO_SRC_PATHS}) - elseif(${COMP} STREQUAL "peo") - set(PEO_FOUND true) + elseif(${COMP} STREQUAL "edo") + set(EDO_FOUND true) find_path(EDO_INCLUDE_DIR edo PATH_SUFFIXES include${INSTALL_SUB_DIR}/edo edo/src PATHS ${PARADISEO_SRC_PATHS}) - elseif(${COMP} STREQUAL "edo") - set(EDO_FOUND true) - find_path(EDO_INCLUDE_DIR peo + elseif(${COMP} STREQUAL "peo") + set(PEO_FOUND true) + find_path(PEO_INCLUDE_DIR peo PATH_SUFFIXES include${INSTALL_SUB_DIR}/peo peo/src PATHS ${PARADISEO_SRC_PATHS}) endif() endforeach() -set(PARADISEO_INCLUDE_DIR ${EO_INCLUDE_DIR} ${EDO_INCLUDE_DIR} ${MO_INCLUDE_DIR} ${MOEO_INCLUDE_DIR}) - if(SMP_FOUND) set(PARADISEO_INCLUDE_DIR ${PARADISEO_INCLUDE_DIR} ${SMP_INCLUDE_DIR}) endif() +if(EDO_FOUND) + set(PARADISEO_INCLUDE_DIR ${PARADISEO_INCLUDE_DIR} ${EDO_INCLUDE_DIR}) +endif() + if(PEO_FOUND) set(PARADISEO_INCLUDE_DIR ${PARADISEO_INCLUDE_DIR} ${PEO_INCLUDE_DIR}) endif() @@ -106,8 +119,14 @@ endif() set(PARADISEO_FOUND true) # will be set to false if one of the required modules is not found set(FIND_PARADISEO_LIB_PATHS - ${PARADISEO_ROOT}/${BUILD_DIR} - $ENV{PARADISEO_ROOT} + # ${PARADISEO_ROOT}/${BUILD_DIR} + ${Paradiseo_DIR} + $ENV{PARADISEO_ROOT}/build + $ENV{PARADISEO_ROOT}/release + $ENV{PARADISEO_ROOT}/debug + ${PARADISEO_ROOT}/build + ${PARADISEO_ROOT}/release + ${PARADISEO_ROOT}/debug /usr/local/ /usr/ /sw # Fink @@ -153,18 +172,20 @@ endforeach() # handle result if(PARADISEO_FOUND) - message(STATUS "Found ParadisEO includes :") - message(${EO_INCLUDE_DIR}) - message(${EDO_INCLUDE_DIR}) - message(${MO_INCLUDE_DIR}) - message(${MOEO_INCLUDE_DIR}) + message(STATUS "Found the following ParadisEO include directories:") + message(STATUS "\tEO\t: " ${EO_INCLUDE_DIR}) + message(STATUS "\tMO\t: " ${MO_INCLUDE_DIR}) + message(STATUS "\tMOEO\t: " ${MOEO_INCLUDE_DIR}) if(SMP_FOUND) - message(${SMP_INCLUDE_DIR}) + message(STATUS "\tSMP\t: " ${SMP_INCLUDE_DIR}) + endif() + if(EDO_FOUND) + message(STATUS "\tEDO\t: " ${EDO_INCLUDE_DIR}) endif() if(PEO_FOUND) - message(${PEO_INCLUDE_DIR}) + message(STATUS "\tPEO\t: " ${PEO_INCLUDE_DIR}) endif() else() # include directory or library not found - message(FATAL_ERROR "Could NOT find ParadisEO (missing : ${FIND_PARADISEO_MISSING})") + message(FATAL_ERROR "Could NOT find ParadisEO (missing \t: ${FIND_PARADISEO_MISSING})") endif() diff --git a/edo/src/utils/CMakeLists.txt b/edo/src/utils/CMakeLists.txt index a6fc4d067..01c928a66 100644 --- a/edo/src/utils/CMakeLists.txt +++ b/edo/src/utils/CMakeLists.txt @@ -14,7 +14,7 @@ set(LIBRARY_OUTPUT_PATH ${EDOUTILS_LIB_OUTPUT_PATH}) file(GLOB SOURCES *.cpp) add_library(edoutils ${SOURCES}) -install(TARGETS edoutils ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS edoutils EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) set(EDOUTILS_VERSION ${GLOBAL_VERSION}) set_target_properties(edoutils PROPERTIES VERSION "${EDOUTILS_VERSION}") diff --git a/eo/src/CMakeLists.txt b/eo/src/CMakeLists.txt index b2b445a93..76f26deae 100644 --- a/eo/src/CMakeLists.txt +++ b/eo/src/CMakeLists.txt @@ -29,7 +29,7 @@ add_library(eo STATIC ${EO_SOURCES}) set(EO_VERSION ${GLOBAL_VERSION}) set_target_properties(eo PROPERTIES VERSION "${EO_VERSION}") -install(TARGETS eo ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS eo EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) file(GLOB HDRS *.h eo) install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/eo COMPONENT headers) diff --git a/eo/src/es/CMakeLists.txt b/eo/src/es/CMakeLists.txt index 15a7f9f3b..55de761eb 100644 --- a/eo/src/es/CMakeLists.txt +++ b/eo/src/es/CMakeLists.txt @@ -38,10 +38,10 @@ set(CMA_SOURCES ) add_library(es STATIC ${ES_SOURCES}) -install(TARGETS es ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS es EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) add_library(cma STATIC ${CMA_SOURCES}) -install(TARGETS cma ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS cma EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) ###################################################################################### ### 3) Optionnal diff --git a/eo/src/ga/CMakeLists.txt b/eo/src/ga/CMakeLists.txt index 1a1cd656d..c03deed66 100644 --- a/eo/src/ga/CMakeLists.txt +++ b/eo/src/ga/CMakeLists.txt @@ -23,7 +23,7 @@ set(GA_SOURCES ) add_library(ga STATIC ${GA_SOURCES}) -install(TARGETS ga ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS ga EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) ###################################################################################### ### 3) Optionnal diff --git a/eo/src/mpi/CMakeLists.txt b/eo/src/mpi/CMakeLists.txt index ebf16335a..2c4eaf149 100644 --- a/eo/src/mpi/CMakeLists.txt +++ b/eo/src/mpi/CMakeLists.txt @@ -20,7 +20,7 @@ set(EOMPI_SOURCES ) add_library(eompi STATIC ${EOMPI_SOURCES}) -install(TARGETS eompi ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS eompi EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) file(GLOB HDRS *.h) install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/eo/mpi COMPONENT headers) diff --git a/eo/src/pyeo/CMakeLists.txt b/eo/src/pyeo/CMakeLists.txt index a8f6c8d54..3e057d924 100644 --- a/eo/src/pyeo/CMakeLists.txt +++ b/eo/src/pyeo/CMakeLists.txt @@ -48,7 +48,7 @@ set(EO_SOURCES # shared library add_library(PyEO MODULE ${SOURCES} ${EO_SOURCES}) -install(TARGETS PyEO LIBRARY DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS PyEO EXPORT paradiseo-targets LIBRARY DESTINATION ${LIB} COMPONENT libraries) # python 2.5 must have pyd if(WIN32 AND NOT CYGWIN) diff --git a/eo/src/serial/CMakeLists.txt b/eo/src/serial/CMakeLists.txt index d7a6fb574..a1f3578a8 100644 --- a/eo/src/serial/CMakeLists.txt +++ b/eo/src/serial/CMakeLists.txt @@ -20,7 +20,7 @@ set(EOSERIAL_SOURCES ) add_library(eoserial STATIC ${EOSERIAL_SOURCES}) -install(TARGETS eoserial ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS eoserial EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) file(GLOB HDRS *.h) install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/eo/serial COMPONENT headers) diff --git a/eo/src/utils/CMakeLists.txt b/eo/src/utils/CMakeLists.txt index 8e927dd4f..649344b0e 100644 --- a/eo/src/utils/CMakeLists.txt +++ b/eo/src/utils/CMakeLists.txt @@ -33,7 +33,7 @@ set(EOUTILS_SOURCES ) add_library(eoutils STATIC ${EOUTILS_SOURCES}) -install(TARGETS eoutils ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS eoutils EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) ###################################################################################### diff --git a/moeo/src/CMakeLists.txt b/moeo/src/CMakeLists.txt index a696cdbb5..c06351346 100644 --- a/moeo/src/CMakeLists.txt +++ b/moeo/src/CMakeLists.txt @@ -23,7 +23,7 @@ add_library(moeo STATIC ${MOEO_CORE}) set(MOEO_VERSION ${GLOBAL_VERSION}) set_target_properties(moeo PROPERTIES VERSION "${MOEO_VERSION}") -install(TARGETS moeo ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS moeo EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) ###################################################################################### ### 3) Look for headers diff --git a/smp/src/CMakeLists.txt b/smp/src/CMakeLists.txt index 07cde8272..d8568f97d 100644 --- a/smp/src/CMakeLists.txt +++ b/smp/src/CMakeLists.txt @@ -37,7 +37,7 @@ set (SMP_FILE add_library(smp STATIC ${SMP_FILE}) -install(TARGETS smp ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS smp EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) ###################################################################################### ### 3) Look for headers From aa5dbe82c6e0930f1b4dd3289492e4755d188d87 Mon Sep 17 00:00:00 2001 From: Ronaldd Pinho Date: Sat, 29 Jun 2019 18:44:27 -0300 Subject: [PATCH 130/419] Use relative includes in headers and absolute in code - relative includes in headers - absolute includes in exe code - include sstream lib in eoExceptions.h - fix ga/make_op_ga.cpp - fix eoSGATransform.h --- eo/src/EO.h | 4 +- eo/src/PO.h | 2 +- eo/src/apply.h | 8 +- eo/src/do/make_algo_easea.h | 28 +-- eo/src/do/make_algo_scalar.h | 36 ++-- eo/src/do/make_checkpoint.h | 10 +- eo/src/do/make_checkpoint_FDC.h | 10 +- eo/src/do/make_checkpoint_assembled.h | 10 +- eo/src/do/make_continue.h | 16 +- eo/src/do/make_general_replacement.h | 8 +- eo/src/do/make_pop.h | 10 +- eo/src/do/make_run.h | 2 +- eo/src/eo | 206 ++++++++++--------- eo/src/eoAlgo.h | 4 +- eo/src/eoBinaryFlight.h | 2 +- eo/src/eoBitParticle.h | 2 +- eo/src/eoBreed.h | 8 +- eo/src/eoCellularEasyEA.h | 12 +- eo/src/eoCloneOps.h | 2 +- eo/src/eoCombinedContinue.h | 8 +- eo/src/eoCombinedInit.h | 2 +- eo/src/eoConstrictedVariableWeightVelocity.h | 10 +- eo/src/eoConstrictedVelocity.h | 10 +- eo/src/eoContinue.h | 6 +- eo/src/eoCounter.h | 6 +- eo/src/eoCtrlCContinue.cpp | 2 +- eo/src/eoCtrlCContinue.h | 2 +- eo/src/eoDetSelect.h | 4 +- eo/src/eoDetTournamentSelect.h | 8 +- eo/src/eoDistribUpdater.h | 4 +- eo/src/eoDistribution.h | 4 +- eo/src/eoDualFitness.h | 4 +- eo/src/eoEDA.h | 2 +- eo/src/eoEasyEA.h | 18 +- eo/src/eoEasyPSO.h | 8 +- eo/src/eoEvalContinue.h | 4 +- eo/src/eoEvalCounterThrowException.h | 6 +- eo/src/eoEvalDump.h | 2 +- eo/src/eoEvalFunc.h | 2 +- eo/src/eoEvalFuncCounter.h | 4 +- eo/src/eoEvalFuncCounterBounder.h | 4 +- eo/src/eoEvalFuncPtr.h | 2 +- eo/src/eoEvalKeepBest.h | 4 +- eo/src/eoEvalTimeThrowException.h | 2 +- eo/src/eoEvalUserTimeThrowException.h | 2 +- eo/src/eoExceptions.h | 1 + eo/src/eoExtendedVelocity.h | 12 +- eo/src/eoFactory.h | 4 +- eo/src/eoFitContinue.h | 4 +- eo/src/eoFitnessScalingSelect.h | 4 +- eo/src/eoFixedInertiaWeightedVelocity.h | 10 +- eo/src/eoFlOrBinOp.h | 4 +- eo/src/eoFlOrMonOp.h | 6 +- eo/src/eoFlOrQuadOp.h | 4 +- eo/src/eoFlight.h | 4 +- eo/src/eoFunctorStore.cpp | 4 +- eo/src/eoFunctorStore.h | 2 +- eo/src/eoG3Replacement.h | 12 +- eo/src/eoGaussRealWeightUp.h | 4 +- eo/src/eoGenContinue.h | 6 +- eo/src/eoGenOp.h | 6 +- eo/src/eoGeneralBreeder.h | 12 +- eo/src/eoInit.h | 8 +- eo/src/eoInitializer.h | 10 +- eo/src/eoInt.h | 2 +- eo/src/eoIntegerVelocity.h | 12 +- eo/src/eoInvalidateOps.h | 2 +- eo/src/eoInvertedContinue.h | 2 +- eo/src/eoLinearDecreasingWeightUp.h | 2 +- eo/src/eoLinearFitScaling.h | 4 +- eo/src/eoLinearTopology.h | 6 +- eo/src/eoMGGReplacement.h | 12 +- eo/src/eoMerge.h | 6 +- eo/src/eoMergeReduce.h | 12 +- eo/src/eoNDSorting.h | 6 +- eo/src/eoObject.h | 6 +- eo/src/eoOneToOneBreeder.h | 18 +- eo/src/eoOp.h | 8 +- eo/src/eoOpContainer.h | 2 +- eo/src/eoOpSelMason.h | 6 +- eo/src/eoOrderXover.h | 4 +- eo/src/eoPSO.h | 2 +- eo/src/eoPartiallyMappedXover.h | 2 +- eo/src/eoParticleBestInit.h | 2 +- eo/src/eoParticleFullInitializer.h | 10 +- eo/src/eoPerf2Worth.h | 6 +- eo/src/eoPeriodicContinue.h | 4 +- eo/src/eoPersistent.cpp | 2 +- eo/src/eoPop.h | 8 +- eo/src/eoPopEvalFunc.h | 14 +- eo/src/eoPopulator.h | 4 +- eo/src/eoPrintable.cpp | 2 +- eo/src/eoPrintable.h | 4 +- eo/src/eoProportionalCombinedOp.h | 12 +- eo/src/eoProportionalSelect.h | 8 +- eo/src/eoRandomRealWeightUp.h | 4 +- eo/src/eoRandomSelect.h | 4 +- eo/src/eoRanking.h | 2 +- eo/src/eoRankingSelect.h | 4 +- eo/src/eoRealBoundModifier.h | 4 +- eo/src/eoRealParticle.h | 2 +- eo/src/eoReduce.h | 8 +- eo/src/eoReduceMerge.h | 12 +- eo/src/eoReduceMergeReduce.h | 10 +- eo/src/eoReduceSplit.h | 6 +- eo/src/eoReplacement.h | 10 +- eo/src/eoRingTopology.h | 4 +- eo/src/eoSGA.h | 16 +- eo/src/eoSGATransform.h | 8 +- eo/src/eoSIGContinue.h | 2 +- eo/src/eoSecondsElapsedContinue.h | 2 +- eo/src/eoSelect.h | 2 +- eo/src/eoSelectFactory.h | 6 +- eo/src/eoSelectFromWorth.h | 6 +- eo/src/eoSelectMany.h | 6 +- eo/src/eoSelectNumber.h | 4 +- eo/src/eoSelectOne.h | 4 +- eo/src/eoSelectPerc.h | 4 +- eo/src/eoSharing.h | 4 +- eo/src/eoSharingSelect.h | 4 +- eo/src/eoSigBinaryFlight.h | 2 +- eo/src/eoSimpleEDA.h | 10 +- eo/src/eoSocialNeighborhood.h | 2 +- eo/src/eoStandardFlight.h | 2 +- eo/src/eoStandardVelocity.h | 12 +- eo/src/eoStarTopology.h | 4 +- eo/src/eoSteadyFitContinue.h | 4 +- eo/src/eoStochTournamentSelect.h | 4 +- eo/src/eoStochasticUniversalSelect.h | 8 +- eo/src/eoSurviveAndDie.h | 10 +- eo/src/eoSyncEasyPSO.h | 10 +- eo/src/eoTimeContinue.h | 4 +- eo/src/eoTopology.h | 2 +- eo/src/eoTransform.h | 2 +- eo/src/eoTruncSelect.h | 4 +- eo/src/eoTruncatedSelectMany.h | 6 +- eo/src/eoTruncatedSelectOne.h | 6 +- eo/src/eoVariableInertiaWeightedVelocity.h | 10 +- eo/src/eoVariableLengthCrossover.h | 4 +- eo/src/eoVariableLengthMutation.h | 6 +- eo/src/eoVector.h | 4 +- eo/src/eoVectorParticle.h | 2 +- eo/src/eoVelocity.h | 8 +- eo/src/eoVelocityInit.h | 6 +- eo/src/eoWeightUpdater.h | 2 +- eo/src/es.h | 26 +-- eo/src/es/CMAParams.cpp | 4 +- eo/src/es/CMAState.cpp | 11 +- eo/src/es/eoCMABreed.h | 6 +- eo/src/es/eoCMAInit.h | 6 +- eo/src/es/eoEsChromInit.h | 8 +- eo/src/es/eoEsFull.h | 2 +- eo/src/es/eoEsGlobalXover.h | 12 +- eo/src/es/eoEsMutate.h | 20 +- eo/src/es/eoEsMutationInit.h | 2 +- eo/src/es/eoEsSimple.h | 4 +- eo/src/es/eoEsStandardXover.h | 12 +- eo/src/es/eoEsStdev.h | 2 +- eo/src/es/eoNormalMutation.h | 10 +- eo/src/es/eoReal.h | 2 +- eo/src/es/eoRealAtomXover.h | 4 +- eo/src/es/eoRealInitBounded.h | 8 +- eo/src/es/eoRealOp.h | 6 +- eo/src/es/eoSBXcross.h | 10 +- eo/src/es/make_algo_scalar_es.cpp | 8 +- eo/src/es/make_algo_scalar_real.cpp | 4 +- eo/src/es/make_checkpoint_es.cpp | 8 +- eo/src/es/make_checkpoint_real.cpp | 4 +- eo/src/es/make_continue_es.cpp | 8 +- eo/src/es/make_continue_real.cpp | 4 +- eo/src/es/make_es.h | 26 +-- eo/src/es/make_genotype_es.cpp | 2 +- eo/src/es/make_genotype_real.cpp | 2 +- eo/src/es/make_genotype_real.h | 10 +- eo/src/es/make_op.h | 22 +- eo/src/es/make_op_es.cpp | 2 +- eo/src/es/make_op_es.h | 28 +-- eo/src/es/make_op_real.cpp | 2 +- eo/src/es/make_op_real.h | 22 +- eo/src/es/make_pop_es.cpp | 8 +- eo/src/es/make_pop_real.cpp | 4 +- eo/src/es/make_real.h | 22 +- eo/src/es/make_run_es.cpp | 10 +- eo/src/es/make_run_real.cpp | 6 +- eo/src/ga.h | 4 +- eo/src/ga/ChangeLog | 6 +- eo/src/ga/eoBit.h | 2 +- eo/src/ga/eoBitOp.h | 8 +- eo/src/ga/eoBitOpFactory.h | 4 +- eo/src/ga/eoBoolFlip.h | 2 +- eo/src/ga/eoPBILAdditive.h | 4 +- eo/src/ga/eoPBILDistrib.h | 2 +- eo/src/ga/eoPBILOrg.h | 4 +- eo/src/ga/make_PBILdistrib.h | 8 +- eo/src/ga/make_PBILupdate.h | 8 +- eo/src/ga/make_algo_scalar_ga.cpp | 4 +- eo/src/ga/make_checkpoint_ga.cpp | 4 +- eo/src/ga/make_continue_ga.cpp | 4 +- eo/src/ga/make_ga.h | 18 +- eo/src/ga/make_genotype_ga.cpp | 2 +- eo/src/ga/make_genotype_ga.h | 8 +- eo/src/ga/make_op.h | 18 +- eo/src/ga/make_op_ga.cpp | 2 +- eo/src/ga/make_pop_ga.cpp | 4 +- eo/src/ga/make_run_ga.cpp | 6 +- eo/src/gp/eoParseTree.h | 8 +- eo/src/gp/eoParseTreeDepthInit.h | 10 +- eo/src/gp/eoParseTreeOp.h | 6 +- eo/src/gp/eoStParseTreeDepthInit.h | 8 +- eo/src/gp/eoStParseTreeOp.h | 6 +- eo/src/mpi/eoMpi.h | 8 +- eo/src/mpi/eoMpiNode.cpp | 2 +- eo/src/mpi/eoMultiStart.h | 2 +- eo/src/mpi/eoParallelApply.h | 2 +- eo/src/mpi/eoTerminateJob.h | 6 +- eo/src/mpi/implMpi.cpp | 2 +- eo/src/mpi/implMpi.h | 8 +- eo/src/other/eoExternalEO.h | 2 +- eo/src/other/eoExternalOpFunctions.h | 8 +- eo/src/other/eoString.h | 3 +- eo/src/other/external_eo | 4 +- eo/src/pyeo/PyEO.cpp | 2 +- eo/src/pyeo/PyEO.h | 2 +- eo/src/pyeo/abstract1.cpp | 10 +- eo/src/pyeo/algos.cpp | 8 +- eo/src/pyeo/breeders.cpp | 6 +- eo/src/pyeo/continuators.cpp | 14 +- eo/src/pyeo/def_abstract_functor.h | 2 +- eo/src/pyeo/geneticOps.cpp | 10 +- eo/src/pyeo/mergers.cpp | 2 +- eo/src/pyeo/monitors.cpp | 4 +- eo/src/pyeo/perf2worth.cpp | 2 +- eo/src/pyeo/random_numbers.cpp | 2 +- eo/src/pyeo/reduce.cpp | 2 +- eo/src/pyeo/replacement.cpp | 10 +- eo/src/pyeo/selectOne.cpp | 12 +- eo/src/pyeo/selectors.cpp | 14 +- eo/src/pyeo/statistics.cpp | 2 +- eo/src/pyeo/valueParam.cpp | 2 +- eo/src/utils/checkpointing | 38 ++-- eo/src/utils/eoAssembledFitnessStat.h | 4 +- eo/src/utils/eoCheckPoint.h | 8 +- eo/src/utils/eoDistance.h | 2 +- eo/src/utils/eoFDCStat.h | 6 +- eo/src/utils/eoFileMonitor.cpp | 6 +- eo/src/utils/eoFileMonitor.h | 4 +- eo/src/utils/eoFileSnapshot.h | 6 +- eo/src/utils/eoFuncPtrStat.h | 4 +- eo/src/utils/eoGenCounter.h | 2 +- eo/src/utils/eoGnuplot1DMonitor.cpp | 4 +- eo/src/utils/eoGnuplot1DMonitor.h | 8 +- eo/src/utils/eoGnuplot1DSnapshot.h | 8 +- eo/src/utils/eoHowMany.h | 2 +- eo/src/utils/eoIntBounds.h | 2 +- eo/src/utils/eoLogger.h | 2 +- eo/src/utils/eoMOFitnessStat.h | 2 +- eo/src/utils/eoMonitor.h | 2 +- eo/src/utils/eoOStreamMonitor.cpp | 8 +- eo/src/utils/eoOStreamMonitor.h | 6 +- eo/src/utils/eoParallel.h | 2 +- eo/src/utils/eoParam.h | 2 +- eo/src/utils/eoParser.cpp | 6 +- eo/src/utils/eoParser.h | 6 +- eo/src/utils/eoPopStat.h | 2 +- eo/src/utils/eoRNG.h | 5 +- eo/src/utils/eoRealBounds.h | 2 +- eo/src/utils/eoRealVectorBounds.h | 4 +- eo/src/utils/eoRndGenerators.h | 2 +- eo/src/utils/eoScalarFitnessStat.h | 4 +- eo/src/utils/eoSignal.cpp | 2 +- eo/src/utils/eoSignal.h | 4 +- eo/src/utils/eoStat.h | 12 +- eo/src/utils/eoState.cpp | 4 +- eo/src/utils/eoState.h | 2 +- eo/src/utils/eoStdoutMonitor.h | 4 +- eo/src/utils/eoTimeCounter.h | 3 +- eo/src/utils/eoTimedMonitor.h | 4 +- eo/src/utils/eoTimer.h | 4 +- eo/src/utils/eoUniformInit.h | 2 +- eo/src/utils/eoUpdatable.h | 2 +- eo/src/utils/eoUpdater.cpp | 4 +- eo/src/utils/eoUpdater.h | 6 +- eo/src/utils/make_help.cpp | 2 +- eo/src/utils/selectors.h | 2 +- 284 files changed, 991 insertions(+), 984 deletions(-) diff --git a/eo/src/EO.h b/eo/src/EO.h index f904559d4..19708314f 100644 --- a/eo/src/EO.h +++ b/eo/src/EO.h @@ -28,8 +28,8 @@ //----------------------------------------------------------------------------- #include // std::runtime_error -#include // eoObject -#include // eoPersistent +#include "eoObject.h" // eoObject +#include "eoPersistent.h" // eoPersistent /** @defgroup Core Core components diff --git a/eo/src/PO.h b/eo/src/PO.h index 0c246135e..c4225cf61 100644 --- a/eo/src/PO.h +++ b/eo/src/PO.h @@ -27,7 +27,7 @@ //----------------------------------------------------------------------------- #include -#include +#include "EO.h" //----------------------------------------------------------------------------- /** PO inheriting from EO is specially designed for particle swarm optimization particle.POs have got a fitness, diff --git a/eo/src/apply.h b/eo/src/apply.h index 45c4cfc2d..71cf892fc 100644 --- a/eo/src/apply.h +++ b/eo/src/apply.h @@ -26,10 +26,10 @@ #ifndef _apply_h #define _apply_h -#include -#include -#include -#include +#include "utils/eoParallel.h" +#include "utils/eoParser.h" +#include "utils/eoLogger.h" +#include "eoFunctor.h" #include #ifdef _OPENMP diff --git a/eo/src/do/make_algo_easea.h b/eo/src/do/make_algo_easea.h index c432c1e82..3fadf05ec 100644 --- a/eo/src/do/make_algo_easea.h +++ b/eo/src/do/make_algo_easea.h @@ -27,35 +27,35 @@ #ifndef _make_algo_easea_h #define _make_algo_easea_h -#include // for eo_is_a_rate +#include "../utils/eoData.h" // for eo_is_a_rate // everything tha's needed for the algorithms - SCALAR fitness // Selection // the eoSelectOne's -#include -#include -#include -#include -#include -#include -#include +#include "../eoRandomSelect.h" +#include "../eoSequentialSelect.h" +#include "../eoDetTournamentSelect.h" +#include "../eoProportionalSelect.h" +#include "../eoFitnessScalingSelect.h" +#include "../eoRankingSelect.h" +#include "../eoStochTournamentSelect.h" // #include included in all others // Breeders -#include +#include "../eoGeneralBreeder.h" // Replacement #include "make_general_replacement.h" -#include "eoMGGReplacement.h" -#include "eoG3Replacement.h" +#include "../eoMGGReplacement.h" +#include "../eoG3Replacement.h" // Algorithm (only this one needed) -#include +#include "../eoEasyEA.h" // also need the parser and param includes -#include -#include +#include "../utils/eoParser.h" +#include "../utils/eoState.h" /* * This function builds the algorithm (i.e. selection and replacement) diff --git a/eo/src/do/make_algo_scalar.h b/eo/src/do/make_algo_scalar.h index 52df8f4f4..92e16d2f2 100644 --- a/eo/src/do/make_algo_scalar.h +++ b/eo/src/do/make_algo_scalar.h @@ -27,39 +27,39 @@ #ifndef _make_algo_scalar_h #define _make_algo_scalar_h -#include // for eo_is_a_rate +#include "../utils/eoData.h" // for eo_is_a_rate // everything tha's needed for the algorithms - SCALAR fitness // Selection // the eoSelectOne's -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "../eoRandomSelect.h" +#include "../eoSequentialSelect.h" +#include "../eoDetTournamentSelect.h" +#include "../eoProportionalSelect.h" +#include "../eoFitnessScalingSelect.h" +#include "../eoRankingSelect.h" +#include "../eoStochTournamentSelect.h" +#include "../eoSharingSelect.h" +#include "../utils/eoDistance.h" // Breeders -#include +#include "../eoGeneralBreeder.h" // Replacement // #include -#include -#include -#include +#include "../eoMergeReduce.h" +#include "../eoReduceMerge.h" +#include "../eoSurviveAndDie.h" // distance -#include +#include "../utils/eoDistance.h" // Algorithm (only this one needed) -#include +#include "../eoEasyEA.h" // also need the parser and param includes -#include -#include +#include "../utils/eoParser.h" +#include "../utils/eoState.h" /* diff --git a/eo/src/do/make_checkpoint.h b/eo/src/do/make_checkpoint.h index cc0746ddb..c06773480 100644 --- a/eo/src/do/make_checkpoint.h +++ b/eo/src/do/make_checkpoint.h @@ -33,11 +33,11 @@ #include -#include -#include // for minimizing_fitness() -#include -#include -#include +#include "../eoScalarFitness.h" +#include "../utils/selectors.h" // for minimizing_fitness() +#include "../EO.h" +#include "../eoEvalFuncCounter.h" +#include "../utils/checkpointing" // at the moment, in utils/make_help.cpp // this should become some eoUtils.cpp with corresponding eoUtils.h diff --git a/eo/src/do/make_checkpoint_FDC.h b/eo/src/do/make_checkpoint_FDC.h index f241667f7..601f94a12 100644 --- a/eo/src/do/make_checkpoint_FDC.h +++ b/eo/src/do/make_checkpoint_FDC.h @@ -29,11 +29,11 @@ #include -#include -#include // for minimizing_fitness() -#include -#include -#include +#include "../eoScalarFitness.h" +#include "../utils/selectors.h" // for minimizing_fitness() +#include "../EO.h" +#include "../eoEvalFuncCounter.h" +#include "../utils/checkpointing" // at the moment, in utils/make_help.cpp // this should become some eoUtils.cpp with corresponding eoUtils.h diff --git a/eo/src/do/make_checkpoint_assembled.h b/eo/src/do/make_checkpoint_assembled.h index 27d050ada..6b2bb5164 100644 --- a/eo/src/do/make_checkpoint_assembled.h +++ b/eo/src/do/make_checkpoint_assembled.h @@ -38,11 +38,11 @@ #include #include -#include -#include -#include -#include -#include +#include "../eoScalarFitnessAssembled.h" +#include "../utils/selectors.h" +#include "../EO.h" +#include "../eoEvalFuncCounter.h" +#include "../utils/checkpointing" // at the moment, in utils/make_help.cpp // this should become some eoUtils.cpp with corresponding eoUtils.h diff --git a/eo/src/do/make_continue.h b/eo/src/do/make_continue.h index 27b4e9450..f09bf8642 100644 --- a/eo/src/do/make_continue.h +++ b/eo/src/do/make_continue.h @@ -34,18 +34,18 @@ It can then be instantiated, and compiled on its own for a given EOType */ // Continuators - all include eoContinue.h -#include -#include -#include -#include -#include +#include "../eoCombinedContinue.h" +#include "../eoGenContinue.h" +#include "../eoSteadyFitContinue.h" +#include "../eoEvalContinue.h" +#include "../eoFitContinue.h" #ifndef _MSC_VER -#include // CtrlC handling (using 2 global variables!) +#include "../eoCtrlCContinue.h" // CtrlC handling (using 2 global variables!) #endif // also need the parser and param includes -#include -#include +#include "../utils/eoParser.h" +#include "../utils/eoState.h" /////////////////// the stopping criterion //////////////// diff --git a/eo/src/do/make_general_replacement.h b/eo/src/do/make_general_replacement.h index 1d42345c8..52c54ff6f 100644 --- a/eo/src/do/make_general_replacement.h +++ b/eo/src/do/make_general_replacement.h @@ -27,14 +27,14 @@ #ifndef _make_general_replacement_h #define _make_general_replacement_h -#include // for eo_is_a_rate +#include "../utils/eoData.h" // for eo_is_a_rate // Replacement -#include +#include "../eoReduceMergeReduce.h" // also need the parser and param includes -#include -#include +#include "../utils/eoParser.h" +#include "../utils/eoState.h" /** a helper function that decodes a parameter read by the parser into an diff --git a/eo/src/do/make_pop.h b/eo/src/do/make_pop.h index c2a1d1a84..516d7a770 100644 --- a/eo/src/do/make_pop.h +++ b/eo/src/do/make_pop.h @@ -28,11 +28,11 @@ #define _make_pop_h #include // for time(0) for random seeding -#include -#include -#include -#include -#include +#include "../eoPop.h" +#include "../eoInit.h" +#include "../utils/eoRNG.h" +#include "../utils/eoParser.h" +#include "../utils/eoState.h" /** @defgroup Builders Automatic builders * diff --git a/eo/src/do/make_run.h b/eo/src/do/make_run.h index 485cb8700..e53831f80 100644 --- a/eo/src/do/make_run.h +++ b/eo/src/do/make_run.h @@ -28,7 +28,7 @@ #define _make_run_h // Algorithm (only this one needed) -#include +#include "../eoAlgo.h" /* * A trivial function - only here to allow instanciation with a give EOType diff --git a/eo/src/eo b/eo/src/eo index 8196e2b14..39109bdb6 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -33,118 +33,120 @@ #endif // general purpose -#include -#include -#include -#include -#include -#include -#include +#include "utils/eoData.h" +#include "eoObject.h" +#include "eoPrintable.h" +#include "eoPersistent.h" +#include "eoScalarFitness.h" +#include "eoDualFitness.h" +#include "EO.h" -#include -#include -#include +#include "utils/rnd_generators.h" +#include "eoFunctor.h" +#include "apply.h" // eo's -#include +#include "eoVector.h" -#include +#include "other/eoString.h" -#include -#include -#include +#include "utils/eoRndGenerators.h" +#include "eoInit.h" +#include "utils/eoUniformInit.h" // the variation operators -#include -#include -#include -#include +#include "eoOp.h" +#include "eoGenOp.h" +#include "eoCloneOps.h" +#include "eoOpContainer.h" // combinations of simple eoOps (eoMonOp and eoQuadOp) -#include +#include "eoProportionalCombinedOp.h" // didactic (mimics SGA-like variation into an eoGenOp) // calls crossover and mutation sequentially, // with their respective mutation rates -#include +#include "eoSGAGenOp.h" // its dual: crossover, mutation (and copy) - proportional choice // w.r.t. given relative weights -#include +#include "eoPropGAGenOp.h" // population -#include +#include "eoPop.h" // Evaluation functions (all include eoEvalFunc.h) -#include -#include -#include -#include -#include +#include "eoPopEvalFunc.h" +#include "eoEvalFuncPtr.h" +#include "eoEvalCounterThrowException.h" +#include "eoEvalTimeThrowException.h" +#include "eoEvalUserTimeThrowException.h" // Continuators - all include eoContinue.h -#include -#include -#include -#include -#include -#include -#include // added th T.Legrand +#include "eoCombinedContinue.h" +#include "eoGenContinue.h" +#include "eoSteadyFitContinue.h" +#include "eoEvalContinue.h" +#include "eoFitContinue.h" +#include "eoPeriodicContinue.h" +#include "eoTimeContinue.h" // added th T.Legrand #ifndef _MSC_VER -#include // CtrlC handling (using 2 global variables!) +#include "eoCtrlCContinue.h" // CtrlC handling (using 2 global variables!) #endif + // Selection // the eoSelectOne's -#include -#include -#include -#include -#include // also contains eoLinearFitScaling.h -#include -#include -#include +#include "eoRandomSelect.h" +#include "eoSequentialSelect.h" +#include "eoDetTournamentSelect.h" +#include "eoProportionalSelect.h" +#include "eoFitnessScalingSelect.h" // also contains eoLinearFitScaling.h +#include "eoRankingSelect.h" +#include "eoStochTournamentSelect.h" +#include "eoSharingSelect.h" + // Embedding truncation selection -#include +#include "eoTruncatedSelectOne.h" // the batch selection - from an eoSelectOne -#include -#include -#include -#include +#include "eoSelectPerc.h" +#include "eoSelectNumber.h" +#include "eoSelectMany.h" +#include "eoTruncatedSelectMany.h" // other batch selections // DetSelect can also be obtained as eoSequentialSelect, an eoSelectOne // (using setup and an index) -#include -#include +#include "eoDetSelect.h" +#include "eoRankMuSelect.h" // Breeders -#include // applies one eoGenOp, stop on offspring count -// #include // parent + SINGLE offspring compete (e.g. DE) - not ready yet... +#include "eoGeneralBreeder.h" // applies one eoGenOp, stop on offspring count +// #include "eoOneToOneBreeder.h" // parent + SINGLE offspring compete (e.g. DE) - not ready yet... // Replacement -// #include -#include -#include -#include +// #include "eoReplacement.h" +#include "eoMergeReduce.h" +#include "eoReduceMerge.h" +#include "eoSurviveAndDie.h" // a simple transformer -#include +#include "eoSGATransform.h" // Perf2Worth stuff - includes eoSelectFromWorth.h -#include +#include "eoNDSorting.h" // Algorithms -#include -#include -// #include removed for a while - until eoGenOp is done +#include "eoEasyEA.h" +#include "eoSGA.h" +// #include "eoEvolutionStrategy.h" removed for a while - until eoGenOp is done // Utils -#include -#include // includes eoRealBounds.h -#include // no eoIntVectorBounds +#include "utils/checkpointing" +#include "utils/eoRealVectorBounds.h" // includes eoRealBounds.h +#include "utils/eoIntBounds.h" // no eoIntVectorBounds // aliens -#include -#include +#include "other/external_eo" +#include "eoCounter.h" //----------------------------------------------------------------------------- @@ -154,54 +156,54 @@ /*** Particle Swarm Optimization stuff ***/ // basic particle definitions -#include -#include -#include -#include +#include "PO.h" +#include "eoVectorParticle.h" +#include "eoBitParticle.h" +#include "eoRealParticle.h" // initialization -#include -#include +#include "eoParticleBestInit.h" +#include "eoInitializer.h" // velocities -#include -#include -#include -#include -#include -#include -#include -#include +#include "eoVelocity.h" +#include "eoStandardVelocity.h" +#include "eoExtendedVelocity.h" +#include "eoIntegerVelocity.h" +#include "eoConstrictedVelocity.h" +#include "eoFixedInertiaWeightedVelocity.h" +#include "eoVariableInertiaWeightedVelocity.h" +#include "eoConstrictedVariableWeightVelocity.h" // flights -#include -#include -#include -#include -#include +#include "eoFlight.h" +#include "eoStandardFlight.h" +#include "eoVelocityInit.h" +#include "eoBinaryFlight.h" +#include "eoSigBinaryFlight.h" // topologies -#include -#include -#include -#include -#include -#include +#include "eoTopology.h" +#include "eoStarTopology.h" +#include "eoLinearTopology.h" +#include "eoRingTopology.h" +#include "eoNeighborhood.h" +#include "eoSocialNeighborhood.h" // PS algorithms -#include -#include -#include +#include "eoPSO.h" +#include "eoEasyPSO.h" +#include "eoSyncEasyPSO.h" // utils -#include -#include -#include -#include -#include +#include "eoRealBoundModifier.h" +#include "eoRandomRealWeightUp.h" +#include "eoWeightUpdater.h" +#include "eoLinearDecreasingWeightUp.h" +#include "eoGaussRealWeightUp.h" -#include -#include +#include "utils/eoLogger.h" +#include "utils/eoParallel.h" #endif diff --git a/eo/src/eoAlgo.h b/eo/src/eoAlgo.h index 494b7b76c..b19b7a0e6 100644 --- a/eo/src/eoAlgo.h +++ b/eo/src/eoAlgo.h @@ -25,8 +25,8 @@ #ifndef _EOALGO_H #define _EOALGO_H -#include // for population -#include +#include "eoPop.h" // for population +#include "eoFunctor.h" /** @defgroup Algorithms Algorithms diff --git a/eo/src/eoBinaryFlight.h b/eo/src/eoBinaryFlight.h index 9672bd3f3..34517c553 100644 --- a/eo/src/eoBinaryFlight.h +++ b/eo/src/eoBinaryFlight.h @@ -26,7 +26,7 @@ #define EOBINARYFLIGHT_H //----------------------------------------------------------------------------- -#include +#include "eoFlight.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoBitParticle.h b/eo/src/eoBitParticle.h index 87f98aa1b..9d03ef0cb 100644 --- a/eo/src/eoBitParticle.h +++ b/eo/src/eoBitParticle.h @@ -26,7 +26,7 @@ #define _EOBITPARTICLE_H -#include +#include "eoVectorParticle.h" /** eoBitParticle: Implementation of a bit-coded particle (swarm optimization). diff --git a/eo/src/eoBreed.h b/eo/src/eoBreed.h index 0b00ec584..fd8448543 100644 --- a/eo/src/eoBreed.h +++ b/eo/src/eoBreed.h @@ -27,10 +27,10 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include +#include "eoPop.h" +#include "eoFunctor.h" +#include "eoSelect.h" +#include "eoTransform.h" //----------------------------------------------------------------------------- /** Breeding: combination of selecting and transforming a population diff --git a/eo/src/eoCellularEasyEA.h b/eo/src/eoCellularEasyEA.h index fbf3085fc..37e4ec009 100644 --- a/eo/src/eoCellularEasyEA.h +++ b/eo/src/eoCellularEasyEA.h @@ -24,12 +24,12 @@ #ifndef eoCellularEasyEA_h #define eoCellularEasyEA_h -#include -#include -#include -#include -#include -#include +#include "eoContinue.h" +#include "eoEvalFunc.h" +#include "eoSelectOne.h" +#include "eoPopEvalFunc.h" +#include "eoAlgo.h" +#include "eoOp.h" /** The abstract cellular easy algorithm. diff --git a/eo/src/eoCloneOps.h b/eo/src/eoCloneOps.h index e53cbd749..2093fd632 100644 --- a/eo/src/eoCloneOps.h +++ b/eo/src/eoCloneOps.h @@ -25,7 +25,7 @@ #ifndef _eoCloneOps_H #define _eoCloneOps_H -#include +#include "eoOp.h" /** * The different null-variation operators (i.e. they do nothing) diff --git a/eo/src/eoCombinedContinue.h b/eo/src/eoCombinedContinue.h index 5162ffaa9..96878b4ea 100644 --- a/eo/src/eoCombinedContinue.h +++ b/eo/src/eoCombinedContinue.h @@ -22,15 +22,15 @@ Authors : todos@geneura.ugr.es Marc Schoenauer - Ramn Casero Caas - Johann Dro + Ram�n Casero Ca�as + Johann Dr�o */ //----------------------------------------------------------------------------- #ifndef _eoCombinedContinue_h #define _eoCombinedContinue_h -#include +#include "eoContinue.h" /** Combined continuators - logical AND: @@ -40,7 +40,7 @@ Authors : to be consistent with other Combined constructs and allow to easily handle more than 2 continuators -02/2003 Ramn Casero Caas - added the removeLast() method +02/2003 Ram�n Casero Ca�as - added the removeLast() method @ingroup Combination */ diff --git a/eo/src/eoCombinedInit.h b/eo/src/eoCombinedInit.h index cc93620d3..98bc05d12 100644 --- a/eo/src/eoCombinedInit.h +++ b/eo/src/eoCombinedInit.h @@ -25,7 +25,7 @@ #ifndef _eoCombinedInit_h #define _eoCombinedInit_h -#include +#include "eoInit.h" /** Combined INIT: a proportional recombination of eoInit objects diff --git a/eo/src/eoConstrictedVariableWeightVelocity.h b/eo/src/eoConstrictedVariableWeightVelocity.h index 9e96d7ef3..cff14bc44 100644 --- a/eo/src/eoConstrictedVariableWeightVelocity.h +++ b/eo/src/eoConstrictedVariableWeightVelocity.h @@ -26,11 +26,11 @@ #define EOCONSTRICTEDVARIABLEWEIGHTVELOCITY_H //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include +#include "eoVelocity.h" +#include "eoTopology.h" +#include "eoWeightUpdater.h" +#include "utils/eoRealVectorBounds.h" +#include "eoRealBoundModifier.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoConstrictedVelocity.h b/eo/src/eoConstrictedVelocity.h index 45f6e03d6..2e13bc1ef 100644 --- a/eo/src/eoConstrictedVelocity.h +++ b/eo/src/eoConstrictedVelocity.h @@ -27,11 +27,11 @@ #define EOCONSTRICTEDVELOCITY_H //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include +#include "eoFunctor.h" +#include "utils/eoRNG.h" +#include "eoPop.h" +#include "utils/eoRealVectorBounds.h" +#include "eoTopology.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoContinue.h b/eo/src/eoContinue.h index 82544115b..429ea58b7 100644 --- a/eo/src/eoContinue.h +++ b/eo/src/eoContinue.h @@ -25,9 +25,9 @@ #ifndef _eoContinue_h #define _eoContinue_h -#include -#include -#include +#include "eoFunctor.h" +#include "eoPop.h" +#include "eoPersistent.h" /** @defgroup Continuators Stopping criteria * diff --git a/eo/src/eoCounter.h b/eo/src/eoCounter.h index afd7fd2ee..d2f0f90d3 100644 --- a/eo/src/eoCounter.h +++ b/eo/src/eoCounter.h @@ -26,9 +26,9 @@ #ifndef _eoCounter_h #define _eoCounter_h -#include -#include -#include +#include "eoFunctor.h" +#include "eoFunctorStore.h" +#include "utils/eoParam.h" /** Generic counter class that counts the number of times diff --git a/eo/src/eoCtrlCContinue.cpp b/eo/src/eoCtrlCContinue.cpp index b7ee7fea3..8d2c32de2 100644 --- a/eo/src/eoCtrlCContinue.cpp +++ b/eo/src/eoCtrlCContinue.cpp @@ -28,7 +28,7 @@ #pragma warning(disable:4786) #endif -#include +#include "utils/eoLogger.h" #include #include diff --git a/eo/src/eoCtrlCContinue.h b/eo/src/eoCtrlCContinue.h index e239f7367..37b665a10 100644 --- a/eo/src/eoCtrlCContinue.h +++ b/eo/src/eoCtrlCContinue.h @@ -31,7 +31,7 @@ #define eoCtrlCContinue_h #include -#include +#include "eoContinue.h" /** * @addtogroup Continuators diff --git a/eo/src/eoDetSelect.h b/eo/src/eoDetSelect.h index c89f41f69..dce958a46 100644 --- a/eo/src/eoDetSelect.h +++ b/eo/src/eoDetSelect.h @@ -29,8 +29,8 @@ //----------------------------------------------------------------------------- -#include -#include +#include "eoSelect.h" +#include "utils/eoHowMany.h" #include //----------------------------------------------------------------------------- diff --git a/eo/src/eoDetTournamentSelect.h b/eo/src/eoDetTournamentSelect.h index c7ecf8b16..8026f7a9b 100644 --- a/eo/src/eoDetTournamentSelect.h +++ b/eo/src/eoDetTournamentSelect.h @@ -31,10 +31,10 @@ #include // #include // accumulate -#include -#include -#include -#include +#include "eoFunctor.h" +#include "eoPop.h" +#include "utils/eoLogger.h" +#include "utils/selectors.h" /** eoDetTournamentSelect: a selection method that selects ONE individual by deterministic tournament diff --git a/eo/src/eoDistribUpdater.h b/eo/src/eoDistribUpdater.h index 79b22814a..05a52c67f 100644 --- a/eo/src/eoDistribUpdater.h +++ b/eo/src/eoDistribUpdater.h @@ -28,8 +28,8 @@ #include -#include -#include +#include "eoDistribution.h" +#include "eoPop.h" /** * Base class for Distribution Evolution Algorithms within EO: diff --git a/eo/src/eoDistribution.h b/eo/src/eoDistribution.h index 6ca90fe42..1f02fe1bb 100644 --- a/eo/src/eoDistribution.h +++ b/eo/src/eoDistribution.h @@ -28,8 +28,8 @@ #include -#include -#include +#include "eoInit.h" +#include "eoPop.h" /** * Abstract class for Distribution Evolution Algorithms within EO: diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index 44839ed67..7fdf402d3 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -31,8 +31,8 @@ Authors: #include // for std::pair #include -#include -#include +#include "utils/eoStat.h" +#include "utils/eoLogger.h" /** @addtogroup Evaluation * @{ diff --git a/eo/src/eoEDA.h b/eo/src/eoEDA.h index 553b751f3..8d8a3992b 100644 --- a/eo/src/eoEDA.h +++ b/eo/src/eoEDA.h @@ -28,7 +28,7 @@ //----------------------------------------------------------------------------- -#include +#include "eoDistribution.h" /** The abstract class for estimation of disribution algorithms. * This design evolve a probability distribution diff --git a/eo/src/eoEasyEA.h b/eo/src/eoEasyEA.h index f5fc534a2..d3fd2825a 100644 --- a/eo/src/eoEasyEA.h +++ b/eo/src/eoEasyEA.h @@ -27,15 +27,15 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "apply.h" +#include "eoAlgo.h" +#include "eoPopEvalFunc.h" +#include "eoContinue.h" +#include "eoSelect.h" +#include "eoTransform.h" +#include "eoBreed.h" +#include "eoMergeReduce.h" +#include "eoReplacement.h" diff --git a/eo/src/eoEasyPSO.h b/eo/src/eoEasyPSO.h index da071bc02..3e9997e3a 100644 --- a/eo/src/eoEasyPSO.h +++ b/eo/src/eoEasyPSO.h @@ -26,10 +26,10 @@ #define _EOEASYPSO_H //----------------------------------------------------------------------------- -#include -#include -#include -#include +#include "eoContinue.h" +#include "eoPSO.h" +#include "eoVelocity.h" +#include "eoFlight.h" //----------------------------------------------------------------------------- /** An easy-to-use particle swarm algorithm. diff --git a/eo/src/eoEvalContinue.h b/eo/src/eoEvalContinue.h index ef74e0758..1933be7b7 100644 --- a/eo/src/eoEvalContinue.h +++ b/eo/src/eoEvalContinue.h @@ -26,8 +26,8 @@ #ifndef _eoEvalContinue_h #define _eoEvalContinue_h -#include -#include +#include "eoContinue.h" +#include "eoEvalFuncCounter.h" /** * Continues until a number of evaluations has been made diff --git a/eo/src/eoEvalCounterThrowException.h b/eo/src/eoEvalCounterThrowException.h index 4eb4fccc4..8b38908e4 100644 --- a/eo/src/eoEvalCounterThrowException.h +++ b/eo/src/eoEvalCounterThrowException.h @@ -26,9 +26,9 @@ Caner Candan #ifndef __eoEvalCounterThrowException_h__ #define __eoEvalCounterThrowException_h__ -#include -#include -#include +#include "eoEvalFuncCounter.h" +#include "utils/eoParam.h" +#include "eoExceptions.h" /*! Wrap an evaluation function so that an exception may be thrown when the diff --git a/eo/src/eoEvalDump.h b/eo/src/eoEvalDump.h index 78630bee7..a5ad8e3fb 100644 --- a/eo/src/eoEvalDump.h +++ b/eo/src/eoEvalDump.h @@ -25,7 +25,7 @@ #include -#include +#include "eoEvalFunc.h" /** Dump an evaluated individual to a given file. diff --git a/eo/src/eoEvalFunc.h b/eo/src/eoEvalFunc.h index b05b667b2..301cdb509 100644 --- a/eo/src/eoEvalFunc.h +++ b/eo/src/eoEvalFunc.h @@ -25,7 +25,7 @@ #ifndef eoEvalFunc_H #define eoEvalFunc_H -#include +#include "eoFunctor.h" /** @defgroup Evaluation Evaluation * @ingroup Operators diff --git a/eo/src/eoEvalFuncCounter.h b/eo/src/eoEvalFuncCounter.h index a63821d61..0641250fa 100644 --- a/eo/src/eoEvalFuncCounter.h +++ b/eo/src/eoEvalFuncCounter.h @@ -27,8 +27,8 @@ #ifndef eoEvalFuncCounter_H #define eoEvalFuncCounter_H -#include -#include +#include "eoEvalFunc.h" +#include "utils/eoParam.h" /** Counts the number of evaluations actually performed. diff --git a/eo/src/eoEvalFuncCounterBounder.h b/eo/src/eoEvalFuncCounterBounder.h index 7114e7f37..30ac03473 100644 --- a/eo/src/eoEvalFuncCounterBounder.h +++ b/eo/src/eoEvalFuncCounterBounder.h @@ -1,8 +1,8 @@ #ifndef eoEvalFuncCounterBounder_H #define eoEvalFuncCounterBounder_H -#include -#include +#include "eoEvalFunc.h" +#include "utils/eoParam.h" /** @addtogroup Evaluation * @{ diff --git a/eo/src/eoEvalFuncPtr.h b/eo/src/eoEvalFuncPtr.h index f4952c212..b0f8b01e1 100644 --- a/eo/src/eoEvalFuncPtr.h +++ b/eo/src/eoEvalFuncPtr.h @@ -28,7 +28,7 @@ #ifndef EOEVALFUNCPTR_H #define EOEVALFUNCPTR_H -#include +#include "eoEvalFunc.h" /** EOEvalFuncPtr: This class * takes an existing function pointer and converts it into a evaluation diff --git a/eo/src/eoEvalKeepBest.h b/eo/src/eoEvalKeepBest.h index 12a9a978f..133e01b87 100644 --- a/eo/src/eoEvalKeepBest.h +++ b/eo/src/eoEvalKeepBest.h @@ -25,8 +25,8 @@ #include -#include -#include +#include "eoEvalFunc.h" +#include "utils/eoParam.h" /** Evaluate with the given evaluator and keep the best individual found so far. diff --git a/eo/src/eoEvalTimeThrowException.h b/eo/src/eoEvalTimeThrowException.h index be0e149a2..3cff76512 100644 --- a/eo/src/eoEvalTimeThrowException.h +++ b/eo/src/eoEvalTimeThrowException.h @@ -23,7 +23,7 @@ Johann Dréo #include -#include +#include "eoExceptions.h" /** Check at each evaluation if a given tie contract has been reached. * diff --git a/eo/src/eoEvalUserTimeThrowException.h b/eo/src/eoEvalUserTimeThrowException.h index 2d9ccadd6..1e2edda6f 100644 --- a/eo/src/eoEvalUserTimeThrowException.h +++ b/eo/src/eoEvalUserTimeThrowException.h @@ -38,7 +38,7 @@ Johann Dréo * @ingroup Evaluation */ -#include +#include "eoExceptions.h" #ifdef __unix__ diff --git a/eo/src/eoExceptions.h b/eo/src/eoExceptions.h index 4d56ddb95..56b5fbfd8 100644 --- a/eo/src/eoExceptions.h +++ b/eo/src/eoExceptions.h @@ -26,6 +26,7 @@ Johann Dréo #include #include +#include class eoMaxException : public std::exception {}; diff --git a/eo/src/eoExtendedVelocity.h b/eo/src/eoExtendedVelocity.h index e7667204c..bcbd51c3a 100644 --- a/eo/src/eoExtendedVelocity.h +++ b/eo/src/eoExtendedVelocity.h @@ -26,12 +26,12 @@ #define eoExtendedVelocity_H //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include +#include "eoFunctor.h" +#include "utils/eoRNG.h" +#include "eoPop.h" +#include "utils/eoRealVectorBounds.h" +#include "eoRealBoundModifier.h" +#include "eoTopology.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoFactory.h b/eo/src/eoFactory.h index 73a8faf1b..51cbc678b 100644 --- a/eo/src/eoFactory.h +++ b/eo/src/eoFactory.h @@ -26,12 +26,12 @@ #define _EOFACTORY_H //----------------------------------------------------------------------------- -#include +#include "eoObject.h" //----------------------------------------------------------------------------- /** EO Factory. A factory is used to create other objects. In particular, -it can be used so that objects of that kind cant be created in any other +it can be used so that objects of that kind can�t be created in any other way. It should be instantiated with anything that needs a factory, like selectors or whatever; but the instance class should be the parent class from which all the object that are going to be created descend. This class basically defines an interface, diff --git a/eo/src/eoFitContinue.h b/eo/src/eoFitContinue.h index 2db88f80b..9725008ed 100644 --- a/eo/src/eoFitContinue.h +++ b/eo/src/eoFitContinue.h @@ -25,8 +25,8 @@ #ifndef _eoFitContinue_h #define _eoFitContinue_h -#include -#include +#include "eoContinue.h" +#include "utils/eoLogger.h" /** Continues until the optimum fitness level is reached. diff --git a/eo/src/eoFitnessScalingSelect.h b/eo/src/eoFitnessScalingSelect.h index c17532019..f4216c20f 100644 --- a/eo/src/eoFitnessScalingSelect.h +++ b/eo/src/eoFitnessScalingSelect.h @@ -29,8 +29,8 @@ //----------------------------------------------------------------------------- -#include -#include +#include "eoSelectFromWorth.h" +#include "eoLinearFitScaling.h" /** eoFitnessScalingSelect: select an individual proportional to the * linearly scaled fitness that is computed by the private diff --git a/eo/src/eoFixedInertiaWeightedVelocity.h b/eo/src/eoFixedInertiaWeightedVelocity.h index 291c85a09..996845c01 100644 --- a/eo/src/eoFixedInertiaWeightedVelocity.h +++ b/eo/src/eoFixedInertiaWeightedVelocity.h @@ -26,11 +26,11 @@ #define EOFIXEDINERTIAWEIGHTEDVELOCITY_H //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include +#include "eoFunctor.h" +#include "utils/eoRNG.h" +#include "eoPop.h" +#include "utils/eoRealVectorBounds.h" +#include "eoTopology.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoFlOrBinOp.h b/eo/src/eoFlOrBinOp.h index bcdc9c5c1..343b2c738 100644 --- a/eo/src/eoFlOrBinOp.h +++ b/eo/src/eoFlOrBinOp.h @@ -26,8 +26,8 @@ #ifndef _eoFlOrBinOp_h #define _eoFlOrBinOp_h -#include -#include +#include "eoFunctor.h" +#include "eoOp.h" /** @addtogroup Variators * @{ diff --git a/eo/src/eoFlOrMonOp.h b/eo/src/eoFlOrMonOp.h index 63dae9cba..8ef903b1f 100644 --- a/eo/src/eoFlOrMonOp.h +++ b/eo/src/eoFlOrMonOp.h @@ -26,9 +26,9 @@ #ifndef _eoFlOrMonOp_h #define _eoFlOrMonOp_h -#include -#include -#include +#include "eoFunctor.h" +#include "eoOp.h" +#include "eoInit.h" /** @addtogroup Variators * @{ diff --git a/eo/src/eoFlOrQuadOp.h b/eo/src/eoFlOrQuadOp.h index 91618aa53..1c0c805fd 100644 --- a/eo/src/eoFlOrQuadOp.h +++ b/eo/src/eoFlOrQuadOp.h @@ -26,8 +26,8 @@ #ifndef _eoFlOrQuadOp_h #define _eoFlOrQuadOp_h -#include -#include +#include "eoFunctor.h" +#include "eoOp.h" /** @addtogroup Variators * @{ diff --git a/eo/src/eoFlight.h b/eo/src/eoFlight.h index 4c46d8e94..83f7d6e5f 100644 --- a/eo/src/eoFlight.h +++ b/eo/src/eoFlight.h @@ -26,8 +26,8 @@ #define EOFLIGHT_H //----------------------------------------------------------------------------- -#include -#include +#include "eoFunctor.h" +#include "utils/eoRealVectorBounds.h" //----------------------------------------------------------------------------- /** Abstract class for particle swarm optimization flight. diff --git a/eo/src/eoFunctorStore.cpp b/eo/src/eoFunctorStore.cpp index 43cd778cd..fe3137ada 100644 --- a/eo/src/eoFunctorStore.cpp +++ b/eo/src/eoFunctorStore.cpp @@ -5,8 +5,8 @@ #include -#include -#include +#include "eoFunctorStore.h" +#include "eoFunctor.h" /// clears the memory diff --git a/eo/src/eoFunctorStore.h b/eo/src/eoFunctorStore.h index 051daf2ae..ffcbe90d7 100644 --- a/eo/src/eoFunctorStore.h +++ b/eo/src/eoFunctorStore.h @@ -28,7 +28,7 @@ #define _eoFunctorStore_h #include -#include +#include #include "utils/eoLogger.h" diff --git a/eo/src/eoG3Replacement.h b/eo/src/eoG3Replacement.h index a235244f8..c7cf20178 100644 --- a/eo/src/eoG3Replacement.h +++ b/eo/src/eoG3Replacement.h @@ -28,12 +28,12 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include +#include "eoPop.h" +#include "eoFunctor.h" +#include "eoMerge.h" +#include "eoReduce.h" +#include "utils/eoHowMany.h" +#include "eoReduceSplit.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoGaussRealWeightUp.h b/eo/src/eoGaussRealWeightUp.h index 47edc321b..28affcad5 100644 --- a/eo/src/eoGaussRealWeightUp.h +++ b/eo/src/eoGaussRealWeightUp.h @@ -26,8 +26,8 @@ #define EOGAUSSREALWEIGHTUP_H //----------------------------------------------------------------------------- -#include -#include +#include "eoWeightUpdater.h" +#include "utils/eoRNG.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoGenContinue.h b/eo/src/eoGenContinue.h index dc756795d..bfe68c60d 100644 --- a/eo/src/eoGenContinue.h +++ b/eo/src/eoGenContinue.h @@ -25,9 +25,9 @@ #ifndef _eoGenContinue_h #define _eoGenContinue_h -#include -#include -#include +#include "eoContinue.h" +#include "utils/eoParam.h" +#include "utils/eoLogger.h" /** Generational continuator: continues until a number of generations is reached diff --git a/eo/src/eoGenOp.h b/eo/src/eoGenOp.h index f0d70c7ba..deb5c27bd 100644 --- a/eo/src/eoGenOp.h +++ b/eo/src/eoGenOp.h @@ -26,9 +26,9 @@ #ifndef _eoGenOp_H #define _eoGenOp_H -#include -#include -#include +#include "eoOp.h" +#include "eoPopulator.h" +#include "eoFunctorStore.h" #include /** @name General variation operators diff --git a/eo/src/eoGeneralBreeder.h b/eo/src/eoGeneralBreeder.h index dc598ba7e..1fdbd5c40 100644 --- a/eo/src/eoGeneralBreeder.h +++ b/eo/src/eoGeneralBreeder.h @@ -32,12 +32,12 @@ * eoGeneralBreeder: transforms a population using the generalOp construct. *****************************************************************************/ -#include -#include -#include -#include -#include -#include +#include "eoOp.h" +#include "eoGenOp.h" +#include "eoPopulator.h" +#include "eoSelectOne.h" +#include "eoBreed.h" +#include "utils/eoHowMany.h" /** Base class for breeders using generalized operators. diff --git a/eo/src/eoInit.h b/eo/src/eoInit.h index 7b460d94b..9230f4b64 100644 --- a/eo/src/eoInit.h +++ b/eo/src/eoInit.h @@ -29,10 +29,10 @@ #include -#include -#include -#include -#include // for shuffle method +#include "eoOp.h" +#include "eoSTLFunctor.h" +#include "utils/eoRndGenerators.h" +#include "utils/rnd_generators.h" // for shuffle method /** diff --git a/eo/src/eoInitializer.h b/eo/src/eoInitializer.h index 9e5cd5caf..3349768b2 100644 --- a/eo/src/eoInitializer.h +++ b/eo/src/eoInitializer.h @@ -27,11 +27,11 @@ #ifndef _eoInitializer_H #define _eoInitializer_H -#include -#include -#include -#include -#include +#include "utils/eoRealVectorBounds.h" +#include "eoVelocityInit.h" +#include "eoPop.h" +#include "eoParticleBestInit.h" +#include "eoTopology.h" /** @addtogroup Initializators diff --git a/eo/src/eoInt.h b/eo/src/eoInt.h index 41c877247..8dc318e2c 100644 --- a/eo/src/eoInt.h +++ b/eo/src/eoInt.h @@ -29,7 +29,7 @@ #include // std::ostream, std::istream #include // std::string -#include +#include "eoVector.h" /** eoInt: implementation of simple integer-valued chromosome. * based on eoVector class diff --git a/eo/src/eoIntegerVelocity.h b/eo/src/eoIntegerVelocity.h index b00b17bf3..2ff8108a4 100644 --- a/eo/src/eoIntegerVelocity.h +++ b/eo/src/eoIntegerVelocity.h @@ -27,12 +27,12 @@ #define EOINTEGERVELOCITY_H //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include +#include "eoFunctor.h" +#include "utils/eoRNG.h" +#include "eoPop.h" +#include "utils/eoRealVectorBounds.h" +#include "eoRealBoundModifier.h" +#include "eoTopology.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoInvalidateOps.h b/eo/src/eoInvalidateOps.h index 97dd39f55..d4a558182 100644 --- a/eo/src/eoInvalidateOps.h +++ b/eo/src/eoInvalidateOps.h @@ -27,7 +27,7 @@ #ifndef _eoInvalidateOps_h #define _eoInvalidateOps_h -#include +#include "eoOp.h" /** @addtogroup Utilities diff --git a/eo/src/eoInvertedContinue.h b/eo/src/eoInvertedContinue.h index 0f677cc08..9b723a5ec 100644 --- a/eo/src/eoInvertedContinue.h +++ b/eo/src/eoInvertedContinue.h @@ -30,7 +30,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr #ifndef _eoInvertedContinue_h #define _eoInvertedContinue_h -#include +#include "eoContinue.h" /** * Return the opposite of the wrapped continuator diff --git a/eo/src/eoLinearDecreasingWeightUp.h b/eo/src/eoLinearDecreasingWeightUp.h index 87f489423..e6a1b315b 100644 --- a/eo/src/eoLinearDecreasingWeightUp.h +++ b/eo/src/eoLinearDecreasingWeightUp.h @@ -26,7 +26,7 @@ #define EOLINEARDECREASINGWEIGHTUP_H //----------------------------------------------------------------------------- -#include +#include "eoWeightUpdater.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoLinearFitScaling.h b/eo/src/eoLinearFitScaling.h index 75598c934..269518f05 100644 --- a/eo/src/eoLinearFitScaling.h +++ b/eo/src/eoLinearFitScaling.h @@ -27,8 +27,8 @@ #ifndef eoLinearFitScaling_h #define eoLinearFitScaling_h -#include -#include +#include "eoSelectFromWorth.h" +#include "eoPerf2Worth.h" /** An instance of eoPerf2Worth * COmputes the linearly scaled fitnesses diff --git a/eo/src/eoLinearTopology.h b/eo/src/eoLinearTopology.h index 813e99b93..027be1871 100644 --- a/eo/src/eoLinearTopology.h +++ b/eo/src/eoLinearTopology.h @@ -27,9 +27,9 @@ #define EOLINEARTOPOLOGY_H_ //----------------------------------------------------------------------------- -#include -#include -#include +#include "eoPop.h" +#include "eoTopology.h" +#include "eoSocialNeighborhood.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoMGGReplacement.h b/eo/src/eoMGGReplacement.h index e2eebbfa5..1e4c40f2d 100644 --- a/eo/src/eoMGGReplacement.h +++ b/eo/src/eoMGGReplacement.h @@ -28,12 +28,12 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include +#include "eoPop.h" +#include "eoFunctor.h" +#include "eoMerge.h" +#include "eoReduce.h" +#include "utils/eoHowMany.h" +#include "eoReduceSplit.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoMerge.h b/eo/src/eoMerge.h index 31da70f08..5870849cf 100644 --- a/eo/src/eoMerge.h +++ b/eo/src/eoMerge.h @@ -31,9 +31,9 @@ #include // EO includes -#include // eoPop -#include // eoMerge -#include +#include "eoPop.h" // eoPop +#include "eoFunctor.h" // eoMerge +#include "utils/eoLogger.h" /** * eoMerge: Base class for elitist replacement algorithms. diff --git a/eo/src/eoMergeReduce.h b/eo/src/eoMergeReduce.h index 6a2618d9d..e5e8c2bcc 100644 --- a/eo/src/eoMergeReduce.h +++ b/eo/src/eoMergeReduce.h @@ -27,12 +27,12 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include +#include "eoPop.h" +#include "eoFunctor.h" +#include "eoMerge.h" +#include "eoReduce.h" +#include "eoReplacement.h" +#include "utils/eoHowMany.h" //----------------------------------------------------------------------------- /** Replacement strategies that combine en eoMerge and an eoReduce. diff --git a/eo/src/eoNDSorting.h b/eo/src/eoNDSorting.h index bb2e94fcc..b8315b458 100644 --- a/eo/src/eoNDSorting.h +++ b/eo/src/eoNDSorting.h @@ -27,10 +27,10 @@ #ifndef eoNDSorting_h #define eoNDSorting_h -#include +#include "EO.h" #include -#include -#include +#include "eoPop.h" +#include "eoPerf2Worth.h" #include /** diff --git a/eo/src/eoObject.h b/eo/src/eoObject.h index bac2f4737..1e119b988 100644 --- a/eo/src/eoObject.h +++ b/eo/src/eoObject.h @@ -27,11 +27,11 @@ //----------------------------------------------------------------------------- -#include // For limits definition +#include "utils/eoData.h" // For limits definition #include // std::istream, std::ostream #include // std::string -#include +#include "utils/compatibility.h" /* eoObject used to be the base class for the whole hierarchy, but this has @@ -39,7 +39,7 @@ changed. eoObject is used to define a name (#className#) that is used when loading or saving the state. Previously, this object also defined a print and read -interface, but its been moved to eoPrintable and eoPersistent. +interface, but it�s been moved to eoPrintable and eoPersistent. */ /** Defines a name (#className#), used when loading or saving a state. diff --git a/eo/src/eoOneToOneBreeder.h b/eo/src/eoOneToOneBreeder.h index a4c18c0b4..587dbce19 100644 --- a/eo/src/eoOneToOneBreeder.h +++ b/eo/src/eoOneToOneBreeder.h @@ -28,15 +28,15 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "eoOp.h" +#include "eoGenOp.h" +#include "eoPopulator.h" +#include "eoSelectOne.h" +#include "eoSequentialSelect.h" +#include "eoBreed.h" +#include "eoEvalFunc.h" +#include "eoPopulator.h" +#include "utils/eoHowMany.h" /** eoOneToOneBreeder: transforms a population using * - an operator that MODIFIES only one parent from the populator diff --git a/eo/src/eoOp.h b/eo/src/eoOp.h index b6ad783c2..5351b9d86 100644 --- a/eo/src/eoOp.h +++ b/eo/src/eoOp.h @@ -25,10 +25,10 @@ #ifndef _eoOp_H #define _eoOp_H -#include -#include -#include -#include +#include "eoObject.h" +#include "eoPrintable.h" +#include "eoFunctor.h" +#include "utils/eoRNG.h" /** @defgroup Operators Evolutionary Operators diff --git a/eo/src/eoOpContainer.h b/eo/src/eoOpContainer.h index e1f43bdf6..41e8b74b8 100644 --- a/eo/src/eoOpContainer.h +++ b/eo/src/eoOpContainer.h @@ -26,7 +26,7 @@ #ifndef _eoOpContainer_H #define _eoOpContainer_H -#include +#include "eoGenOp.h" /** eoOpContainer is a base class for the sequential and proportional selectors * It takes care of wrapping the other operators, diff --git a/eo/src/eoOpSelMason.h b/eo/src/eoOpSelMason.h index 577b5b56f..377de0c95 100644 --- a/eo/src/eoOpSelMason.h +++ b/eo/src/eoOpSelMason.h @@ -24,7 +24,7 @@ #ifndef _EOOPSELMASON_H #define _EOOPSELMASON_H -#include // for eoFactory and eoOpFactory +#include "eoFactory.h" // for eoFactory and eoOpFactory #include @@ -58,7 +58,7 @@ public: ...\\ Stores all operators built in a database (#allocMap#), so that somebody can destroy them later. The Mason is in charge or destroying the operators, - since the built object cant do it itself. The objects built must be destroyed + since the built object can�t do it itself. The objects built must be destroyed from outside, using the "destroy" method */ virtual eoOpSelector* make(std::istream& _is) { @@ -79,7 +79,7 @@ public: _is >> rate; if ( _is ) { eoOp* op = operatorFactory.make( _is ); // This reads the rest of the line - // Add the operators to the selector, dont pay attention to the IDs + // Add the operators to the selector, don�t pay attention to the IDs opSelectorP->addOp( *op, rate ); // Keep it in the store, to destroy later tmpPVec.push_back( op ); diff --git a/eo/src/eoOrderXover.h b/eo/src/eoOrderXover.h index daaf52e0c..4efc8ea6b 100644 --- a/eo/src/eoOrderXover.h +++ b/eo/src/eoOrderXover.h @@ -9,8 +9,8 @@ //----------------------------------------------------------------------------- #include -#include -#include +#include "utils/eoRNG.h" +#include "eoInit.h" /** * apply orderXover on two chromosomes. diff --git a/eo/src/eoPSO.h b/eo/src/eoPSO.h index 16d2c9b58..869ac43c2 100644 --- a/eo/src/eoPSO.h +++ b/eo/src/eoPSO.h @@ -26,7 +26,7 @@ #define _EOPSO_H //----------------------------------------------------------------------------- -#include +#include "eoAlgo.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoPartiallyMappedXover.h b/eo/src/eoPartiallyMappedXover.h index 16b23f6c9..f88a469be 100644 --- a/eo/src/eoPartiallyMappedXover.h +++ b/eo/src/eoPartiallyMappedXover.h @@ -32,7 +32,7 @@ //----------------------------------------------------------------------------- #include -#include +#include "utils/eoRNG.h" /** * diff --git a/eo/src/eoParticleBestInit.h b/eo/src/eoParticleBestInit.h index b203c8246..d179e6c75 100644 --- a/eo/src/eoParticleBestInit.h +++ b/eo/src/eoParticleBestInit.h @@ -26,7 +26,7 @@ #define _EOPARTICLEBESTINIT_H //----------------------------------------------------------------------------- -#include +#include "eoFunctor.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoParticleFullInitializer.h b/eo/src/eoParticleFullInitializer.h index 96bebb579..06503497a 100644 --- a/eo/src/eoParticleFullInitializer.h +++ b/eo/src/eoParticleFullInitializer.h @@ -27,11 +27,11 @@ #ifndef _eoParticleFullInitializer_H #define _eoParticleFullInitializer_H -#include -#include -#include -#include -#include +#include "utils/eoRealVectorBounds.h" +#include "eoVelocityInit.h" +#include "eoPop.h" +#include "eoParticleBestInit.h" +#include "eoTopology.h" /** @addtogroup Initializators diff --git a/eo/src/eoPerf2Worth.h b/eo/src/eoPerf2Worth.h index 9f1746ecf..f7d08f512 100644 --- a/eo/src/eoPerf2Worth.h +++ b/eo/src/eoPerf2Worth.h @@ -27,9 +27,9 @@ #ifndef eoPerf2Worth_h #define eoPerf2Worth_h -#include -#include -#include +#include "utils/eoParam.h" +#include "eoPop.h" +#include "eoFunctor.h" #include #include diff --git a/eo/src/eoPeriodicContinue.h b/eo/src/eoPeriodicContinue.h index 1a3f9d0de..3aac35bed 100644 --- a/eo/src/eoPeriodicContinue.h +++ b/eo/src/eoPeriodicContinue.h @@ -22,8 +22,8 @@ #ifndef __eoPeriodicContinue_h #define __eoPeriodicContinue_h -#include -#include +#include "eoContinue.h" +#include "eoPop.h" /** A continue that becomes true periodically. */ diff --git a/eo/src/eoPersistent.cpp b/eo/src/eoPersistent.cpp index c1334ebc4..4be731f94 100644 --- a/eo/src/eoPersistent.cpp +++ b/eo/src/eoPersistent.cpp @@ -3,7 +3,7 @@ #pragma warning(disable:4786) #endif -#include +#include "eoPersistent.h" //Implementation of these objects diff --git a/eo/src/eoPop.h b/eo/src/eoPop.h index eb6be46fb..9213bca5c 100644 --- a/eo/src/eoPop.h +++ b/eo/src/eoPop.h @@ -41,10 +41,10 @@ Authors: #include // EO includes -#include // for eoInit -#include -#include -#include // for shuffle method +#include "eoOp.h" // for eoInit +#include "eoPersistent.h" +#include "eoInit.h" +#include "utils/rnd_generators.h" // for shuffle method /** A std::vector of EO object, to be used in all algorithms * (selectors, operators, replacements, ...). diff --git a/eo/src/eoPopEvalFunc.h b/eo/src/eoPopEvalFunc.h index 7fcad1467..c3037c20d 100644 --- a/eo/src/eoPopEvalFunc.h +++ b/eo/src/eoPopEvalFunc.h @@ -27,15 +27,15 @@ #ifndef eoPopEvalFunc_H #define eoPopEvalFunc_H -#include -#include +#include "eoEvalFunc.h" +#include "apply.h" # ifdef WITH_MPI -#include -#include -#include -#include -#include +#include "mpi/eoMpi.h" +#include "mpi/eoTerminateJob.h" +#include "mpi/eoMpiAssignmentAlgorithm.h" +#include "mpi/eoParallelApply.h" +#include "utils/eoParallel.h" #include // ceil # endif // WITH_MPI diff --git a/eo/src/eoPopulator.h b/eo/src/eoPopulator.h index 104aafe5e..9c8d28af9 100644 --- a/eo/src/eoPopulator.h +++ b/eo/src/eoPopulator.h @@ -26,8 +26,8 @@ #ifndef _eoPopulator_H #define _eoPopulator_H -#include -#include +#include "eoPop.h" +#include "eoSelectOne.h" /** eoPopulator is a helper class for general operators eoGenOp It is an eoPop but also behaves like an eoPop::iterator diff --git a/eo/src/eoPrintable.cpp b/eo/src/eoPrintable.cpp index ec6e32462..1f0b4ab4a 100644 --- a/eo/src/eoPrintable.cpp +++ b/eo/src/eoPrintable.cpp @@ -7,7 +7,7 @@ // eoPrintable.cpp //----------------------------------------------------------------------------- -#include +#include "eoPrintable.h" //----------------------------------------------------------------------------- //Implementation of these objects diff --git a/eo/src/eoPrintable.h b/eo/src/eoPrintable.h index 1f2404a89..f04f50fb6 100644 --- a/eo/src/eoPrintable.h +++ b/eo/src/eoPrintable.h @@ -27,8 +27,8 @@ //----------------------------------------------------------------------------- -#include // std::istream, std::ostream -#include // para std::string +#include "iostream" // std::istream, std::ostream +#include "string" // para std::string /* This functionality was separated from eoObject, since it makes no sense to print diff --git a/eo/src/eoProportionalCombinedOp.h b/eo/src/eoProportionalCombinedOp.h index 823ac79c9..0dce5b0fc 100644 --- a/eo/src/eoProportionalCombinedOp.h +++ b/eo/src/eoProportionalCombinedOp.h @@ -24,12 +24,12 @@ #ifndef _eoCombinedOp_H #define _eoCombinedOp_H -#include -#include -#include -#include -#include -#include +#include "eoObject.h" +#include "eoPrintable.h" +#include "eoFunctor.h" +#include "eoOp.h" +#include "utils/eoRNG.h" +#include "utils/eoLogger.h" /** \defgroup Utilities Utilities diff --git a/eo/src/eoProportionalSelect.h b/eo/src/eoProportionalSelect.h index ec1243cee..35dd3065c 100644 --- a/eo/src/eoProportionalSelect.h +++ b/eo/src/eoProportionalSelect.h @@ -29,10 +29,10 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include +#include "utils/eoRNG.h" +#include "utils/selectors.h" +#include "eoSelectOne.h" +#include "eoPop.h" /** eoProportionalSelect: select an individual proportional to her stored fitness value diff --git a/eo/src/eoRandomRealWeightUp.h b/eo/src/eoRandomRealWeightUp.h index 81521b512..d135af93f 100644 --- a/eo/src/eoRandomRealWeightUp.h +++ b/eo/src/eoRandomRealWeightUp.h @@ -26,8 +26,8 @@ #define EORANDOMREALWEIGHTUP_H //----------------------------------------------------------------------------- -#include -#include +#include "eoWeightUpdater.h" +#include "utils/eoRNG.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoRandomSelect.h b/eo/src/eoRandomSelect.h index 065f050f9..1b15bbffa 100644 --- a/eo/src/eoRandomSelect.h +++ b/eo/src/eoRandomSelect.h @@ -32,8 +32,8 @@ * eoSequentialSelect returns all individuals in turn */ -#include -#include +#include "utils/eoRNG.h" +#include "eoSelectOne.h" /** eoRandomSelect: a selection method that selects ONE individual randomly * diff --git a/eo/src/eoRanking.h b/eo/src/eoRanking.h index 5e7342911..65fbe87a4 100644 --- a/eo/src/eoRanking.h +++ b/eo/src/eoRanking.h @@ -27,7 +27,7 @@ #ifndef eoRanking_h #define eoRanking_h -#include +#include "eoPerf2Worth.h" /** An instance of eoPerfFromWorth * COmputes the ranked fitness: fitnesses range in [m,M] diff --git a/eo/src/eoRankingSelect.h b/eo/src/eoRankingSelect.h index 70a2e44c0..1a3b9a254 100644 --- a/eo/src/eoRankingSelect.h +++ b/eo/src/eoRankingSelect.h @@ -28,8 +28,8 @@ //----------------------------------------------------------------------------- -#include -#include +#include "eoSelectFromWorth.h" +#include "eoRanking.h" /** eoRankingSelect: select an individual by roulette wheel on its rank * is an eoRouletteWorthSelect, i.e. a selector using a std::vector of worthes diff --git a/eo/src/eoRealBoundModifier.h b/eo/src/eoRealBoundModifier.h index 9a9e032bc..1b4405737 100644 --- a/eo/src/eoRealBoundModifier.h +++ b/eo/src/eoRealBoundModifier.h @@ -24,8 +24,8 @@ #ifndef EOREALBOUNDMODIFIER_H #define EOREALBOUNDMODIFIER_H -#include -#include +#include "eoFunctor.h" +#include "utils/eoRealVectorBounds.h" /** @defgroup Bounds Bounds management * diff --git a/eo/src/eoRealParticle.h b/eo/src/eoRealParticle.h index 14326558c..f7e758173 100644 --- a/eo/src/eoRealParticle.h +++ b/eo/src/eoRealParticle.h @@ -26,7 +26,7 @@ #define _EOREALPARTICLE_H -#include +#include "eoVectorParticle.h" /** eoRealParticle: Implementation of a real-coded particle for diff --git a/eo/src/eoReduce.h b/eo/src/eoReduce.h index 7f0c17729..c1039e47b 100644 --- a/eo/src/eoReduce.h +++ b/eo/src/eoReduce.h @@ -31,10 +31,10 @@ #include // EO includes -#include // eoPop -#include // eoReduce -#include -#include +#include "eoPop.h" // eoPop +#include "eoFunctor.h" // eoReduce +#include "utils/selectors.h" +#include "utils/eoLogger.h" /** * eoReduce: .reduce the new generation to the specified size diff --git a/eo/src/eoReduceMerge.h b/eo/src/eoReduceMerge.h index 02933b404..a9f6c82fa 100644 --- a/eo/src/eoReduceMerge.h +++ b/eo/src/eoReduceMerge.h @@ -29,12 +29,12 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include +#include "eoPop.h" +#include "eoFunctor.h" +#include "eoMerge.h" +#include "eoReduce.h" +#include "eoReplacement.h" +#include "utils/eoHowMany.h" //----------------------------------------------------------------------------- /** @addtogroup Replacors diff --git a/eo/src/eoReduceMergeReduce.h b/eo/src/eoReduceMergeReduce.h index 17721f733..0f7f0ad4c 100644 --- a/eo/src/eoReduceMergeReduce.h +++ b/eo/src/eoReduceMergeReduce.h @@ -28,11 +28,11 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include +#include "eoPop.h" +#include "eoFunctor.h" +#include "eoMerge.h" +#include "eoReduce.h" +#include "utils/eoHowMany.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoReduceSplit.h b/eo/src/eoReduceSplit.h index 4b21aa25e..a8640c039 100644 --- a/eo/src/eoReduceSplit.h +++ b/eo/src/eoReduceSplit.h @@ -31,9 +31,9 @@ #include // EO includes -#include // eoPop -#include // eoReduce -#include +#include "eoPop.h" // eoPop +#include "eoFunctor.h" // eoReduce +#include "utils/selectors.h" /** @addtogroup Replacors * @{ diff --git a/eo/src/eoReplacement.h b/eo/src/eoReplacement.h index 033d441cb..a705f5254 100644 --- a/eo/src/eoReplacement.h +++ b/eo/src/eoReplacement.h @@ -29,11 +29,11 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include +#include "eoPop.h" +#include "eoFunctor.h" +#include "eoMerge.h" +#include "eoReduce.h" +#include "utils/eoHowMany.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoRingTopology.h b/eo/src/eoRingTopology.h index 6bad13cd7..615227909 100644 --- a/eo/src/eoRingTopology.h +++ b/eo/src/eoRingTopology.h @@ -29,8 +29,8 @@ #define EORINGTOPOLOGY_H_ //----------------------------------------------------------------------------- -#include -#include +#include "eoTopology.h" +#include "eoSocialNeighborhood.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoSGA.h b/eo/src/eoSGA.h index b31dff04e..bfbee45b6 100644 --- a/eo/src/eoSGA.h +++ b/eo/src/eoSGA.h @@ -27,14 +27,14 @@ #ifndef _eoSGA_h #define _eoSGA_h -#include -#include -#include -#include -#include -#include -#include -#include +#include "eoInvalidateOps.h" +#include "eoContinue.h" +#include "eoPop.h" +#include "eoSelectOne.h" +#include "eoSelectPerc.h" +#include "eoEvalFunc.h" +#include "eoAlgo.h" +#include "apply.h" /** The Simple Genetic Algorithm, following Holland and Goldberg * diff --git a/eo/src/eoSGATransform.h b/eo/src/eoSGATransform.h index 55b5e5eda..e9284aa0a 100644 --- a/eo/src/eoSGATransform.h +++ b/eo/src/eoSGATransform.h @@ -27,15 +27,15 @@ #ifndef _eoSGATransform_h #define _eoSGATransform_h -#include -#include +#include "eoInvalidateOps.h" +#include "eoPop.h" /////////////////////////////////////////////////////////////////////////////// // class eoSGATransform /////////////////////////////////////////////////////////////////////////////// #include // std::vector -#include -#include +#include "utils/eoRNG.h" +#include "eoTransform.h" /** eoSGATransform: transforms a population using genetic operators. * It does it exactly as class eoSGA, i.e. only accepts diff --git a/eo/src/eoSIGContinue.h b/eo/src/eoSIGContinue.h index 2199b49ef..32e7c1857 100644 --- a/eo/src/eoSIGContinue.h +++ b/eo/src/eoSIGContinue.h @@ -33,7 +33,7 @@ #define eoSIGContinue_h #include -#include +#include "eoContinue.h" /** @addtogroup Continuators * @{ diff --git a/eo/src/eoSecondsElapsedContinue.h b/eo/src/eoSecondsElapsedContinue.h index e29aeefb5..a580b7f42 100644 --- a/eo/src/eoSecondsElapsedContinue.h +++ b/eo/src/eoSecondsElapsedContinue.h @@ -25,7 +25,7 @@ #ifndef _eoSecondsElapsedContinue_h #define _eoSecondsElapsedContinue_h -#include +#include "eoContinue.h" /** Timed continuator: continues until a number of seconds is used diff --git a/eo/src/eoSelect.h b/eo/src/eoSelect.h index aae338434..e48f9051f 100644 --- a/eo/src/eoSelect.h +++ b/eo/src/eoSelect.h @@ -27,7 +27,7 @@ //----------------------------------------------------------------------------- -#include +#include "eoPop.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoSelectFactory.h b/eo/src/eoSelectFactory.h index 9dc19dabf..65818a64d 100644 --- a/eo/src/eoSelectFactory.h +++ b/eo/src/eoSelectFactory.h @@ -26,9 +26,9 @@ #ifndef _EOSELECTFACTORY_H #define _EOSELECTFACTORY_H -#include -#include -#include +#include "eoFactory.h" +#include "eoRandomSelect.h" +#include "eoTournament.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoSelectFromWorth.h b/eo/src/eoSelectFromWorth.h index 342be9da7..c6ba5c1e5 100644 --- a/eo/src/eoSelectFromWorth.h +++ b/eo/src/eoSelectFromWorth.h @@ -28,9 +28,9 @@ #include //----------------------------------------------------------------------------- -#include -#include -#include +#include "eoSelectOne.h" +#include "eoPerf2Worth.h" +#include "utils/selectors.h" //----------------------------------------------------------------------------- /** selects one element from a population (is an eoSelectOne) diff --git a/eo/src/eoSelectMany.h b/eo/src/eoSelectMany.h index 63da51503..6fb7da6e2 100644 --- a/eo/src/eoSelectMany.h +++ b/eo/src/eoSelectMany.h @@ -29,9 +29,9 @@ //----------------------------------------------------------------------------- -#include -#include -#include +#include "eoSelect.h" +#include "eoSelectOne.h" +#include "utils/eoHowMany.h" #include //----------------------------------------------------------------------------- diff --git a/eo/src/eoSelectNumber.h b/eo/src/eoSelectNumber.h index f6f094ef2..242db4daf 100644 --- a/eo/src/eoSelectNumber.h +++ b/eo/src/eoSelectNumber.h @@ -27,8 +27,8 @@ //----------------------------------------------------------------------------- -#include -#include +#include "eoSelect.h" +#include "eoSelectOne.h" #include //----------------------------------------------------------------------------- diff --git a/eo/src/eoSelectOne.h b/eo/src/eoSelectOne.h index 5afdd1404..fc4ed0982 100644 --- a/eo/src/eoSelectOne.h +++ b/eo/src/eoSelectOne.h @@ -27,8 +27,8 @@ //----------------------------------------------------------------------------- -#include -#include +#include "eoPop.h" +#include "eoFunctor.h" //----------------------------------------------------------------------------- /** eoSelectOne selects only one element from a whole population. diff --git a/eo/src/eoSelectPerc.h b/eo/src/eoSelectPerc.h index 131a3d591..9693f7870 100644 --- a/eo/src/eoSelectPerc.h +++ b/eo/src/eoSelectPerc.h @@ -27,8 +27,8 @@ //----------------------------------------------------------------------------- -#include -#include +#include "eoSelect.h" +#include "eoSelectOne.h" #include //----------------------------------------------------------------------------- diff --git a/eo/src/eoSharing.h b/eo/src/eoSharing.h index 170a03b9e..fa7583030 100644 --- a/eo/src/eoSharing.h +++ b/eo/src/eoSharing.h @@ -26,8 +26,8 @@ #ifndef eoSharing_h #define eoSharing_h -#include -#include +#include "eoPerf2Worth.h" +#include "utils/eoDistance.h" /** Sharing is a perf2worth class that implements * Goldberg and Richardson's basic sharing diff --git a/eo/src/eoSharingSelect.h b/eo/src/eoSharingSelect.h index 0754cdd08..523d18426 100644 --- a/eo/src/eoSharingSelect.h +++ b/eo/src/eoSharingSelect.h @@ -28,8 +28,8 @@ //----------------------------------------------------------------------------- -#include -#include +#include "eoSelectFromWorth.h" +#include "eoSharing.h" /** eoSharingSelect: select an individual by roulette wheel * on its SHARED fitness. It is an eoRouletteWorthSelect, diff --git a/eo/src/eoSigBinaryFlight.h b/eo/src/eoSigBinaryFlight.h index dccf2e5f6..e55423bd8 100644 --- a/eo/src/eoSigBinaryFlight.h +++ b/eo/src/eoSigBinaryFlight.h @@ -27,7 +27,7 @@ #define EOSIGBINARYFLIGHT_H //----------------------------------------------------------------------------- -#include +#include "eoBinaryFlight.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoSimpleEDA.h b/eo/src/eoSimpleEDA.h index afbf152f0..0704b5722 100644 --- a/eo/src/eoSimpleEDA.h +++ b/eo/src/eoSimpleEDA.h @@ -28,11 +28,11 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include +#include "apply.h" +#include "eoEDA.h" +#include "eoContinue.h" +#include "eoDistribUpdater.h" +#include "eoEvalFunc.h" /** A very simple Estimation of Distribution Algorithm * diff --git a/eo/src/eoSocialNeighborhood.h b/eo/src/eoSocialNeighborhood.h index 944031f9d..3f46b4a4e 100644 --- a/eo/src/eoSocialNeighborhood.h +++ b/eo/src/eoSocialNeighborhood.h @@ -26,7 +26,7 @@ #define EOSOCIALNEIGHBORHOOD_H_ //----------------------------------------------------------------------------- -#include +#include "eoNeighborhood.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoStandardFlight.h b/eo/src/eoStandardFlight.h index 228839eb7..eae90a63a 100644 --- a/eo/src/eoStandardFlight.h +++ b/eo/src/eoStandardFlight.h @@ -26,7 +26,7 @@ #define EOSTANDARDFLIGHT_H //----------------------------------------------------------------------------- -#include +#include "eoFlight.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoStandardVelocity.h b/eo/src/eoStandardVelocity.h index 62abd487b..3f67eec91 100644 --- a/eo/src/eoStandardVelocity.h +++ b/eo/src/eoStandardVelocity.h @@ -27,12 +27,12 @@ #define EOSTANDARDVELOCITY_H //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include +#include "eoFunctor.h" +#include "utils/eoRNG.h" +#include "eoPop.h" +#include "utils/eoRealVectorBounds.h" +#include "eoRealBoundModifier.h" +#include "eoTopology.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoStarTopology.h b/eo/src/eoStarTopology.h index 02df64a98..a345c8bc3 100644 --- a/eo/src/eoStarTopology.h +++ b/eo/src/eoStarTopology.h @@ -27,8 +27,8 @@ #define EOSTARTOPOLOGY_H_ //----------------------------------------------------------------------------- -#include -#include +#include "eoTopology.h" +#include "eoSocialNeighborhood.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoSteadyFitContinue.h b/eo/src/eoSteadyFitContinue.h index f05697b50..0b63c5e87 100644 --- a/eo/src/eoSteadyFitContinue.h +++ b/eo/src/eoSteadyFitContinue.h @@ -25,8 +25,8 @@ #ifndef _eoSteadyFitContinue_h #define _eoSteadyFitContinue_h -#include -#include +#include "eoContinue.h" +#include "utils/eoLogger.h" /** A continuator: does a minimum number of generations, then diff --git a/eo/src/eoStochTournamentSelect.h b/eo/src/eoStochTournamentSelect.h index 650041296..c3b6b2d21 100644 --- a/eo/src/eoStochTournamentSelect.h +++ b/eo/src/eoStochTournamentSelect.h @@ -27,8 +27,8 @@ #include #include // accumulate -#include // eoSelectOne -#include // stochastic_tournament +#include "eoSelectOne.h" // eoSelectOne +#include "utils/selectors.h" // stochastic_tournament /** eoStochTournamentSelect: a selection method that selects ONE individual by binary stochastic tournament diff --git a/eo/src/eoStochasticUniversalSelect.h b/eo/src/eoStochasticUniversalSelect.h index fb1669ecc..956bf62c7 100644 --- a/eo/src/eoStochasticUniversalSelect.h +++ b/eo/src/eoStochasticUniversalSelect.h @@ -29,10 +29,10 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include +#include "utils/eoRNG.h" +#include "eoSelectOne.h" +#include "utils/selectors.h" +#include "eoPop.h" /** eoStochasticUniversalSelect: select an individual proportional to her stored fitness value, but in contrast with eoStochasticUniversalSelect, get rid of most finite sampling effects diff --git a/eo/src/eoSurviveAndDie.h b/eo/src/eoSurviveAndDie.h index 63cf22197..2ca4a3833 100644 --- a/eo/src/eoSurviveAndDie.h +++ b/eo/src/eoSurviveAndDie.h @@ -29,11 +29,11 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include +#include "eoPop.h" +#include "eoFunctor.h" +#include "eoMerge.h" +#include "eoReduce.h" +#include "utils/eoHowMany.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoSyncEasyPSO.h b/eo/src/eoSyncEasyPSO.h index d0a82059a..0fc7a2492 100644 --- a/eo/src/eoSyncEasyPSO.h +++ b/eo/src/eoSyncEasyPSO.h @@ -26,11 +26,11 @@ #define _EOSYNCEASYPSO_H //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include +#include "eoContinue.h" +#include "eoPopEvalFunc.h" +#include "eoPSO.h" +#include "eoVelocity.h" +#include "eoFlight.h" //----------------------------------------------------------------------------- /** An easy-to-use synchronous particle swarm algorithm; you can use any particle, diff --git a/eo/src/eoTimeContinue.h b/eo/src/eoTimeContinue.h index c0fcc3fe5..3d086e571 100644 --- a/eo/src/eoTimeContinue.h +++ b/eo/src/eoTimeContinue.h @@ -27,8 +27,8 @@ #include -#include -#include +#include "eoContinue.h" +#include "utils/eoLogger.h" /** * Termination condition until a running time is reached. diff --git a/eo/src/eoTopology.h b/eo/src/eoTopology.h index a12bf43dc..86fd214f3 100644 --- a/eo/src/eoTopology.h +++ b/eo/src/eoTopology.h @@ -27,7 +27,7 @@ #define EOTOPOLOGY_H_ //----------------------------------------------------------------------------- -#include +#include "eoNeighborhood.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoTransform.h b/eo/src/eoTransform.h index f8823382a..5ee23a4ad 100644 --- a/eo/src/eoTransform.h +++ b/eo/src/eoTransform.h @@ -27,7 +27,7 @@ //----------------------------------------------------------------------------- -#include +#include "eoPop.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoTruncSelect.h b/eo/src/eoTruncSelect.h index e46b39bc3..f469e02b6 100644 --- a/eo/src/eoTruncSelect.h +++ b/eo/src/eoTruncSelect.h @@ -29,8 +29,8 @@ //----------------------------------------------------------------------------- -#include -#include +#include "eoSelect.h" +#include "utils/eoHowMany.h" #include //----------------------------------------------------------------------------- diff --git a/eo/src/eoTruncatedSelectMany.h b/eo/src/eoTruncatedSelectMany.h index 1b3bad726..d5ab0f01b 100644 --- a/eo/src/eoTruncatedSelectMany.h +++ b/eo/src/eoTruncatedSelectMany.h @@ -29,9 +29,9 @@ //----------------------------------------------------------------------------- -#include -#include -#include +#include "eoSelect.h" +#include "eoSelectOne.h" +#include "utils/eoHowMany.h" #include //----------------------------------------------------------------------------- diff --git a/eo/src/eoTruncatedSelectOne.h b/eo/src/eoTruncatedSelectOne.h index e86cce81d..431f7465a 100644 --- a/eo/src/eoTruncatedSelectOne.h +++ b/eo/src/eoTruncatedSelectOne.h @@ -29,9 +29,9 @@ //----------------------------------------------------------------------------- -#include -#include -#include +#include "eoSelect.h" +#include "eoSelectOne.h" +#include "utils/eoHowMany.h" #include //----------------------------------------------------------------------------- diff --git a/eo/src/eoVariableInertiaWeightedVelocity.h b/eo/src/eoVariableInertiaWeightedVelocity.h index a926feee8..33bbe4f43 100644 --- a/eo/src/eoVariableInertiaWeightedVelocity.h +++ b/eo/src/eoVariableInertiaWeightedVelocity.h @@ -26,11 +26,11 @@ #define EOVARIABLEINERTIAWEIGHTEDVELOCITY_H //----------------------------------------------------------------------------- -#include -#include -#include -#include -#include +#include "eoVelocity.h" +#include "eoTopology.h" +#include "eoWeightUpdater.h" +#include "utils/eoRealVectorBounds.h" +#include "eoRealBoundModifier.h" //----------------------------------------------------------------------------- diff --git a/eo/src/eoVariableLengthCrossover.h b/eo/src/eoVariableLengthCrossover.h index 510fc9b03..c61f91651 100644 --- a/eo/src/eoVariableLengthCrossover.h +++ b/eo/src/eoVariableLengthCrossover.h @@ -26,8 +26,8 @@ #ifndef _eoVariableLengthCrossover_h #define _eoVariableLengthCrossover_h -#include -#include +#include "eoFunctor.h" +#include "eoOp.h" /** Base classes for generic crossovers on variable length chromosomes. diff --git a/eo/src/eoVariableLengthMutation.h b/eo/src/eoVariableLengthMutation.h index 542541d70..a3bdfac19 100644 --- a/eo/src/eoVariableLengthMutation.h +++ b/eo/src/eoVariableLengthMutation.h @@ -26,9 +26,9 @@ #ifndef _eoVariableLengthMutation_h #define _eoVariableLengthMutation_h -#include -#include -#include +#include "eoFunctor.h" +#include "eoOp.h" +#include "eoInit.h" /** Base classes for generic mutations on variable length chromosomes. diff --git a/eo/src/eoVector.h b/eo/src/eoVector.h index fce05d117..bdedd5e94 100644 --- a/eo/src/eoVector.h +++ b/eo/src/eoVector.h @@ -25,8 +25,8 @@ Old contact: todos@geneura.ugr.es, http://geneura.ugr.es #include #include -#include -#include +#include "EO.h" +#include "utils/eoLogger.h" /** diff --git a/eo/src/eoVectorParticle.h b/eo/src/eoVectorParticle.h index 25cfcc9fa..773234752 100644 --- a/eo/src/eoVectorParticle.h +++ b/eo/src/eoVectorParticle.h @@ -25,7 +25,7 @@ #ifndef _EOVECTORPARTICLE_H #define _EOVECTORPARTICLE_H -#include +#include "PO.h" /** diff --git a/eo/src/eoVelocity.h b/eo/src/eoVelocity.h index e388078c1..ef9b695d6 100644 --- a/eo/src/eoVelocity.h +++ b/eo/src/eoVelocity.h @@ -26,10 +26,10 @@ #define EOVELOCITY_H //----------------------------------------------------------------------------- -#include -#include -#include -#include +#include "eoFunctor.h" +#include "utils/eoRNG.h" +#include "eoPop.h" +#include "eoTopology.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/eoVelocityInit.h b/eo/src/eoVelocityInit.h index 8c57a6891..9c271b004 100644 --- a/eo/src/eoVelocityInit.h +++ b/eo/src/eoVelocityInit.h @@ -28,9 +28,9 @@ #include -#include -#include -#include +#include "eoOp.h" +#include "eoSTLFunctor.h" +#include "utils/eoRndGenerators.h" /** @addtogroup Initializators diff --git a/eo/src/eoWeightUpdater.h b/eo/src/eoWeightUpdater.h index d4970eca4..eee5d6309 100644 --- a/eo/src/eoWeightUpdater.h +++ b/eo/src/eoWeightUpdater.h @@ -26,7 +26,7 @@ #define EOWEIGHTUPDATER_H //----------------------------------------------------------------------------- -#include +#include "eoFunctor.h" //----------------------------------------------------------------------------- /** diff --git a/eo/src/es.h b/eo/src/es.h index d5dffc2f3..9e2fd78f9 100644 --- a/eo/src/es.h +++ b/eo/src/es.h @@ -36,28 +36,28 @@ //----------------------------------------------------------------------------- // the genotypes - from plain std::vector to full correlated mutation -#include -#include -#include -#include +#include "eoReal.h" +#include "eoEsSimple.h" +#include "eoEsStdev.h" +#include "eoEsFull.h" // the initialization -#include +#include "eoEsChromInit.h" // general operators -#include -#include -#include // for generic operators +#include "eoRealOp.h" +#include "eoNormalMutation.h" +#include "eoRealAtomXover.h" // for generic operators // SBX crossover (following Deb) -#include +#include "eoSBXcross.h" // ES specific operators -#include // Global ES Xover -#include // 2-parents ES Xover +#include "eoEsGlobalXover.h" // Global ES Xover +#include "eoEsStandardXover.h" // 2-parents ES Xover // the ES-mutations -#include -#include +#include "eoEsMutationInit.h" +#include "eoEsMutate.h" #endif diff --git a/eo/src/es/CMAParams.cpp b/eo/src/es/CMAParams.cpp index 131edb72f..2862cdd1a 100644 --- a/eo/src/es/CMAParams.cpp +++ b/eo/src/es/CMAParams.cpp @@ -43,8 +43,8 @@ * Version 2.23. * */ -#include -#include +#include "CMAParams.h" +#include "../utils/eoParser.h" #include diff --git a/eo/src/es/CMAState.cpp b/eo/src/es/CMAState.cpp index 328552434..897b32f0f 100644 --- a/eo/src/es/CMAState.cpp +++ b/eo/src/es/CMAState.cpp @@ -56,12 +56,11 @@ #include #include -#include - -#include -#include -#include -#include +#include "../utils/eoRNG.h" +#include "CMAState.h" +#include "CMAParams.h" +#include "matrices.h" +#include "eig.h" using namespace std; diff --git a/eo/src/es/eoCMABreed.h b/eo/src/es/eoCMABreed.h index 450654a7f..37f0389fb 100644 --- a/eo/src/es/eoCMABreed.h +++ b/eo/src/es/eoCMABreed.h @@ -25,9 +25,9 @@ #ifndef _EOCMABREED_H #define _EOCMABREED_H -#include -#include -#include +#include "../eoBreed.h" +#include "../eoVector.h" +#include "CMAState.h" #include diff --git a/eo/src/es/eoCMAInit.h b/eo/src/es/eoCMAInit.h index 2fdb967e0..73c63122d 100644 --- a/eo/src/es/eoCMAInit.h +++ b/eo/src/es/eoCMAInit.h @@ -28,9 +28,9 @@ #ifndef _EOCMAINIT_H #define _EOCMAINIT_H -#include -#include -#include +#include "../eoInit.h" +#include "../eoVector.h" +#include "CMAState.h" /// @todo handle bounds template diff --git a/eo/src/es/eoEsChromInit.h b/eo/src/es/eoEsChromInit.h index c5382890b..2d4b7b8a1 100644 --- a/eo/src/es/eoEsChromInit.h +++ b/eo/src/es/eoEsChromInit.h @@ -29,10 +29,10 @@ Contact: http://eodev.sourceforge.net #include #include -#include -#include -#include -#include +#include "eoRealInitBounded.h" +#include "eoEsSimple.h" +#include "eoEsStdev.h" +#include "eoEsFull.h" #ifndef M_PI #define M_PI 3.1415926535897932384626433832795 diff --git a/eo/src/es/eoEsFull.h b/eo/src/es/eoEsFull.h index a1091c83d..1dfdc58b6 100644 --- a/eo/src/es/eoEsFull.h +++ b/eo/src/es/eoEsFull.h @@ -27,7 +27,7 @@ #ifndef _eoEsFull_h #define _eoEsFull_h -#include +#include "../eoVector.h" /** \ingroup Real diff --git a/eo/src/es/eoEsGlobalXover.h b/eo/src/es/eoEsGlobalXover.h index 5be4b5061..3e25370be 100644 --- a/eo/src/es/eoEsGlobalXover.h +++ b/eo/src/es/eoEsGlobalXover.h @@ -26,15 +26,15 @@ #ifndef _eoEsGlobalXover_H #define _eoEsGlobalXover_H -#include +#include "../utils/eoRNG.h" -#include -#include -#include +#include "eoEsSimple.h" +#include "eoEsStdev.h" +#include "eoEsFull.h" -#include +#include "../eoGenOp.h" // needs a selector - here random -#include +#include "../eoRandomSelect.h" /** Global crossover operator for ES genotypes. * Uses some Atom crossovers to handle both the object variables diff --git a/eo/src/es/eoEsMutate.h b/eo/src/es/eoEsMutate.h index fd1152685..1b2bd5580 100644 --- a/eo/src/es/eoEsMutate.h +++ b/eo/src/es/eoEsMutate.h @@ -30,14 +30,14 @@ #define _EOESMUTATE_H #include -#include -#include -#include -#include -#include -#include -#include -#include +#include "../eoInit.h" +#include "../eoOp.h" +#include "eoEsMutationInit.h" +#include "eoEsSimple.h" +#include "eoEsStdev.h" +#include "eoEsFull.h" +#include "../utils/eoRealBounds.h" +#include "../utils/eoRNG.h" #ifndef M_PI #define M_PI 3.1415926535897932384626433832795 @@ -158,7 +158,7 @@ public: Diploma Thesis, University of Dortmund, 1990. */ virtual bool operator()( eoEsFull & _eo ) - // Code originally from Thomas Bck + // Code originally from Thomas B�ck { // First: mutate standard deviations (as for eoEsStdev). double global = TauGlb * rng.normal(); @@ -268,7 +268,7 @@ public: lower bound. The actual value used is somewhat arbitrary and the is no theoretical reasoning known for it (Sep 2005). - The code that we have in EO is a port from a C code that Thomas Bck kindly + The code that we have in EO is a port from a C code that Thomas B�ck kindly donated to the community some years ago. It has been modified by Marc Schoenauer for inclusion in EvolC, than by Maarten Keijzer into EO. The exact value was adjusted based on practice. diff --git a/eo/src/es/eoEsMutationInit.h b/eo/src/es/eoEsMutationInit.h index 987de86bd..b33dadb20 100644 --- a/eo/src/es/eoEsMutationInit.h +++ b/eo/src/es/eoEsMutationInit.h @@ -27,7 +27,7 @@ #ifndef _eoEsMutationInit_h #define _eoEsMutationInit_h -#include +#include "../utils/eoParser.h" /** Initialize Mutation operator diff --git a/eo/src/es/eoEsSimple.h b/eo/src/es/eoEsSimple.h index ac93ab4b6..812b9936b 100644 --- a/eo/src/es/eoEsSimple.h +++ b/eo/src/es/eoEsSimple.h @@ -23,10 +23,10 @@ Contact: http://eodev.sourceforge.net #ifndef _eoEsSimple_h #define _eoEsSimple_h -#include +#include "../EO.h" #include -#include +#include "../eoVector.h" /** Simple Evolution Strategy diff --git a/eo/src/es/eoEsStandardXover.h b/eo/src/es/eoEsStandardXover.h index 34739693c..ce00a0674 100644 --- a/eo/src/es/eoEsStandardXover.h +++ b/eo/src/es/eoEsStandardXover.h @@ -26,15 +26,15 @@ #ifndef _eoEsLocalXover_H #define _eoEsLocalXover_H -#include +#include "../utils/eoRNG.h" -#include -#include -#include +#include "eoEsSimple.h" +#include "eoEsStdev.h" +#include "eoEsFull.h" -#include +#include "../eoGenOp.h" // needs a selector - here random -#include +#include "../eoRandomSelect.h" /** Standard (i.e. eoBinOp) crossover operator for ES genotypes. * Uses some Atom crossovers to handle both the object variables diff --git a/eo/src/es/eoEsStdev.h b/eo/src/es/eoEsStdev.h index b8910512c..ad8ffb26f 100644 --- a/eo/src/es/eoEsStdev.h +++ b/eo/src/es/eoEsStdev.h @@ -23,7 +23,7 @@ Contact: http://eodev.sourceforge.net #ifndef _eoEsStdev_h #define _eoEsStdev_h -#include +#include "../eoVector.h" /** Evolutionary Strategy with a standard deviation per parameter diff --git a/eo/src/es/eoNormalMutation.h b/eo/src/es/eoNormalMutation.h index fd3916c22..48d09c6d5 100644 --- a/eo/src/es/eoNormalMutation.h +++ b/eo/src/es/eoNormalMutation.h @@ -29,11 +29,11 @@ //----------------------------------------------------------------------------- #include // swap_ranges -#include -#include -#include -#include -#include +#include "../utils/eoRNG.h" +#include "../utils/eoUpdatable.h" +#include "../eoEvalFunc.h" +#include "eoReal.h" +#include "../utils/eoRealBounds.h" //----------------------------------------------------------------------------- /** Simple normal mutation of a std::vector of real values. diff --git a/eo/src/es/eoReal.h b/eo/src/es/eoReal.h index ff1908a0c..dc6d51126 100644 --- a/eo/src/es/eoReal.h +++ b/eo/src/es/eoReal.h @@ -29,7 +29,7 @@ #include // std::ostream, std::istream #include // std::string -#include +#include "../eoVector.h" /** eoReal: implementation of simple real-valued chromosome. * based on eoVector class diff --git a/eo/src/es/eoRealAtomXover.h b/eo/src/es/eoRealAtomXover.h index 4d4244dd2..47e713386 100644 --- a/eo/src/es/eoRealAtomXover.h +++ b/eo/src/es/eoRealAtomXover.h @@ -31,9 +31,9 @@ #ifndef _eoRealAtomXover_H #define _eoRealAtomXover_H -#include +#include "../utils/eoRNG.h" -#include +#include "../eoOp.h" /** Discrete crossover == exchange of values diff --git a/eo/src/es/eoRealInitBounded.h b/eo/src/es/eoRealInitBounded.h index 6488dd056..fa0259ec4 100644 --- a/eo/src/es/eoRealInitBounded.h +++ b/eo/src/es/eoRealInitBounded.h @@ -28,10 +28,10 @@ //----------------------------------------------------------------------------- -#include -#include -#include -#include +#include "../utils/eoRNG.h" +#include "../eoInit.h" +#include "eoReal.h" +#include "../utils/eoRealVectorBounds.h" /** Simple initialization for any EOT that derives from std::vector * uniformly in some bounds diff --git a/eo/src/es/eoRealOp.h b/eo/src/es/eoRealOp.h index c8c6471a5..64b64101d 100644 --- a/eo/src/es/eoRealOp.h +++ b/eo/src/es/eoRealOp.h @@ -29,9 +29,9 @@ //----------------------------------------------------------------------------- #include // swap_ranges -#include -#include -#include +#include "../utils/eoRNG.h" +#include "eoReal.h" +#include "../utils/eoRealVectorBounds.h" //----------------------------------------------------------------------------- diff --git a/eo/src/es/eoSBXcross.h b/eo/src/es/eoSBXcross.h index 40f8ac360..c13369f01 100644 --- a/eo/src/es/eoSBXcross.h +++ b/eo/src/es/eoSBXcross.h @@ -24,11 +24,11 @@ //----------------------------------------------------------------------------- #include // swap_ranges -#include -#include -#include -#include -#include +#include "../utils/eoParser.h" +#include "../utils/eoRNG.h" +#include "eoReal.h" +#include "../utils/eoRealBounds.h" +#include "../utils/eoRealVectorBounds.h" diff --git a/eo/src/es/make_algo_scalar_es.cpp b/eo/src/es/make_algo_scalar_es.cpp index 47585a78c..e1bd1fb9d 100644 --- a/eo/src/es/make_algo_scalar_es.cpp +++ b/eo/src/es/make_algo_scalar_es.cpp @@ -41,11 +41,11 @@ */ // The templatized code -#include +#include "../do/make_algo_scalar.h" // the instanciating EOType(s) -#include // one Sigma per individual -#include // one sigmal per object variable -#include // full correlation matrix per indi +#include "eoEsSimple.h" // one Sigma per individual +#include "eoEsStdev.h" // one sigmal per object variable +#include "eoEsFull.h" // full correlation matrix per indi /// The following function merely call the templatized do_* functions above diff --git a/eo/src/es/make_algo_scalar_real.cpp b/eo/src/es/make_algo_scalar_real.cpp index 1a1796bed..fd8fe7dd7 100644 --- a/eo/src/es/make_algo_scalar_real.cpp +++ b/eo/src/es/make_algo_scalar_real.cpp @@ -41,9 +41,9 @@ */ // The templatized code -#include +#include "../do/make_algo_scalar.h" // the instanciating EOType -#include +#include "eoReal.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/es/make_checkpoint_es.cpp b/eo/src/es/make_checkpoint_es.cpp index 12bc78605..3f4329cf4 100644 --- a/eo/src/es/make_checkpoint_es.cpp +++ b/eo/src/es/make_checkpoint_es.cpp @@ -41,11 +41,11 @@ */ // The templatized code -#include +#include "../do/make_checkpoint.h" // the instanciating EOType(s) -#include // one Sigma per individual -#include // one sigmal per object variable -#include // full correlation matrix per indi +#include "eoEsSimple.h" // one Sigma per individual +#include "eoEsStdev.h" // one sigmal per object variable +#include "eoEsFull.h" // full correlation matrix per indi /// The following function merely call the templatized do_* functions diff --git a/eo/src/es/make_checkpoint_real.cpp b/eo/src/es/make_checkpoint_real.cpp index a1cf6d4f3..f73c8a3c4 100644 --- a/eo/src/es/make_checkpoint_real.cpp +++ b/eo/src/es/make_checkpoint_real.cpp @@ -41,9 +41,9 @@ */ // The templatized code -#include +#include "../do/make_checkpoint.h" // the instanciating EOType -#include +#include "eoReal.h" /// The following function merely call the templatized do_* functions diff --git a/eo/src/es/make_continue_es.cpp b/eo/src/es/make_continue_es.cpp index e50167959..f270e0244 100644 --- a/eo/src/es/make_continue_es.cpp +++ b/eo/src/es/make_continue_es.cpp @@ -41,11 +41,11 @@ */ // The templatized code -#include +#include "../do/make_continue.h" // the instanciating EOType(s) -#include // one Sigma per individual -#include // one sigmal per object variable -#include // full correlation matrix per indi +#include "eoEsSimple.h" // one Sigma per individual +#include "eoEsStdev.h" // one sigmal per object variable +#include "eoEsFull.h" // full correlation matrix per indi /// The following function merely call the templatized do_* functions diff --git a/eo/src/es/make_continue_real.cpp b/eo/src/es/make_continue_real.cpp index 060852172..c326bb8d3 100644 --- a/eo/src/es/make_continue_real.cpp +++ b/eo/src/es/make_continue_real.cpp @@ -41,9 +41,9 @@ */ // The templatized code -#include +#include "../do/make_continue.h" // the instanciating EOType -#include +#include "eoReal.h" /// The following function merely call the templatized do_* functions diff --git a/eo/src/es/make_es.h b/eo/src/es/make_es.h index 46a4e23f6..b1a8801a5 100644 --- a/eo/src/es/make_es.h +++ b/eo/src/es/make_es.h @@ -44,23 +44,23 @@ #ifndef es_h #define es_h -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "../eoAlgo.h" +#include "../eoScalarFitness.h" +#include "../utils/eoParser.h" +#include "../eoEvalFuncPtr.h" +#include "../eoEvalFuncCounter.h" +#include "../utils/eoCheckPoint.h" +#include "../eoGenOp.h" +#include "../eoPop.h" +#include "../utils/eoDistance.h" -#include // one Sigma per individual -#include // one sigmal per object variable -#include // full correlation matrix per indi +#include "eoEsSimple.h" // one Sigma per individual +#include "eoEsStdev.h" // one sigmal per object variable +#include "eoEsFull.h" // full correlation matrix per indi // include all similar declaration for eoReal - i.e. real-valued genotyes // without self-adaptation -#include +#include "make_real.h" /** @addtogroup Builders * @{ diff --git a/eo/src/es/make_genotype_es.cpp b/eo/src/es/make_genotype_es.cpp index 41f764cdf..d0861c9fd 100644 --- a/eo/src/es/make_genotype_es.cpp +++ b/eo/src/es/make_genotype_es.cpp @@ -54,7 +54,7 @@ the default ctor of EOT, resulting in most cases in an EOT that is */ // the templatized code (same for real and es here) -#include +#include "make_genotype_real.h" /// The following function merely call the templatized do_* functions diff --git a/eo/src/es/make_genotype_real.cpp b/eo/src/es/make_genotype_real.cpp index d5ad238d4..e34b69598 100644 --- a/eo/src/es/make_genotype_real.cpp +++ b/eo/src/es/make_genotype_real.cpp @@ -53,7 +53,7 @@ */ // the templatized code -#include +#include "make_genotype_real.h" /// The following functions merely call the templatized do_* functions eoRealInitBounded > & make_genotype(eoParser& _parser, diff --git a/eo/src/es/make_genotype_real.h b/eo/src/es/make_genotype_real.h index 6ab62967f..82b07db8f 100644 --- a/eo/src/es/make_genotype_real.h +++ b/eo/src/es/make_genotype_real.h @@ -28,11 +28,11 @@ Contact: http://eodev.sourceforge.net #include #include -#include "es/eoReal.h" -#include "es/eoEsChromInit.h" -#include "utils/eoParser.h" -#include "utils/eoRealVectorBounds.h" -#include "utils/eoState.h" +#include "eoReal.h" +#include "eoEsChromInit.h" +#include "../utils/eoParser.h" +#include "../utils/eoRealVectorBounds.h" +#include "../utils/eoState.h" /** @addtogroup Builders diff --git a/eo/src/es/make_op.h b/eo/src/es/make_op.h index 1c7fe50e7..35767b5df 100644 --- a/eo/src/es/make_op.h +++ b/eo/src/es/make_op.h @@ -28,21 +28,21 @@ #define _make_op_h // the operators -#include -#include -#include -#include +#include "../eoOp.h" +#include "../eoGenOp.h" +#include "../eoCloneOps.h" +#include "../eoOpContainer.h" // combinations of simple eoOps (eoMonOp and eoQuadOp) -#include +#include "../eoProportionalCombinedOp.h" // the specialized Real stuff -#include -#include -#include -#include +#include "eoReal.h" +#include "eoRealInitBounded.h" +#include "eoRealOp.h" +#include "eoNormalMutation.h" // also need the parser and param includes -#include -#include +#include "../utils/eoParser.h" +#include "../utils/eoState.h" /** @addtogroup Builders diff --git a/eo/src/es/make_op_es.cpp b/eo/src/es/make_op_es.cpp index 4dfbacf34..8da5c9fc8 100644 --- a/eo/src/es/make_op_es.cpp +++ b/eo/src/es/make_op_es.cpp @@ -42,7 +42,7 @@ */ // Templatized code -#include +#include "make_op_es.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/es/make_op_es.h b/eo/src/es/make_op_es.h index 00a3373f9..0b78a724f 100644 --- a/eo/src/es/make_op_es.h +++ b/eo/src/es/make_op_es.h @@ -24,24 +24,24 @@ Contact: http://eodev.sourceforge.net #define EO_make_op_h // the operators -#include -#include -#include -#include +#include "../eoOp.h" +#include "../eoGenOp.h" +#include "../eoCloneOps.h" +#include "../eoOpContainer.h" // combinations of simple eoOps (eoMonOp and eoQuadOp) -#include +#include "../eoProportionalCombinedOp.h" // the specialized Real stuff -#include -#include -#include -#include -#include -#include -#include +#include "eoReal.h" +#include "eoRealAtomXover.h" +#include "eoEsChromInit.h" +#include "eoEsMutationInit.h" +#include "eoEsMutate.h" +#include "eoEsGlobalXover.h" +#include "eoEsStandardXover.h" // also need the parser and param includes -#include -#include +#include "../utils/eoParser.h" +#include "../utils/eoState.h" /** @addtogroup Builders diff --git a/eo/src/es/make_op_real.cpp b/eo/src/es/make_op_real.cpp index b429cd411..2748470ec 100644 --- a/eo/src/es/make_op_real.cpp +++ b/eo/src/es/make_op_real.cpp @@ -42,7 +42,7 @@ */ // Templatized code -#include +#include "make_op_real.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/es/make_op_real.h b/eo/src/es/make_op_real.h index 19a8b16b6..198483a5a 100644 --- a/eo/src/es/make_op_real.h +++ b/eo/src/es/make_op_real.h @@ -28,21 +28,21 @@ #define _make_op_h // the operators -#include -#include -#include -#include +#include "../eoOp.h" +#include "../eoGenOp.h" +#include "../eoCloneOps.h" +#include "../eoOpContainer.h" // combinations of simple eoOps (eoMonOp and eoQuadOp) -#include +#include "../eoProportionalCombinedOp.h" // the specialized Real stuff -#include -#include -#include -#include +#include "../es/eoReal.h" +#include "../es/eoEsChromInit.h" +#include "../es/eoRealOp.h" +#include "../es/eoNormalMutation.h" // also need the parser and param includes -#include -#include +#include "../utils/eoParser.h" +#include "../utils/eoState.h" /** @addtogroup Builders diff --git a/eo/src/es/make_pop_es.cpp b/eo/src/es/make_pop_es.cpp index 4f72e3441..a4c17fe04 100644 --- a/eo/src/es/make_pop_es.cpp +++ b/eo/src/es/make_pop_es.cpp @@ -41,11 +41,11 @@ */ // The templatized code -#include +#include "../do/make_pop.h" // the instanciating EOType(s) -#include // one Sigma per individual -#include // one sigmal per object variable -#include // full correlation matrix per indi +#include "eoEsSimple.h" // one Sigma per individual +#include "eoEsStdev.h" // one sigmal per object variable +#include "eoEsFull.h" // full correlation matrix per indi /// The following function merely call the templatized do_* functions above diff --git a/eo/src/es/make_pop_real.cpp b/eo/src/es/make_pop_real.cpp index 968e7251e..cc137f531 100644 --- a/eo/src/es/make_pop_real.cpp +++ b/eo/src/es/make_pop_real.cpp @@ -41,9 +41,9 @@ */ // The templatized code -#include +#include "../do/make_pop.h" // the instanciating EOType -#include +#include "eoReal.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/es/make_real.h b/eo/src/es/make_real.h index bc04ba1f1..0c54b6c39 100644 --- a/eo/src/es/make_real.h +++ b/eo/src/es/make_real.h @@ -44,18 +44,18 @@ #ifndef real_h #define real_h -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "../eoAlgo.h" +#include "../eoScalarFitness.h" +#include "../utils/eoParser.h" +#include "../eoEvalFuncPtr.h" +#include "../eoEvalFuncCounter.h" +#include "../utils/eoCheckPoint.h" +#include "../eoGenOp.h" +#include "../eoPop.h" +#include "../utils/eoDistance.h" -#include -#include +#include "eoRealInitBounded.h" +#include "eoReal.h" //Representation dependent - rewrite everything anew for each representation ////////////////////////// diff --git a/eo/src/es/make_run_es.cpp b/eo/src/es/make_run_es.cpp index 59912a7f8..64b4ad659 100644 --- a/eo/src/es/make_run_es.cpp +++ b/eo/src/es/make_run_es.cpp @@ -41,13 +41,13 @@ */ // The templatized code -#include +#include"../do/make_run.h" // the instanciating EOType(s) -#include // one Sigma per individual -#include // one sigmal per object variable -#include // full correlation matrix per indi +#include "eoEsSimple.h" // one Sigma per individual +#include "eoEsStdev.h" // one sigmal per object variable +#include "eoEsFull.h" // full correlation matrix per indi // the instanciating fitnesses -#include +#include "eoScalarFitness.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/es/make_run_real.cpp b/eo/src/es/make_run_real.cpp index 2c61963c6..ee6732773 100644 --- a/eo/src/es/make_run_real.cpp +++ b/eo/src/es/make_run_real.cpp @@ -41,11 +41,11 @@ */ // The templatized code -#include +#include "../do/make_run.h" // the instanciating EOType -#include +#include "eoReal.h" // the instanciating fitnesses -#include +#include "../eoScalarFitness.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/ga.h b/eo/src/ga.h index 6abb0181a..2f20dc879 100644 --- a/eo/src/ga.h +++ b/eo/src/ga.h @@ -30,10 +30,10 @@ #define _ga_h // all bitstring-specific files -#include +#include "ga/eoBit.h" // the operators -#include +#include "ga/eoBitOp.h" // #include to be corrected - thanks someone! diff --git a/eo/src/ga/ChangeLog b/eo/src/ga/ChangeLog index 56ed12d06..b8ba4afa0 100644 --- a/eo/src/ga/ChangeLog +++ b/eo/src/ga/ChangeLog @@ -1,4 +1,8 @@ -2007-08-21 Jochen Kpper +2019-06-29 Ronaldd Pinho + + * all files: Change from absolute to relative include. + +2007-08-21 Jochen K�pper * eoBitOp.h (eoNPtsBitXover::operator()): Make sure bit is within allocated length of vector points: [0, max_size). diff --git a/eo/src/ga/eoBit.h b/eo/src/ga/eoBit.h index c1bc9c75e..040e57418 100644 --- a/eo/src/ga/eoBit.h +++ b/eo/src/ga/eoBit.h @@ -40,7 +40,7 @@ #include #include -#include "eoVector.h" +#include "../eoVector.h" /** @defgroup bitstring Bit strings diff --git a/eo/src/ga/eoBitOp.h b/eo/src/ga/eoBitOp.h index 15d77434d..a95ec58f4 100644 --- a/eo/src/ga/eoBitOp.h +++ b/eo/src/ga/eoBitOp.h @@ -30,10 +30,10 @@ //----------------------------------------------------------------------------- -#include // swap_ranges -#include -#include // eoMonOp -#include +#include // swap_ranges +#include "../utils/eoRNG.h" +#include "../eoInit.h" // eoMonOp +#include "eoBit.h" /** eoOneBitFlip --> changes 1 bit diff --git a/eo/src/ga/eoBitOpFactory.h b/eo/src/ga/eoBitOpFactory.h index 6511f9375..91168d3e5 100644 --- a/eo/src/ga/eoBitOpFactory.h +++ b/eo/src/ga/eoBitOpFactory.h @@ -26,8 +26,8 @@ #ifndef _EOBITOPFACTORY_H #define _EOBITOPFACTORY_H -#include -#include +#include "../eoFactory.h" +#include "eoBitOp.h" //----------------------------------------------------------------------------- diff --git a/eo/src/ga/eoBoolFlip.h b/eo/src/ga/eoBoolFlip.h index 47c43ee06..119952863 100644 --- a/eo/src/ga/eoBoolFlip.h +++ b/eo/src/ga/eoBoolFlip.h @@ -25,7 +25,7 @@ #ifndef _eoBoolFlip_h #define _eoBoolFlip_h -#include +#include "../eoOp.h" /** a simple boolean mutation - to be used in generic eoOp's * diff --git a/eo/src/ga/eoPBILAdditive.h b/eo/src/ga/eoPBILAdditive.h index e57a05a2b..2f3aea944 100644 --- a/eo/src/ga/eoPBILAdditive.h +++ b/eo/src/ga/eoPBILAdditive.h @@ -26,8 +26,8 @@ #ifndef _eoPBILAdditive_H #define _eoPBILAdditive_H -#include -#include +#include "../eoDistribUpdater.h" +#include "eoPBILDistrib.h" /** * Distribution Class for PBIL algorithm diff --git a/eo/src/ga/eoPBILDistrib.h b/eo/src/ga/eoPBILDistrib.h index 56556ba05..f85c143b5 100644 --- a/eo/src/ga/eoPBILDistrib.h +++ b/eo/src/ga/eoPBILDistrib.h @@ -25,7 +25,7 @@ #ifndef _eoPBILDistrib_H #define _eoPBILDistrib_H -#include +#include "../eoDistribution.h" /** * Distribution Class for PBIL algorithm diff --git a/eo/src/ga/eoPBILOrg.h b/eo/src/ga/eoPBILOrg.h index 45b95c843..865d95727 100644 --- a/eo/src/ga/eoPBILOrg.h +++ b/eo/src/ga/eoPBILOrg.h @@ -26,8 +26,8 @@ #ifndef _eoPBILOrg_H #define _eoPBILOrg_H -#include -#include +#include "eoDistribUpdater.h" +#include "../eoPBILDistrib.h" /** * Distribution Class for PBIL algorithm diff --git a/eo/src/ga/make_PBILdistrib.h b/eo/src/ga/make_PBILdistrib.h index b3c725d6d..cef9765f5 100644 --- a/eo/src/ga/make_PBILdistrib.h +++ b/eo/src/ga/make_PBILdistrib.h @@ -27,10 +27,10 @@ #define _make_PBILdistrib_h #include // for time(0) for random seeding -#include -#include -#include -#include +#include "eoPBILOrg.h" +#include "../utils/eoRNG.h" +#include "../utils/eoParser.h" +#include "../utils/eoState.h" //////////////////////////DISTRIB CONSTRUCTION /////////////////////////////// diff --git a/eo/src/ga/make_PBILupdate.h b/eo/src/ga/make_PBILupdate.h index a8572136d..34a062a96 100644 --- a/eo/src/ga/make_PBILupdate.h +++ b/eo/src/ga/make_PBILupdate.h @@ -26,10 +26,10 @@ #ifndef _make_PBILupdate_h #define _make_PBILupdate_h -#include -#include -#include -#include +#include "eoPBILOrg.h" +#include "../utils/eoRNG.h" +#include "../utils/eoParser.h" +#include "../utils/eoState.h" ///////CONSTRUCTION of PBIL distribution updaters///////////////// diff --git a/eo/src/ga/make_algo_scalar_ga.cpp b/eo/src/ga/make_algo_scalar_ga.cpp index 631e6dadf..df8926c88 100644 --- a/eo/src/ga/make_algo_scalar_ga.cpp +++ b/eo/src/ga/make_algo_scalar_ga.cpp @@ -44,9 +44,9 @@ */ // The templatized code -#include +#include "../do/make_algo_scalar.h" // the instanciating EOType -#include +#include "eoBit.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/ga/make_checkpoint_ga.cpp b/eo/src/ga/make_checkpoint_ga.cpp index eecc40caa..ffd0c54cf 100644 --- a/eo/src/ga/make_checkpoint_ga.cpp +++ b/eo/src/ga/make_checkpoint_ga.cpp @@ -44,9 +44,9 @@ */ // The templatized code -#include +#include "../do/make_checkpoint.h" // the instanciating EOType -#include +#include "eoBit.h" /// The following function merely call the templatized do_* functions diff --git a/eo/src/ga/make_continue_ga.cpp b/eo/src/ga/make_continue_ga.cpp index fb4662c32..b2c9a60ee 100644 --- a/eo/src/ga/make_continue_ga.cpp +++ b/eo/src/ga/make_continue_ga.cpp @@ -44,9 +44,9 @@ */ // The templatized code -#include +#include "../do/make_continue.h" // the instanciating EOType -#include +#include "eoBit.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/ga/make_ga.h b/eo/src/ga/make_ga.h index 206094881..6feacb6e2 100644 --- a/eo/src/ga/make_ga.h +++ b/eo/src/ga/make_ga.h @@ -38,16 +38,16 @@ #ifndef ga_h #define ga_h -#include -#include -#include -#include -#include -#include -#include -#include +#include "../eoAlgo.h" +#include "../eoScalarFitness.h" +#include "../utils/eoParser.h" +#include "../eoEvalFuncCounter.h" +#include "../utils/eoCheckPoint.h" +#include "../eoGenOp.h" +#include "../eoPop.h" +#include "../utils/eoDistance.h" -#include +#include "eoBit.h" //Representation dependent - rewrite everything anew for each representation ////////////////////////// diff --git a/eo/src/ga/make_genotype_ga.cpp b/eo/src/ga/make_genotype_ga.cpp index 3344a8d87..013f416c9 100644 --- a/eo/src/ga/make_genotype_ga.cpp +++ b/eo/src/ga/make_genotype_ga.cpp @@ -41,7 +41,7 @@ */ // the templatized code -#include +#include "make_genotype_ga.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/ga/make_genotype_ga.h b/eo/src/ga/make_genotype_ga.h index fad4f7563..93cab894d 100644 --- a/eo/src/ga/make_genotype_ga.h +++ b/eo/src/ga/make_genotype_ga.h @@ -27,11 +27,11 @@ #ifndef _make_genotype_h #define _make_genotype_h -#include -#include +#include "eoBit.h" +#include "../eoInit.h" // also need the parser and param includes -#include -#include +#include "../utils/eoParser.h" +#include "../utils/eoState.h" /////////////////// the bitstring //////////////// diff --git a/eo/src/ga/make_op.h b/eo/src/ga/make_op.h index 2035a4f85..b8993f312 100644 --- a/eo/src/ga/make_op.h +++ b/eo/src/ga/make_op.h @@ -28,19 +28,19 @@ #define _make_op_h // the operators -#include -#include -#include -#include +#include "../eoOp.h" +#include "../eoGenOp.h" +#include "../eoCloneOps.h" +#include "../eoOpContainer.h" // combinations of simple eoOps (eoMonOp and eoQuadOp) -#include +#include "../eoProportionalCombinedOp.h" // the specialized GA stuff -#include -#include +#include "eoBit.h" +#include "eoBitOp.h" // also need the parser and param includes -#include -#include +#include "../utils/eoParser.h" +#include "../utils/eoState.h" /////////////////// bitstring operators /////////////// diff --git a/eo/src/ga/make_op_ga.cpp b/eo/src/ga/make_op_ga.cpp index e3a53d651..249b002a3 100644 --- a/eo/src/ga/make_op_ga.cpp +++ b/eo/src/ga/make_op_ga.cpp @@ -44,7 +44,7 @@ */ // Templatized code -#include +#include "make_op.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/ga/make_pop_ga.cpp b/eo/src/ga/make_pop_ga.cpp index 319279793..1ec32f6b5 100644 --- a/eo/src/ga/make_pop_ga.cpp +++ b/eo/src/ga/make_pop_ga.cpp @@ -42,9 +42,9 @@ */ // The templatized code -#include +#include "../do/make_pop.h" // the instanciating EOType -#include +#include "eoBit.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/ga/make_run_ga.cpp b/eo/src/ga/make_run_ga.cpp index d64d2b025..f9284b80f 100644 --- a/eo/src/ga/make_run_ga.cpp +++ b/eo/src/ga/make_run_ga.cpp @@ -44,11 +44,11 @@ */ // The templatized code -#include +#include "../do/make_run.h" // the instanciating EOType -#include +#include "eoBit.h" // the instanciating fitnesses -#include +#include "../eoScalarFitness.h" /// The following function merely call the templatized do_* functions above diff --git a/eo/src/gp/eoParseTree.h b/eo/src/gp/eoParseTree.h index 88737d919..666445fa3 100644 --- a/eo/src/gp/eoParseTree.h +++ b/eo/src/gp/eoParseTree.h @@ -30,10 +30,10 @@ #include #include -#include -#include -#include -#include +#include "../EO.h" +#include "../eoInit.h" +#include "../eoOp.h" +#include "parse_tree.h" using namespace gp_parse_tree; diff --git a/eo/src/gp/eoParseTreeDepthInit.h b/eo/src/gp/eoParseTreeDepthInit.h index 18dc55b91..6abe2e4ff 100644 --- a/eo/src/gp/eoParseTreeDepthInit.h +++ b/eo/src/gp/eoParseTreeDepthInit.h @@ -28,11 +28,11 @@ #ifndef eoParseTreeDepthInit_h #define eoParseTreeDepthInit_h -#include -#include -#include -#include -#include +#include "../EO.h" +#include "eoParseTree.h" +#include "eoInit.h" +#include "eoOp.h" +#include "eoPop.h" using namespace gp_parse_tree; diff --git a/eo/src/gp/eoParseTreeOp.h b/eo/src/gp/eoParseTreeOp.h index 0b623f3d8..37511963b 100644 --- a/eo/src/gp/eoParseTreeOp.h +++ b/eo/src/gp/eoParseTreeOp.h @@ -29,10 +29,10 @@ #ifndef eoParseTreeOp_h #define eoParseTreeOp_h -#include -#include +#include "../EO.h" +#include "../eoOp.h" -#include +#include "eoParseTree.h" /** eoSubtreeXOver --> subtree xover \class eoSubtreeXOver eoParseTreeOp.h gp/eoParseTreeOp.h diff --git a/eo/src/gp/eoStParseTreeDepthInit.h b/eo/src/gp/eoStParseTreeDepthInit.h index 37b178873..aa7247dd8 100644 --- a/eo/src/gp/eoStParseTreeDepthInit.h +++ b/eo/src/gp/eoStParseTreeDepthInit.h @@ -27,10 +27,10 @@ #ifndef eoStParseTreeDepthInit_h #define eoStParseTreeDepthInit_h -#include -#include -#include -#include +#include "../EO.h" +#include "eoParseTree.h" +#include "../eoInit.h" +#include "../eoOp.h" #include diff --git a/eo/src/gp/eoStParseTreeOp.h b/eo/src/gp/eoStParseTreeOp.h index 88020448d..d5b520beb 100644 --- a/eo/src/gp/eoStParseTreeOp.h +++ b/eo/src/gp/eoStParseTreeOp.h @@ -28,13 +28,13 @@ #ifndef eoStParseTreeOp_h #define eoStParseTreeOp_h -#include -#include +#include "../EO.h" +#include "../eoOp.h" #include #include #include -#include +#include "eoParseTree.h" // a help function template diff --git a/eo/src/mpi/eoMpi.h b/eo/src/mpi/eoMpi.h index a47ce8a33..0bef5fea8 100644 --- a/eo/src/mpi/eoMpi.h +++ b/eo/src/mpi/eoMpi.h @@ -24,10 +24,10 @@ Authors: # include // std::vector -# include -# include -# include -# include +# include "../utils/eoLogger.h" +# include "../utils/eoTimer.h" +# include "../eoFunctor.h" +# include "../eoExceptions.h" # include "eoMpiNode.h" # include "eoMpiAssignmentAlgorithm.h" diff --git a/eo/src/mpi/eoMpiNode.cpp b/eo/src/mpi/eoMpiNode.cpp index 69f06576b..ba6424bc4 100644 --- a/eo/src/mpi/eoMpiNode.cpp +++ b/eo/src/mpi/eoMpiNode.cpp @@ -19,7 +19,7 @@ Contact: http://eodev.sourceforge.net Authors: Benjamin Bouvier */ -# include "eoMpiNode.h" +#include "eoMpiNode.h" namespace eo { diff --git a/eo/src/mpi/eoMultiStart.h b/eo/src/mpi/eoMultiStart.h index 23a8cc04a..71e084bb4 100644 --- a/eo/src/mpi/eoMultiStart.h +++ b/eo/src/mpi/eoMultiStart.h @@ -1,7 +1,7 @@ # ifndef __EO_MULTISTART_H__ # define __EO_MULTISTART_H__ -# include +# include "../eo" # include "eoMpi.h" /** diff --git a/eo/src/mpi/eoParallelApply.h b/eo/src/mpi/eoParallelApply.h index 671c3843f..dfb66e027 100644 --- a/eo/src/mpi/eoParallelApply.h +++ b/eo/src/mpi/eoParallelApply.h @@ -24,7 +24,7 @@ Authors: # include "eoMpi.h" -# include // eoUF +# include "../eoFunctor.h" // eoUF # include // std::vector population /** diff --git a/eo/src/mpi/eoTerminateJob.h b/eo/src/mpi/eoTerminateJob.h index fe231f0e3..2f299916b 100644 --- a/eo/src/mpi/eoTerminateJob.h +++ b/eo/src/mpi/eoTerminateJob.h @@ -19,10 +19,10 @@ Contact: http://eodev.sourceforge.net Authors: Benjamin Bouvier */ -# ifndef __EO_TERMINATE_H__ -# define __EO_TERMINATE_H__ +#ifndef __EO_TERMINATE_H__ +#define __EO_TERMINATE_H__ -# include "eoMpi.h" +#include "eoMpi.h" namespace eo { diff --git a/eo/src/mpi/implMpi.cpp b/eo/src/mpi/implMpi.cpp index 6ae0c0996..16b9ea2ce 100644 --- a/eo/src/mpi/implMpi.cpp +++ b/eo/src/mpi/implMpi.cpp @@ -19,7 +19,7 @@ Contact: http://eodev.sourceforge.net Authors: Benjamin Bouvier */ -# include "implMpi.h" +#include "implMpi.h" namespace mpi { diff --git a/eo/src/mpi/implMpi.h b/eo/src/mpi/implMpi.h index b7c1cd4ba..c55cff6f8 100644 --- a/eo/src/mpi/implMpi.h +++ b/eo/src/mpi/implMpi.h @@ -19,11 +19,11 @@ Contact: http://eodev.sourceforge.net Authors: Benjamin Bouvier */ -# ifndef __EO_IMPL_MPI_HPP__ -# define __EO_IMPL_MPI_HPP__ +#ifndef __EO_IMPL_MPI_HPP__ +#define __EO_IMPL_MPI_HPP__ -# include -# include +#include "eoMpi.h" +#include "../serial/eoSerial.h" /** * This namespace contains reimplementations of some parts of the Boost::MPI API in C++, so as to be used in diff --git a/eo/src/other/eoExternalEO.h b/eo/src/other/eoExternalEO.h index 4440b428f..cb37206b8 100644 --- a/eo/src/other/eoExternalEO.h +++ b/eo/src/other/eoExternalEO.h @@ -26,7 +26,7 @@ #ifndef eoExternalEO_h #define eoExternalEO_h -#include // EO +#include "../EO.h" // EO /** * Definition of an object that allows an external struct diff --git a/eo/src/other/eoExternalOpFunctions.h b/eo/src/other/eoExternalOpFunctions.h index d86b49c45..75455f079 100644 --- a/eo/src/other/eoExternalOpFunctions.h +++ b/eo/src/other/eoExternalOpFunctions.h @@ -28,10 +28,10 @@ #ifndef eoExternalOpFunc_h #define eoExternalOpFunc_h -#include -#include -#include -#include +#include "eoExternalEO.h" +#include "../eoOp.h" +#include "../eoInit.h" +#include "../eoEvalFunc.h" /** Initialization of external struct, ctor expects a function of the following diff --git a/eo/src/other/eoString.h b/eo/src/other/eoString.h index 3071d1ee6..2fff076ee 100644 --- a/eo/src/other/eoString.h +++ b/eo/src/other/eoString.h @@ -30,8 +30,7 @@ #include #include - -#include +#include "../EO.h" //----------------------------------------------------------------------------- // eoString diff --git a/eo/src/other/external_eo b/eo/src/other/external_eo index aeaaaab6b..449053a05 100644 --- a/eo/src/other/external_eo +++ b/eo/src/other/external_eo @@ -1,2 +1,2 @@ -#include -#include +#include "eoExternalEO.h" +#include "eoExternalOpFunctions.h" diff --git a/eo/src/pyeo/PyEO.cpp b/eo/src/pyeo/PyEO.cpp index 7c3f1b93f..8517c9aad 100644 --- a/eo/src/pyeo/PyEO.cpp +++ b/eo/src/pyeo/PyEO.cpp @@ -21,7 +21,7 @@ #include #include "PyEO.h" -#include +#include "../eoPop.h" using namespace std; //using namespace boost::python; diff --git a/eo/src/pyeo/PyEO.h b/eo/src/pyeo/PyEO.h index 188b7f8da..e9452800e 100644 --- a/eo/src/pyeo/PyEO.h +++ b/eo/src/pyeo/PyEO.h @@ -26,7 +26,7 @@ #include #include -#include +#include "../EO.h" struct index_error : public std::exception { diff --git a/eo/src/pyeo/abstract1.cpp b/eo/src/pyeo/abstract1.cpp index 43c0dadb9..bb9097967 100644 --- a/eo/src/pyeo/abstract1.cpp +++ b/eo/src/pyeo/abstract1.cpp @@ -18,11 +18,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include -#include -#include +#include "../eoEvalFunc.h" +#include "../eoInit.h" +#include "../eoTransform.h" +#include "../eoSGATransform.h" +#include "../eoPopEvalFunc.h" #include "PyEO.h" #include "def_abstract_functor.h" diff --git a/eo/src/pyeo/algos.cpp b/eo/src/pyeo/algos.cpp index caa2fcd33..c95fc3319 100644 --- a/eo/src/pyeo/algos.cpp +++ b/eo/src/pyeo/algos.cpp @@ -18,10 +18,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include -#include +#include "../eoSGA.h" +#include "../eoEasyEA.h" +#include "../eoDetSelect.h" +#include "../eoCellularEasyEA.h" #include "PyEO.h" #include "def_abstract_functor.h" diff --git a/eo/src/pyeo/breeders.cpp b/eo/src/pyeo/breeders.cpp index c66b6bccd..2adc55e16 100644 --- a/eo/src/pyeo/breeders.cpp +++ b/eo/src/pyeo/breeders.cpp @@ -18,9 +18,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include +#include "../eoBreed.h" +#include "../eoGeneralBreeder.h" +#include "../eoOneToOneBreeder.h" #include "PyEO.h" #include "def_abstract_functor.h" diff --git a/eo/src/pyeo/continuators.cpp b/eo/src/pyeo/continuators.cpp index d31613d2c..4d787a09a 100644 --- a/eo/src/pyeo/continuators.cpp +++ b/eo/src/pyeo/continuators.cpp @@ -18,13 +18,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include -#include -#include -#include -#include +#include "../eoGenContinue.h" +#include "../eoCombinedContinue.h" +#include "../eoEvalContinue.h" +#include "../eoFitContinue.h" +#include "../eoSteadyFitContinue.h" +#include "../utils/eoCheckPoint.h" +#include "../utils/eoStat.h" #include "PyEO.h" #include "def_abstract_functor.h" diff --git a/eo/src/pyeo/def_abstract_functor.h b/eo/src/pyeo/def_abstract_functor.h index 4c3101dfd..5bba6cb3d 100644 --- a/eo/src/pyeo/def_abstract_functor.h +++ b/eo/src/pyeo/def_abstract_functor.h @@ -21,7 +21,7 @@ #ifndef MAKE_ABSTRACT_FUNCTOR_H #define MAKE_ABSTRACT_FUNCTOR_H -#include +#include "../eoFunctor.h" // DEFINES for call #define WC1 boost::python::with_custodian_and_ward<1,2>() diff --git a/eo/src/pyeo/geneticOps.cpp b/eo/src/pyeo/geneticOps.cpp index 40617680e..a67108576 100644 --- a/eo/src/pyeo/geneticOps.cpp +++ b/eo/src/pyeo/geneticOps.cpp @@ -18,11 +18,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include -#include -#include +#include "../eoGenOp.h" +#include "../eoOp.h" +#include "../eoCloneOps.h" +#include "../eoPopulator.h" +#include "../eoOpContainer.h" #include "PyEO.h" #include "def_abstract_functor.h" diff --git a/eo/src/pyeo/mergers.cpp b/eo/src/pyeo/mergers.cpp index f41af0490..84e0970ba 100644 --- a/eo/src/pyeo/mergers.cpp +++ b/eo/src/pyeo/mergers.cpp @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "../eoMerge.h" #include "PyEO.h" #include "def_abstract_functor.h" diff --git a/eo/src/pyeo/monitors.cpp b/eo/src/pyeo/monitors.cpp index 02d011d89..f64881659 100644 --- a/eo/src/pyeo/monitors.cpp +++ b/eo/src/pyeo/monitors.cpp @@ -18,8 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include +#include "../utils/eoParam.h" +#include "../utils/eoMonitor.h" #include "PyEO.h" using namespace boost::python; diff --git a/eo/src/pyeo/perf2worth.cpp b/eo/src/pyeo/perf2worth.cpp index a257b0cd9..3c6cc0f04 100644 --- a/eo/src/pyeo/perf2worth.cpp +++ b/eo/src/pyeo/perf2worth.cpp @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "../eoNDSorting.h" #include "PyEO.h" diff --git a/eo/src/pyeo/random_numbers.cpp b/eo/src/pyeo/random_numbers.cpp index c9047385d..01bb883b4 100644 --- a/eo/src/pyeo/random_numbers.cpp +++ b/eo/src/pyeo/random_numbers.cpp @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "../utils/eoRNG.h" #include using namespace boost::python; diff --git a/eo/src/pyeo/reduce.cpp b/eo/src/pyeo/reduce.cpp index 6c9b78c64..031ff282a 100644 --- a/eo/src/pyeo/reduce.cpp +++ b/eo/src/pyeo/reduce.cpp @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "../eoReduce.h" #include "PyEO.h" diff --git a/eo/src/pyeo/replacement.cpp b/eo/src/pyeo/replacement.cpp index eb1bc5d70..f85e4759b 100644 --- a/eo/src/pyeo/replacement.cpp +++ b/eo/src/pyeo/replacement.cpp @@ -18,11 +18,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include -#include -#include +#include "../eoReplacement.h" +#include "../eoMergeReduce.h" +#include "../eoReduceMerge.h" +#include "../eoReduceMergeReduce.h" +#include "../eoMGGReplacement.h" #include "PyEO.h" #include "def_abstract_functor.h" diff --git a/eo/src/pyeo/selectOne.cpp b/eo/src/pyeo/selectOne.cpp index 5a28fcff3..1adb7d15a 100644 --- a/eo/src/pyeo/selectOne.cpp +++ b/eo/src/pyeo/selectOne.cpp @@ -18,12 +18,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include -#include -#include -#include +#include "../eoSelectOne.h" +#include "../eoDetTournamentSelect.h" +#include "../eoRandomSelect.h" +#include "../eoStochTournamentSelect.h" +#include "../eoTruncatedSelectOne.h" +#include "../eoSequentialSelect.h" #include "PyEO.h" #include "pickle.h" diff --git a/eo/src/pyeo/selectors.cpp b/eo/src/pyeo/selectors.cpp index 7c8f4096a..23ce85ccd 100644 --- a/eo/src/pyeo/selectors.cpp +++ b/eo/src/pyeo/selectors.cpp @@ -18,13 +18,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include -#include -#include -#include -#include +#include "../eoSelect.h" +#include "../eoDetSelect.h" +#include "../eoSelectMany.h" +#include "../eoSelectNumber.h" +#include "../eoSelectPerc.h" +#include "../eoTruncSelect.h" +#include "../eoTruncatedSelectMany.h" #include "PyEO.h" #include "def_abstract_functor.h" diff --git a/eo/src/pyeo/statistics.cpp b/eo/src/pyeo/statistics.cpp index fbad92694..e48b6f2fa 100644 --- a/eo/src/pyeo/statistics.cpp +++ b/eo/src/pyeo/statistics.cpp @@ -1,4 +1,4 @@ -#include +#include "../utils/eoStat.h" #include "PyEO.h" #include "valueParam.h" diff --git a/eo/src/pyeo/valueParam.cpp b/eo/src/pyeo/valueParam.cpp index 59ed1a472..6e4b06218 100644 --- a/eo/src/pyeo/valueParam.cpp +++ b/eo/src/pyeo/valueParam.cpp @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "../utils/eoParam.h" #include // Here's 'len'. Why? dunno diff --git a/eo/src/utils/checkpointing b/eo/src/utils/checkpointing index f7fd0e55b..68c0c8856 100644 --- a/eo/src/utils/checkpointing +++ b/eo/src/utils/checkpointing @@ -24,27 +24,27 @@ #ifndef _CHECKPOINTING_ #define _CHECKPOINTING_ -#include -#include -#include -#include -#include -#include -#include +#include "eoParser.h" +#include "eoState.h" +#include "eoUpdater.h" +#include "eoMonitor.h" +#include "eoFileMonitor.h" +#include "eoStdoutMonitor.h" +#include "eoOStreamMonitor.h" #ifndef _MSC_VER -#include -#include +#include "eoGnuplot1DMonitor.h" +#include "eoGnuplot1DSnapshot.h" #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "eoCheckPoint.h" +#include "eoSignal.h" +#include "eoStat.h" +#include "eoScalarFitnessStat.h" +#include "eoAssembledFitnessStat.h" +#include "eoFDCStat.h" +#include "eoMOFitnessStat.h" +#include "eoPopStat.h" +#include "eoTimeCounter.h" +#include "eoGenCounter.h" // and make_help - any better suggestion to include it? void make_help(eoParser & _parser); diff --git a/eo/src/utils/eoAssembledFitnessStat.h b/eo/src/utils/eoAssembledFitnessStat.h index 44586932b..43e922f3f 100644 --- a/eo/src/utils/eoAssembledFitnessStat.h +++ b/eo/src/utils/eoAssembledFitnessStat.h @@ -33,8 +33,8 @@ #ifndef _eoAssembledFitnessStat_h #define _eoAssembledFitnessStat_h -#include -#include +#include "eoStat.h" +#include "../eoScalarFitnessAssembled.h" /** @addtogroup Stats * @{ diff --git a/eo/src/utils/eoCheckPoint.h b/eo/src/utils/eoCheckPoint.h index ea562e8bf..ba540bf66 100644 --- a/eo/src/utils/eoCheckPoint.h +++ b/eo/src/utils/eoCheckPoint.h @@ -27,10 +27,10 @@ #ifndef _eoCheckPoint_h #define _eoCheckPoint_h -#include -#include -#include -#include +#include "../eoContinue.h" +#include "eoUpdater.h" +#include "eoMonitor.h" +#include "eoStat.h" /** @defgroup Checkpoints Checkpointing * diff --git a/eo/src/utils/eoDistance.h b/eo/src/utils/eoDistance.h index 35ce9a109..661b5f7cb 100644 --- a/eo/src/utils/eoDistance.h +++ b/eo/src/utils/eoDistance.h @@ -26,7 +26,7 @@ #ifndef _eoDistance_H #define _eoDistance_H -#include +#include "../eoFunctor.h" /** @addtogroup Stats * @{ diff --git a/eo/src/utils/eoFDCStat.h b/eo/src/utils/eoFDCStat.h index 1d2050b78..b8536db53 100644 --- a/eo/src/utils/eoFDCStat.h +++ b/eo/src/utils/eoFDCStat.h @@ -27,9 +27,9 @@ #ifndef _eoFDCStat_h #define _eoFDCStat_h -#include -#include -#include +#include "eoStat.h" +#include "eoDistance.h" +#include "eoFileSnapshot.h" /** The Fitness Distance Correlation computation. diff --git a/eo/src/utils/eoFileMonitor.cpp b/eo/src/utils/eoFileMonitor.cpp index 80b7afaff..e1e58ba21 100644 --- a/eo/src/utils/eoFileMonitor.cpp +++ b/eo/src/utils/eoFileMonitor.cpp @@ -7,9 +7,9 @@ #include #include -#include -#include -#include +#include "eoFileMonitor.h" +#include "compatibility.h" +#include "eoParam.h" using namespace std; diff --git a/eo/src/utils/eoFileMonitor.h b/eo/src/utils/eoFileMonitor.h index dcd48e4c4..0d23dcbf5 100644 --- a/eo/src/utils/eoFileMonitor.h +++ b/eo/src/utils/eoFileMonitor.h @@ -31,8 +31,8 @@ #include #include -#include "utils/eoMonitor.h" -#include "eoObject.h" +#include "eoMonitor.h" +#include "../eoObject.h" /** Prints statistics to file diff --git a/eo/src/utils/eoFileSnapshot.h b/eo/src/utils/eoFileSnapshot.h index cdd2e36cc..c474a9293 100644 --- a/eo/src/utils/eoFileSnapshot.h +++ b/eo/src/utils/eoFileSnapshot.h @@ -29,9 +29,9 @@ #include #include -#include -#include -#include +#include "eoParam.h" +#include "eoMonitor.h" +#include "../eoObject.h" /** diff --git a/eo/src/utils/eoFuncPtrStat.h b/eo/src/utils/eoFuncPtrStat.h index c77281577..b97e53105 100644 --- a/eo/src/utils/eoFuncPtrStat.h +++ b/eo/src/utils/eoFuncPtrStat.h @@ -1,8 +1,8 @@ #ifndef eoFuncPtrStat_h #define eoFuncPtrStat_h -#include -#include +#include "../eoFunctorStore.h" +#include "eoStat.h" diff --git a/eo/src/utils/eoGenCounter.h b/eo/src/utils/eoGenCounter.h index a06949c21..1ac9b8719 100644 --- a/eo/src/utils/eoGenCounter.h +++ b/eo/src/utils/eoGenCounter.h @@ -22,7 +22,7 @@ #define _eoGenCounter_h #include -#include +#include "eoStat.h" /** An eoStat that simply gives the current generation index diff --git a/eo/src/utils/eoGnuplot1DMonitor.cpp b/eo/src/utils/eoGnuplot1DMonitor.cpp index c0cff842c..ab54b1132 100644 --- a/eo/src/utils/eoGnuplot1DMonitor.cpp +++ b/eo/src/utils/eoGnuplot1DMonitor.cpp @@ -29,8 +29,8 @@ #include -#include "utils/eoGnuplot1DMonitor.h" -#include "utils/eoParam.h" +#include "eoGnuplot1DMonitor.h" +#include "eoParam.h" eoMonitor& eoGnuplot1DMonitor::operator() (void) diff --git a/eo/src/utils/eoGnuplot1DMonitor.h b/eo/src/utils/eoGnuplot1DMonitor.h index e32e22275..0d1dc8b37 100644 --- a/eo/src/utils/eoGnuplot1DMonitor.h +++ b/eo/src/utils/eoGnuplot1DMonitor.h @@ -27,10 +27,10 @@ #include #include -#include "eoObject.h" -#include "utils/eoFileMonitor.h" -#include "utils/eoGnuplot.h" -#include "utils/pipecom.h" +#include "../eoObject.h" +#include "eoFileMonitor.h" +#include "eoGnuplot.h" +#include "pipecom.h" /** Plot eoStat diff --git a/eo/src/utils/eoGnuplot1DSnapshot.h b/eo/src/utils/eoGnuplot1DSnapshot.h index 38c5af745..10519e26e 100644 --- a/eo/src/utils/eoGnuplot1DSnapshot.h +++ b/eo/src/utils/eoGnuplot1DSnapshot.h @@ -32,11 +32,11 @@ #include #include -#include +#include "../eoObject.h" #include "eoRealVectorBounds.h" -#include -#include -#include +#include "pipecom.h" +#include "eoFileSnapshot.h" +#include "eoGnuplot.h" /** Plot stats through gnuplot diff --git a/eo/src/utils/eoHowMany.h b/eo/src/utils/eoHowMany.h index 1105f3b73..bb47417a1 100644 --- a/eo/src/utils/eoHowMany.h +++ b/eo/src/utils/eoHowMany.h @@ -31,7 +31,7 @@ Contact: http://eodev.sourceforge.net #include -#include +#include "eoLogger.h" /** A helper class, to determine a number of individuals from another one diff --git a/eo/src/utils/eoIntBounds.h b/eo/src/utils/eoIntBounds.h index 2127c92f7..924d0e022 100644 --- a/eo/src/utils/eoIntBounds.h +++ b/eo/src/utils/eoIntBounds.h @@ -28,7 +28,7 @@ #define _eoIntBounds_h #include // std::exceptions! -#include +#include "eoRNG.h" /** \class eoIntBounds eoIntBounds.h es/eoIntBounds.h diff --git a/eo/src/utils/eoLogger.h b/eo/src/utils/eoLogger.h index 9ac1c2115..a3c377fed 100644 --- a/eo/src/utils/eoLogger.h +++ b/eo/src/utils/eoLogger.h @@ -92,7 +92,7 @@ Caner Candan #include #include -#include "eoObject.h" +#include "../eoObject.h" #include "eoParser.h" namespace eo diff --git a/eo/src/utils/eoMOFitnessStat.h b/eo/src/utils/eoMOFitnessStat.h index 8e1b2d3fd..3f7b14d00 100644 --- a/eo/src/utils/eoMOFitnessStat.h +++ b/eo/src/utils/eoMOFitnessStat.h @@ -27,7 +27,7 @@ #ifndef _eoFitnessStat_h #define _eoFitnessStat_h -#include +#include "eoStat.h" /** The fitnesses of a whole population, as a vector diff --git a/eo/src/utils/eoMonitor.h b/eo/src/utils/eoMonitor.h index 1c92e9c00..0a00f9ead 100644 --- a/eo/src/utils/eoMonitor.h +++ b/eo/src/utils/eoMonitor.h @@ -27,7 +27,7 @@ #include #include -#include +#include "../eoFunctor.h" /** @defgroup Monitors Monitoring * diff --git a/eo/src/utils/eoOStreamMonitor.cpp b/eo/src/utils/eoOStreamMonitor.cpp index b9e848c58..edb091690 100644 --- a/eo/src/utils/eoOStreamMonitor.cpp +++ b/eo/src/utils/eoOStreamMonitor.cpp @@ -9,10 +9,10 @@ #include #include -#include -#include -#include -#include +#include "eoOStreamMonitor.h" +#include "compatibility.h" +#include "eoParam.h" +#include "eoLogger.h" //using namespace std; diff --git a/eo/src/utils/eoOStreamMonitor.h b/eo/src/utils/eoOStreamMonitor.h index 032665224..dab0ea776 100644 --- a/eo/src/utils/eoOStreamMonitor.h +++ b/eo/src/utils/eoOStreamMonitor.h @@ -30,9 +30,9 @@ Authors: #include #include -#include -#include -#include +#include "eoMonitor.h" +#include "eoLogger.h" +#include "../eoObject.h" /** Prints statistics to a given ostream. diff --git a/eo/src/utils/eoParallel.h b/eo/src/utils/eoParallel.h index c7a15a4f9..6608706dc 100644 --- a/eo/src/utils/eoParallel.h +++ b/eo/src/utils/eoParallel.h @@ -31,7 +31,7 @@ Authors: #ifndef eoParallel_h #define eoParallel_h -#include "eoObject.h" +#include "../eoObject.h" #include "eoParser.h" /** diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index e3a09f215..d2c39efbd 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include "../eoScalarFitness.h" /** @defgroup Parameters Parameters management * diff --git a/eo/src/utils/eoParser.cpp b/eo/src/utils/eoParser.cpp index cc306bf73..15a66105a 100644 --- a/eo/src/utils/eoParser.cpp +++ b/eo/src/utils/eoParser.cpp @@ -37,9 +37,9 @@ Authors: #include #include -#include -#include -#include +#include "compatibility.h" +#include "eoParser.h" +#include "eoLogger.h" using namespace std; diff --git a/eo/src/utils/eoParser.h b/eo/src/utils/eoParser.h index a53230da8..793da622c 100644 --- a/eo/src/utils/eoParser.h +++ b/eo/src/utils/eoParser.h @@ -30,9 +30,9 @@ Authors: #include #include "eoParam.h" -#include "eoObject.h" -#include "eoPersistent.h" -#include "eoExceptions.h" +#include "../eoObject.h" +#include "../eoPersistent.h" +#include "../eoExceptions.h" /** Parameter saving and loading diff --git a/eo/src/utils/eoPopStat.h b/eo/src/utils/eoPopStat.h index f3f091a6e..8102af087 100644 --- a/eo/src/utils/eoPopStat.h +++ b/eo/src/utils/eoPopStat.h @@ -35,7 +35,7 @@ that can be used to dump to the screen #ifndef _eoPopStat_h #define _eoPopStat_h -#include +#include "eoStat.h" /** Thanks to MS/VC++, eoParam mechanism is unable to handle std::vectors of stats. diff --git a/eo/src/utils/eoRNG.h b/eo/src/utils/eoRNG.h index ce648cabf..ad5c440bf 100644 --- a/eo/src/utils/eoRNG.h +++ b/eo/src/utils/eoRNG.h @@ -50,8 +50,9 @@ typedef unsigned long uint32_t; #include #include -#include "eoPersistent.h" -#include "eoObject.h" +// Relative includes +#include "../eoPersistent.h" +#include "../eoObject.h" /** Random Number Generator diff --git a/eo/src/utils/eoRealBounds.h b/eo/src/utils/eoRealBounds.h index 8d55d793a..5d28c1741 100644 --- a/eo/src/utils/eoRealBounds.h +++ b/eo/src/utils/eoRealBounds.h @@ -31,7 +31,7 @@ #include #include // std::exceptions! -#include +#include "eoRNG.h" #include "eoLogger.h" /** diff --git a/eo/src/utils/eoRealVectorBounds.h b/eo/src/utils/eoRealVectorBounds.h index 56feff345..7fb880f53 100644 --- a/eo/src/utils/eoRealVectorBounds.h +++ b/eo/src/utils/eoRealVectorBounds.h @@ -28,8 +28,8 @@ #define _eoRealVectorBounds_h #include // std::exceptions! -#include -#include +#include "eoRNG.h" +#include "eoRealBounds.h" /** Vector type for bounds (see eoRealBounds.h for scalar types) diff --git a/eo/src/utils/eoRndGenerators.h b/eo/src/utils/eoRndGenerators.h index 62e62ccff..454845b17 100644 --- a/eo/src/utils/eoRndGenerators.h +++ b/eo/src/utils/eoRndGenerators.h @@ -30,7 +30,7 @@ #define eoRndGenerators_h #include "eoRNG.h" -#include +#include "../eoFunctor.h" #include /** @defgroup Random Random number generation diff --git a/eo/src/utils/eoScalarFitnessStat.h b/eo/src/utils/eoScalarFitnessStat.h index e56e46822..0260baa2a 100644 --- a/eo/src/utils/eoScalarFitnessStat.h +++ b/eo/src/utils/eoScalarFitnessStat.h @@ -27,8 +27,8 @@ #ifndef _eoScalarFitnessStat_h #define _eoScalarFitnessStat_h -#include -#include +#include "eoRealVectorBounds.h" +#include "eoStat.h" /** The fitnesses of a whole population, as a std::vector diff --git a/eo/src/utils/eoSignal.cpp b/eo/src/utils/eoSignal.cpp index 745d21bd3..eb12382fd 100644 --- a/eo/src/utils/eoSignal.cpp +++ b/eo/src/utils/eoSignal.cpp @@ -23,7 +23,7 @@ Caner.Candan@univ-angers.fr */ -#include +#include "eoSignal.h" /** * @addtogroup Continuators diff --git a/eo/src/utils/eoSignal.h b/eo/src/utils/eoSignal.h index 9a89cb196..c9f7ecf57 100644 --- a/eo/src/utils/eoSignal.h +++ b/eo/src/utils/eoSignal.h @@ -27,8 +27,8 @@ #define _eoSignal_h #include -#include -#include +#include "eoCheckPoint.h" +#include "eoLogger.h" #include #include diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index 313426c3f..5610ecbee 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -35,12 +35,12 @@ Contact: http://eodev.sourceforge.net #include #include // accumulate -#include -#include -#include -#include -//#include -#include +#include "../eoFunctor.h" +#include "eoParam.h" +#include "../eoPop.h" +#include "eoMonitor.h" +//#include "eoCheckPoint.h" +#include "eoLogger.h" /** @defgroup Stats Statistics computation * diff --git a/eo/src/utils/eoState.cpp b/eo/src/utils/eoState.cpp index c6d385001..884549244 100644 --- a/eo/src/utils/eoState.cpp +++ b/eo/src/utils/eoState.cpp @@ -11,8 +11,8 @@ #include #include "eoState.h" -#include "eoObject.h" -#include "eoPersistent.h" +#include "../eoObject.h" +#include "../eoPersistent.h" using namespace std; diff --git a/eo/src/utils/eoState.h b/eo/src/utils/eoState.h index 256dcd965..e96917e9d 100644 --- a/eo/src/utils/eoState.h +++ b/eo/src/utils/eoState.h @@ -33,7 +33,7 @@ #include #include -#include +#include "../eoFunctorStore.h" class eoObject; class eoPersistent; diff --git a/eo/src/utils/eoStdoutMonitor.h b/eo/src/utils/eoStdoutMonitor.h index d886aed3a..dba8be98c 100644 --- a/eo/src/utils/eoStdoutMonitor.h +++ b/eo/src/utils/eoStdoutMonitor.h @@ -32,8 +32,8 @@ Authors: #include -#include -#include +#include "eoOStreamMonitor.h" +#include "../eoObject.h" /** Prints statistics to stdout diff --git a/eo/src/utils/eoTimeCounter.h b/eo/src/utils/eoTimeCounter.h index 623714156..e56ed1452 100644 --- a/eo/src/utils/eoTimeCounter.h +++ b/eo/src/utils/eoTimeCounter.h @@ -28,7 +28,8 @@ #define _eoTimeCounter_h #include -#include +#include "eoStat.h" +#include "eoUpdater.h" /** diff --git a/eo/src/utils/eoTimedMonitor.h b/eo/src/utils/eoTimedMonitor.h index a06ae6cce..93abc4aa3 100644 --- a/eo/src/utils/eoTimedMonitor.h +++ b/eo/src/utils/eoTimedMonitor.h @@ -30,8 +30,8 @@ #include #include -#include -#include +#include "eoMonitor.h" +#include "../eoObject.h" /** Holds a collection of monitors and only fires them when a time limit diff --git a/eo/src/utils/eoTimer.h b/eo/src/utils/eoTimer.h index 8a1fbb1a8..5ced8c6bd 100644 --- a/eo/src/utils/eoTimer.h +++ b/eo/src/utils/eoTimer.h @@ -28,9 +28,9 @@ Authors: # include // std::vector # include // std::map -# include "utils/eoParallel.h" // eo::parallel +# include "eoParallel.h" // eo::parallel -# include "serial/eoSerial.h" // eo::Persistent +# include "../serial/eoSerial.h" // eo::Persistent /** * @brief Timer allowing to measure time between a start point and a stop point. diff --git a/eo/src/utils/eoUniformInit.h b/eo/src/utils/eoUniformInit.h index cede61b73..8f4cd9d86 100644 --- a/eo/src/utils/eoUniformInit.h +++ b/eo/src/utils/eoUniformInit.h @@ -39,7 +39,7 @@ #define eoUniformInit_h #include "eoRNG.h" -#include "eoInit.h" +#include "../eoInit.h" #include "eoRealBounds.h" #include diff --git a/eo/src/utils/eoUpdatable.h b/eo/src/utils/eoUpdatable.h index 202ef962c..1c1103afc 100644 --- a/eo/src/utils/eoUpdatable.h +++ b/eo/src/utils/eoUpdatable.h @@ -27,7 +27,7 @@ #ifndef _eoUpdatable_h #define _eoUpdatable_h -#include +#include "eoUpdater.h" /** eoUpdatable is a generic class for adding updatation to an existing class diff --git a/eo/src/utils/eoUpdater.cpp b/eo/src/utils/eoUpdater.cpp index dd6a38960..de2d0ba8a 100644 --- a/eo/src/utils/eoUpdater.cpp +++ b/eo/src/utils/eoUpdater.cpp @@ -8,8 +8,8 @@ #include -#include -#include +#include "eoState.h" +#include "eoUpdater.h" using namespace std; diff --git a/eo/src/utils/eoUpdater.h b/eo/src/utils/eoUpdater.h index 072b9a9bb..0ae3b9c25 100644 --- a/eo/src/utils/eoUpdater.h +++ b/eo/src/utils/eoUpdater.h @@ -28,9 +28,9 @@ #define _eoUpdater_h #include -#include -#include -#include +#include "../eoFunctor.h" +#include "eoState.h" +#include "eoParam.h" template class eoCheckPoint; diff --git a/eo/src/utils/make_help.cpp b/eo/src/utils/make_help.cpp index a7ab040cd..fd2c5efb3 100644 --- a/eo/src/utils/make_help.cpp +++ b/eo/src/utils/make_help.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include "eoParser.h" using namespace std; diff --git a/eo/src/utils/selectors.h b/eo/src/utils/selectors.h index 37df7997b..43992ac3c 100644 --- a/eo/src/utils/selectors.h +++ b/eo/src/utils/selectors.h @@ -41,7 +41,7 @@ #include #include "eoRNG.h" -#include +#include "../eoPop.h" /** @addtogroup Selectors @{ From 646f20934e02c8c11ee12c8b8c7a98fdafca5072 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 6 Dec 2019 15:26:21 +0100 Subject: [PATCH 131/419] fix back some errors inserted by previous refactoring - move PBIL classes in deprecated/, superseeded by the EDO module --- .../ga => deprecated/eo/es}/eoPBILAdditive.h | 0 .../ga => deprecated/eo/es}/eoPBILDistrib.h | 0 {eo/src/ga => deprecated/eo/es}/eoPBILOrg.h | 0 {eo/test => deprecated/eo/es}/t-eoPBIL.cpp | 0 edo/test/t-bounderno.cpp | 2 +- edo/test/t-continue.cpp | 2 +- edo/test/t-edoEstimatorNormalMulti.cpp | 4 +-- edo/test/t-mean-distance.cpp | 4 +-- edo/test/t-uniform.cpp | 2 +- eo/src/eoCombinedContinue.h | 6 ++--- eo/src/eoFactory.h | 2 +- eo/src/eoObject.h | 2 +- eo/src/eoOpSelMason.h | 2 +- eo/src/eoPrintable.h | 4 +-- eo/src/es.h | 26 +++++++++---------- eo/src/ga/ChangeLog | 2 +- eo/test/CMakeLists.txt | 2 +- 17 files changed, 30 insertions(+), 30 deletions(-) rename {eo/src/ga => deprecated/eo/es}/eoPBILAdditive.h (100%) rename {eo/src/ga => deprecated/eo/es}/eoPBILDistrib.h (100%) rename {eo/src/ga => deprecated/eo/es}/eoPBILOrg.h (100%) rename {eo/test => deprecated/eo/es}/t-eoPBIL.cpp (100%) diff --git a/eo/src/ga/eoPBILAdditive.h b/deprecated/eo/es/eoPBILAdditive.h similarity index 100% rename from eo/src/ga/eoPBILAdditive.h rename to deprecated/eo/es/eoPBILAdditive.h diff --git a/eo/src/ga/eoPBILDistrib.h b/deprecated/eo/es/eoPBILDistrib.h similarity index 100% rename from eo/src/ga/eoPBILDistrib.h rename to deprecated/eo/es/eoPBILDistrib.h diff --git a/eo/src/ga/eoPBILOrg.h b/deprecated/eo/es/eoPBILOrg.h similarity index 100% rename from eo/src/ga/eoPBILOrg.h rename to deprecated/eo/es/eoPBILOrg.h diff --git a/eo/test/t-eoPBIL.cpp b/deprecated/eo/es/t-eoPBIL.cpp similarity index 100% rename from eo/test/t-eoPBIL.cpp rename to deprecated/eo/es/t-eoPBIL.cpp diff --git a/edo/test/t-bounderno.cpp b/edo/test/t-bounderno.cpp index ac294ce7d..8f7a49b0c 100644 --- a/edo/test/t-bounderno.cpp +++ b/edo/test/t-bounderno.cpp @@ -28,7 +28,7 @@ Authors: #include #include -#include "Rosenbrock.h" +#include "../application/common/Rosenbrock.h" typedef eoReal< eoMinimizingFitness > EOT; diff --git a/edo/test/t-continue.cpp b/edo/test/t-continue.cpp index 2f2bd3247..a5d661dac 100644 --- a/edo/test/t-continue.cpp +++ b/edo/test/t-continue.cpp @@ -28,7 +28,7 @@ Authors: #include #include -#include "Rosenbrock.h" +#include "../application/common/Rosenbrock.h" typedef eoReal< eoMinimizingFitness > EOT; typedef edoUniform< EOT > Distrib; diff --git a/edo/test/t-edoEstimatorNormalMulti.cpp b/edo/test/t-edoEstimatorNormalMulti.cpp index 6483a1062..4bc802fbd 100644 --- a/edo/test/t-edoEstimatorNormalMulti.cpp +++ b/edo/test/t-edoEstimatorNormalMulti.cpp @@ -33,8 +33,8 @@ Authors: #include -#include "Rosenbrock.h" -#include "Sphere.h" +#include "../application/common/Rosenbrock.h" +#include "../application/common/Sphere.h" typedef eoReal< eoMinimizingFitness > EOT; typedef edoNormalMulti< EOT > Distrib; diff --git a/edo/test/t-mean-distance.cpp b/edo/test/t-mean-distance.cpp index 59b1c8aa5..8c79bc037 100644 --- a/edo/test/t-mean-distance.cpp +++ b/edo/test/t-mean-distance.cpp @@ -38,8 +38,8 @@ Authors: #include -#include "Rosenbrock.h" -#include "Sphere.h" +#include "../application/common/Rosenbrock.h" +#include "../application/common/Sphere.h" typedef eoReal< eoMinimizingFitness > EOT; typedef edoNormalMulti< EOT > Distrib; diff --git a/edo/test/t-uniform.cpp b/edo/test/t-uniform.cpp index 228ce5e22..8496425b3 100644 --- a/edo/test/t-uniform.cpp +++ b/edo/test/t-uniform.cpp @@ -28,7 +28,7 @@ Authors: #include #include -#include "Rosenbrock.h" +#include "../application/common/Rosenbrock.h" typedef eoReal< eoMinimizingFitness > EOT; diff --git a/eo/src/eoCombinedContinue.h b/eo/src/eoCombinedContinue.h index 96878b4ea..756a44a89 100644 --- a/eo/src/eoCombinedContinue.h +++ b/eo/src/eoCombinedContinue.h @@ -22,8 +22,8 @@ Authors : todos@geneura.ugr.es Marc Schoenauer - Ram�n Casero Ca�as - Johann Dr�o + Ramón Casero Cañas + Johann Dreo */ //----------------------------------------------------------------------------- @@ -40,7 +40,7 @@ Authors : to be consistent with other Combined constructs and allow to easily handle more than 2 continuators -02/2003 Ram�n Casero Ca�as - added the removeLast() method +02/2003 Ramón Casero Cañas - added the removeLast() method @ingroup Combination */ diff --git a/eo/src/eoFactory.h b/eo/src/eoFactory.h index 51cbc678b..b6dd62de0 100644 --- a/eo/src/eoFactory.h +++ b/eo/src/eoFactory.h @@ -31,7 +31,7 @@ //----------------------------------------------------------------------------- /** EO Factory. A factory is used to create other objects. In particular, -it can be used so that objects of that kind can�t be created in any other +it can be used so that objects of that kind can't be created in any other way. It should be instantiated with anything that needs a factory, like selectors or whatever; but the instance class should be the parent class from which all the object that are going to be created descend. This class basically defines an interface, diff --git a/eo/src/eoObject.h b/eo/src/eoObject.h index 1e119b988..9744c35e7 100644 --- a/eo/src/eoObject.h +++ b/eo/src/eoObject.h @@ -39,7 +39,7 @@ changed. eoObject is used to define a name (#className#) that is used when loading or saving the state. Previously, this object also defined a print and read -interface, but it�s been moved to eoPrintable and eoPersistent. +interface, but it's been moved to eoPrintable and eoPersistent. */ /** Defines a name (#className#), used when loading or saving a state. diff --git a/eo/src/eoOpSelMason.h b/eo/src/eoOpSelMason.h index 377de0c95..7df95066f 100644 --- a/eo/src/eoOpSelMason.h +++ b/eo/src/eoOpSelMason.h @@ -79,7 +79,7 @@ public: _is >> rate; if ( _is ) { eoOp* op = operatorFactory.make( _is ); // This reads the rest of the line - // Add the operators to the selector, don�t pay attention to the IDs + // Add the operators to the selector, don't pay attention to the IDs opSelectorP->addOp( *op, rate ); // Keep it in the store, to destroy later tmpPVec.push_back( op ); diff --git a/eo/src/eoPrintable.h b/eo/src/eoPrintable.h index f04f50fb6..1f2404a89 100644 --- a/eo/src/eoPrintable.h +++ b/eo/src/eoPrintable.h @@ -27,8 +27,8 @@ //----------------------------------------------------------------------------- -#include "iostream" // std::istream, std::ostream -#include "string" // para std::string +#include // std::istream, std::ostream +#include // para std::string /* This functionality was separated from eoObject, since it makes no sense to print diff --git a/eo/src/es.h b/eo/src/es.h index 9e2fd78f9..d38485b69 100644 --- a/eo/src/es.h +++ b/eo/src/es.h @@ -36,28 +36,28 @@ //----------------------------------------------------------------------------- // the genotypes - from plain std::vector to full correlated mutation -#include "eoReal.h" -#include "eoEsSimple.h" -#include "eoEsStdev.h" -#include "eoEsFull.h" +#include "es/eoReal.h" +#include "es/eoEsSimple.h" +#include "es/eoEsStdev.h" +#include "es/eoEsFull.h" // the initialization -#include "eoEsChromInit.h" +#include "es/eoEsChromInit.h" // general operators -#include "eoRealOp.h" -#include "eoNormalMutation.h" -#include "eoRealAtomXover.h" // for generic operators +#include "es/eoRealOp.h" +#include "es/eoNormalMutation.h" +#include "es/eoRealAtomXover.h" // for generic operators // SBX crossover (following Deb) -#include "eoSBXcross.h" +#include "es/eoSBXcross.h" // ES specific operators -#include "eoEsGlobalXover.h" // Global ES Xover -#include "eoEsStandardXover.h" // 2-parents ES Xover +#include "es/eoEsGlobalXover.h" // Global ES Xover +#include "es/eoEsStandardXover.h" // 2-parents ES Xover // the ES-mutations -#include "eoEsMutationInit.h" -#include "eoEsMutate.h" +#include "es/eoEsMutationInit.h" +#include "es/eoEsMutate.h" #endif diff --git a/eo/src/ga/ChangeLog b/eo/src/ga/ChangeLog index b8ba4afa0..4d62600ed 100644 --- a/eo/src/ga/ChangeLog +++ b/eo/src/ga/ChangeLog @@ -2,7 +2,7 @@ * all files: Change from absolute to relative include. -2007-08-21 Jochen K�pper +2007-08-21 Jochen Küpper * eoBitOp.h (eoNPtsBitXover::operator()): Make sure bit is within allocated length of vector points: [0, max_size). diff --git a/eo/test/CMakeLists.txt b/eo/test/CMakeLists.txt index 4a0c74e43..aa4f17035 100644 --- a/eo/test/CMakeLists.txt +++ b/eo/test/CMakeLists.txt @@ -45,7 +45,7 @@ set (TEST_LIST t-eoReal t-eoVector t-eoESAll - t-eoPBIL + # t-eoPBIL # deprecated, see EDO module. t-eoFitnessAssembled t-eoFitnessAssembledEA t-eoRoulette From e64417f2a56ec86b5a13ecb5897a778edec788ee Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 10 Dec 2019 11:11:47 +0100 Subject: [PATCH 132/419] BREAKING CHANGE: set standard to C++11, feat: accessor to breeder ops Give an access to the operators held by a breeder. This is needed to design algorithms that dynamically update their internal parameters during search. To simplify the interface, we use a returned tuple, and thus upgrade the C++ standard to C++11. --- CMakeLists.txt | 1 + eo/src/eoGeneralBreeder.h | 28 +++++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bb3a2c4e..b125b0966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ project("ParadisEO") ## Language enable_language(CXX) +set(CMAKE_CXX_STANDARD 11) ## Test the presence of a compiler if("${CMAKE_CXX_COMPILER}" STREQUAL "" OR "${CMAKE_C_COMPILER}" STREQUAL "") diff --git a/eo/src/eoGeneralBreeder.h b/eo/src/eoGeneralBreeder.h index 1fdbd5c40..fb1bc88b8 100644 --- a/eo/src/eoGeneralBreeder.h +++ b/eo/src/eoGeneralBreeder.h @@ -32,6 +32,8 @@ * eoGeneralBreeder: transforms a population using the generalOp construct. *****************************************************************************/ +#include + #include "eoOp.h" #include "eoGenOp.h" #include "eoPopulator.h" @@ -58,9 +60,12 @@ class eoGeneralBreeder: public eoBreed eoGeneralBreeder( eoSelectOne& _select, eoGenOp& _op, - double _rate=1.0, + double _rate=1.0, bool _interpret_as_rate = true) : - select( _select ), op(_op), howMany(_rate, _interpret_as_rate) {} + select( _select ), op(_op), + local_howMany(_rate, _interpret_as_rate), + howMany(local_howMany) + {} /** Ctor: * @@ -71,8 +76,8 @@ class eoGeneralBreeder: public eoBreed eoGeneralBreeder( eoSelectOne& _select, eoGenOp& _op, - eoHowMany _howMany ) : - select( _select ), op(_op), howMany(_howMany) {} + eoHowMany& _howMany ) : + select( _select ), op(_op), howMany(_howMany) {} /** The breeder: simply calls the genOp on a selective populator! * @@ -82,7 +87,6 @@ class eoGeneralBreeder: public eoBreed void operator()(const eoPop& _parents, eoPop& _offspring) { unsigned target = howMany(_parents.size()); - _offspring.clear(); eoSelectivePopulator it(_parents, _offspring, select); @@ -98,10 +102,20 @@ class eoGeneralBreeder: public eoBreed /// The class name. virtual std::string className() const { return "eoGeneralBreeder"; } - private: + virtual std::tuple + &,eoGenOp&,eoHowMany&> + operators() + { + return std::forward_as_tuple + &,eoGenOp&,eoHowMany&> + (select, op, howMany); + } + + protected: eoSelectOne& select; eoGenOp& op; - eoHowMany howMany; + eoHowMany local_howMany; + eoHowMany& howMany; }; #endif From 87d4f082588ed906868ee922f6b7bdd178323ea8 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 10 Dec 2019 11:18:09 +0100 Subject: [PATCH 133/419] eoBitOp feat: access to preference, fix: use doubles and swap - Makes the `preference` member protected instead of private, which may be used for algorithms managing their internal parameters during search. - Replace float parameter with double, used everywhere else in the framework. - use std::swap instead of handmade swap. --- eo/src/ga/eoBitOp.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/eo/src/ga/eoBitOp.h b/eo/src/ga/eoBitOp.h index a95ec58f4..b5436327f 100644 --- a/eo/src/ga/eoBitOp.h +++ b/eo/src/ga/eoBitOp.h @@ -30,9 +30,10 @@ //----------------------------------------------------------------------------- -#include // swap_ranges +#include // swap_ranges + #include "../utils/eoRNG.h" -#include "../eoInit.h" // eoMonOp +#include "../eoInit.h" // eoMonOp #include "eoBit.h" @@ -187,7 +188,7 @@ template class eoBitMutation: public eoMonOp return changed_something; } - private: + protected: double rate; bool normalize; // divide rate by chromSize }; @@ -330,7 +331,7 @@ template class eoUBitXover: public eoQuadOp { public: /// (Default) Constructor. - eoUBitXover(const float& _preference = 0.5): preference(_preference) + eoUBitXover(const double& _preference = 0.5): preference(_preference) { if ( (_preference <= 0.0) || (_preference >= 1.0) ) std::runtime_error("UxOver --> invalid preference"); @@ -353,16 +354,17 @@ template class eoUBitXover: public eoQuadOp { if (chrom1[i] != chrom2[i] && eo::rng.flip(preference)) { - bool tmp = chrom1[i]; - chrom1[i]=chrom2[i]; - chrom2[i] = tmp; + // bool tmp = chrom1[i]; + // chrom1[i]=chrom2[i]; + // chrom2[i] = tmp; + std::swap(chrom1[i], chrom2[i]); changed = true; } } return changed; } - private: - float preference; + protected: + double preference; }; From 9b887c83a616e1cdd5c06f669a91e9f2713af7ed Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 10 Dec 2019 11:20:54 +0100 Subject: [PATCH 134/419] feat: class to wrap a eoMonOp into a eoQuadOp --- eo/src/eoOp.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/eo/src/eoOp.h b/eo/src/eoOp.h index 5351b9d86..bf0e24de9 100644 --- a/eo/src/eoOp.h +++ b/eo/src/eoOp.h @@ -184,6 +184,50 @@ private: eoQuadOp & quadOp; }; +/** Wrap eoMonOp into an eoQuadOp: simply don't touch the second arg. + */ +template +class eoMon2QuadOp1: public eoQuadOp +{ +public: + /** Ctor + * @param _monOp the eoMonOp to be transformed + */ + eoMon2QuadOp1(eoMonOp & _monOp) : monOp(_monOp) {} + + /** Call the eoMonOp on the first argument only. + */ + bool operator()(EOT & _eo1, EOT & /*_eo2*/) + { + return monOp(_eo1); + } + +private: + eoMonOp & monOp; +}; + +/** Wrap eoMonOp into an eoQuadOp: simply don't touch the first arg. + */ +template +class eoMon2QuadOp2: public eoQuadOp +{ +public: + /** Ctor + * @param _monOp the eoMonOp to be transformed + */ + eoMon2QuadOp2(eoMonOp & _monOp) : monOp(_monOp) {} + + /** Call the eoMonOp on the second argument only. + */ + bool operator()(EOT & /*_eo1*/, EOT & _eo2) + { + return monOp(_eo2); + } + +private: + eoMonOp & monOp; +}; + #endif //@} From be782f8cfbe024e4dea727f771da9dd356031bd6 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 10 Dec 2019 11:24:39 +0100 Subject: [PATCH 135/419] feat: add a sequential select that returns the best individual --- eo/src/eoSequentialSelect.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/eo/src/eoSequentialSelect.h b/eo/src/eoSequentialSelect.h index 1a1f02e4e..adf3cf452 100644 --- a/eo/src/eoSequentialSelect.h +++ b/eo/src/eoSequentialSelect.h @@ -51,7 +51,8 @@ always returns individuals from best to worst @ingroup Selectors */ -template class eoSequentialSelect: public eoSelectOne +template +class eoSequentialSelect: public eoSelectOne { public: /** Ctor: sets the current pter to numeric_limits::max() so init will take place first time @@ -60,7 +61,7 @@ template class eoSequentialSelect: public eoSelectOne eoSequentialSelect(bool _ordered = true) : ordered(_ordered), current(std::numeric_limits::max()) {} - void setup(const eoPop& _pop) + virtual void setup(const eoPop& _pop) { eoPters.resize(_pop.size()); if (ordered) // probably we could have a marker to avoid re-sorting @@ -86,6 +87,24 @@ private: }; +/** An eoSelectOne that returns the best individual each time it's called. + +@ingroup Selectors +*/ +template +class eoEliteSelect: public eoSequentialSelect +{ + public: + eoEliteSelect() : + eoSequentialSelect(true) + {} + + virtual const EOT& operator()(const eoPop& pop) + { + this->setup(pop); + return pop[0]; // the best one + } +}; /** All Individuals in order From 728bc6e8978430f6eb78da5b8cedf7aea094d38b Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 10 Dec 2019 11:26:09 +0100 Subject: [PATCH 136/419] feat: get a param handle from its name Useful for introspection and dynamic parameter management. --- eo/src/utils/eoParser.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/eo/src/utils/eoParser.h b/eo/src/utils/eoParser.h index 793da622c..8e1df04f5 100644 --- a/eo/src/utils/eoParser.h +++ b/eo/src/utils/eoParser.h @@ -29,10 +29,10 @@ Authors: #include #include -#include "eoParam.h" #include "../eoObject.h" #include "../eoPersistent.h" #include "../eoExceptions.h" +#include "eoParam.h" /** Parameter saving and loading @@ -195,13 +195,28 @@ public: */ eoParam * getParam(const std::string& _name) const; + /** + * Get a eoValueParam handle on a param from its long name + * If not found, raise an eoMissingParamException + */ + template + eoValueParam& getValueParam(const std::string& _name) + { + eoParam* p = getParamWithLongName( _name ); + if( p == NULL ) { + throw eoMissingParamException(_name ); + } else { + return dynamic_cast< eoValueParam& >(*p); + } + } + /** * Get the value of a param from its long name * If not found, raise an eoMissingParamException * * Remember to specify the expected return type with a templated call: - * unsigned int popSize = eoparser.value("popSize"); + * unsigned int popSize = eoparser.valueOf("popSize"); * * If the template type is not the good one, an eoWrongParamTypeException is raised. */ From 90c3e8ffa14268f99d9a0a0a3e554be4f40681f0 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 10 Dec 2019 11:27:35 +0100 Subject: [PATCH 137/419] refactor: expose a eoHowMany::value function --- eo/src/utils/eoHowMany.h | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/eo/src/utils/eoHowMany.h b/eo/src/utils/eoHowMany.h index bb47417a1..56c730f17 100644 --- a/eo/src/utils/eoHowMany.h +++ b/eo/src/utils/eoHowMany.h @@ -83,22 +83,7 @@ public: eoHowMany(double _rate = 0.0, bool _interpret_as_rate = true): rate(_rate), count(0) { - if (_interpret_as_rate) - { - if (_rate<0) - { - rate = 1.0+_rate; - if (rate < 0) // was < -1 - throw std::logic_error("rate<-1 in eoHowMany!"); - } - } - else - { - rate = 0.0; // just in case, but shoud be unused - count = int(_rate); // negative values are allowed here - if (count != _rate) - eo::log << eo::warnings << "Number was rounded in eoHowMany"; - } + this->value(_rate, _interpret_as_rate); } /** Ctor from an int - both from int and unsigned int are needed @@ -195,6 +180,26 @@ public: return (*this); } + void value(double _rate, bool _interpret_as_rate) + { + if (_interpret_as_rate) + { + if (_rate<0) + { + rate = 1.0+_rate; + if (rate < 0) // was < -1 + throw std::logic_error("rate < -1 in eoHowMany!"); + } + } + else + { + rate = 0.0; // just in case, but shoud be unused + count = int(_rate); // negative values are allowed here + if (count != _rate) + eo::log << eo::warnings << "Number was rounded in eoHowMany"; + } + } + private : double rate; int count; From 9056ed898953108d7dfc3b3e35ee7a0d259e3659 Mon Sep 17 00:00:00 2001 From: nojhan Date: Thu, 6 Feb 2020 21:55:12 +0100 Subject: [PATCH 138/419] add an eoSystemError exception - make members const in eoException.h classes --- eo/src/eoExceptions.h | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/eo/src/eoExceptions.h b/eo/src/eoExceptions.h index 56b5fbfd8..ef1a5c67e 100644 --- a/eo/src/eoExceptions.h +++ b/eo/src/eoExceptions.h @@ -52,7 +52,7 @@ public: } private: - time_t _elapsed; + const time_t _elapsed; }; @@ -76,7 +76,7 @@ public: } private: - unsigned long _threshold; + const unsigned long _threshold; }; @@ -102,7 +102,7 @@ public: ~eoMissingParamException() throw() {} private: - std::string _name; + const std::string _name; }; /*! @@ -127,7 +127,40 @@ public: ~eoWrongParamTypeException() throw() {} private: - std::string _name; + const std::string _name; +}; + + +class eoSystemError : public std::exception +{ +public: + eoSystemError(std::string cmd) + : _cmd(cmd), _has_pipe(false), _err_code(-1), _output("") + {} + + eoSystemError(std::string cmd, int err_code, std::string output) + : _cmd(cmd), _has_pipe(true), _err_code(err_code), _output(output) + {} + + virtual const char* what() const throw() + { + std::ostringstream ss; + ss << "System call: `" << _cmd << "` error"; + if(_has_pipe) { + ss << " code #" << _err_code + << " with the following output:" << std::endl << _output; + } + return ss.str().c_str(); + } + + ~eoSystemError() throw() {} + +private: + const std::string _cmd; + const bool _has_pipe; + const int _err_code; + const std::string _output; + }; #endif // __eoExceptions_h__ From ccb4b3787b05b134457199f57cbc1137de27d3b8 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sat, 8 Feb 2020 16:34:34 +0100 Subject: [PATCH 139/419] add eoEvalCmd, an eval that call a system command --- eo/src/eo | 1 + eo/src/eoEvalCmd.h | 142 ++++++++++++++++++++++++++++++++++++++++ eo/test/CMakeLists.txt | 1 + eo/test/t-eoEvalCmd.cpp | 29 ++++++++ 4 files changed, 173 insertions(+) create mode 100644 eo/src/eoEvalCmd.h create mode 100644 eo/test/t-eoEvalCmd.cpp diff --git a/eo/src/eo b/eo/src/eo index 39109bdb6..89fac3d0d 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -78,6 +78,7 @@ #include "eoEvalCounterThrowException.h" #include "eoEvalTimeThrowException.h" #include "eoEvalUserTimeThrowException.h" +#include "eoEvalCmd.h" // Continuators - all include eoContinue.h #include "eoCombinedContinue.h" diff --git a/eo/src/eoEvalCmd.h b/eo/src/eoEvalCmd.h new file mode 100644 index 000000000..57d9a9712 --- /dev/null +++ b/eo/src/eoEvalCmd.h @@ -0,0 +1,142 @@ +/* +(c) Thales group, 2020 + + 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 +*/ + +#ifndef eoEvalCmd_H +#define eoEvalCmd_H + +#include +#include + +#include "eoEvalFunc.h" +#include "eoExceptions.h" + + +/** Call a system command to evaluate an individual. + * + * @note Tested only under Unix systems, may not be portable as is. + * + * Use the default string serialization of the EOT + * and pass it as command line arguments of the command. + * The command is expected to output on stdout a string + * that can be interpreted as a float by `atof`. + * + * @todo Use the serialization of fitness instead of atof. + * + * For example, an eoReal would lead to a call like: + * ```>&2 cmd INVALID 3 1.0 2.1 3.2``` + * + * Throw an eoSystemError exception if the command exited with + * a return code different from zero. + * + *@ingroup Evaluation + */ +template +class eoEvalCmd : public eoEvalFunc< EOT > +{ +public: + using Fitness = typename EOT::Fitness; + + /** Constructor + * + * @note The prefix and suffix are automatically + * separated from the command by a space. + * + * The formated command looks like: `prefix cmd infix sol suffix` + * + * The default prefix allows to redirect any output to stdout under Unix. + * + * @param cmd The command to run. + * @param prefix Inserted before the command + * @param suffix Inserted between cmd and the serialized solution. + * @param suffix Append after the solution. + */ + eoEvalCmd( const std::string cmd, + const std::string prefix = ">&1", + const std::string infix = "", + const std::string suffix = "" + ) : + _cmd(cmd), + _suffix(suffix), + _infix(infix), + _prefix(prefix), + _last_call("") + {} + + virtual void operator()( EOT& sol ) + { + // Any modification to sol would makes it invalid, + // it is thus useless to evaluate it, if it is not invalid. + if(not sol.invalid()) { + return; + } + + sol.fitness( call( sol ) ); + } + + //! Return the last command string that was called. + std::string last_call() const + { + return _last_call; + } + +private: + const std::string _cmd; + const std::string _prefix; + const std::string _infix; + const std::string _suffix; + std::string _last_call; + + Fitness call( EOT& sol ) + { + std::array buffer; + std::string result; + + std::ostringstream cmd; + + cmd << _prefix << " " << _cmd << " " + << _infix << " " << sol << " " << _suffix; + + // Keep track of the built command for debugging purpose. + _last_call = cmd.str(); + + FILE* pipe = popen(cmd.str().c_str(), "r"); + if(not pipe) { + throw eoSystemError(cmd.str()); + } + while(fgets(buffer.data(), BUFFER_SIZE, pipe) != NULL) { + result += buffer.data(); + } + auto return_code = pclose(pipe); + + if(return_code != 0) { + throw eoSystemError(cmd.str(), return_code, result); + } + + // FIXME Use serialized input for the fitness instead of atof. + Fitness f = std::atof(result.c_str()); + + return f; + } +}; + +#endif // eoEvalCmd_H diff --git a/eo/test/CMakeLists.txt b/eo/test/CMakeLists.txt index aa4f17035..d776237f6 100644 --- a/eo/test/CMakeLists.txt +++ b/eo/test/CMakeLists.txt @@ -70,6 +70,7 @@ set (TEST_LIST #t-eoDualFitness t-eoParser t-eoPartiallyMappedXover + t-eoEvalCmd ) diff --git a/eo/test/t-eoEvalCmd.cpp b/eo/test/t-eoEvalCmd.cpp new file mode 100644 index 000000000..d9e812275 --- /dev/null +++ b/eo/test/t-eoEvalCmd.cpp @@ -0,0 +1,29 @@ +#include + +#include +#include + +using namespace std; + +int main(int /*argc*/, char* /*argv[]*/) +{ + typedef eoReal EOT; + + // Build something like: ">&1 echo 1.2; # INVALID 2 1 2" + eoEvalCmd eval("echo 1.2", ">&1", "; #"); + + EOT sol = {1,2}; + std::clog << sol << std::endl; + + try { + eval(sol); + } catch(eoSystemError& e) { + std::cerr << e.what() << std::endl; + exit(1); + } + + std::clog << eval.last_call() << std::endl; + EOT::Fitness f = sol.fitness(); + std::clog << "fitness: " << f << std::endl; + assert(f = 1.2); +} From 2f5a00a7ac2680c7f5938406c5a042fb4b1ab7f3 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sun, 9 Feb 2020 05:43:32 +0100 Subject: [PATCH 140/419] fix: eoEvalCmd use serialized input for the fitness instead of atof --- eo/src/eoEvalCmd.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/eo/src/eoEvalCmd.h b/eo/src/eoEvalCmd.h index 57d9a9712..afc3d60fb 100644 --- a/eo/src/eoEvalCmd.h +++ b/eo/src/eoEvalCmd.h @@ -108,32 +108,35 @@ private: Fitness call( EOT& sol ) { - std::array buffer; - std::string result; - std::ostringstream cmd; - cmd << _prefix << " " << _cmd << " " << _infix << " " << sol << " " << _suffix; // Keep track of the built command for debugging purpose. _last_call = cmd.str(); + // Run the command and read its output. + std::array buffer; + std::string output; FILE* pipe = popen(cmd.str().c_str(), "r"); if(not pipe) { throw eoSystemError(cmd.str()); } while(fgets(buffer.data(), BUFFER_SIZE, pipe) != NULL) { - result += buffer.data(); + output += buffer.data(); } auto return_code = pclose(pipe); + // We want the evaluation to fail if the command failed + // (you can still catch the exception if you do not want your program to exit). if(return_code != 0) { - throw eoSystemError(cmd.str(), return_code, result); + throw eoSystemError(cmd.str(), return_code, output); } - // FIXME Use serialized input for the fitness instead of atof. - Fitness f = std::atof(result.c_str()); + // Convert the output string in a valid fitness object. + Fitness f; + std::istringstream result(output); + result >> f; return f; } From 9623f4d1f8db6843ac2f93541a1ec9aaf94e88ec Mon Sep 17 00:00:00 2001 From: nojhan Date: Sun, 9 Feb 2020 06:53:36 +0100 Subject: [PATCH 141/419] add missing eoEval* headers in --- eo/src/eo | 9 +++++++-- eo/src/eoEvalTimeThrowException.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/eo/src/eo b/eo/src/eo index 89fac3d0d..35fa13d9a 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -74,11 +74,16 @@ // Evaluation functions (all include eoEvalFunc.h) #include "eoPopEvalFunc.h" -#include "eoEvalFuncPtr.h" +#include "eoEvalCmd.h" #include "eoEvalCounterThrowException.h" +#include "eoEvalDump.h" +#include "eoEvalFuncCounterBounder.h" +#include "eoEvalFuncCounter.h" +#include "eoEvalFunc.h" +#include "eoEvalFuncPtr.h" +#include "eoEvalKeepBest.h" #include "eoEvalTimeThrowException.h" #include "eoEvalUserTimeThrowException.h" -#include "eoEvalCmd.h" // Continuators - all include eoContinue.h #include "eoCombinedContinue.h" diff --git a/eo/src/eoEvalTimeThrowException.h b/eo/src/eoEvalTimeThrowException.h index 3cff76512..5b72de6bc 100644 --- a/eo/src/eoEvalTimeThrowException.h +++ b/eo/src/eoEvalTimeThrowException.h @@ -25,7 +25,7 @@ Johann Dréo #include "eoExceptions.h" -/** Check at each evaluation if a given tie contract has been reached. +/** Check at each evaluation if a given 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. From 6232ff2f2144290630dba9038ed37151f433b66d Mon Sep 17 00:00:00 2001 From: nojhan Date: Sun, 8 Mar 2020 21:44:42 +0100 Subject: [PATCH 142/419] add eoEvalNamedPipe - a class to connect an external objective function through file(s) - fix doc error in eoEvalCmd --- eo/src/eo | 1 + eo/src/eoEvalCmd.h | 4 +- eo/src/eoEvalNamedPipe.h | 120 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 eo/src/eoEvalNamedPipe.h diff --git a/eo/src/eo b/eo/src/eo index 35fa13d9a..c415c214b 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -74,6 +74,7 @@ // Evaluation functions (all include eoEvalFunc.h) #include "eoPopEvalFunc.h" +#include "eoEvalNamedPipe.h" #include "eoEvalCmd.h" #include "eoEvalCounterThrowException.h" #include "eoEvalDump.h" diff --git a/eo/src/eoEvalCmd.h b/eo/src/eoEvalCmd.h index afc3d60fb..e34dd3eee 100644 --- a/eo/src/eoEvalCmd.h +++ b/eo/src/eoEvalCmd.h @@ -38,9 +38,7 @@ Johann Dréo * Use the default string serialization of the EOT * and pass it as command line arguments of the command. * The command is expected to output on stdout a string - * that can be interpreted as a float by `atof`. - * - * @todo Use the serialization of fitness instead of atof. + * that can be deserialized as a fitness. * * For example, an eoReal would lead to a call like: * ```>&2 cmd INVALID 3 1.0 2.1 3.2``` diff --git a/eo/src/eoEvalNamedPipe.h b/eo/src/eoEvalNamedPipe.h new file mode 100644 index 000000000..02d6dc67a --- /dev/null +++ b/eo/src/eoEvalNamedPipe.h @@ -0,0 +1,120 @@ +/* +(c) Thales group, 2020 + + 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 +*/ + +#ifndef eoEvalNamedPipe_H +#define eoEvalNamedPipe_H + +#include +#include +#include +#include + +#include "eoEvalFunc.h" +#include "eoExceptions.h" + +/** Communicate through a named pipe FIFO to evaluate an individual. + * + * With this class, you can plug an external process computing the fitness + * of a serialized solution with a process hosting the EO algorithm. + * Both processes just have to read/write solutions/fitness in files. + * + * The code would work with any file, but it is actually only useful with + * FIFO pipes, which are blocking on I/O. + * Thus, the process actually computing the fitness will ait for the solution to be wrote, + * then compute and write the fitness back, waiting it to be read. + * Conversely, the EO process will wait after having wrote the solution, that the other process + * actually read it, then wait itself for the fitness to be read in the pipe. + * With pipes, the synchronization of the two processes is guaranteed. + * + * To create a named FIFO pipe under Linux, see the command `mkfifo`. + * + * @note: if you use a single pipe for input/output, take care + * of the synchronization with the process handling the fitness computation. + * In particular, the first call of eoEvalNamedPipe + * is to write the solution, THEN to read the fitness. + * + * @note Tested only under Unix systems, may not be portable as is. + * + * Use the default string serialization of the EOT and + * the default deserialization of the fitness. + * + *@ingroup Evaluation + */ +template +class eoEvalNamedPipe : public eoEvalFunc< EOT > +{ +public: + using Fitness = typename EOT::Fitness; + + /** Constructor + * + * @param output_pipe_name The named pipe in which to write the serialized solution. + * @param input_pipe_name The named pipe in which to read the serialized fitness. If it is "", use the output pipe. + */ + eoEvalNamedPipe( + const std::string output_pipe_name, + const std::string input_pipe_name = "" + ) : + _output_pipe_name(output_pipe_name), + _input_pipe_name(input_pipe_name) + { + if( _input_pipe_name == "") { + _input_pipe_name = _output_pipe_name; + } + } + + virtual void operator()( EOT& sol ) + { + // Any modification to sol would makes it invalid, + // it is thus useless to evaluate it, if it is not invalid. + if(not sol.invalid()) { + return; + } + + sol.fitness( call( sol ) ); + } + +private: + const std::string _output_pipe_name; + std::string _input_pipe_name; + + Fitness call( EOT& sol ) + { + // Write the passed solution. + std::ofstream out(_output_pipe_name); + out << sol << std::endl; + out.close(); + + // Read the output string in a valid fitness object. + Fitness fit; + std::ifstream if_fit(_input_pipe_name); + std::stringstream ss_fit; + ss_fit << if_fit.rdbuf(); + if_fit.close(); + ss_fit >> fit; + + return fit; + } +}; + +#endif // eoEvalNamedPipe_H From 2da161fc85d1c2394afbae1ceccbdc999a8d7a70 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 10 Mar 2020 09:11:16 +0100 Subject: [PATCH 143/419] update eoRNG to fit C++17 standard ISO C++17 does not allow 'register' storage class specifier --- eo/src/utils/eoRNG.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/eo/src/utils/eoRNG.h b/eo/src/utils/eoRNG.h index ad5c440bf..0093d37da 100644 --- a/eo/src/utils/eoRNG.h +++ b/eo/src/utils/eoRNG.h @@ -483,9 +483,14 @@ inline void eoRng::initialize(uint32_t seed) { left = -1; + // ISO C++17 does not allow 'register' storage class specifier +#if __cplusplus < 201703L register uint32_t x = (seed | 1U) & 0xFFFFFFFFU, *s = state; register int j; - +#else + uint32_t x = (seed | 1U) & 0xFFFFFFFFU, *s = state; + int j; +#endif for(left=0, *s++=x, j=N; --j; *s++ = (x*=69069U) & 0xFFFFFFFFU) ; } @@ -494,8 +499,14 @@ inline void eoRng::initialize(uint32_t seed) inline uint32_t eoRng::restart() { + // ISO C++17 does not allow 'register' storage class specifier +#if __cplusplus < 201703L register uint32_t *p0=state, *p2=state+2, *pM=state+M, s0, s1; register int j; +#else + uint32_t *p0=state, *p2=state+2, *pM=state+M, s0, s1; + int j; +#endif left=N-1, next=state+1; From 124701a3648182c3fb8578796ad9def53b779ec5 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 10 Mar 2020 09:12:01 +0100 Subject: [PATCH 144/419] expose ScalarType in eoScalarFitness --- eo/src/eoScalarFitness.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/eo/src/eoScalarFitness.h b/eo/src/eoScalarFitness.h index 31a9dbffe..6b09305ca 100644 --- a/eo/src/eoScalarFitness.h +++ b/eo/src/eoScalarFitness.h @@ -48,18 +48,19 @@ * Suitable constructors and assignments and casts are defined to work * with this quantity as if it were a ScalarType. */ -template +template class eoScalarFitness { public : + using ScalarType = SCALAR; eoScalarFitness() : value() {} eoScalarFitness(const eoScalarFitness& other) : value(other.value) {} - eoScalarFitness(const ScalarType& v) : value(v) {} + eoScalarFitness(const SCALAR& v) : value(v) {} eoScalarFitness& operator=(const eoScalarFitness& other) { value = other.value; return *this; } - eoScalarFitness& operator=(const ScalarType& v) + eoScalarFitness& operator=(const SCALAR& v) { value = v; return *this; } /** Conversion operator: it permits to use a fitness instance as its scalar @@ -69,27 +70,27 @@ class eoScalarFitness * fit = val; * val = fit; */ - operator ScalarType(void) const { return value; } + operator SCALAR(void) const { return value; } /// Comparison, using less by default bool operator<(const eoScalarFitness& other) const - { return Compare()(value, other.value); } + { return CMP()(value, other.value); } /// Comparison, using less by default // needed for MSVC 8 (MSVC 2005) added by J.Eggermont 20-11-2006 - bool operator<(const ScalarType& other) const - { return Compare()(value, other); } + bool operator<(const SCALAR& other) const + { return CMP()(value, other); } // implementation of the other operators - bool operator>( const eoScalarFitness& y ) const { return y < *this; } + bool operator>( const eoScalarFitness& y ) const { return y < *this; } // implementation of the other operators - bool operator<=( const eoScalarFitness& y ) const { return !(*this > y); } + bool operator<=( const eoScalarFitness& y ) const { return !(*this > y); } // implementation of the other operators - bool operator>=(const eoScalarFitness& y ) const { return !(*this < y); } + bool operator>=(const eoScalarFitness& y ) const { return !(*this < y); } private : - ScalarType value; + SCALAR value; }; /** @example t-eofitness.cpp * From 67aaf8b0255c1f3116c4861eeaabf51a7b83dc53 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 10 Mar 2020 09:12:39 +0100 Subject: [PATCH 145/419] add option to exit after make_help + fix exit code - Defaults to previous behaviour, which was to exit. - Fix the returned exit code: was 1, but should be 0, as asking for help is not an error. --- eo/src/es/make_es.h | 2 +- eo/src/es/make_real.h | 2 +- eo/src/ga/make_ga.h | 2 +- eo/src/utils/checkpointing | 2 +- eo/src/utils/make_help.cpp | 6 ++++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/eo/src/es/make_es.h b/eo/src/es/make_es.h index b1a8801a5..540609741 100644 --- a/eo/src/es/make_es.h +++ b/eo/src/es/make_es.h @@ -145,7 +145,7 @@ void run_ea(eoAlgo >& _ga, eoPop >& _ga, eoPop >& _ga, eoPop Date: Wed, 11 Mar 2020 11:39:38 +0100 Subject: [PATCH 146/419] make_checkpoint writes stats on clog by default Allow for separating logs from output of an algorithm. --- eo/src/do/make_checkpoint.h | 10 +++++----- eo/src/utils/eoOStreamMonitor.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eo/src/do/make_checkpoint.h b/eo/src/do/make_checkpoint.h index c06773480..84ef99961 100644 --- a/eo/src/do/make_checkpoint.h +++ b/eo/src/do/make_checkpoint.h @@ -194,14 +194,14 @@ eoCheckPoint& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu // The monitors /////////////// - // do we want an eoStdoutMonitor? - bool needStdoutMonitor = printBestParam.value() + // do we want an eoOStreamMonitor? + bool needOutMonitor = printBestParam.value() || printPopParam.value() ; - // The Stdout monitor will print parameters to the screen ... - if ( needStdoutMonitor ) + // The monitor will print parameters to the screen ... + if ( needOutMonitor ) { - eoStdoutMonitor *monitor = new eoStdoutMonitor(/*false FIXME remove this deprecated prototype*/); + eoMonitor *monitor = new eoOStreamMonitor(std::clog); _state.storeFunctor(monitor); // when called by the checkpoint (i.e. at every generation) diff --git a/eo/src/utils/eoOStreamMonitor.cpp b/eo/src/utils/eoOStreamMonitor.cpp index edb091690..af2bfcf63 100644 --- a/eo/src/utils/eoOStreamMonitor.cpp +++ b/eo/src/utils/eoOStreamMonitor.cpp @@ -19,7 +19,7 @@ eoMonitor& eoOStreamMonitor::operator()(void) { if (!out) { - std::string str = "eoOStreamMonitor: Could not write to the ooutput stream"; + std::string str = "eoOStreamMonitor: Could not write to the output stream"; throw std::runtime_error(str); } From 08bbf69f441dd886431f8fd478d76f477af5b910 Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 16 Mar 2020 18:17:35 +0100 Subject: [PATCH 147/419] add EDO continuator checking matrices of adaptive distribution --- edo/src/edo | 3 + edo/src/edoCombinedContinue.h | 74 +++++++++++++++++++++++++ edo/src/edoContAdaptiveFinite.h | 95 ++++++++++++++++++++++++++++++++ edo/src/edoContAdaptiveIllCond.h | 83 ++++++++++++++++++++++++++++ edo/src/edoContinue.h | 18 +++--- 5 files changed, 263 insertions(+), 10 deletions(-) create mode 100644 edo/src/edoCombinedContinue.h create mode 100644 edo/src/edoContAdaptiveFinite.h create mode 100644 edo/src/edoContAdaptiveIllCond.h diff --git a/edo/src/edo b/edo/src/edo index 1668a2ee2..a6a0861b5 100644 --- a/edo/src/edo +++ b/edo/src/edo @@ -78,6 +78,9 @@ Authors: #include "edoBounderUniform.h" #include "edoContinue.h" +#include "edoCombinedContinue.h" +#include "edoContAdaptiveIllCond.h" +#include "edoContAdaptiveFinite.h" #include "utils/edoCheckPoint.h" #include "utils/edoStat.h" diff --git a/edo/src/edoCombinedContinue.h b/edo/src/edoCombinedContinue.h new file mode 100644 index 000000000..54aacc143 --- /dev/null +++ b/edo/src/edoCombinedContinue.h @@ -0,0 +1,74 @@ +/* +The Evolving Distribution Objects framework (EDO) is a template-based, +ANSI-C++ evolutionary computation library which helps you to write your +own estimation of distribution algorithms. + +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; either +version 2.1 of the License, or (at your option) any later version. + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Copyright (C) 2020 Thales group +*/ +/* +Authors: + Johann Dréo +*/ + +#ifndef _edoCombinedContinue_h +#define _edoCombinedContinue_h + +#include +#include + +/** Combine several EDO continuators in a single one. + * + * Return true if any of the managed continuator ask for a stop. + * + * @see edoContinue + * + * @ingroup Continuators + * @ingroup Core + */ +template +class edoCombinedContinue : public edoContinue, public std::vector*> +{ +public: + edoCombinedContinue( edoContinue& cont ) : + edoContinue(), + std::vector*>(1,&cont) + { } + + edoCombinedContinue( std::vector*> conts ) : + edoContinue(), + std::vector*>(conts) + { } + + void add( edoContinue& cont) + { + this->push_back(&cont); + } + + bool operator()(const D& distrib) + { + for(const auto cont : *this) { + if( not (*cont)(distrib)) { + return false; + } + } + return true; + } + + virtual std::string className() const { return "edoCombinedContinue"; } +}; + +#endif // !_edoCombinedContinue_h diff --git a/edo/src/edoContAdaptiveFinite.h b/edo/src/edoContAdaptiveFinite.h new file mode 100644 index 000000000..a01775759 --- /dev/null +++ b/edo/src/edoContAdaptiveFinite.h @@ -0,0 +1,95 @@ +/* +The Evolving Distribution Objects framework (EDO) is a template-based, +ANSI-C++ evolutionary computation library which helps you to write your +own estimation of distribution algorithms. + +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; either +version 2.1 of the License, or (at your option) any later version. + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Copyright (C) 2020 Thales group +*/ +/* +Authors: + Johann Dréo +*/ + +#ifndef _edoContAdaptiveFinite_h +#define _edoContAdaptiveFinite_h + +#include "edoContinue.h" + +/** A continuator that check if any element in the parameters + * of an edoNormalAdaptive distribution are finite + * + * If any element of any parameter is infinity or NaN (Not A Number), + * it will ask for a stop. + * + * @ingroup Continuators + */ +template +class edoContAdaptiveFinite : public edoContinue +{ +public: + using EOType = typename D::EOType; + using Matrix = typename D::Matrix; + using Vector = typename D::Vector; + + bool operator()(const D& d) + { + // Try to finite_check in most probably ill-conditioned order. + return finite_check(d.covar()) + and finite_check(d.path_covar()) + and finite_check(d.coord_sys()) + and finite_check(d.scaling()) + and finite_check(d.path_sigma()) + and finite_check(d.sigma()) + ; + } + + virtual std::string className() const { return "edoContAdaptiveFinite"; } + +protected: + bool finite_check(const Matrix& mat) const + { + for(long i=0; i +*/ + +#ifndef _edoContAdaptiveIllCond_h +#define _edoContAdaptiveIllCond_h + +#ifdef WITH_EIGEN + +#include + +#include "edoContinue.h" + +/** A continuator that check if any matrix among the parameters + * of an edoNormalAdaptive distribution are ill-conditioned. + * + * If the condition number of the covariance matrix + * or the coordinate system matrix are strictly greater + * than the threshold given at construction, it will ask for a stop. + * + * @ingroup Continuators + */ +template +class edoContAdaptiveIllCond : public edoContinue +{ +public: + using EOType = typename D::EOType; + using Matrix = typename D::Matrix; + using Vector = typename D::Vector; + + edoContAdaptiveIllCond( double threshold = 1e6) : + _threshold(threshold) + { } + + bool operator()(const D& d) + { + if( condition(d.covar()) > _threshold + or condition(d.coord_sys()) > _threshold ) { + return false; + } else { + return true; + } + } + + virtual std::string className() const { return "edoContAdaptiveIllCond"; } + +public: + // Public function in case someone would want to dimensionate the condition threshold. + //! Returns the condition number + bool condition(const Matrix& mat) const + { + Eigen::JacobiSVD svd(mat); + return svd.singularValues()(0) / svd.singularValues()(svd.singularValues().size()-1); + } + + const double _threshold; +}; + +#endif // WITH_EIGEN + +#endif diff --git a/edo/src/edoContinue.h b/edo/src/edoContinue.h index 8089601e2..6540b9b0b 100644 --- a/edo/src/edoContinue.h +++ b/edo/src/edoContinue.h @@ -25,8 +25,8 @@ Authors: Caner Candan */ -#ifndef _doContinue_h -#define _doContinue_h +#ifndef _edoContinue_h +#define _edoContinue_h #include #include @@ -44,20 +44,18 @@ class edoContinue : public eoUF< const D&, bool >, public eoPersistent public: virtual std::string className(void) const { return "edoContinue"; } - void readFrom(std::istream&) - { - /* It should be implemented by subclasses ! */ - } + // May be implemented by subclasses if persistent interface needed + virtual void readFrom(std::istream&) + { } - void printOn(std::ostream&) const - { - /* It should be implemented by subclasses ! */ - } + virtual void printOn(std::ostream&) const + { } }; template < typename D > class edoDummyContinue : public edoContinue< D > { +public: bool operator()(const D&){ return true; } virtual std::string className() const { return "edoDummyContinue"; } From c99ed01dc6b2c308ce89e1a13a8591cf7a7d359a Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 16 Mar 2020 18:19:10 +0100 Subject: [PATCH 148/419] REMOVE eoEvalFuncCounterBounder duplicate of eoEvalCounterThrowException --- eo/src/eoEvalCounterThrowException.h | 6 ++- eo/src/eoEvalFuncCounterBounder.h | 67 ---------------------------- 2 files changed, 5 insertions(+), 68 deletions(-) delete mode 100644 eo/src/eoEvalFuncCounterBounder.h diff --git a/eo/src/eoEvalCounterThrowException.h b/eo/src/eoEvalCounterThrowException.h index 8b38908e4..b83699916 100644 --- a/eo/src/eoEvalCounterThrowException.h +++ b/eo/src/eoEvalCounterThrowException.h @@ -37,6 +37,10 @@ algorithm have reached a maximum number of evaluations. This may be useful if you want to check this kind of stopping criterion at each _evaluation_, instead of using continuators at each _iteration_. +This eval counter permits to stop a search during a generation, without waiting for a continue to be +checked at the end of the loop. Useful if you have 10 individuals and 10 generations, +but want to stop after 95 evaluations. + The class first call the evaluation function, then check the number of times it has been called. If the maximum number of evaluation has been reached, it throw an eoMaxEvalException. You can catch this exception @@ -72,7 +76,7 @@ public : } // evaluate - func(eo); + this->eoEvalFuncCounter::operator()(eo); } // if invalid } diff --git a/eo/src/eoEvalFuncCounterBounder.h b/eo/src/eoEvalFuncCounterBounder.h deleted file mode 100644 index 30ac03473..000000000 --- a/eo/src/eoEvalFuncCounterBounder.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef eoEvalFuncCounterBounder_H -#define eoEvalFuncCounterBounder_H - -#include "eoEvalFunc.h" -#include "utils/eoParam.h" - -/** @addtogroup Evaluation - * @{ - */ - -/** The exception raised by eoEvalFuncCounterBounder - * when the maximum number of allowed evaluations is reached. - */ -class eoEvalFuncCounterBounderException : public std::exception -{ -public: - eoEvalFuncCounterBounderException(unsigned long threshold) : _threshold(threshold){} - - const char* what() const throw() - { - std::ostringstream ss; - ss << "STOP in eoEvalFuncCounterBounderException: the maximum number of evaluation has been reached (" << _threshold << ")."; - return ss.str().c_str(); - } - -private: - unsigned long _threshold; -}; - -/** Counts the number of evaluations actually performed and throw an eoEvalFuncCounterBounderException - * when the maximum number of allowed evaluations is reached. - * - * This eval counter permits to stop a search during a generation, without waiting for a continue to be - * checked at the end of the loop. Useful if you have 10 individuals and 10 generations, - * but want to stop after 95 evaluations. -*/ -template < typename EOT > -class eoEvalFuncCounterBounder : public eoEvalFuncCounter< EOT > -{ -public : - eoEvalFuncCounterBounder(eoEvalFunc& func, unsigned long threshold, std::string name = "Eval. ") - : eoEvalFuncCounter< EOT >( func, name ), _threshold( threshold ) - {} - - using eoEvalFuncCounter< EOT >::value; - - virtual void operator()(EOT& eo) - { - if (eo.invalid()) - { - value()++; - - if (_threshold > 0 && value() >= _threshold) - { - throw eoEvalFuncCounterBounderException(_threshold); - } - - this->func(eo); - } - } - -private : - unsigned long _threshold; -}; - -/** @} */ -#endif From a5354f8ef3216ab8a6901dfdba210ca77eb38df4 Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 16 Mar 2020 18:20:04 +0100 Subject: [PATCH 149/419] add eoEvalNanThrowException Wrap an evaluation function so that an exception may be thrown when the eval function returns a bad value (Not A Number or infinity). --- eo/src/eoEvalNanThrowException.h | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 eo/src/eoEvalNanThrowException.h diff --git a/eo/src/eoEvalNanThrowException.h b/eo/src/eoEvalNanThrowException.h new file mode 100644 index 000000000..41251d10f --- /dev/null +++ b/eo/src/eoEvalNanThrowException.h @@ -0,0 +1,73 @@ +/* +(c) Thales group, 2020 + + 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 + +*/ + +#ifndef __eoEvalNanThrowException_h__ +#define __eoEvalNanThrowException_h__ + +#include + +#include "eoEvalFunc.h" +#include "eoExceptions.h" + +/*! +Wrap an evaluation function so that an exception may be thrown when the +eval function returns a bad value (Not A Number or infinity). + +@warning: Only work for eoScalarFitness. + +The class throw an eoNanException. You can catch this exception +from your main function, so as to stop everything properly. + +@ingroup Evaluation +*/ +template < typename EOT > +class eoEvalNanThrowException : public eoEvalFunc< EOT > +{ +public : + eoEvalNanThrowException( eoEvalFunc& func) + : _func(func) + {} + + //! Evaluate the individual, then throw an exception if it exceed the max number of evals. + virtual void operator()(EOT& sol) + { + if(sol.invalid()) { + _func(sol); + + if(not std::isfinite(sol.fitness()) ) { +#ifndef NDEBUG + eo::log << eo::xdebug << sol << std::endl; +#endif + throw eoNanException(); + } + } // if invalid + } + + virtual std::string className() const {return "eoEvalNanThrowException";} + +protected: + eoEvalFunc& _func; +}; + +#endif // __eoEvalNanThrowException_h__ From 80a11c70590625a3d796512c6757004155b37a1e Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 16 Mar 2020 18:21:25 +0100 Subject: [PATCH 150/419] add a reset method to edoNormalAdaptive Useful when performing restart after exception catch. --- edo/src/edoNormalAdaptive.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/edo/src/edoNormalAdaptive.h b/edo/src/edoNormalAdaptive.h index edde019b1..1d8a82bd7 100644 --- a/edo/src/edoNormalAdaptive.h +++ b/edo/src/edoNormalAdaptive.h @@ -153,6 +153,17 @@ public: void path_covar( Vector p ) { _p_c = p; assert( p.size() == _dim ); } void path_sigma( Vector p ) { _p_s = p; assert( p.size() == _dim ); } + void reset() + { + _mean = Vector::Zero(_dim); + _C = Matrix::Identity(_dim,_dim); + _B = Matrix::Identity(_dim,_dim); + _D = Vector::Constant( _dim, 1); + _sigma = 1.0; + _p_c = Vector::Zero(_dim); + _p_s = Vector::Zero(_dim); + } + private: unsigned int _dim; Vector _mean; // mean vector From 11254b4fbdcccfc36fe7acc7a8dbb86d11f004bb Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 16 Mar 2020 18:22:14 +0100 Subject: [PATCH 151/419] remove eoEvalFuncCounterBounder.h from general eo header --- eo/src/eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo/src/eo b/eo/src/eo index c415c214b..57f9e5cc0 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -77,8 +77,8 @@ #include "eoEvalNamedPipe.h" #include "eoEvalCmd.h" #include "eoEvalCounterThrowException.h" +#include "eoEvalNanThrowException.h" #include "eoEvalDump.h" -#include "eoEvalFuncCounterBounder.h" #include "eoEvalFuncCounter.h" #include "eoEvalFunc.h" #include "eoEvalFuncPtr.h" From f68d3c1396fdd004a991d0613593a7c0f02dadde Mon Sep 17 00:00:00 2001 From: nojhan Date: Mon, 16 Mar 2020 18:30:48 +0100 Subject: [PATCH 152/419] add an interface toward IOHexperimenter Handle IOH mono-objective function and CSV logger. --- problems/eval/eoEvalIOH.h | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 problems/eval/eoEvalIOH.h diff --git a/problems/eval/eoEvalIOH.h b/problems/eval/eoEvalIOH.h new file mode 100644 index 000000000..7bbc3d449 --- /dev/null +++ b/problems/eval/eoEvalIOH.h @@ -0,0 +1,61 @@ + +#ifndef _eoEvalIOH_h +#define _eoEvalIOH_h + +#include +#include + +/** Wrap an IOHexperimenter's problem class within an eoEvalFunc. + * + * See https://github.com/IOHprofiler/IOHexperimenter + * + * Handle only fitnesses that inherits from eoScalarFitness. + * + * @note: You're responsible of matching the fitness' scalar type (IOH handle double and int, as of 2020-03-09). + * + * You will need to pass the IOH include directory to your compiler (e.g. IOHexperimenter/build/Cpp/src/). + */ +template +class eoEvalIOH : public eoEvalFunc +{ + public: + using Fitness = typename EOT::Fitness; + using ScalarType = typename Fitness::ScalarType; + + eoEvalIOH( IOHprofiler_problem & pb) : + _ioh_pb(pb), + _has_log(false) + { } + + eoEvalIOH( IOHprofiler_problem & pb, IOHprofiler_csv_logger & log ) : + _ioh_pb(pb), + _has_log(true), + _ioh_log(log) + { } + + virtual void operator()(EOT& sol) + { + if(not sol.invalid()) { + return; + } + + sol.fitness( call( sol ) ); + } + + protected: + IOHprofiler_problem & _ioh_pb; + bool _has_log; + IOHprofiler_csv_logger & _ioh_log; + + virtual Fitness call(EOT& sol) + { + Fitness f = _ioh_pb.evaluate(sol); + if(_has_log) { + _ioh_log.write_line(_ioh_pb.loggerInfo()); + } + return f; + } + +}; + +#endif // _eoEvalIOH_h From 64e14e09dfb11a2c3e6ce8fd36fd6fd62fe505ad Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 17 Mar 2020 12:04:02 +0100 Subject: [PATCH 153/419] move the distrib continue in EDO adaptive algos - Call the continuator right after the distribution update, because we may have generated an ill-conditioned distribution, which would lead to bad solution sampling. - Reserve mem of sampled vector. --- edo/src/edoAlgoAdaptive.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/edo/src/edoAlgoAdaptive.h b/edo/src/edoAlgoAdaptive.h index 5ee0f359a..7de567eee 100644 --- a/edo/src/edoAlgoAdaptive.h +++ b/edo/src/edoAlgoAdaptive.h @@ -160,13 +160,26 @@ public: // (2) Estimation of the distribution parameters _distrib = _estimator(selected_pop); + // TODO modularization: the estimator and the continuator perform + // the same decomposition twice, see how to decompose those operators + + // Call the continuator right after the distribution update, + // because we may have generated an ill-conditioned distribution, + // which would lead to bad solution sampling. + if(not _distribution_continuator(_distrib)) { + break; + } + // (3) sampling // The sampler produces feasible solutions (@see edoSampler that // encapsulate an edoBounder) - current_pop.clear(); + current_pop.clear(); current_pop.reserve(pop.size()); for( unsigned int i = 0; i < pop.size(); ++i ) { current_pop.push_back( _sampler(_distrib) ); } + // TODO modluraziation: the sampler may generate solution that are + // not finite. See how to stop right from there instead of + // performing useless evaluations. // (4) Evaluate new solutions _evaluator( pop, current_pop ); @@ -174,7 +187,7 @@ public: // (5) Replace old solutions by new ones _replacor(pop, current_pop); // e.g. copy current_pop in pop - } while( _distribution_continuator( _distrib ) && _pop_continuator( pop ) ); + } while( _pop_continuator( pop ) ); } // operator() From 38e3f40bad3f4da6916831dd532d1db8f18e6763 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 17 Mar 2020 12:05:56 +0100 Subject: [PATCH 154/419] cleaner numerical errors management for EDO adaptive algos - Change the ill-condition continuator to use eigen decomposition of the covariance matrix, just like in the adaptive estimator. - Add a warning message in adaptive sampler. --- edo/src/edo | 2 +- edo/src/edoContAdaptiveFinite.h | 51 ++++++++---- edo/src/edoContAdaptiveIllCond.h | 83 -------------------- edo/src/edoContAdaptiveIllCovar.h | 112 +++++++++++++++++++++++++++ edo/src/edoEstimatorNormalAdaptive.h | 7 +- edo/src/edoSamplerNormalAdaptive.h | 23 +++++- 6 files changed, 174 insertions(+), 104 deletions(-) delete mode 100644 edo/src/edoContAdaptiveIllCond.h create mode 100644 edo/src/edoContAdaptiveIllCovar.h diff --git a/edo/src/edo b/edo/src/edo index a6a0861b5..e6a03a1ed 100644 --- a/edo/src/edo +++ b/edo/src/edo @@ -79,7 +79,7 @@ Authors: #include "edoContinue.h" #include "edoCombinedContinue.h" -#include "edoContAdaptiveIllCond.h" +#include "edoContAdaptiveIllCovar.h" #include "edoContAdaptiveFinite.h" #include "utils/edoCheckPoint.h" diff --git a/edo/src/edoContAdaptiveFinite.h b/edo/src/edoContAdaptiveFinite.h index a01775759..c92e6d4ff 100644 --- a/edo/src/edoContAdaptiveFinite.h +++ b/edo/src/edoContAdaptiveFinite.h @@ -47,24 +47,43 @@ public: bool operator()(const D& d) { - // Try to finite_check in most probably ill-conditioned order. - return finite_check(d.covar()) - and finite_check(d.path_covar()) - and finite_check(d.coord_sys()) - and finite_check(d.scaling()) - and finite_check(d.path_sigma()) - and finite_check(d.sigma()) - ; + bool fin_sigma = is_finite(d.sigma() ); + bool fin_path_sigma = is_finite(d.path_sigma()); + bool fin_scaling = is_finite(d.scaling() ); + bool fin_coord_sys = is_finite(d.coord_sys() ); + bool fin_path_covar = is_finite(d.path_covar()); + bool fin_covar = is_finite(d.covar() ); + + bool all_finite = fin_covar + and fin_path_covar + and fin_coord_sys + and fin_scaling + and fin_path_sigma + and fin_sigma; + + if( not all_finite ) { + eo::log << eo::progress << "STOP because parameters are not finite: "; + if( not fin_covar ) { eo::log << eo::errors << "covar, "; } + if( not fin_path_covar ) { eo::log << eo::errors << "path_covar, "; } + if( not fin_coord_sys ) { eo::log << eo::errors << "coord_sys, "; } + if( not fin_scaling ) { eo::log << eo::errors << "scaling, "; } + if( not fin_path_sigma ) { eo::log << eo::errors << "path_sigma, "; } + if( not fin_sigma ) { eo::log << eo::errors << "sigma"; } + eo::log << eo::errors << std::endl; + } + return all_finite; } virtual std::string className() const { return "edoContAdaptiveFinite"; } protected: - bool finite_check(const Matrix& mat) const + bool is_finite(const Matrix& mat) const { for(long i=0; i -*/ - -#ifndef _edoContAdaptiveIllCond_h -#define _edoContAdaptiveIllCond_h - -#ifdef WITH_EIGEN - -#include - -#include "edoContinue.h" - -/** A continuator that check if any matrix among the parameters - * of an edoNormalAdaptive distribution are ill-conditioned. - * - * If the condition number of the covariance matrix - * or the coordinate system matrix are strictly greater - * than the threshold given at construction, it will ask for a stop. - * - * @ingroup Continuators - */ -template -class edoContAdaptiveIllCond : public edoContinue -{ -public: - using EOType = typename D::EOType; - using Matrix = typename D::Matrix; - using Vector = typename D::Vector; - - edoContAdaptiveIllCond( double threshold = 1e6) : - _threshold(threshold) - { } - - bool operator()(const D& d) - { - if( condition(d.covar()) > _threshold - or condition(d.coord_sys()) > _threshold ) { - return false; - } else { - return true; - } - } - - virtual std::string className() const { return "edoContAdaptiveIllCond"; } - -public: - // Public function in case someone would want to dimensionate the condition threshold. - //! Returns the condition number - bool condition(const Matrix& mat) const - { - Eigen::JacobiSVD svd(mat); - return svd.singularValues()(0) / svd.singularValues()(svd.singularValues().size()-1); - } - - const double _threshold; -}; - -#endif // WITH_EIGEN - -#endif diff --git a/edo/src/edoContAdaptiveIllCovar.h b/edo/src/edoContAdaptiveIllCovar.h new file mode 100644 index 000000000..409d6db33 --- /dev/null +++ b/edo/src/edoContAdaptiveIllCovar.h @@ -0,0 +1,112 @@ +/* +The Evolving Distribution Objects framework (EDO) is a template-based, +ANSI-C++ evolutionary computation library which helps you to write your +own estimation of distribution algorithms. + +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; either +version 2.1 of the License, or (at your option) any later version. + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Copyright (C) 2020 Thales group +*/ +/* +Authors: + Johann Dréo +*/ + +#ifndef _edoContAdaptiveIllCovar_h +#define _edoContAdaptiveIllCovar_h + +#ifdef WITH_EIGEN + +#include + +#include "edoContinue.h" + +/** A continuator that check if the covariance matrix + * of an edoNormalAdaptive distribution is ill-conditioned. + * + * If the condition number of the covariance matrix + * is strictly greater than the threshold given at construction, + * it will ask for a stop. + * + * @ingroup Continuators + */ +template +class edoContAdaptiveIllCovar : public edoContinue +{ +public: + using EOType = typename D::EOType; + using Matrix = typename D::Matrix; + using Vector = typename D::Vector; + + edoContAdaptiveIllCovar( double threshold = 1e6) : + _threshold(threshold) + { } + + bool operator()(const D& d) + { + Eigen::SelfAdjointEigenSolver eigensolver( d.covar() ); + + auto info = eigensolver.info(); + if(info == Eigen::ComputationInfo::NumericalIssue) { + eo::log << eo::warnings << "WARNING: the eigen decomposition of the covariance matrix" + << " did not satisfy the prerequisites." << std::endl; + } else if(info == Eigen::ComputationInfo::NoConvergence) { + eo::log << eo::warnings << "WARNING: the eigen decomposition of the covariance matrix" + << " did not converged." << std::endl; + } else if(info == Eigen::ComputationInfo::InvalidInput) { + eo::log << eo::warnings << "WARNING: the eigen decomposition of the covariance matrix" + << " had invalid inputs." << std::endl; + } + if(info != Eigen::ComputationInfo::Success) { + eo::log << eo::progress << "STOP because the covariance matrix" + << " cannot be decomposed" << std::endl; +#ifndef NDEBUG + eo::log << eo::xdebug + << "mean:\n" << d.mean() << std::endl + << "sigma:" << d.sigma() << std::endl + << "coord_sys:\n" << d.coord_sys() << std::endl + << "scaling:\n" << d.scaling() << std::endl; +#endif + return false; + + }else { + Matrix EV = eigensolver.eigenvalues(); + double condition = EV.maxCoeff() / EV.minCoeff(); + + if( not std::isfinite(condition) ) { + eo::log << eo::progress << "STOP because the covariance matrix" + << " condition is not finite." << std::endl; + return false; + + } else if( condition >= _threshold ) { + eo::log << eo::progress << "STOP because the covariance matrix" + << " is ill-conditionned (condition number: " << condition << ")" << std::endl; + return false; + + } else { + return true; + } + } + } + + virtual std::string className() const { return "edoContAdaptiveIllCovar"; } + +protected: + const double _threshold; +}; + +#endif // WITH_EIGEN + +#endif diff --git a/edo/src/edoEstimatorNormalAdaptive.h b/edo/src/edoEstimatorNormalAdaptive.h index f1adf723f..be8c88d15 100644 --- a/edo/src/edoEstimatorNormalAdaptive.h +++ b/edo/src/edoEstimatorNormalAdaptive.h @@ -227,14 +227,15 @@ public: // Matrix CS = C.triangularView() + C.triangularView().transpose(); d.covar( C ); - Eigen::SelfAdjointEigenSolver eigensolver( d.covar() ); // FIXME use JacobiSVD? - d.coord_sys( eigensolver.eigenvectors() ); + Eigen::SelfAdjointEigenSolver eigensolver( d.covar() ); + Matrix mD = eigensolver.eigenvalues().asDiagonal(); - assert( mD.innerSize() == N && mD.outerSize() == N ); // from variance to standard deviations mD.cwiseSqrt(); d.scaling( mD.diagonal() ); + + d.coord_sys( eigensolver.eigenvectors() ); } return d; diff --git a/edo/src/edoSamplerNormalAdaptive.h b/edo/src/edoSamplerNormalAdaptive.h index 051e14835..f1b33d10f 100644 --- a/edo/src/edoSamplerNormalAdaptive.h +++ b/edo/src/edoSamplerNormalAdaptive.h @@ -72,11 +72,32 @@ public: // mean(N,1) + sigma * B(N,N) * ( D(N,1) .* T(N,1) ) Vector sol = distrib.mean() + distrib.sigma() - * distrib.coord_sys() * (distrib.scaling().cwiseProduct(T) ); // C * T = B * (D .* T) + * distrib.coord_sys() + * (distrib.scaling().cwiseProduct(T) ); // C * T = B * (D .* T) assert( sol.size() == N ); /*Vector sol = distrib.mean() + distrib.sigma() * distrib.coord_sys().dot( distrib.scaling().dot( T ) );*/ +#ifndef NDEBUG + bool is_finite = true; + for(long i=0; i Date: Sun, 22 Mar 2020 18:57:50 +0100 Subject: [PATCH 155/419] add eoStoreFunctor::pack to allocate & store in one line Instead of calling `new`, then `state.storeFunctor`, the user can just call `Class& inst = state.pack< Class >( params )` in one line. Use C++11's variadic templates. --- eo/src/eoFunctorStore.h | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/eo/src/eoFunctorStore.h b/eo/src/eoFunctorStore.h index ffcbe90d7..889b832de 100644 --- a/eo/src/eoFunctorStore.h +++ b/eo/src/eoFunctorStore.h @@ -54,20 +54,36 @@ public: /// Add an eoFunctorBase to the store template Functor& storeFunctor(Functor* r) - { + { #ifndef NDEBUG - unsigned int existing = std::count( vec.begin(), vec.end(), r ); - if( existing > 0 ) { - eo::log << eo::warnings << "WARNING: you asked eoFunctorStore to store the functor " << r << " " - << existing + 1 << " times, a segmentation fault may occur in the destructor." << std::endl; - } + unsigned int existing = std::count( vec.begin(), vec.end(), r ); + if( existing > 0 ) { + eo::log << eo::warnings << "WARNING: you asked eoFunctorStore to store the functor " << r << " " + << existing + 1 << " times, a segmentation fault may occur in the destructor." << std::endl; + } #endif - // If the compiler complains about the following line, - // check if you really are giving it a pointer to an - // eoFunctorBase derived object - vec.push_back(r); - return *r; - } + // If the compiler complains about the following line, + // check if you really are giving it a pointer to an + // eoFunctorBase derived object + vec.push_back(r); + return *r; + } + + /** Allocate the given functor, store it and return its reference. + * + * Indicate the class to instanciate as template paramater, + * and pass its constructor arguments. + * + * @code + * eoSelect& selector = state.pack< eoRankMuSelect >( mu ); + * @endcode + */ + template + Functor& pack( Args&&... args ) + { + Functor* f = new Functor(args...); + return this->storeFunctor(f); + } private : From ab740b2a72552b3babadd57d684fae6f6ba64b96 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 24 Mar 2020 16:27:58 +0100 Subject: [PATCH 156/419] add a monitor to print on eo::log at given level - add eoTimedMonitor missing header --- eo/src/utils/checkpointing | 2 + eo/src/utils/eoLogMonitor.h | 73 +++++++++++++++++++++++++++++++++++++ eo/src/utils/eoLogger.h | 3 +- 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 eo/src/utils/eoLogMonitor.h diff --git a/eo/src/utils/checkpointing b/eo/src/utils/checkpointing index f630c3744..79fdab123 100644 --- a/eo/src/utils/checkpointing +++ b/eo/src/utils/checkpointing @@ -29,8 +29,10 @@ #include "eoUpdater.h" #include "eoMonitor.h" #include "eoFileMonitor.h" +#include "eoTimedMonitor.h" #include "eoStdoutMonitor.h" #include "eoOStreamMonitor.h" +#include "eoLogMonitor.h" #ifndef _MSC_VER #include "eoGnuplot1DMonitor.h" #include "eoGnuplot1DSnapshot.h" diff --git a/eo/src/utils/eoLogMonitor.h b/eo/src/utils/eoLogMonitor.h new file mode 100644 index 000000000..94884250b --- /dev/null +++ b/eo/src/utils/eoLogMonitor.h @@ -0,0 +1,73 @@ +/* + +(c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000 +(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 +*/ + +#ifndef _eoLogMonitor_h_ +#define _eoLogMonitor_h_ + +#include +#include +#include + +#include "eoOStreamMonitor.h" +#include "eoLogger.h" + +/** + Prints statistics to a given ostream. + + You can pass any instance of an ostream to the constructor, like, for example, std::clog. + + @ingroup Monitors +*/ +class eoLogMonitor : public eoOStreamMonitor +{ +public : + eoLogMonitor( + eoLogger& logger = eo::log, + eo::Levels level = eo::progress, + std::string delim = "\t", unsigned int width=20, char fill=' ', + bool print_names = false, std::string name_sep = ":" + ) : + eoOStreamMonitor(_oss, delim, width, fill, print_names, name_sep), + _log(logger), + _level(level) + {} + + eoMonitor& operator()(void) + { + eoOStreamMonitor::operator()(); // write to _oss + // Output at the log level. + _log << _level << _oss.str(); + // Empty the output stream to avoid duplicated lines. + _oss.str(""); _oss.clear(); + return *this; + } + + virtual std::string className(void) const { return "eoLogMonitor"; } + +private : + std::ostringstream _oss; + eoLogger & _log; + eo::Levels _level; +}; + +#endif // _eoLogMonitor_h_ diff --git a/eo/src/utils/eoLogger.h b/eo/src/utils/eoLogger.h index a3c377fed..785d37acd 100644 --- a/eo/src/utils/eoLogger.h +++ b/eo/src/utils/eoLogger.h @@ -138,8 +138,7 @@ namespace eo * Class providing a verbose management through EO * Use of a global variable eo::log to easily use the logger like std::cout */ -class eoLogger : public eoObject, - public std::ostream +class eoLogger : public eoObject, public std::ostream { public: //! default ctor From e0e1cb8bc9db7636312cacacf99af2c95c781567 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 24 Mar 2020 16:31:49 +0100 Subject: [PATCH 157/419] feat: separate estimators for init and in loop in edoAlgoAdaptive Allows for easier reseting or editing of distribution during restarts. --- edo/src/edoAlgoAdaptive.h | 54 ++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/edo/src/edoAlgoAdaptive.h b/edo/src/edoAlgoAdaptive.h index 7de567eee..efc23db9a 100644 --- a/edo/src/edoAlgoAdaptive.h +++ b/edo/src/edoAlgoAdaptive.h @@ -34,7 +34,7 @@ Authors: #include "edoAlgo.h" #include "edoEstimator.h" -#include "edoModifierMass.h" +// #include "edoModifierMass.h" #include "edoSampler.h" #include "edoContinue.h" @@ -67,7 +67,44 @@ public: public: /*! - Takes algo operators, all are mandatory + Takes all operators. + + \param distrib A distribution to use, if you want to update this parameter (e.gMA-ES) instead of replacing it (e.g. an EDA) + \param evaluator Evaluate a population + \param selector Selection of the best candidate solutions in the population + \param estimator Estimation of the distribution parameters + \param estimator_init Estimation of the distribution parameters, called before the main loop. + \param sampler Generate feasible solutions using the distribution + \param replacor Replace old solutions by new ones + \param pop_continuator Stopping criterion based on the population features + \param distribution_continuator Stopping criterion based on the distribution features + */ + edoAlgoAdaptive( + D & distrib, + eoPopEvalFunc < EOType > & evaluator, + eoSelect< EOType > & selector, + edoEstimator< D > & estimator, + edoEstimator< D > & estimator_init, + edoSampler< D > & sampler, + eoReplacement< EOType > & replacor, + eoContinue< EOType > & pop_continuator, + edoContinue< D > & distribution_continuator + ) : + _distrib(distrib), + _evaluator(evaluator), + _selector(selector), + _estimator(estimator), + _estimator_init(estimator_init), + _sampler(sampler), + _replacor(replacor), + _pop_continuator(pop_continuator), + _dummy_continue(), + _distribution_continuator(distribution_continuator) + {} + + + /*! + Without the initialization estimator (set the same estimator everywhere). \param distrib A distribution to use, if you want to update this parameter (e.gMA-ES) instead of replacing it (e.g. an EDA) \param evaluator Evaluate a population @@ -92,6 +129,7 @@ public: _evaluator(evaluator), _selector(selector), _estimator(estimator), + _estimator_init(estimator), _sampler(sampler), _replacor(replacor), _pop_continuator(pop_continuator), @@ -125,6 +163,7 @@ public: _evaluator(evaluator), _selector(selector), _estimator(estimator), + _estimator_init(estimator), _sampler(sampler), _replacor(replacor), _pop_continuator(pop_continuator), @@ -141,18 +180,18 @@ public: { assert(pop.size() > 0); - eoPop< EOType > current_pop; - eoPop< EOType > selected_pop; - // update the extern distribution passed to the estimator (cf. CMA-ES) // OR replace the dummy distribution for estimators that do not need extern distributions (cf. EDA) - _distrib = _estimator(pop); + _distrib = _estimator_init(pop); // Evaluating a first time the candidate solutions // The first pop is not supposed to be evaluated (@see eoPopLoopEval). // _evaluator( current_pop, pop ); do { + eoPop< EOType > current_pop; + eoPop< EOType > selected_pop; + // (1) Selection of the best points in the population _selector(pop, selected_pop); assert( selected_pop.size() > 0 ); @@ -205,6 +244,9 @@ protected: //! A EOType estimator. It is going to estimate distribution parameters. edoEstimator & _estimator; + //! A EOType estimator. Called before the main loop. + edoEstimator & _estimator_init; + //! A D sampler edoSampler & _sampler; From 77921fea0c12ecff76a7fd42e7327099bd5bc772 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 24 Mar 2020 16:34:01 +0100 Subject: [PATCH 158/419] feat: add initializer list interface to eoFunctorStore Easier to use while state initialize combined operators. --- eo/src/eoFunctorStore.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eo/src/eoFunctorStore.h b/eo/src/eoFunctorStore.h index 889b832de..7ed2947ac 100644 --- a/eo/src/eoFunctorStore.h +++ b/eo/src/eoFunctorStore.h @@ -85,6 +85,14 @@ public: return this->storeFunctor(f); } + // Allow to pass initializer lists of pointers, for example for edoCombinedContinue. + template + Functor& pack( std::initializer_list args ) + { + Functor* f = new Functor(args); + return this->storeFunctor(f); + } + private : /** no copying allowed */ From e389294cbb906e18778568abcc3b3f5baa989950 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 24 Mar 2020 16:35:49 +0100 Subject: [PATCH 159/419] feat: EDO add combinable estimators Useful to edit the distribution during init, restart or even search. --- edo/src/edo | 3 + edo/src/edoEstimatorAdaptiveEdit.h | 79 +++++++++++++++++++++ edo/src/edoEstimatorAdaptiveReset.h | 54 +++++++++++++++ edo/src/edoEstimatorCombined.h | 103 ++++++++++++++++++++++++++++ 4 files changed, 239 insertions(+) create mode 100644 edo/src/edoEstimatorAdaptiveEdit.h create mode 100644 edo/src/edoEstimatorAdaptiveReset.h create mode 100644 edo/src/edoEstimatorCombined.h diff --git a/edo/src/edo b/edo/src/edo index e6a03a1ed..030da23b0 100644 --- a/edo/src/edo +++ b/edo/src/edo @@ -46,9 +46,12 @@ Authors: #include "edoEstimatorNormalMono.h" #include "edoEstimatorNormalMulti.h" #include "edoEstimatorAdaptive.h" +#include "edoEstimatorAdaptiveReset.h" +#include "edoEstimatorAdaptiveEdit.h" #include "edoEstimatorNormalAdaptive.h" #include "edoEstimatorBinomial.h" #include "edoEstimatorBinomialMulti.h" +#include "edoEstimatorCombined.h" #include "edoModifier.h" #include "edoModifierDispersion.h" diff --git a/edo/src/edoEstimatorAdaptiveEdit.h b/edo/src/edoEstimatorAdaptiveEdit.h new file mode 100644 index 000000000..dbf0d920b --- /dev/null +++ b/edo/src/edoEstimatorAdaptiveEdit.h @@ -0,0 +1,79 @@ +/* +The Evolving Distribution Objects framework (EDO) is a template-based, +ANSI-C++ evolutionary computation library which helps you to write your +own estimation of distribution algorithms. + +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; either +version 2.1 of the License, or (at your option) any later version. + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Copyright (C) 2020 Thales group +*/ +/* +Authors: + Johann Dréo +*/ + +#ifndef _edoEstimatorAdaptiveEdit_h +#define _edoEstimatorAdaptiveEdit_h + +#include + +#include "edoEstimatorAdaptive.h" + +/** An estimator that calls `reset` on the managed distribution. + * + * @ingroup Estimators + */ +template +class edoEstimatorAdaptiveEdit : public edoEstimatorAdaptive +{ +public: + typedef typename D::EOType EOType; + + /** Edit the given distribution's members with the given accessors. + * + * For example, to shift the distribution's mean toward pop's best element + * (note the lack of parenthesis): + * @code + * edoEstimatorAdaptiveEdit e(distrib, + * std::bind(&eoPop::best_element, &pop), + * // std::bind(&D::mean, &distrib, std::placeholders::_1) // Fail to deduce templates + * // but you can use lambdas (even more readable): + * [&distrib](S center){distrib.mean(center);} + * distrib.mean, pop.best_element); + * @endcode + */ + edoEstimatorAdaptiveEdit( + D& distrib, + std::function getter, + std::function setter + ) : + edoEstimatorAdaptive(distrib), + _getter(getter), + _setter(setter) + {} + + virtual D operator()( eoPop& pop ) + { + _setter( _getter() ); + return this->_distrib; + } + +protected: + std::function< P ( )> _getter; + std::function _setter; + +}; + +#endif // !_edoEstimatorAdaptiveEdit_h diff --git a/edo/src/edoEstimatorAdaptiveReset.h b/edo/src/edoEstimatorAdaptiveReset.h new file mode 100644 index 000000000..012784a3d --- /dev/null +++ b/edo/src/edoEstimatorAdaptiveReset.h @@ -0,0 +1,54 @@ +/* +The Evolving Distribution Objects framework (EDO) is a template-based, +ANSI-C++ evolutionary computation library which helps you to write your +own estimation of distribution algorithms. + +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; either +version 2.1 of the License, or (at your option) any later version. + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Copyright (C) 2020 Thales group +*/ +/* +Authors: + Johann Dréo +*/ + +#ifndef _edoEstimatorAdaptiveReset_h +#define _edoEstimatorAdaptiveReset_h + +#include + +#include "edoEstimatorAdaptive.h" + +/** An estimator that calls `reset` on the managed distribution. + * + * @ingroup Estimators + */ +template +class edoEstimatorAdaptiveReset : public edoEstimatorAdaptive +{ +public: + typedef typename D::EOType EOType; + + edoEstimatorAdaptiveReset( D& distrib ) : edoEstimatorAdaptive(distrib) {} + + virtual D operator() ( eoPop& ) + { + this->_distrib.reset(); + return this->_distrib; + } + +}; + +#endif // !_edoEstimatorAdaptiveReset_h diff --git a/edo/src/edoEstimatorCombined.h b/edo/src/edoEstimatorCombined.h new file mode 100644 index 000000000..f884f38f1 --- /dev/null +++ b/edo/src/edoEstimatorCombined.h @@ -0,0 +1,103 @@ +/* +The Evolving Distribution Objects framework (EDO) is a template-based, +ANSI-C++ evolutionary computation library which helps you to write your +own estimation of distribution algorithms. + +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; either +version 2.1 of the License, or (at your option) any later version. + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Copyright (C) 2020 Thales group +*/ +/* +Authors: + Johann Dréo +*/ + +#ifndef _edoEstimatorAdaptiveCombined_h +#define _edoEstimatorAdaptiveCombined_h + +#include + +#include + +#include "edoEstimatorAdaptive.h" + +/** An estimator that calls several ordered estimators, stateful version. + * + * @ingroup Estimators + */ +template +class edoEstimatorCombinedAdaptive : public edoEstimatorAdaptive, public std::vector*> +{ +public: + typedef typename D::EOType EOType; + + edoEstimatorCombinedAdaptive( D& distrib, edoEstimator& estim) : + edoEstimatorAdaptive(distrib), + std::vector*>(1,&estim) + {} + + edoEstimatorCombinedAdaptive( D& distrib, std::vector*> estims) : + edoEstimatorAdaptive(distrib), + std::vector*>(estims) + {} + + void add( edoEstimator& estim ) + { + this->push_back(&estim); + } + + virtual D operator()( eoPop& pop ) + { + for(edoEstimator* pestim : *this) { + this->_distrib = (*pestim)( pop ); + } + return this->_distrib; + } + +}; + +/** An estimator that calls several ordered estimators, stateless version. + * + * @ingroup Estimators + */ +template +class edoEstimatorCombinedStateless : public edoEstimatorCombinedAdaptive +{ +public: + typedef typename D::EOType EOType; + + edoEstimatorCombinedStateless( edoEstimator& estim ) : + edoEstimatorCombinedAdaptive(*(new D), estim) + {} + + edoEstimatorCombinedStateless( std::vector*> estims) : + edoEstimatorCombinedAdaptive(*(new D), estims) + {} + + virtual D operator()( eoPop& pop ) + { + delete &(this->_distrib); + this->_distrib = *(new D); + return edoEstimatorCombinedAdaptive::operator()(pop); + } + + ~edoEstimatorCombinedStateless() + { + delete &(this->_distrib); + } + +}; + +#endif // !_edoEstimatorAdaptiveCombined_h From 40fb64a5aaecb0844fd427c65e3da6dab2efba44 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 24 Mar 2020 16:37:30 +0100 Subject: [PATCH 160/419] feat: add a dummy continue, always returning true. Useful in do_make* when no continue may be instanciated. --- eo/src/eoContinue.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/eo/src/eoContinue.h b/eo/src/eoContinue.h index 429ea58b7..cdf9ea432 100644 --- a/eo/src/eoContinue.h +++ b/eo/src/eoContinue.h @@ -67,6 +67,17 @@ public: } }; +/** A continue that always return true. + * + * @ingroup Continuators + */ +template< class EOT > +class eoDummyContinue : public eoContinue< EOT > +{ + public: + bool operator()(const eoPop&) {return true;} +}; + /** * Termination condition with a count condition (totalGenerations). This continuator contains * a count of cycles, which can be retrieved or set. From 98501e0dd4aff8a57329fc6788e2817193c8f0bc Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 24 Mar 2020 18:25:25 +0100 Subject: [PATCH 161/419] feat: add an algo that manage restarts Reset the pop for you, then call the algo, until continue. --- eo/src/eo | 3 + eo/src/eoAlgoRestart.h | 120 ++++++++++++++++++++++++++++++++++++ eo/src/utils/eoLogMonitor.h | 4 +- 3 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 eo/src/eoAlgoRestart.h diff --git a/eo/src/eo b/eo/src/eo index 57f9e5cc0..c0fe2b8d7 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -92,8 +92,10 @@ #include "eoSteadyFitContinue.h" #include "eoEvalContinue.h" #include "eoFitContinue.h" +#include "eoSIGContinue.h" #include "eoPeriodicContinue.h" #include "eoTimeContinue.h" // added th T.Legrand +#include "eoSecondsElapsedContinue.h" #ifndef _MSC_VER #include "eoCtrlCContinue.h" // CtrlC handling (using 2 global variables!) #endif @@ -145,6 +147,7 @@ #include "eoEasyEA.h" #include "eoSGA.h" // #include "eoEvolutionStrategy.h" removed for a while - until eoGenOp is done +#include "eoAlgoRestart.h" // Utils #include "utils/checkpointing" diff --git a/eo/src/eoAlgoRestart.h b/eo/src/eoAlgoRestart.h new file mode 100644 index 000000000..6e98d774a --- /dev/null +++ b/eo/src/eoAlgoRestart.h @@ -0,0 +1,120 @@ +/* +The Evolving Objects framework is a template-based, +ANSI-C++ evolutionary computation library which helps you to write your +own evolutionary algorithms. + +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; either +version 2.1 of the License, or (at your option) any later version. + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Copyright (C) 2010 Thales group +*/ +/* +Authors: + Johann Dréo +*/ + +#ifndef _EOALGORESTART_H_ +#define _EOALGORESTART_H_ + +#include "eoPop.h" +#include "eoAlgo.h" + +/** An algo that restart the given algorithm on a freshly init pop. + * + * @note: The fresh population size is set to the size of the last population at previous run. + * + * @ingroup Algorithms + */ +template +class eoAlgoRestart : public eoAlgo +{ +public: + /** Constructor with an eoPopEvalFunc + * + * @param init the initialization operator + * @param popeval an evaluator for populations + * @param algo the algorithm to restart + * @param continuator a stopping criterion to manage the number of restarts + */ + eoAlgoRestart( + eoInit& init, + eoPopEvalFunc& pop_eval, + eoAlgo& algo, + eoContinue& continuator + ) : + eoAlgo(), + _init(init), + _eval(_dummy_eval), + _loop_eval(_dummy_eval), + _pop_eval(pop_eval), + _algo(algo), + _continue(continuator) + {} + + /** Constructor with an eoEvalFunc + * + * @param init the initialization operator + * @param popeval an evaluator for populations + * @param algo the algorithm to restart + * @param continuator a stopping criterion to manage the number of restarts + */ + eoAlgoRestart( + eoInit& init, + eoEvalFunc& eval, + eoAlgo& algo, + eoContinue& continuator + ) : + eoAlgo(), + _init(init), + _eval(eval), + _loop_eval(_eval), + _pop_eval(_loop_eval), + _algo(algo), + _continue(continuator) + {} + + virtual void operator()(eoPop & pop) + { + do { + size_t pop_size = pop.size(); + pop.clear(); + pop.append(pop_size, _init); + _pop_eval(pop,pop); + + _algo(pop); + + } while( _continue(pop) ); + } + +protected: + eoInit& _init; + + eoEvalFunc& _eval; + eoPopLoopEval _loop_eval; + eoPopEvalFunc& _pop_eval; + + eoAlgo& _algo; + eoContinue& _continue; + + class eoDummyEval : public eoEvalFunc + { + public: + void operator()(EOT &) + {} + }; + eoDummyEval _dummy_eval; +}; + + +#endif // _EOALGORESTART_H_ diff --git a/eo/src/utils/eoLogMonitor.h b/eo/src/utils/eoLogMonitor.h index 94884250b..46420ef3f 100644 --- a/eo/src/utils/eoLogMonitor.h +++ b/eo/src/utils/eoLogMonitor.h @@ -32,9 +32,9 @@ Authors: #include "eoLogger.h" /** - Prints statistics to a given ostream. + Prints statistics to the given eoLogger. - You can pass any instance of an ostream to the constructor, like, for example, std::clog. + You can configure the log level. @ingroup Monitors */ From 193ea83eb3153b07d2ddd13296f332ef70ac8e0d Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 24 Mar 2020 23:01:06 +0100 Subject: [PATCH 162/419] feat: add a way to print a message at each stop criterion call --- eo/src/utils/checkpointing | 1 + eo/src/utils/eoLogMessage.h | 59 +++++++++++++++++++++++++++++++++++++ eo/src/utils/eoUpdater.h | 1 - 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 eo/src/utils/eoLogMessage.h diff --git a/eo/src/utils/checkpointing b/eo/src/utils/checkpointing index 79fdab123..ad190602a 100644 --- a/eo/src/utils/checkpointing +++ b/eo/src/utils/checkpointing @@ -27,6 +27,7 @@ #include "eoParser.h" #include "eoState.h" #include "eoUpdater.h" +#include "eoLogMessage.h" #include "eoMonitor.h" #include "eoFileMonitor.h" #include "eoTimedMonitor.h" diff --git a/eo/src/utils/eoLogMessage.h b/eo/src/utils/eoLogMessage.h new file mode 100644 index 000000000..4a9a02381 --- /dev/null +++ b/eo/src/utils/eoLogMessage.h @@ -0,0 +1,59 @@ +/* +(c) Thales group, 2020 + + 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 +*/ + +#ifndef _eoLogMessage_h +#define _eoLogMessage_h + +#include +#include "eoUpdater.h" +#include "eoLogger.h" + +/** + An updater that print its message when called (usually within an eoCheckPoint) + + @ingroup Utilities +*/ +class eoLogMessage : public eoUpdater +{ +public : + eoLogMessage( + std::string msg, + eoLogger& log = eo::log, + eo::Levels level = eo::progress + ) : + _msg(msg), + _log(log), + _level(level) + { } + + virtual void operator()() + { + _log << _level << _msg << std::endl; + } + +protected: + std::string _msg; + eoLogger& _log; + eo::Levels _level; + +}; + +#endif diff --git a/eo/src/utils/eoUpdater.h b/eo/src/utils/eoUpdater.h index 0ae3b9c25..6626fabec 100644 --- a/eo/src/utils/eoUpdater.h +++ b/eo/src/utils/eoUpdater.h @@ -168,5 +168,4 @@ private : const std::string extension; }; - #endif From 1cdbb036d36b94c4736aac75c233050c47504f4e Mon Sep 17 00:00:00 2001 From: nojhan Date: Wed, 25 Mar 2020 14:43:36 +0100 Subject: [PATCH 163/419] add a dimension accessor to eoInitFixedLength Useful to avoid divergence on indiv size in auto makers. --- eo/src/eoInit.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/eo/src/eoInit.h b/eo/src/eoInit.h index 9230f4b64..9965af919 100644 --- a/eo/src/eoInit.h +++ b/eo/src/eoInit.h @@ -90,20 +90,22 @@ class eoInitFixedLength: public eoInit { public: - typedef typename EOT::AtomType AtomType; + typedef typename EOT::AtomType AtomType; - eoInitFixedLength(unsigned _combien, eoRndGenerator& _generator) - : combien(_combien), generator(_generator) {} + eoInitFixedLength(unsigned _dimension, eoRndGenerator& _generator) + : dim(_dimension), generator(_generator) {} virtual void operator()(EOT& chrom) { - chrom.resize(combien); + chrom.resize(dim); std::generate(chrom.begin(), chrom.end(), generator); chrom.invalidate(); } + unsigned dimension() const {return dim;} + private : - unsigned combien; + unsigned dim; /// generic wrapper for eoFunctor (s), to make them have the function-pointer style copy semantics eoSTLF generator; }; From 0332920d633fe2ddba834df019a1757083a152c8 Mon Sep 17 00:00:00 2001 From: nojhan Date: Wed, 25 Mar 2020 14:45:11 +0100 Subject: [PATCH 164/419] several fix of minor warnings --- edo/src/edoEstimatorAdaptiveEdit.h | 2 +- edo/src/edoSamplerBinomialMulti.h | 4 ++-- eo/src/eoEasyPSO.h | 4 ++-- eo/src/eoEvalCmd.h | 4 ++-- eo/src/eoEvalDump.h | 2 +- eo/src/eoEvalKeepBest.h | 2 +- eo/src/eoSIGContinue.h | 2 +- eo/src/eoSecondsElapsedContinue.h | 2 +- eo/src/eoStarTopology.h | 6 +++--- eo/src/eoSyncEasyPSO.h | 4 ++-- eo/src/eoTruncatedSelectOne.h | 4 ++-- eo/src/ga/make_ga.h | 2 +- eo/src/utils/eoFDCStat.h | 2 +- eo/src/utils/eoTimedMonitor.h | 2 ++ 14 files changed, 22 insertions(+), 20 deletions(-) diff --git a/edo/src/edoEstimatorAdaptiveEdit.h b/edo/src/edoEstimatorAdaptiveEdit.h index dbf0d920b..cefd4187c 100644 --- a/edo/src/edoEstimatorAdaptiveEdit.h +++ b/edo/src/edoEstimatorAdaptiveEdit.h @@ -64,7 +64,7 @@ public: _setter(setter) {} - virtual D operator()( eoPop& pop ) + virtual D operator()( eoPop& ) { _setter( _getter() ); return this->_distrib; diff --git a/edo/src/edoSamplerBinomialMulti.h b/edo/src/edoSamplerBinomialMulti.h index 732cdbed5..dda1a4eb1 100644 --- a/edo/src/edoSamplerBinomialMulti.h +++ b/edo/src/edoSamplerBinomialMulti.h @@ -51,13 +51,13 @@ public: * The default implementation is to push back a true boolean. * If you have a more complex data structure, you can just overload this. */ - virtual void make_true( AtomType & atom, unsigned int i, unsigned int j ) + virtual void make_true( AtomType & atom, unsigned int, unsigned int ) { atom.push_back( 1 ); } /** @see make_true */ - virtual void make_false( AtomType & atom, unsigned int i, unsigned int j ) + virtual void make_false( AtomType & atom, unsigned int, unsigned int ) { atom.push_back( 0 ); } diff --git a/eo/src/eoEasyPSO.h b/eo/src/eoEasyPSO.h index 3e9997e3a..f1e00bf2a 100644 --- a/eo/src/eoEasyPSO.h +++ b/eo/src/eoEasyPSO.h @@ -176,7 +176,7 @@ protected: { public: eoDummyFlight () {} - void operator () (POT & _po) {} + void operator () (POT &) {} }dummyFlight; // if the initializer does not need to be used, use the dummy one instead @@ -184,7 +184,7 @@ protected: { public: eoDummyInitializer () {} - void operator () (POT & _po) {} + void operator () (POT &) {} }dummyInit; }; diff --git a/eo/src/eoEvalCmd.h b/eo/src/eoEvalCmd.h index e34dd3eee..0f2633a98 100644 --- a/eo/src/eoEvalCmd.h +++ b/eo/src/eoEvalCmd.h @@ -74,9 +74,9 @@ public: const std::string suffix = "" ) : _cmd(cmd), - _suffix(suffix), - _infix(infix), _prefix(prefix), + _infix(infix), + _suffix(suffix), _last_call("") {} diff --git a/eo/src/eoEvalDump.h b/eo/src/eoEvalDump.h index a5ad8e3fb..2f26ee327 100644 --- a/eo/src/eoEvalDump.h +++ b/eo/src/eoEvalDump.h @@ -120,7 +120,7 @@ protected: protected: class DummyEval : public eoEvalFunc { - void operator()(EOT& sol) {/*empty*/} + void operator()(EOT&) {/*empty*/} }; DummyEval _dummy_eval; eoEvalFunc& _func; diff --git a/eo/src/eoEvalKeepBest.h b/eo/src/eoEvalKeepBest.h index 133e01b87..86dd50456 100644 --- a/eo/src/eoEvalKeepBest.h +++ b/eo/src/eoEvalKeepBest.h @@ -142,7 +142,7 @@ template class eoEvalKeepBest : public eoEvalFunc, public eoValu class DummyEval : public eoEvalFunc { - void operator()(EOT& sol) {/*empty*/} + void operator()(EOT&) {/*empty*/} }; protected : diff --git a/eo/src/eoSIGContinue.h b/eo/src/eoSIGContinue.h index 32e7c1857..a0afae040 100644 --- a/eo/src/eoSIGContinue.h +++ b/eo/src/eoSIGContinue.h @@ -71,7 +71,7 @@ public: } /** Returns false when the signal has been typed in reached */ - virtual bool operator() ( const eoPop& _vEO ) + virtual bool operator() ( const eoPop& ) { if (call_func) { diff --git a/eo/src/eoSecondsElapsedContinue.h b/eo/src/eoSecondsElapsedContinue.h index a580b7f42..a258819fa 100644 --- a/eo/src/eoSecondsElapsedContinue.h +++ b/eo/src/eoSecondsElapsedContinue.h @@ -41,7 +41,7 @@ public: eoSecondsElapsedContinue(int nSeconds) : start(time(0)), seconds(nSeconds) {} - virtual bool operator() ( const eoPop& _vEO ) { + virtual bool operator() ( const eoPop& ) { time_t now = time(0); time_t diff = now - start; diff --git a/eo/src/eoStarTopology.h b/eo/src/eoStarTopology.h index a345c8bc3..6083dbba8 100644 --- a/eo/src/eoStarTopology.h +++ b/eo/src/eoStarTopology.h @@ -86,7 +86,7 @@ public: * @param _po - The particle to update * @param _indice - The indice of the given particle in the population */ - void updateNeighborhood(POT & _po,unsigned _indice) + void updateNeighborhood(POT & _po, unsigned) { // update the best fitness of the particle if (_po.fitness() > _po.best()) @@ -108,13 +108,13 @@ public: * @param _indice - The indice of a particle in the population * @return POT & - The best particle in the neighborhood of the particle whose indice is _indice */ - POT & best (unsigned _indice) {return (neighborhood.best());} + POT & best (unsigned) {return (neighborhood.best());} /* * Return the global best of the topology */ - virtual POT & globalBest(const eoPop& _pop) + virtual POT & globalBest(const eoPop&) { return neighborhood.best(); } diff --git a/eo/src/eoSyncEasyPSO.h b/eo/src/eoSyncEasyPSO.h index 0fc7a2492..64cf64724 100644 --- a/eo/src/eoSyncEasyPSO.h +++ b/eo/src/eoSyncEasyPSO.h @@ -241,7 +241,7 @@ protected: { public: eoDummyFlight () {} - void operator () (POT & /*_po*/) {} + void operator () (POT &) {} }dummyFlight; // if the initializer does not need to be used, use the dummy one instead @@ -249,7 +249,7 @@ protected: { public: eoDummyInitializer () {} - void operator () (POT & _po) {} + void operator () (POT &) {} }dummyInit; }; diff --git a/eo/src/eoTruncatedSelectOne.h b/eo/src/eoTruncatedSelectOne.h index 431f7465a..5bda5600f 100644 --- a/eo/src/eoTruncatedSelectOne.h +++ b/eo/src/eoTruncatedSelectOne.h @@ -93,10 +93,10 @@ public: /** The implementation selects an individual from the fertile pop - @param _pop the source population + @param unused @return the selected guy */ - const EOT& operator()(const eoPop& _pop) + const EOT& operator()(const eoPop& ) { return select(actualPop); } diff --git a/eo/src/ga/make_ga.h b/eo/src/ga/make_ga.h index 660462477..9cec19ae4 100644 --- a/eo/src/ga/make_ga.h +++ b/eo/src/ga/make_ga.h @@ -93,7 +93,7 @@ void run_ea(eoAlgo >& _ga, eoPop Date: Thu, 26 Mar 2020 07:53:23 +0100 Subject: [PATCH 165/419] refactor exceptions and exceptions hierarchy --- eo/src/eoExceptions.h | 161 ++++++++++++++++++++++++++--------------- eo/src/utils/eoState.h | 4 +- 2 files changed, 106 insertions(+), 59 deletions(-) diff --git a/eo/src/eoExceptions.h b/eo/src/eoExceptions.h index ef1a5c67e..618173f91 100644 --- a/eo/src/eoExceptions.h +++ b/eo/src/eoExceptions.h @@ -28,8 +28,63 @@ Johann Dréo #include #include -class eoMaxException : public std::exception {}; +//! You can catch this base exception if you want to catch anything thrown by ParadisEO. @ingroup Core +class eoException : public std::runtime_error +{ +public: + eoException(std::string msg = "") : + std::runtime_error(msg) + { + _msg << msg; + } + const char* what() const throw() + { + return _msg.str().c_str(); + } + + ~eoException() throw() {} + +protected: + std::ostringstream _msg; +}; + +/** Base class for exceptions which need to stop the algorithm to be handled + * + * (like stopping criterion or numerical errors). + */ +class eoStopException : public eoException +{ +public: + eoStopException(std::string msg = "") : eoException(msg) {} + ~eoStopException() throw() {} +}; + + +//! Base class for limit-based exceptions (see eoMaxTimeException and eoMaxEvalException. +class eoMaxException : public eoStopException +{ +public: + eoMaxException(std::string msg = "") : eoStopException(msg) {} + ~eoMaxException() throw() {} +}; + + +/*! +An error that signals that some bad data have been returned. + +Thrown by @see eoEvalNanThrowException + +@ingroup Evaluation +*/ +class eoNanException : public eoStopException +{ +public: + eoNanException() : + eoStopException("The objective function returned a bad value (nan or inf)") + { } + ~eoNanException() throw() {} +}; /*! @@ -42,107 +97,103 @@ Thrown by @see eoEvalTimeThrowException class eoMaxTimeException : public eoMaxException { public: - eoMaxTimeException( time_t elapsed) : _elapsed(elapsed) {} - - virtual const char* what() const throw() + eoMaxTimeException( time_t elapsed) : + eoMaxException("STOP") { - std::ostringstream ss; - ss << "STOP in eoMaxTimeException: the maximum number of allowed seconds has been reached (" << _elapsed << ")."; - return ss.str().c_str(); + _msg << " the maximum number of allowed seconds has been reached (" + << elapsed << ")"; } - -private: - const time_t _elapsed; + ~eoMaxTimeException() throw() {} }; /*! An error that signals that a maximum number of evaluations has been reached. -Thrown by @see eoEvalEvalThrowException +Thrown by @see eoEvalThrowException @ingroup Evaluation */ class eoMaxEvalException : public eoMaxException { public: - eoMaxEvalException(unsigned long threshold) : _threshold(threshold){} - - virtual const char* what() const throw() + eoMaxEvalException(unsigned long threshold) : + eoMaxException("STOP") { - std::ostringstream ss; - ss << "STOP in eoMaxEvalException: the maximum number of evaluation has been reached (" << _threshold << ")."; - return ss.str().c_str(); + _msg << " the maximum number of evaluation has been reached (" + << threshold << ")."; } - -private: - const unsigned long _threshold; + ~eoMaxEvalException() throw() {} }; +//! Base class for exceptions related to eoParam management. @ingroup Parameters +class eoParamException : public eoException +{ +public: + eoParamException(std::string msg = "") : eoException(msg) {} +}; /*! * An error that signals a missing parameter * * Thrown by eoParser::getParam * - * @ingroup Parameters + * @ingroup Parameters */ -class eoMissingParamException : public std::exception +class eoMissingParamException : public eoParamException { public: - eoMissingParamException(std::string name) : _name(name){} - - virtual const char* what() const throw() + eoMissingParamException(std::string name) : + eoParamException() { - std::ostringstream ss; - ss << "The command parameter " << _name << " has not been declared"; - return ss.str().c_str(); + _msg << "The command parameter " << name << " has not been declared"; } - ~eoMissingParamException() throw() {} - -private: - const std::string _name; }; + /*! * An error that signals a bad parameter type * * Thrown by eoParser::valueOf * - * @ingroup Parameters + * @ingroup Parameters */ -class eoWrongParamTypeException : public std::exception +class eoWrongParamTypeException : public eoParamException { public: - eoWrongParamTypeException(std::string name) : _name(name){} - - virtual const char* what() const throw() + eoWrongParamTypeException(std::string name) : + eoParamException() { - std::ostringstream ss; - ss << "You asked for the parameter " << _name << " but it has not been declared under this type"; - return ss.str().c_str(); + _msg << "You asked for the parameter " << name + << " but it has not been declared under this type"; } - ~eoWrongParamTypeException() throw() {} - -private: - const std::string _name; }; -class eoSystemError : public std::exception +//! Exception related to a system call. +class eoSystemError : public eoException { public: - eoSystemError(std::string cmd) - : _cmd(cmd), _has_pipe(false), _err_code(-1), _output("") - {} + eoSystemError(std::string cmd) : + eoException(), + _cmd(cmd), _has_pipe(false), _err_code(-1), _output("") + { + _msg << msg(); + } - eoSystemError(std::string cmd, int err_code, std::string output) - : _cmd(cmd), _has_pipe(true), _err_code(err_code), _output(output) - {} + eoSystemError(std::string cmd, int err_code, std::string output) : + eoException(), + _cmd(cmd), _has_pipe(true), _err_code(err_code), _output(output) + { + _msg << msg(); + } - virtual const char* what() const throw() + ~eoSystemError() throw() {} + +protected: + const std::string msg() const throw() { std::ostringstream ss; ss << "System call: `" << _cmd << "` error"; @@ -150,17 +201,13 @@ public: ss << " code #" << _err_code << " with the following output:" << std::endl << _output; } - return ss.str().c_str(); + return ss.str(); } - ~eoSystemError() throw() {} - -private: const std::string _cmd; const bool _has_pipe; const int _err_code; const std::string _output; - }; #endif // __eoExceptions_h__ diff --git a/eo/src/utils/eoState.h b/eo/src/utils/eoState.h index e96917e9d..802709b30 100644 --- a/eo/src/utils/eoState.h +++ b/eo/src/utils/eoState.h @@ -122,9 +122,9 @@ public : /** * Loading error thrown when nothing seems to work. */ - struct loading_error : public std::runtime_error + struct loading_error : public eoException { - loading_error(std::string huh = "Error while loading") : std::runtime_error(huh) {} + loading_error(std::string huh = "Error while loading") : eoException(huh) {} }; std::string getCommentString(void) const { return "#"; } From 6aeb74f6e04d2ead9fceeda47ccde628e51413a7 Mon Sep 17 00:00:00 2001 From: nojhan Date: Thu, 26 Mar 2020 22:46:52 +0100 Subject: [PATCH 166/419] refactor exceptions --- eo/src/eoExceptions.h | 89 +++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 24 deletions(-) diff --git a/eo/src/eoExceptions.h b/eo/src/eoExceptions.h index 618173f91..476a064d6 100644 --- a/eo/src/eoExceptions.h +++ b/eo/src/eoExceptions.h @@ -27,26 +27,31 @@ Johann Dréo #include #include #include +#include //! You can catch this base exception if you want to catch anything thrown by ParadisEO. @ingroup Core class eoException : public std::runtime_error { public: eoException(std::string msg = "") : - std::runtime_error(msg) + std::runtime_error(""), + _msg(msg) + { } + + virtual std::string message() const throw() { - _msg << msg; + return _msg; } const char* what() const throw() { - return _msg.str().c_str(); + return message().c_str(); } ~eoException() throw() {} protected: - std::ostringstream _msg; + const std::string _msg; }; /** Base class for exceptions which need to stop the algorithm to be handled @@ -98,12 +103,22 @@ class eoMaxTimeException : public eoMaxException { public: eoMaxTimeException( time_t elapsed) : - eoMaxException("STOP") + eoMaxException(), + _elapsed(elapsed) + { } + + virtual std::string message() const throw() { - _msg << " the maximum number of allowed seconds has been reached (" - << elapsed << ")"; + std::ostringstream msg; + msg << "STOP because the maximum number of allowed seconds has been reached (" + << _elapsed << ")"; + return msg.str(); } + ~eoMaxTimeException() throw() {} + +protected: + const time_t _elapsed; }; @@ -118,12 +133,22 @@ class eoMaxEvalException : public eoMaxException { public: eoMaxEvalException(unsigned long threshold) : - eoMaxException("STOP") + eoMaxException(), + _threshold(threshold) + { } + + virtual std::string message() const throw() { - _msg << " the maximum number of evaluation has been reached (" - << threshold << ")."; + std::ostringstream msg; + msg << " the maximum number of evaluation has been reached (" + << _threshold << ")."; + return msg.str(); } + ~eoMaxEvalException() throw() {} + +protected: + const unsigned long _threshold; }; //! Base class for exceptions related to eoParam management. @ingroup Parameters @@ -144,11 +169,21 @@ class eoMissingParamException : public eoParamException { public: eoMissingParamException(std::string name) : - eoParamException() + eoParamException(), + _name(name) + { } + + virtual std::string message() const throw() { - _msg << "The command parameter " << name << " has not been declared"; + std::ostringstream msg; + msg << "The command parameter " << _name << " has not been declared"; + return msg.str(); } + ~eoMissingParamException() throw() {} + +protected: + const std::string _name; }; @@ -163,12 +198,22 @@ class eoWrongParamTypeException : public eoParamException { public: eoWrongParamTypeException(std::string name) : - eoParamException() + eoParamException(), + _name(name) + { } + + virtual std::string message() const throw() { - _msg << "You asked for the parameter " << name + std::ostringstream msg; + msg << "You asked for the parameter " << _name << " but it has not been declared under this type"; + return msg.str(); } + ~eoWrongParamTypeException() throw() {} + +protected: + const std::string _name; }; @@ -179,21 +224,14 @@ public: eoSystemError(std::string cmd) : eoException(), _cmd(cmd), _has_pipe(false), _err_code(-1), _output("") - { - _msg << msg(); - } + { } eoSystemError(std::string cmd, int err_code, std::string output) : eoException(), _cmd(cmd), _has_pipe(true), _err_code(err_code), _output(output) - { - _msg << msg(); - } + { } - ~eoSystemError() throw() {} - -protected: - const std::string msg() const throw() + virtual std::string message() const throw() { std::ostringstream ss; ss << "System call: `" << _cmd << "` error"; @@ -204,6 +242,9 @@ protected: return ss.str(); } + ~eoSystemError() throw() {} + +protected: const std::string _cmd; const bool _has_pipe; const int _err_code; From 75ac37b02afe5698e0dc04cc54020717c7deb987 Mon Sep 17 00:00:00 2001 From: nojhan Date: Thu, 26 Mar 2020 22:47:26 +0100 Subject: [PATCH 167/419] fix some errors in tests - use eoEvalCounterThrowException - use make_help --- edo/application/cmaes/main.cpp | 6 +++--- edo/application/eda/main.cpp | 6 +++--- eo/src/eoSIGContinue.cpp | 6 ++++++ eo/src/eoSIGContinue.h | 5 +---- eo/src/es/make_es.h | 2 +- eo/src/es/make_real.h | 2 +- eo/test/t-eoEvalCmd.cpp | 2 +- eo/test/t-eoFitnessAssembledEA.cpp | 2 +- eo/test/t-eoGA.cpp | 1 + eo/test/t-eoReal.cpp | 1 + eo/tutorial/Lesson4/RealEA.cpp | 1 + eo/tutorial/Lesson5/OneMaxEA.cpp | 2 +- eo/tutorial/Lesson5/OneMaxLibEA.cpp | 2 +- moeo/tutorial/Lesson2/FlowShopEA.cpp | 2 +- moeo/tutorial/Lesson3/FlowShopEA2.cpp | 2 +- moeo/tutorial/Lesson4/FlowShopDMLS.cpp | 2 +- 16 files changed, 25 insertions(+), 19 deletions(-) diff --git a/edo/application/cmaes/main.cpp b/edo/application/cmaes/main.cpp index ed7f10a44..47a09f998 100644 --- a/edo/application/cmaes/main.cpp +++ b/edo/application/cmaes/main.cpp @@ -28,7 +28,7 @@ Authors: #include //#include -#include +#include #include #include @@ -67,7 +67,7 @@ int main(int ac, char** av) eoEvalFunc< RealVec >* plainEval = new Rosenbrock< RealVec >(); state.storeFunctor(plainEval); - eoEvalFuncCounterBounder< RealVec > eval(*plainEval, max_eval); + eoEvalCounterThrowException< RealVec > eval(*plainEval, max_eval); eoRndGenerator< double >* gen = new eoUniformGenerator< double >(-5, 5); state.storeFunctor(gen); @@ -145,7 +145,7 @@ int main(int ac, char** av) eo::log << eo::progress << "Best solution after random init: " << pop.best_element().fitness() << std::endl; do_run(*algo, pop); - } catch (eoEvalFuncCounterBounderException& e) { + } catch (eoMaxEvalException& e) { eo::log << eo::warnings << "warning: " << e.what() << std::endl; } diff --git a/edo/application/eda/main.cpp b/edo/application/eda/main.cpp index 6e024545b..6b0311fe0 100644 --- a/edo/application/eda/main.cpp +++ b/edo/application/eda/main.cpp @@ -28,7 +28,7 @@ Authors: #include // #include -#include +#include #include #include @@ -69,7 +69,7 @@ int main(int ac, char** av) state.storeFunctor(plainEval); unsigned long max_eval = parser.getORcreateParam((unsigned long)0, "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion").value(); // E - eoEvalFuncCounterBounder< EOT > eval(*plainEval, max_eval); + eoEvalCounterThrowException< EOT > eval(*plainEval, max_eval); eoRndGenerator< double >* gen = new eoUniformGenerator< double >(-5, 5); state.storeFunctor(gen); @@ -169,7 +169,7 @@ int main(int ac, char** av) try { do_run(*algo, pop); - } catch (eoEvalFuncCounterBounderException& e) { + } catch (eoMaxEvalException& e) { eo::log << eo::warnings << "warning: " << e.what() << std::endl; } catch (std::exception& e) { diff --git a/eo/src/eoSIGContinue.cpp b/eo/src/eoSIGContinue.cpp index 2f126ea91..0e4299c71 100644 --- a/eo/src/eoSIGContinue.cpp +++ b/eo/src/eoSIGContinue.cpp @@ -36,3 +36,9 @@ // --- Global variables - but don't know what else to do - MS --- bool existSIGContinue = false; bool call_func = false; + +void set_bool(int) +{ + call_func = true; +} + diff --git a/eo/src/eoSIGContinue.h b/eo/src/eoSIGContinue.h index a0afae040..416cad692 100644 --- a/eo/src/eoSIGContinue.h +++ b/eo/src/eoSIGContinue.h @@ -42,10 +42,7 @@ extern bool existSIGContinue; extern bool call_func; -void set_bool(int) -{ - call_func = true; -} +void set_bool(int); /** A continuator that stops if a given signal is received during the execution diff --git a/eo/src/es/make_es.h b/eo/src/es/make_es.h index 540609741..84c4fa823 100644 --- a/eo/src/es/make_es.h +++ b/eo/src/es/make_es.h @@ -145,7 +145,7 @@ void run_ea(eoAlgo >& _ga, eoPop >& _ga, eoPop EOT; diff --git a/eo/test/t-eoFitnessAssembledEA.cpp b/eo/test/t-eoFitnessAssembledEA.cpp index e04535673..3dfb063ba 100644 --- a/eo/test/t-eoFitnessAssembledEA.cpp +++ b/eo/test/t-eoFitnessAssembledEA.cpp @@ -95,7 +95,7 @@ public: }; // checks for help demand, and writes the status file and make_help; in libutils -void make_help(eoParser & _parser); +// void make_help(eoParser & _parser); // now use all of the above, + representation dependent things int main(int argc, char* argv[]){ diff --git a/eo/test/t-eoGA.cpp b/eo/test/t-eoGA.cpp index fafed297d..bc2d3df30 100644 --- a/eo/test/t-eoGA.cpp +++ b/eo/test/t-eoGA.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include "binary_value.h" diff --git a/eo/test/t-eoReal.cpp b/eo/test/t-eoReal.cpp index 163b0ea86..7d5bd4cf8 100644 --- a/eo/test/t-eoReal.cpp +++ b/eo/test/t-eoReal.cpp @@ -1,5 +1,6 @@ #include +#include #include #include "real_value.h" #include diff --git a/eo/tutorial/Lesson4/RealEA.cpp b/eo/tutorial/Lesson4/RealEA.cpp index 1775b12b7..ef7ad6521 100644 --- a/eo/tutorial/Lesson4/RealEA.cpp +++ b/eo/tutorial/Lesson4/RealEA.cpp @@ -1,5 +1,6 @@ #include +#include #include #include "real_value.h" #include diff --git a/eo/tutorial/Lesson5/OneMaxEA.cpp b/eo/tutorial/Lesson5/OneMaxEA.cpp index 14a0f4c5e..b75e57e51 100644 --- a/eo/tutorial/Lesson5/OneMaxEA.cpp +++ b/eo/tutorial/Lesson5/OneMaxEA.cpp @@ -116,7 +116,7 @@ void run_ea(eoAlgo& _ga, eoPop& _pop) // checks for help demand, and writes the status file // and make_help; in libutils -void make_help(eoParser & _parser); +// void make_help(eoParser & _parser); // now use all of the above, + representation dependent things int main(int argc, char* argv[]) diff --git a/eo/tutorial/Lesson5/OneMaxLibEA.cpp b/eo/tutorial/Lesson5/OneMaxLibEA.cpp index febcca445..3943379f0 100644 --- a/eo/tutorial/Lesson5/OneMaxLibEA.cpp +++ b/eo/tutorial/Lesson5/OneMaxLibEA.cpp @@ -89,7 +89,7 @@ void run_ea(eoAlgo& _ga, eoPop& _pop); // checks for help demand, and writes the status file // and make_help; in libutils - just a declaration, code in libeoutils.a -void make_help(eoParser & _parser); +// void make_help(eoParser & _parser); // now use all of the above, + representation dependent things // from here on, no difference with eoOneMax.cpp diff --git a/moeo/tutorial/Lesson2/FlowShopEA.cpp b/moeo/tutorial/Lesson2/FlowShopEA.cpp index 4f7a28913..445f4b227 100644 --- a/moeo/tutorial/Lesson2/FlowShopEA.cpp +++ b/moeo/tutorial/Lesson2/FlowShopEA.cpp @@ -47,7 +47,7 @@ // how to initialize the population #include // checks for help demand, and writes the status file and make_help; in libutils -void make_help(eoParser & _parser); +// void make_help(eoParser & _parser); // definition of the representation #include diff --git a/moeo/tutorial/Lesson3/FlowShopEA2.cpp b/moeo/tutorial/Lesson3/FlowShopEA2.cpp index 1752bab4f..1985eb75e 100644 --- a/moeo/tutorial/Lesson3/FlowShopEA2.cpp +++ b/moeo/tutorial/Lesson3/FlowShopEA2.cpp @@ -55,7 +55,7 @@ // simple call to the algo #include // checks for help demand, and writes the status file and make_help; in libutils -void make_help(eoParser & _parser); +// void make_help(eoParser & _parser); // definition of the representation #include diff --git a/moeo/tutorial/Lesson4/FlowShopDMLS.cpp b/moeo/tutorial/Lesson4/FlowShopDMLS.cpp index a2e864a77..a84a33dcf 100644 --- a/moeo/tutorial/Lesson4/FlowShopDMLS.cpp +++ b/moeo/tutorial/Lesson4/FlowShopDMLS.cpp @@ -48,7 +48,7 @@ // how to initialize the population #include // checks for help demand, and writes the status file and make_help; in libutils -void make_help(eoParser & _parser); +// void make_help(eoParser & _parser); // definition of the representation #include From eba2e149503d5fa07e16c79b7a2dcaceb80868e3 Mon Sep 17 00:00:00 2001 From: nojhan Date: Fri, 27 Mar 2020 00:21:52 +0100 Subject: [PATCH 168/419] use eoExceptions everywhere --- edo/src/utils/edoFileSnapshot.cpp | 6 +- eo/src/EO.h | 8 +- eo/src/PO.h | 4 +- eo/src/do/make_algo_easea.h | 6 +- eo/src/do/make_algo_scalar.h | 6 +- eo/src/do/make_continue.h | 2 +- eo/src/do/make_general_replacement.h | 4 +- eo/src/eoCtrlCContinue.h | 2 +- eo/src/eoEasyEA.h | 22 ++--- eo/src/eoEasyPSO.h | 18 ++-- eo/src/eoEvalDump.h | 4 +- eo/src/eoExceptions.h | 97 +++++++++++++++++-- eo/src/eoFlOrBinOp.h | 8 +- eo/src/eoFlOrQuadOp.h | 6 +- eo/src/eoG3Replacement.h | 2 +- eo/src/eoInit.h | 3 +- eo/src/eoLinearTopology.h | 2 +- eo/src/eoMGGReplacement.h | 2 +- eo/src/eoMerge.h | 6 +- eo/src/eoNDSorting.h | 4 +- eo/src/eoOneToOneBreeder.h | 2 +- eo/src/eoPop.h | 5 +- eo/src/eoProportionalSelect.h | 2 +- eo/src/eoRandomRealWeightUp.h | 2 +- eo/src/eoRanking.h | 4 +- eo/src/eoReduce.h | 12 +-- eo/src/eoReduceMerge.h | 2 +- eo/src/eoReduceMergeReduce.h | 2 +- eo/src/eoReduceSplit.h | 14 +-- eo/src/eoSIGContinue.h | 2 +- eo/src/eoSelectFactory.h | 2 +- eo/src/eoSelectFromWorth.h | 2 +- eo/src/eoSequentialSelect.h | 2 +- eo/src/eoSharing.h | 3 +- eo/src/eoSimpleEDA.h | 18 ++-- eo/src/eoSocialNeighborhood.h | 2 +- eo/src/eoStochasticUniversalSelect.h | 2 +- eo/src/eoSurviveAndDie.h | 4 +- eo/src/eoSwapMutation.h | 2 +- eo/src/eoSyncEasyPSO.h | 18 ++-- eo/src/es/eoNormalMutation.h | 2 +- eo/src/es/eoRealInitBounded.h | 2 +- eo/src/es/eoRealOp.h | 8 +- eo/src/es/make_algo_scalar_es.cpp | 12 +-- eo/src/es/make_genotype_real.h | 2 +- eo/src/es/make_op.h | 24 ++--- eo/src/es/make_op_es.h | 12 +-- eo/src/es/make_op_real.h | 24 ++--- eo/src/ga/make_PBILupdate.h | 2 +- eo/src/ga/make_op.h | 22 ++--- eo/src/gp/eoParseTreeDepthInit.h | 2 +- eo/src/gp/eoStParseTreeDepthInit.h | 2 +- eo/src/mpi/eoParallelApply.h | 2 +- eo/src/pyeo/PyEO.cpp | 8 +- eo/src/pyeo/PyEO.h | 4 +- eo/src/pyeo/monitors.cpp | 2 +- eo/src/pyeo/statistics.cpp | 2 +- eo/src/pyeo/valueParam.cpp | 6 +- eo/src/utils/eoAssembledFitnessStat.h | 4 +- eo/src/utils/eoFDCStat.h | 2 +- eo/src/utils/eoFileMonitor.cpp | 9 +- eo/src/utils/eoFileMonitor.h | 5 +- eo/src/utils/eoFileSnapshot.h | 10 +- eo/src/utils/eoGnuplot.cpp | 3 +- eo/src/utils/eoGnuplot1DMonitor.cpp | 2 +- eo/src/utils/eoHowMany.h | 6 +- eo/src/utils/eoIntBounds.cpp | 10 +- eo/src/utils/eoIntBounds.h | 37 +++---- eo/src/utils/eoOStreamMonitor.cpp | 4 +- eo/src/utils/eoParam.h | 5 +- eo/src/utils/eoParser.cpp | 4 +- eo/src/utils/eoRealBounds.cpp | 16 +-- eo/src/utils/eoRealBounds.h | 28 +++--- eo/src/utils/eoRealVectorBounds.h | 16 +-- eo/src/utils/eoRndGenerators.h | 3 +- eo/src/utils/eoStat.h | 2 +- eo/src/utils/eoState.cpp | 16 +-- eo/src/utils/eoUniformInit.h | 2 +- eo/src/utils/make_help.cpp | 6 +- eo/src/utils/rnd_generators.h | 5 +- eo/src/utils/selectors.h | 2 +- eo/test/fitness_traits.cpp | 10 +- eo/test/mpi/t-mpi-distrib-exp.cpp | 6 +- eo/test/mpi/t-mpi-multipleRoles.cpp | 2 +- eo/test/mpi/t-mpi-parallelApply.cpp | 2 +- eo/test/t-eoESFull.cpp | 2 +- eo/test/t-eoGenOp.cpp | 2 +- eo/test/t-eoInitPermutation.cpp | 2 +- eo/test/t-eoOrderXover.cpp | 2 +- eo/test/t-eoSelect.cpp | 4 +- eo/test/t-eoSharing.cpp | 2 +- eo/test/t-eoShiftMutation.cpp | 2 +- eo/test/t-eoSwapMutation.cpp | 2 +- eo/test/t-eoTwoOptMutation.cpp | 2 +- eo/tutorial/Lesson5/make_op_OneMax.h | 4 +- eo/tutorial/Templates/EO.tpl | 6 +- eo/tutorial/Templates/MyStructSEA.cpp | 6 +- eo/tutorial/Templates/make_op_MyStruct.h | 4 +- mo/src/continuator/moVectorMonitor.h | 4 +- mo/src/problems/bitString/moBitNeighbor.h | 2 +- mo/src/sampling/moSampling.h | 6 +- moeo/src/CMakeLists.txt | 2 +- moeo/src/algo/moeoEasyEA.h | 22 ++--- .../comparator/moeoOneObjectiveComparator.h | 2 +- moeo/src/core/MOEO.h | 6 +- moeo/src/core/moeoObjectiveVectorTraits.h | 8 +- moeo/src/core/moeoVector.h | 2 +- moeo/src/do/make_continue_moeo.h | 2 +- moeo/src/do/make_ea_moeo.h | 12 +-- .../moeoDominanceDepthFitnessAssignment.h | 2 +- .../explorer/moeoHCMoveLoopExpl.h | 2 +- .../explorer/moeoTSMoveLoopExpl.h | 2 +- moeo/src/utils/moeoBestObjVecStat.h | 2 +- .../flowshop/FlowShopBenchmarkParser.cpp | 3 +- .../examples/flowshop/make_op_FlowShop.h | 4 +- problems/eval/maxSATeval.h | 10 +- problems/eval/nkLandscapesEval.h | 16 +-- problems/eval/nkpLandscapesEval.h | 16 +-- problems/eval/nkqLandscapesEval.h | 18 ++-- problems/eval/qapEval.h | 4 +- problems/eval/ubqpEval.h | 6 +- smp/src/MWAlgo/eoEasyEA.cpp | 24 ++--- smp/src/MWAlgo/eoEasyPSO.cpp | 18 ++-- smp/src/MWAlgo/eoSyncEasyPSO.cpp | 18 ++-- smp/src/MWModel.cpp | 2 +- smp/src/topology/customBooleanTopology.cpp | 8 +- smp/src/topology/customStochasticTopology.cpp | 8 +- 127 files changed, 523 insertions(+), 417 deletions(-) diff --git a/edo/src/utils/edoFileSnapshot.cpp b/edo/src/utils/edoFileSnapshot.cpp index 1860ac0f1..32107b409 100644 --- a/edo/src/utils/edoFileSnapshot.cpp +++ b/edo/src/utils/edoFileSnapshot.cpp @@ -59,7 +59,7 @@ edoFileSnapshot::edoFileSnapshot(std::string dirname, if ( (res == -1) || (res == 127) ) { - throw std::runtime_error("Problem executing test of dir in eoFileSnapshot"); + throw eoSystemError(s, res); } // now make sure there is a dir without any genXXX file in it @@ -112,8 +112,8 @@ eoMonitor& edoFileSnapshot::operator()(void) if (!os) { - std::string str = "edoFileSnapshot: Could not open " + _currentFileName; - throw std::runtime_error(str); + // std::string str = "edoFileSnapshot: Could not open " + _currentFileName; + throw eoFileError(_currentFileName); } if ( _saveFilenames ) diff --git a/eo/src/EO.h b/eo/src/EO.h index 19708314f..490dd7d83 100644 --- a/eo/src/EO.h +++ b/eo/src/EO.h @@ -30,6 +30,7 @@ #include // std::runtime_error #include "eoObject.h" // eoObject #include "eoPersistent.h" // eoPersistent +#include "eoExceptions.h" /** @defgroup Core Core components @@ -73,13 +74,14 @@ public: /// Return fitness value. const Fitness& fitness() const { if (invalid()) - throw std::runtime_error("invalid fitness"); + throw eoInvalidFitnessError("Cannot retrieve unevaluated fitness"); return repFitness; } /// Get fitness as reference, useful when fitness is set in a multi-stage way, e.g., MOFitness gets performance information, is subsequently ranked Fitness& fitnessReference() { - if (invalid()) throw std::runtime_error("invalid fitness"); + if (invalid()) + throw eoInvalidFitnessError("Cannot retrieve unevaluated fitness reference"); return repFitness; } @@ -120,7 +122,7 @@ public: * The read and print methods should be compatible and have the same format. * In principle, format is "plain": they just print a number * @param _is a std::istream. - * @throw runtime_std::exception If a valid object can't be read. + * @throw eoInvalidFitnessError If a valid object can't be read. */ virtual void readFrom(std::istream& _is) { diff --git a/eo/src/PO.h b/eo/src/PO.h index c4225cf61..477f165c9 100644 --- a/eo/src/PO.h +++ b/eo/src/PO.h @@ -60,7 +60,7 @@ public: Fitness fitness () const { if (invalid ()) - throw std::runtime_error ("invalid fitness in PO.h"); + throw eoInvalidFitnessError("invalid fitness in PO.h"); return repFitness; } @@ -80,7 +80,7 @@ public: Fitness best () const { if (invalid ()) - throw std::runtime_error ("invalid best fitness in PO.h"); + throw eoInvalidFitnessError("invalid best fitness in PO.h"); return bestFitness; } diff --git a/eo/src/do/make_algo_easea.h b/eo/src/do/make_algo_easea.h index 3fadf05ec..bf5b8b188 100644 --- a/eo/src/do/make_algo_easea.h +++ b/eo/src/do/make_algo_easea.h @@ -183,7 +183,7 @@ eoAlgo & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF else { std::string stmp = std::string("Invalid selection: ") + ppSelect.first; - throw std::runtime_error(stmp.c_str()); + throw eoException(stmp.c_str()); } _state.storeFunctor(select); @@ -260,7 +260,7 @@ eoAlgo & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF } else { - throw std::runtime_error("Sorry, only deterministic tournament available at the moment"); + throw eoException("Sorry, only deterministic tournament available at the moment"); } } ptReplace = new eoMGGReplacement(-surviveParents, tSize); @@ -341,7 +341,7 @@ eoAlgo & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoPopEvalF } else // no replacement recognized { - throw std::runtime_error("Invalid replacement type " + replacementParam.first); + throw eoException("Invalid replacement type " + replacementParam.first); } ptReplace = & make_general_replacement( diff --git a/eo/src/do/make_algo_scalar.h b/eo/src/do/make_algo_scalar.h index 92e16d2f2..7819a4270 100644 --- a/eo/src/do/make_algo_scalar.h +++ b/eo/src/do/make_algo_scalar.h @@ -120,7 +120,7 @@ eoAlgo & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc else // parameter passed by user as DetTour(T) nicheSize = atof(ppSelect.second[0].c_str()); if (_dist == NULL) // no distance - throw std::runtime_error("You didn't specify a distance when calling make_algo_scalar and using sharing"); + throw eoException("You didn't specify a distance when calling make_algo_scalar and using sharing"); select = new eoSharingSelect(nicheSize, *_dist); } else if (ppSelect.first == std::string("StochTour")) @@ -206,7 +206,7 @@ eoAlgo & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc else { std::string stmp = std::string("Invalid selection: ") + ppSelect.first; - throw std::runtime_error(stmp.c_str()); + throw eoException(stmp.c_str()); } _state.storeFunctor(select); @@ -282,7 +282,7 @@ eoAlgo & do_make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc else { std::string stmp = std::string("Invalid replacement: ") + ppReplace.first; - throw std::runtime_error(stmp.c_str()); + throw eoException(stmp.c_str()); } _state.storeFunctor(replace); diff --git a/eo/src/do/make_continue.h b/eo/src/do/make_continue.h index f09bf8642..9d773fec1 100644 --- a/eo/src/do/make_continue.h +++ b/eo/src/do/make_continue.h @@ -156,7 +156,7 @@ eoContinue & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu // now check that there is at least one! if (!continuator) - throw std::runtime_error("You MUST provide a stopping criterion"); + throw eoException("You MUST provide a stopping criterion"); // OK, it's there: store in the eoState _state.storeFunctor(continuator); diff --git a/eo/src/do/make_general_replacement.h b/eo/src/do/make_general_replacement.h index 52c54ff6f..717cc668d 100644 --- a/eo/src/do/make_general_replacement.h +++ b/eo/src/do/make_general_replacement.h @@ -97,7 +97,7 @@ eoReduce & decode_reduce(eoParamParamType & _ppReduce, eoState & _state) { p = atof(_ppReduce.second[0].c_str()); if ( (p<=0.5) || (p>1) ) - throw std::runtime_error("Stochastic tournament size should be in [0.5,1]"); + throw eoException("Stochastic tournament size should be in [0.5,1]"); } ptReduce = new eoStochTournamentTruncate(p); @@ -110,7 +110,7 @@ eoReduce & decode_reduce(eoParamParamType & _ppReduce, eoState & _state) } else // no known reduction entered { - throw std::runtime_error("Unknown reducer: " + _ppReduce.first); + throw eoException("Unknown reducer: " + _ppReduce.first); } // all done, stores and return a reference _state.storeFunctor(ptReduce); diff --git a/eo/src/eoCtrlCContinue.h b/eo/src/eoCtrlCContinue.h index 37b665a10..b184ffcfe 100644 --- a/eo/src/eoCtrlCContinue.h +++ b/eo/src/eoCtrlCContinue.h @@ -56,7 +56,7 @@ public: { // First checks that no other eoCtrlCContinue does exist if (existCtrlCContinue) - throw std::runtime_error("A signal handler for Ctrl C is already defined!\n"); + throw eoParamException("A signal handler for Ctrl C is already defined!\n"); #ifndef _WINDOWS #ifdef SIGQUIT diff --git a/eo/src/eoEasyEA.h b/eo/src/eoEasyEA.h index d3fd2825a..effe81a14 100644 --- a/eo/src/eoEasyEA.h +++ b/eo/src/eoEasyEA.h @@ -261,8 +261,8 @@ template class eoEasyEA: public eoAlgo do { - try - { + // try + // { unsigned pSize = _pop.size(); offspring.clear(); // new offspring @@ -273,17 +273,17 @@ template class eoEasyEA: public eoAlgo replace(_pop, offspring); // after replace, the new pop. is in _pop if (pSize > _pop.size()) - throw std::runtime_error("Population shrinking!"); + throw eoException("Population shrinking!"); else if (pSize < _pop.size()) - throw std::runtime_error("Population growing!"); + throw eoException("Population growing!"); - } - catch (std::exception& e) - { - std::string s = e.what(); - s.append( " in eoEasyEA"); - throw std::runtime_error( s ); - } + // } + // catch (std::exception& e) + // { + // std::string s = e.what(); + // s.append( " in eoEasyEA"); + // throw std::runtime_error( s ); + // } } while ( continuator( _pop ) ); } diff --git a/eo/src/eoEasyPSO.h b/eo/src/eoEasyPSO.h index f1e00bf2a..87c27cad3 100644 --- a/eo/src/eoEasyPSO.h +++ b/eo/src/eoEasyPSO.h @@ -129,8 +129,8 @@ public: /// Apply a few iteration of flight to the population (=swarm). virtual void operator () (eoPop < POT > &_pop) { - try - { + // try + // { // initializes the topology, velocity, best particle(s) init(); do @@ -154,13 +154,13 @@ public: } while (continuator (_pop)); - } - catch (std::exception & e) - { - std::string s = e.what (); - s.append (" in eoEasyPSO"); - throw std::runtime_error (s); - } + // } + // catch (std::exception & e) + // { + // std::string s = e.what (); + // s.append (" in eoEasyPSO"); + // throw std::runtime_error (s); + // } } diff --git a/eo/src/eoEvalDump.h b/eo/src/eoEvalDump.h index 2f26ee327..7a7349360 100644 --- a/eo/src/eoEvalDump.h +++ b/eo/src/eoEvalDump.h @@ -105,8 +105,8 @@ protected: } #ifndef NDEBUG if ( !_of.is_open() ) { - std::string str = "Error, eoEvalDump could not open: " + _filename; - throw std::runtime_error( str ); + // std::string str = "Error, eoEvalDump could not open: " + _filename; + throw eoFileError( _filename ); } #endif // here, in release mode, we assume that the file could be opened diff --git a/eo/src/eoExceptions.h b/eo/src/eoExceptions.h index 476a064d6..b91bd6207 100644 --- a/eo/src/eoExceptions.h +++ b/eo/src/eoExceptions.h @@ -54,6 +54,69 @@ protected: const std::string _msg; }; + +class eoInvalidFitnessError : public eoException +{ +public: + eoInvalidFitnessError(std::string msg = "Invalid fitness") : eoException(msg) {} + ~eoInvalidFitnessError() throw() {} +}; + + +class eoPopSizeException : public eoException +{ +public: + eoPopSizeException(size_t size, std::string msg = "") : + eoException(), + _size(size), + _msg(msg) + {} + + virtual std::string message() const throw() + { + std::ostringstream oss; + oss << "Bad population size: " << _size; + if(_msg != "") { + oss << ", " << _msg; + } + return oss.str(); + } + + ~eoPopSizeException() throw() {} +protected: + const size_t _size; + const std::string _msg; +}; + + +class eoPopSizeChangeException : public eoPopSizeException +{ +public: + eoPopSizeChangeException(size_t size_from, size_t size_to, std::string msg="") : + eoPopSizeException(0), + _size_from(size_from), + _size_to(size_to), + _msg(msg) + {} + + virtual std::string message() const throw() + { + std::ostringstream oss; + oss << "Population size changed from " << _size_from << " to " << _size_to; + if(_msg != "") { + oss << ", " << _msg; + } + return oss.str(); + } + + ~eoPopSizeChangeException() throw() {} +protected: + const size_t _size_from; + const size_t _size_to; + const std::string _msg; +}; + + /** Base class for exceptions which need to stop the algorithm to be handled * * (like stopping criterion or numerical errors). @@ -110,7 +173,7 @@ public: virtual std::string message() const throw() { std::ostringstream msg; - msg << "STOP because the maximum number of allowed seconds has been reached (" + msg << "The maximum number of allowed seconds has been reached (" << _elapsed << ")"; return msg.str(); } @@ -140,7 +203,7 @@ public: virtual std::string message() const throw() { std::ostringstream msg; - msg << " the maximum number of evaluation has been reached (" + msg << "The maximum number of evaluation has been reached (" << _threshold << ")."; return msg.str(); } @@ -226,7 +289,7 @@ public: _cmd(cmd), _has_pipe(false), _err_code(-1), _output("") { } - eoSystemError(std::string cmd, int err_code, std::string output) : + eoSystemError(std::string cmd, int err_code, std::string output = "") : eoException(), _cmd(cmd), _has_pipe(true), _err_code(err_code), _output(output) { } @@ -234,10 +297,12 @@ public: virtual std::string message() const throw() { std::ostringstream ss; - ss << "System call: `" << _cmd << "` error"; + ss << "System call: `" << _cmd << "` ended with error"; if(_has_pipe) { - ss << " code #" << _err_code - << " with the following output:" << std::endl << _output; + ss << " code #" << _err_code; + if(_output != "") { + ss << " with the following output:" << std::endl << _output; + } } return ss.str(); } @@ -251,4 +316,24 @@ protected: const std::string _output; }; + +class eoFileError : public eoSystemError +{ +public: + eoFileError(std::string filename) : + eoSystemError(""), + _filename(filename) + { } + + virtual std::string message() const throw() + { + std::ostringstream oss; + oss << "Could not open file: " << _filename; + return oss.str(); + } + +protected: + std::string _filename; +}; + #endif // __eoExceptions_h__ diff --git a/eo/src/eoFlOrBinOp.h b/eo/src/eoFlOrBinOp.h index 343b2c738..a4f18128c 100644 --- a/eo/src/eoFlOrBinOp.h +++ b/eo/src/eoFlOrBinOp.h @@ -66,7 +66,7 @@ public : if (_eo1.size() != _eo2.size()) { string s = "Operand size don't match in " + className(); - throw runtime_error(s); + throw eoException(s); } bool changed = false; for ( unsigned i = 0; i < _eo1.size(); i++ ) { @@ -109,7 +109,7 @@ public : if (_eo1.size() != _eo2.size()) { string s = "Operand size don't match in " + className(); - throw runtime_error(s); + throw eoException(s); } bool changed = false; @@ -155,7 +155,7 @@ public : if (_eo1.size() != _eo2.size()) { string s = "Operand size don't match in " + className(); - throw runtime_error(s); + throw eoException(s); } bool hasChanged = false; for (unsigned i=0; i<_eo1.size(); i++) @@ -199,7 +199,7 @@ public : if (_eo1.size() != _eo2.size()) { string s = "Operand size don't match in " + className(); - throw runtime_error(s); + throw eoException(s); } bool hasChanged = false; unsigned where = eo::rng.random(_eo1.size()-1); diff --git a/eo/src/eoFlOrQuadOp.h b/eo/src/eoFlOrQuadOp.h index 1c0c805fd..f887d952a 100644 --- a/eo/src/eoFlOrQuadOp.h +++ b/eo/src/eoFlOrQuadOp.h @@ -101,7 +101,7 @@ public : if (_eo1.size() != _eo2.size()) { string s = "Operand size don't match in " + className(); - throw runtime_error(s); + throw eoException(s); } bool changed = false; @@ -146,7 +146,7 @@ public : if (_eo1.size() != _eo2.size()) { string s = "Operand size don't match in " + className(); - throw runtime_error(s); + throw eoException(s); } bool hasChanged = false; for (unsigned i=0; i<_eo1.size(); i++) @@ -191,7 +191,7 @@ public : if (_eo1.size() != _eo2.size()) { string s = "Operand size don't match in " + className(); - throw runtime_error(s); + throw eoException(s); } bool hasChanged = false; unsigned where = eo::rng.random(_eo1.size()-1); diff --git a/eo/src/eoG3Replacement.h b/eo/src/eoG3Replacement.h index c7cf20178..e9de717cc 100644 --- a/eo/src/eoG3Replacement.h +++ b/eo/src/eoG3Replacement.h @@ -71,7 +71,7 @@ public: if (_offspring.size() != toKeep) { std::cerr << "Les tailles " << _offspring.size() << " " << toKeep << std::endl; - throw std::runtime_error("eoG3Replacement: wrong number of remaining offspring"); + throw eoException("eoG3Replacement: wrong number of remaining offspring"); } // and put back into _parents plus(_offspring, _parents); diff --git a/eo/src/eoInit.h b/eo/src/eoInit.h index 9965af919..d9b4a0e30 100644 --- a/eo/src/eoInit.h +++ b/eo/src/eoInit.h @@ -33,6 +33,7 @@ #include "eoSTLFunctor.h" #include "utils/eoRndGenerators.h" #include "utils/rnd_generators.h" // for shuffle method +#include "eoExceptions.h" /** @@ -134,7 +135,7 @@ typedef typename EOT::AtomType AtomType; : offset(_minSize), extent(_maxSize - _minSize), init(_init) { if (_minSize >= _maxSize) - throw std::logic_error("eoInitVariableLength: minSize larger or equal to maxSize"); + throw eoException("eoInitVariableLength: minSize larger or equal to maxSize"); } diff --git a/eo/src/eoLinearTopology.h b/eo/src/eoLinearTopology.h index 027be1871..a9dff1e3c 100644 --- a/eo/src/eoLinearTopology.h +++ b/eo/src/eoLinearTopology.h @@ -67,7 +67,7 @@ public: if (neighborhoodSize >= _pop.size()){ std::string s; s.append (" Invalid neighborhood size in eoLinearTopology "); - throw std::runtime_error (s); + throw eoException(s); } unsigned howManyNeighborhood=_pop.size()/ neighborhoodSize; diff --git a/eo/src/eoMGGReplacement.h b/eo/src/eoMGGReplacement.h index 1e4c40f2d..d33ff6a06 100644 --- a/eo/src/eoMGGReplacement.h +++ b/eo/src/eoMGGReplacement.h @@ -71,7 +71,7 @@ public: unsigned toKeep = temp.size(); // how many to keep from merged populations // minimal check if (toKeep < 2) - throw std::runtime_error("Not enough parents killed in eoMGGReplacement"); + throw eoException("Not enough parents killed in eoMGGReplacement"); // select best offspring typename eoPop::iterator it = _offspring.it_best_element(); diff --git a/eo/src/eoMerge.h b/eo/src/eoMerge.h index 5870849cf..1564f3977 100644 --- a/eo/src/eoMerge.h +++ b/eo/src/eoMerge.h @@ -67,13 +67,13 @@ public : if (_interpret_as_rate) { if ( (_rate<0) || (_rate>1) ) - throw std::logic_error("eoElitism: rate shoud be in [0,1]"); + throw eoParamException("eoElitism: rate shoud be in [0,1]"); rate = _rate; } else { if (_rate<0) - throw std::logic_error("Negative number of offspring in eoElitism!"); + throw eoParamException("Negative number of offspring in eoElitism!"); combien = (unsigned int)_rate; if (combien != _rate) eo::log << eo::warnings << "Warning: Number of guys to merge in eoElitism was rounded" << std::endl; @@ -91,7 +91,7 @@ public : combienLocal = combien; if (combienLocal > _pop.size()) - throw std::logic_error("Elite larger than population"); + throw eoException("Elite larger than population"); std::vector result; _pop.nth_element(combienLocal, result); diff --git a/eo/src/eoNDSorting.h b/eo/src/eoNDSorting.h index b8315b458..fee6d1cb8 100644 --- a/eo/src/eoNDSorting.h +++ b/eo/src/eoNDSorting.h @@ -222,7 +222,7 @@ private : // Check whether the derived class was nice if (niche_count.size() != fronts[i].size()) { - throw std::logic_error("eoNDSorting: niche and front should have the same size"); + throw eoException("eoNDSorting: niche and front should have the same size"); } double max_niche = *std::max_element(niche_count.begin(), niche_count.end()); @@ -322,7 +322,7 @@ private : // Check whether the derived class was nice if (niche_count.size() != current_front.size()) { - throw std::logic_error("eoNDSorting: niche and front should have the same size"); + throw eoException("eoNDSorting: niche and front should have the same size"); } double max_niche = *std::max_element(niche_count.begin(), niche_count.end()); diff --git a/eo/src/eoOneToOneBreeder.h b/eo/src/eoOneToOneBreeder.h index 587dbce19..87470e0f1 100644 --- a/eo/src/eoOneToOneBreeder.h +++ b/eo/src/eoOneToOneBreeder.h @@ -95,7 +95,7 @@ class eoOneToOneBreeder: public eoBreed // check: only one offspring? unsigned posEnd = popit.tellp(); if (posEnd != pos) - throw std::runtime_error("Operator can only generate a SINGLE offspring in eoOneToOneBreeder"); + throw eoException("Operator can only generate a SINGLE offspring in eoOneToOneBreeder"); // do the tournament between parent and offspring eval(leOffspring); // first need to evaluate the offspring diff --git a/eo/src/eoPop.h b/eo/src/eoPop.h index 9213bca5c..ed2c09ef8 100644 --- a/eo/src/eoPop.h +++ b/eo/src/eoPop.h @@ -45,6 +45,7 @@ Authors: #include "eoPersistent.h" #include "eoInit.h" #include "utils/rnd_generators.h" // for shuffle method +#include "eoExceptions.h" /** A std::vector of EO object, to be used in all algorithms * (selectors, operators, replacements, ...). @@ -108,7 +109,7 @@ class eoPop: public std::vector, public eoObject, public eoPersistent unsigned oldSize = size(); if (_newPopSize < oldSize) { - throw std::runtime_error("New size smaller than old size in pop.append"); + throw eoPopSizeChangeException(oldSize, _newPopSize); return; } if (_newPopSize == oldSize) @@ -222,7 +223,7 @@ class eoPop: public std::vector, public eoObject, public eoPersistent typename eoPop::const_iterator it = std::max_element(begin(), end()); #endif if( it == end() ) - throw std::runtime_error("eoPop: Empty population, when calling best_element()."); + throw eoPopSizeException(this->size()); return (*it); } diff --git a/eo/src/eoProportionalSelect.h b/eo/src/eoProportionalSelect.h index 35dd3065c..8da608f6f 100644 --- a/eo/src/eoProportionalSelect.h +++ b/eo/src/eoProportionalSelect.h @@ -49,7 +49,7 @@ public: eoProportionalSelect(const eoPop& /*pop*/ = eoPop()) { if (minimizing_fitness()) - throw std::logic_error("eoProportionalSelect: minimizing fitness"); + throw eoException("eoProportionalSelect: minimizing fitness"); } void setup(const eoPop& _pop) diff --git a/eo/src/eoRandomRealWeightUp.h b/eo/src/eoRandomRealWeightUp.h index d135af93f..1adbca105 100644 --- a/eo/src/eoRandomRealWeightUp.h +++ b/eo/src/eoRandomRealWeightUp.h @@ -56,7 +56,7 @@ public: { std::string s; s.append (" min > max in eoRandomRealWeightUp"); - throw std::runtime_error (s); + throw eoException(s); } } diff --git a/eo/src/eoRanking.h b/eo/src/eoRanking.h index 65fbe87a4..63a031071 100644 --- a/eo/src/eoRanking.h +++ b/eo/src/eoRanking.h @@ -59,7 +59,7 @@ public: if (_eo == &(*it)) return it-_pop.begin(); } - throw std::runtime_error("Not found in eoLinearRanking"); + throw eoException("Not found in eoLinearRanking"); } /* COmputes the ranked fitness: fitnesses range in [m,M] @@ -74,7 +74,7 @@ public: unsigned int pSizeMinusOne = pSize-1; if (pSize <= 1) - throw std::runtime_error("Cannot do ranking with population of size <= 1"); + throw eoPopSizeException(pSize,"cannot do ranking with population of size <= 1"); // value() refers to the std::vector of worthes (we're in an eoParamvalue) value().resize(pSize); diff --git a/eo/src/eoReduce.h b/eo/src/eoReduce.h index c1039e47b..81c9b49a1 100644 --- a/eo/src/eoReduce.h +++ b/eo/src/eoReduce.h @@ -57,7 +57,7 @@ template class eoTruncate : public eoReduce if (_newgen.size() == _newsize) return; if (_newgen.size() < _newsize) - throw std::logic_error("eoTruncate: Cannot truncate to a larger size!\n"); + throw eoException("eoTruncate: Cannot truncate to a larger size!\n"); _newgen.sort(); _newgen.resize(_newsize); @@ -74,7 +74,7 @@ template class eoRandomReduce : public eoReduce if (_newgen.size() == _newsize) return; if (_newgen.size() < _newsize) - throw std::logic_error("eoRandomReduce: Cannot truncate to a larger size!\n"); + throw eoException("eoRandomReduce: Cannot truncate to a larger size!\n"); // shuffle the population, then trucate _newgen.shuffle(); @@ -123,7 +123,7 @@ public: if (presentSize == _newsize) return; if (presentSize < _newsize) - throw std::logic_error("eoTruncate: Cannot truncate to a larger size!\n"); + throw eoException("eoTruncate: Cannot truncate to a larger size!\n"); std::vector scores(presentSize); for (unsigned i=0; i if (oldSize == _newsize) return; if (oldSize < _newsize) - throw std::logic_error("eoLinearTruncate: Cannot truncate to a larger size!\n"); + throw eoException("eoLinearTruncate: Cannot truncate to a larger size!\n"); for (unsigned i=0; i::iterator it = _newgen.it_worse_element(); @@ -224,7 +224,7 @@ public: if (oldSize == _newsize) return; if (oldSize < _newsize) - throw std::logic_error("eoDetTournamentTruncate: Cannot truncate to a larger size!\n"); + throw eoException("eoDetTournamentTruncate: Cannot truncate to a larger size!\n"); // Now OK to erase some losers @@ -280,7 +280,7 @@ public: if (oldSize == _newsize) return; if (oldSize < _newsize) - throw std::logic_error("eoStochTournamentTruncate: Cannot truncate to a larger size!\n"); + throw eoException("eoStochTournamentTruncate: Cannot truncate to a larger size!\n"); // Now OK to erase some losers for (unsigned i=0; i void operator()(eoPop& _parents, eoPop& _offspring) { if (_parents.size() < _offspring.size()) - throw std::logic_error("eoReduceMerge: More offspring than parents!\n"); + throw eoPopSizeChangeException(_parents.size(), _offspring.size(),"more offspring than parents!"); reduce(_parents, _parents.size() - _offspring.size()); merge(_offspring, _parents); } diff --git a/eo/src/eoReduceMergeReduce.h b/eo/src/eoReduceMergeReduce.h index 0f7f0ad4c..d12a2b692 100644 --- a/eo/src/eoReduceMergeReduce.h +++ b/eo/src/eoReduceMergeReduce.h @@ -90,7 +90,7 @@ public: // then the offspring unsigned reducedOffspringSize = howManyReducedOffspring(offSize); if (!reducedOffspringSize) - throw std::runtime_error("No offspring left after reduction!"); + throw eoPopSizeException(reducedOffspringSize,"no offspring left after reduction!"); if (reducedOffspringSize != offSize) // need reduction reduceOffspring(_offspring, reducedOffspringSize); diff --git a/eo/src/eoReduceSplit.h b/eo/src/eoReduceSplit.h index a8640c039..b31008768 100644 --- a/eo/src/eoReduceSplit.h +++ b/eo/src/eoReduceSplit.h @@ -66,7 +66,7 @@ public: return ; unsigned newsize = popSize - eliminated; if (newsize < 0) - throw std::logic_error("eoTruncateSplit: Cannot truncate to a larger size!\n"); + throw eoException("eoTruncateSplit: Cannot truncate to a larger size!\n"); _newgen.nth_element(newsize); @@ -106,7 +106,7 @@ public: return ; long newsize = static_cast(popSize) - static_cast(eliminated); if (newsize < 0) - throw std::logic_error("eoLinearTruncateSplit: Cannot truncate to a larger size!\n"); + throw eoException("eoLinearTruncateSplit: Cannot truncate to a larger size!\n"); _eliminated.reserve(_eliminated.size()+eliminated); //in case not empty? for (unsigned i=0; i( rate ); } else { - throw std::runtime_error( "Incorrect selector type" ); + throw eoException( "Incorrect selector type" ); } } return selectPtr; diff --git a/eo/src/eoSelectFromWorth.h b/eo/src/eoSelectFromWorth.h index c6ba5c1e5..bbd0380a3 100644 --- a/eo/src/eoSelectFromWorth.h +++ b/eo/src/eoSelectFromWorth.h @@ -79,7 +79,7 @@ protected: std::vector fitness; void check_sync(unsigned index, const EOT& _eo) { if (fitness[index] != _eo.fitness()) { - throw std::runtime_error("eoSelectFromWorth: fitnesses are not in sync"); + throw eoException("eoSelectFromWorth: fitnesses are not in sync"); } } #endif diff --git a/eo/src/eoSequentialSelect.h b/eo/src/eoSequentialSelect.h index adf3cf452..53ffdd3b2 100644 --- a/eo/src/eoSequentialSelect.h +++ b/eo/src/eoSequentialSelect.h @@ -134,7 +134,7 @@ template class eoEliteSequentialSelect: public eoSelectOne unsigned int ibest = 0; const EOT * best = eoPters[0]; if (_pop.size() == 1) - throw std::runtime_error("Trying eoEliteSequentialSelect with only one individual!"); + throw eoException("Trying eoEliteSequentialSelect with only one individual!"); for (unsigned i=1; i<_pop.size(); i++) if (*eoPters[i]>*best) { diff --git a/eo/src/eoSharing.h b/eo/src/eoSharing.h index fa7583030..824bb20a4 100644 --- a/eo/src/eoSharing.h +++ b/eo/src/eoSharing.h @@ -26,6 +26,7 @@ #ifndef eoSharing_h #define eoSharing_h +#include "eoExceptions.h" #include "eoPerf2Worth.h" #include "utils/eoDistance.h" @@ -100,7 +101,7 @@ public: unsigned i, j, pSize=_pop.size(); if (pSize <= 1) - throw std::runtime_error("Apptempt to do sharing with population of size 1"); + throw eoPopSizeException(pSize, "attempt to do sharing with population of size 1"); value().resize(pSize); std::vector sim(pSize); // to hold the similarities dMatrix distMatrix(pSize); // to hold the distances diff --git a/eo/src/eoSimpleEDA.h b/eo/src/eoSimpleEDA.h index 0704b5722..ac815e1b7 100644 --- a/eo/src/eoSimpleEDA.h +++ b/eo/src/eoSimpleEDA.h @@ -73,21 +73,21 @@ template class eoSimpleEDA: public eoEDA eoPop pop(popSize, _distrib); do { - try - { + // try + // { apply(_distrib, pop); // re-init. of _pop from distrib apply(eval, pop); // eval of current population update(_distrib, pop); // updates distrib from _pop - } - catch (std::exception& e) - { - std::string s = e.what(); - s.append( " in eoSimpleEDA"); - throw std::runtime_error( s ); - } + // } + // catch (std::exception& e) + // { + // std::string s = e.what(); + // s.append( " in eoSimpleEDA"); + // throw std::runtime_error( s ); + // } } while ( continuator( pop ) ); } diff --git a/eo/src/eoSocialNeighborhood.h b/eo/src/eoSocialNeighborhood.h index 3f46b4a4e..315d105e8 100644 --- a/eo/src/eoSocialNeighborhood.h +++ b/eo/src/eoSocialNeighborhood.h @@ -94,7 +94,7 @@ public: else{ std::string s; s.append (" Invalid indice in eoSocialNeighborhood "); - throw std::runtime_error (s); + throw eoException(s); } } diff --git a/eo/src/eoStochasticUniversalSelect.h b/eo/src/eoStochasticUniversalSelect.h index 956bf62c7..e95f9eb0b 100644 --- a/eo/src/eoStochasticUniversalSelect.h +++ b/eo/src/eoStochasticUniversalSelect.h @@ -47,7 +47,7 @@ public: eoStochasticUniversalSelect(const eoPop& pop = eoPop()) { if (minimizing_fitness()) - throw std::logic_error("eoStochasticUniversalSelect: minimizing fitness"); + throw eoException("eoStochasticUniversalSelect: minimizing fitness"); } void setup(const eoPop& _pop) diff --git a/eo/src/eoSurviveAndDie.h b/eo/src/eoSurviveAndDie.h index 2ca4a3833..3e36ce54e 100644 --- a/eo/src/eoSurviveAndDie.h +++ b/eo/src/eoSurviveAndDie.h @@ -107,7 +107,7 @@ public: // carefull, we can have a rate of 1 if we want to kill all remaining unsigned nbDie = std::min(howmanyDie(pSize), pSize-nbSurvive); if (nbDie > nbRemaining) - throw std::logic_error("eoDeterministicSurviveAndDie: Too many to kill!\n"); + throw eoException("eoDeterministicSurviveAndDie: Too many to kill!\n"); if (!nbDie) { @@ -169,7 +169,7 @@ public: unsigned survivorSize = luckyOffspring.size() + luckyParents.size(); if (survivorSize > pSize) - throw std::logic_error("eoGeneralReplacement: More survivors than parents!\n"); + throw eoPopSizeChangeException(survivorSize, pSize, "more survivors than parents!"); plus(_parents, _offspring); // all that remain in _offspring diff --git a/eo/src/eoSwapMutation.h b/eo/src/eoSwapMutation.h index 58d3cf604..33d04ac8d 100644 --- a/eo/src/eoSwapMutation.h +++ b/eo/src/eoSwapMutation.h @@ -46,7 +46,7 @@ template class eoSwapMutation: public eoMonOp { // consistency check if(howManySwaps < 1) - throw std::runtime_error("Invalid number of swaps in eoSwapMutation"); + throw eoException("Invalid number of swaps in eoSwapMutation"); } /// The class name. diff --git a/eo/src/eoSyncEasyPSO.h b/eo/src/eoSyncEasyPSO.h index 64cf64724..11640af53 100644 --- a/eo/src/eoSyncEasyPSO.h +++ b/eo/src/eoSyncEasyPSO.h @@ -181,8 +181,8 @@ public: virtual void operator () (eoPop < POT > &_pop) { - try - { + // try + // { // initializes the topology, velocity, best particle(s) init(); @@ -206,13 +206,13 @@ public: } while (continuator (_pop)); - } - catch (std::exception & e) - { - std::string s = e.what (); - s.append (" in eoSyncEasyPSO"); - throw std::runtime_error (s); - } + // } + // catch (std::exception & e) + // { + // std::string s = e.what (); + // s.append (" in eoSyncEasyPSO"); + // throw std::runtime_error (s); + // } } diff --git a/eo/src/es/eoNormalMutation.h b/eo/src/es/eoNormalMutation.h index 48d09c6d5..266b10103 100644 --- a/eo/src/es/eoNormalMutation.h +++ b/eo/src/es/eoNormalMutation.h @@ -207,7 +207,7 @@ public: { // minimal check if (updateFactor>=1) - throw std::runtime_error("Update factor must be < 1 in eoOneFifthMutation"); + throw eoParamException("Update factor must be < 1 in eoOneFifthMutation"); } /** The class name */ diff --git a/eo/src/es/eoRealInitBounded.h b/eo/src/es/eoRealInitBounded.h index fa0259ec4..a011484a7 100644 --- a/eo/src/es/eoRealInitBounded.h +++ b/eo/src/es/eoRealInitBounded.h @@ -47,7 +47,7 @@ class eoRealInitBounded : public eoInit eoRealInitBounded(eoRealVectorBounds & _bounds):bounds(_bounds) { if (!bounds.isBounded()) - throw std::runtime_error("Needs bounded bounds to initialize a std::vector"); + throw eoException("Needs bounded bounds to initialize a std::vector"); } /** simply passes the argument to the uniform method of the bounds */ diff --git a/eo/src/es/eoRealOp.h b/eo/src/es/eoRealOp.h index 64b64101d..8c957413d 100644 --- a/eo/src/es/eoRealOp.h +++ b/eo/src/es/eoRealOp.h @@ -111,7 +111,7 @@ template class eoUniformMutation: public eoMonOp { // sanity check ? if (_eo.size() != bounds.size()) - throw std::runtime_error("Invalid size of indi in eoUniformMutation"); + throw eoException("Invalid size of indi in eoUniformMutation"); for (unsigned lieu=0; lieu<_eo.size(); lieu++) if (rng.flip(p_change[lieu])) @@ -213,7 +213,7 @@ template class eoDetUniformMutation: public eoMonOp { // sanity check ? if (_eo.size() != bounds.size()) - throw std::runtime_error("Invalid size of indi in eoDetUniformMutation"); + throw eoException("Invalid size of indi in eoDetUniformMutation"); for (unsigned i=0; i class eoHypercubeCrossover: public eoQuadOp bounds(eoDummyVectorNoBounds), alpha(_alpha), range(1+2*_alpha) { if (_alpha < 0) - throw std::runtime_error("BLX coefficient should be positive"); + throw eoParamException("BLX coefficient should be positive"); } /** @@ -373,7 +373,7 @@ template class eoHypercubeCrossover: public eoQuadOp bounds(_bounds), alpha(_alpha), range(1+2*_alpha) { if (_alpha < 0) - throw std::runtime_error("BLX coefficient should be positive"); + throw eoParamException("BLX coefficient should be positive"); } /// The class name. diff --git a/eo/src/es/make_algo_scalar_es.cpp b/eo/src/es/make_algo_scalar_es.cpp index e1bd1fb9d..3216a2f01 100644 --- a/eo/src/es/make_algo_scalar_es.cpp +++ b/eo/src/es/make_algo_scalar_es.cpp @@ -51,34 +51,34 @@ // Algo /////// -eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* _dist) +eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* /*_dist*/) { return do_make_algo_scalar(_parser, _state, _eval, _continue, _op); } -eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* _dist) +eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* /*_dist*/) { return do_make_algo_scalar(_parser, _state, _eval, _continue, _op); } ////////////// -eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* _dist) +eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* /*_dist*/) { return do_make_algo_scalar(_parser, _state, _eval, _continue, _op); } -eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* _dist) +eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* /*_dist*/) { return do_make_algo_scalar(_parser, _state, _eval, _continue, _op); } /////////////// -eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* _dist) +eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* /*_dist*/) { return do_make_algo_scalar(_parser, _state, _eval, _continue, _op); } -eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* _dist) +eoAlgo >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc >& _eval, eoContinue >& _continue, eoGenOp >& _op, eoDistance >* /*_dist*/) { return do_make_algo_scalar(_parser, _state, _eval, _continue, _op); } diff --git a/eo/src/es/make_genotype_real.h b/eo/src/es/make_genotype_real.h index 82b07db8f..7f86e6720 100644 --- a/eo/src/es/make_genotype_real.h +++ b/eo/src/es/make_genotype_real.h @@ -98,7 +98,7 @@ eoEsChromInit & do_make_genotype(eoParser& _parser, eoState& _state, EOT) is >> sigma; // minimum check if(sigma < 0) - throw std::runtime_error("Negative sigma in make_genotype"); + throw eoException("Negative sigma in make_genotype"); if(to_scale) init = new eoEsChromInit(boundsParam.value(), sigma, to_scale); else { diff --git a/eo/src/es/make_op.h b/eo/src/es/make_op.h index 35767b5df..b53022bfe 100644 --- a/eo/src/es/make_op.h +++ b/eo/src/es/make_op.h @@ -107,7 +107,7 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit proportional choice @@ -138,14 +138,14 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit 1) ) - throw std::runtime_error("Invalid pCross"); + throw eoParamException("Invalid pCross"); eoValueParam& pMutParam = _parser.getORcreateParam(0.1, "pMut", "Probability of Mutation", 'M', "Genetic Operators" ); // minimum check if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) ) - throw std::runtime_error("Invalid pMut"); + throw eoParamException("Invalid pMut"); // the crossovers ///////////////// @@ -156,7 +156,7 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit& arithmeticRateParam = _parser.getORcreateParam(double(2.0), "arithmeticRate", @@ -164,7 +164,7 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit & uniformMutRateParam = _parser.getORcreateParam(1.0, "uniformMutRate", "Relative rate for uniform mutation", 'u', "Genetic Operators" ); // minimum check if ( (uniformMutRateParam.value() < 0) ) - throw std::runtime_error("Invalid uniformMutRate"); + throw eoParamException("Invalid uniformMutRate"); eoValueParam & detMutRateParam = _parser.getORcreateParam(1.0, "detMutRate", @@ -217,7 +217,7 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit & normalMutRateParam = _parser.getORcreateParam(1.0, "normalMutRate", @@ -225,7 +225,7 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit & sigmaParam = _parser.getORcreateParam(1.0, "sigma", @@ -233,7 +233,7 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit *ptCombinedMonOp = NULL; diff --git a/eo/src/es/make_op_es.h b/eo/src/es/make_op_es.h index 0b78a724f..d52669489 100644 --- a/eo/src/es/make_op_es.h +++ b/eo/src/es/make_op_es.h @@ -88,7 +88,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'o', "Variation Operators"); if (operatorParam.value() != std::string("SGA")) - throw std::runtime_error("Sorry, only SGA-like operator available right now\n"); + throw eoException("Sorry, only SGA-like operator available right now\n"); // now we read Pcross and Pmut, // and create the eoGenOp that is exactly @@ -99,14 +99,14 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'C', "Variation Operators" ); // minimum check if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) ) - throw std::runtime_error("Invalid pCross"); + throw eoParamException("Invalid pCross"); eoValueParam& pMutParam = _parser.getORcreateParam(1.0, "pMut", "Probability of Mutation", 'M', "Variation Operators" ); // minimum check if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) ) - throw std::runtime_error("Invalid pMut"); + throw eoParamException("Invalid pMut"); // crossover @@ -140,7 +140,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< ptObjAtomCross = new eoDoubleIntermediate; else if (crossObjParam.value() == std::string("none")) ptObjAtomCross = new eoBinCloneOp; - else throw std::runtime_error("Invalid Object variable crossover type"); + else throw eoException("Invalid Object variable crossover type"); if (crossStdevParam.value() == std::string("discrete")) ptStdevAtomCross = new eoDoubleExchange; @@ -148,7 +148,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< ptStdevAtomCross = new eoDoubleIntermediate; else if (crossStdevParam.value() == std::string("none")) ptStdevAtomCross = new eoBinCloneOp; - else throw std::runtime_error("Invalid mutation strategy parameter crossover type"); + else throw eoException("Invalid mutation strategy parameter crossover type"); // and build the indi Xover if (crossTypeParam.value() == std::string("global")) @@ -160,7 +160,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< ); ptCross = new eoBinGenOp(crossTmp); } - else throw std::runtime_error("Invalide Object variable crossover type"); + else throw eoException("Invalide Object variable crossover type"); // now that everything is OK, DON'T FORGET TO STORE MEMORY _state.storeFunctor(ptObjAtomCross); diff --git a/eo/src/es/make_op_real.h b/eo/src/es/make_op_real.h index 198483a5a..0c202d767 100644 --- a/eo/src/es/make_op_real.h +++ b/eo/src/es/make_op_real.h @@ -89,7 +89,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'o', "Variation Operators"); if (operatorParam.value() != std::string("SGA")) - throw std::runtime_error("Sorry, only SGA-like operator available right now\n"); + throw eoException("Sorry, only SGA-like operator available right now\n"); // now we read Pcross and Pmut, // the relative weights for all crossovers -> proportional choice @@ -103,7 +103,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'C', "Variation Operators" ); // minimum check if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) ) - throw std::runtime_error("Invalid pCross"); + throw eoParamException("Invalid pCross"); eoValueParam& pMutParam = _parser.getORcreateParam(0.1, "pMut", @@ -111,7 +111,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'M', "Variation Operators" ); // minimum check if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) ) - throw std::runtime_error("Invalid pMut"); + throw eoParamException("Invalid pMut"); // the crossovers ///////////////// @@ -122,7 +122,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'a', "Variation Operators" ); // minimum check if ( (alphaParam.value() < 0) ) - throw std::runtime_error("Invalid BLX coefficient alpha"); + throw eoParamException("Invalid BLX coefficient alpha"); eoValueParam& segmentRateParam @@ -131,7 +131,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 's', "Variation Operators" ); // minimum check if ( (segmentRateParam.value() < 0) ) - throw std::runtime_error("Invalid segmentRate"); + throw eoParamException("Invalid segmentRate"); eoValueParam& hypercubeRateParam = _parser.getORcreateParam(double(1.0), "hypercubeRate", @@ -139,7 +139,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'A', "Variation Operators" ); // minimum check if ( (hypercubeRateParam.value() < 0) ) - throw std::runtime_error("Invalid hypercubeRate"); + throw eoParamException("Invalid hypercubeRate"); eoValueParam& uxoverRateParam = _parser.getORcreateParam(double(1.0), "uxoverRate", @@ -147,7 +147,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'A', "Variation Operators" ); // minimum check if ( (uxoverRateParam.value() < 0) ) - throw std::runtime_error("Invalid uxoverRate"); + throw eoParamException("Invalid uxoverRate"); // minimum check bool bCross = true; @@ -191,7 +191,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'e', "Variation Operators" ); // minimum check if ( (epsilonParam.value() < 0) ) - throw std::runtime_error("Invalid epsilon"); + throw eoParamException("Invalid epsilon"); eoValueParam & uniformMutRateParam = _parser.getORcreateParam(1.0, "uniformMutRate", @@ -199,7 +199,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'u', "Variation Operators" ); // minimum check if ( (uniformMutRateParam.value() < 0) ) - throw std::runtime_error("Invalid uniformMutRate"); + throw eoParamException("Invalid uniformMutRate"); eoValueParam & detMutRateParam = _parser.getORcreateParam(1.0, "detMutRate", @@ -207,14 +207,14 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< 'd', "Variation Operators" ); // minimum check if ( (detMutRateParam.value() < 0) ) - throw std::runtime_error("Invalid detMutRate"); + throw eoParamException("Invalid detMutRate"); eoValueParam & normalMutRateParam = _parser.getORcreateParam(1.0, "normalMutRate", "Relative rate for Gaussian mutation", 'd', "Variation Operators" ); // minimum check if ( (normalMutRateParam.value() < 0) ) - throw std::runtime_error("Invalid normalMutRate"); + throw eoParamException("Invalid normalMutRate"); eoValueParam & sigmaParam = _parser.getORcreateParam(0.3, "sigma", @@ -234,7 +234,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded< bMut = false; } if (!bCross && !bMut) - throw std::runtime_error("No operator called in SGA operator definition!!!"); + throw eoException("No operator called in SGA operator definition!!!"); // Create the CombinedMonOp eoPropCombinedMonOp *ptCombinedMonOp = NULL; diff --git a/eo/src/ga/make_PBILupdate.h b/eo/src/ga/make_PBILupdate.h index 34a062a96..43a04dd88 100644 --- a/eo/src/ga/make_PBILupdate.h +++ b/eo/src/ga/make_PBILupdate.h @@ -69,7 +69,7 @@ eoDistribUpdater & do_make_PBILupdate(eoParser & _parser, eoState& _state, ptUpdate = new eoPBILAdditive(LRBest, nbBest, tolerance, LRWorst, nbWorst); } else - throw std::runtime_error("Only PBIL additive update rule available at the moment"); + throw eoException("Only PBIL additive update rule available at the moment"); // done: don't forget to store the allocated pointers _state.storeFunctor(ptUpdate); diff --git a/eo/src/ga/make_op.h b/eo/src/ga/make_op.h index b8993f312..afe5a5bc9 100644 --- a/eo/src/ga/make_op.h +++ b/eo/src/ga/make_op.h @@ -78,7 +78,7 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoInit& _init eoValueParam& operatorParam = _parser.createParam(std::string("SGA"), "operator", "Description of the operator (SGA only now)", 'o', "Variation Operators"); if (operatorParam.value() != std::string("SGA")) - throw std::runtime_error("Only SGA-like operator available right now\n"); + throw eoException("Only SGA-like operator available right now\n"); // now we read Pcross and Pmut, // the relative weights for all crossovers -> proportional choice @@ -89,12 +89,12 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoInit& _init eoValueParam& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" ); // minimum check if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) ) - throw std::runtime_error("Invalid pCross"); + throw eoParamException("Invalid pCross"); eoValueParam& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" ); // minimum check if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) ) - throw std::runtime_error("Invalid pMut"); + throw eoParamException("Invalid pMut"); // the crossovers ///////////////// @@ -102,17 +102,17 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoInit& _init eoValueParam& onePointRateParam = _parser.createParam(double(1.0), "onePointRate", "Relative rate for one point crossover", '1', "Variation Operators" ); // minimum check if ( (onePointRateParam.value() < 0) ) - throw std::runtime_error("Invalid onePointRate"); + throw eoParamException("Invalid onePointRate"); eoValueParam& twoPointsRateParam = _parser.createParam(double(1.0), "twoPointRate", "Relative rate for two point crossover", '2', "Variation Operators" ); // minimum check if ( (twoPointsRateParam.value() < 0) ) - throw std::runtime_error("Invalid twoPointsRate"); + throw eoParamException("Invalid twoPointsRate"); eoValueParam& uRateParam = _parser.createParam(double(2.0), "uRate", "Relative rate for uniform crossover", 'U', "Variation Operators" ); // minimum check if ( (uRateParam.value() < 0) ) - throw std::runtime_error("Invalid uRate"); + throw eoParamException("Invalid uRate"); // minimum check // bool bCross = true; // not used ? @@ -149,29 +149,29 @@ eoGenOp & do_make_op(eoParser& _parser, eoState& _state, eoInit& _init eoValueParam & pMutPerBitParam = _parser.createParam(0.01, "pMutPerBit", "Probability of flipping 1 bit in bit-flip mutation", 'b', "Variation Operators" ); // minimum check if ( (pMutPerBitParam.value() < 0) || (pMutPerBitParam.value() > 0.5) ) - throw std::runtime_error("Invalid pMutPerBit"); + throw eoParamException("Invalid pMutPerBit"); eoValueParam & bitFlipRateParam = _parser.createParam(0.01, "bitFlipRate", "Relative rate for bit-flip mutation", 's', "Variation Operators" ); // minimum check if ( (bitFlipRateParam.value() < 0) ) - throw std::runtime_error("Invalid bitFlipRate"); + throw eoParamException("Invalid bitFlipRate"); // oneBitFlip eoValueParam & oneBitRateParam = _parser.createParam(0.01, "oneBitRate", "Relative rate for deterministic bit-flip mutation", 'd', "Variation Operators" ); // minimum check if ( (oneBitRateParam.value() < 0) ) - throw std::runtime_error("Invalid oneBitRate"); + throw eoParamException("Invalid oneBitRate"); // kBitFlip eoValueParam & kBitParam = _parser.createParam((unsigned)1, "kBit", "Number of bit for deterministic k bit-flip mutation", 0, "Variation Operators" ); // minimum check if ( ! kBitParam.value() ) - throw std::runtime_error("Invalid kBit"); + throw eoParamException("Invalid kBit"); eoValueParam & kBitRateParam = _parser.createParam(0.0, "kBitRate", "Relative rate for deterministic k bit-flip mutation", 0, "Variation Operators" ); // minimum check if ( (kBitRateParam.value() < 0) ) - throw std::runtime_error("Invalid kBitRate"); + throw eoParamException("Invalid kBitRate"); // minimum check // bool bMut = true; // not used ? diff --git a/eo/src/gp/eoParseTreeDepthInit.h b/eo/src/gp/eoParseTreeDepthInit.h index 6abe2e4ff..ba1cf1f5a 100644 --- a/eo/src/gp/eoParseTreeDepthInit.h +++ b/eo/src/gp/eoParseTreeDepthInit.h @@ -81,7 +81,7 @@ class eoParseTreeDepthInit : public eoInit< eoParseTree > { if(initializor.empty()) { - throw std::logic_error("eoParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?"); + throw eoException("eoParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?"); } // lets sort the initializor std::vector according to arity (so we can be sure the terminals are in front) // we use stable_sort so that if element i was in front of element j and they have the same arity i remains in front of j diff --git a/eo/src/gp/eoStParseTreeDepthInit.h b/eo/src/gp/eoStParseTreeDepthInit.h index aa7247dd8..54764b1b6 100644 --- a/eo/src/gp/eoStParseTreeDepthInit.h +++ b/eo/src/gp/eoStParseTreeDepthInit.h @@ -87,7 +87,7 @@ class eoStParseTreeDepthInit : public eoInit< eoParseTree > { if(_node.empty()) { - throw std::logic_error("eoStParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?"); + throw eoException("eoStParseTreeDepthInit: uhm, wouldn't you rather give a non-empty set of Nodes?"); } diff --git a/eo/src/mpi/eoParallelApply.h b/eo/src/mpi/eoParallelApply.h index dfb66e027..c85e5f7a8 100644 --- a/eo/src/mpi/eoParallelApply.h +++ b/eo/src/mpi/eoParallelApply.h @@ -102,7 +102,7 @@ namespace eo { if ( _packetSize <= 0 ) { - throw std::runtime_error("Packet size should not be negative."); + throw eoException("Packet size should not be negative."); } if( table ) diff --git a/eo/src/pyeo/PyEO.cpp b/eo/src/pyeo/PyEO.cpp index 8517c9aad..f29f13230 100644 --- a/eo/src/pyeo/PyEO.cpp +++ b/eo/src/pyeo/PyEO.cpp @@ -115,13 +115,13 @@ PyEO& pop_getitem(eoPop& pop, boost::python::object key) { boost::python::extract x(key); if (!x.check()) - throw index_error("Slicing not allowed"); + throw eoException("Slicing not allowed"); int i = x(); if (static_cast(i) >= pop.size()) { - throw index_error("Index out of bounds"); + throw eoException("Index out of bounds"); } return pop[i]; } @@ -130,13 +130,13 @@ void pop_setitem(eoPop& pop, boost::python::object key, PyEO& value) { boost::python::extract x(key); if (!x.check()) - throw index_error("Slicing not allowed"); + throw eoException("Slicing not allowed"); int i = x(); if (static_cast(i) >= pop.size()) { - throw index_error("Index out of bounds"); + throw eoException("Index out of bounds"); } pop[i] = value; diff --git a/eo/src/pyeo/PyEO.h b/eo/src/pyeo/PyEO.h index e9452800e..ba5cabd38 100644 --- a/eo/src/pyeo/PyEO.h +++ b/eo/src/pyeo/PyEO.h @@ -55,7 +55,7 @@ public : { if (which >= objective_info.size()) { - throw index_error("Too few elements allocated, resize objectives first"); + throw eoException("Too few elements allocated, resize objectives first"); } objective_info[which] = value; @@ -70,7 +70,7 @@ public : boost::python::extract x(object::operator[](i)); if (!x.check()) - throw std::runtime_error("PyFitness: does not contain doubles"); + throw eoException("PyFitness: does not contain doubles"); return x(); } diff --git a/eo/src/pyeo/monitors.cpp b/eo/src/pyeo/monitors.cpp index f64881659..814a4c859 100644 --- a/eo/src/pyeo/monitors.cpp +++ b/eo/src/pyeo/monitors.cpp @@ -42,7 +42,7 @@ public: { if (static_cast(i) >= vec.size()) { - throw index_error("Index out of bounds"); + throw eoException("Index out of bounds"); } return vec[i]->getValue(); diff --git a/eo/src/pyeo/statistics.cpp b/eo/src/pyeo/statistics.cpp index e48b6f2fa..df7504b51 100644 --- a/eo/src/pyeo/statistics.cpp +++ b/eo/src/pyeo/statistics.cpp @@ -35,7 +35,7 @@ const PyEO& popview_getitem(const std::vector& pop, int it) { unsigned item = unsigned(it); if (item > pop.size()) - throw index_error("too much"); + throw eoException("too much"); return *pop[item]; } diff --git a/eo/src/pyeo/valueParam.cpp b/eo/src/pyeo/valueParam.cpp index 6e4b06218..3d1a867e2 100644 --- a/eo/src/pyeo/valueParam.cpp +++ b/eo/src/pyeo/valueParam.cpp @@ -109,7 +109,7 @@ void setv< std::vector, numeric::array > { extract x(val[i]); if (!x.check()) - throw std::runtime_error("double expected"); + throw eoException("double expected"); v[i] = x(); } @@ -130,9 +130,9 @@ void setv< std::pair, tuple > extract second(val[1]); if (!first.check()) - throw std::runtime_error("doubles expected"); + throw eoException("doubles expected"); if (!second.check()) - throw std::runtime_error("doubles expected"); + throw eoException("doubles expected"); p.value().first = first(); p.value().second = second(); diff --git a/eo/src/utils/eoAssembledFitnessStat.h b/eo/src/utils/eoAssembledFitnessStat.h index 43e922f3f..c9cd7d464 100644 --- a/eo/src/utils/eoAssembledFitnessStat.h +++ b/eo/src/utils/eoAssembledFitnessStat.h @@ -63,7 +63,7 @@ public : virtual void operator()(const eoPop& _pop) { if( whichFitnessTerm >= _pop[0].fitness().size() ) - throw std::logic_error("Fitness term requested out of range"); + throw eoException("Fitness term requested out of range"); double result =0.0; unsigned count = 0; @@ -102,7 +102,7 @@ public: virtual void operator()(const eoPop& _pop) { if( whichFitnessTerm >= _pop[0].fitness().size() ) - throw std::logic_error("Fitness term requested out of range"); + throw eoException("Fitness term requested out of range"); value() = _pop.best_element().fitness()[whichFitnessTerm]; } diff --git a/eo/src/utils/eoFDCStat.h b/eo/src/utils/eoFDCStat.h index 69ce60072..75a49674a 100644 --- a/eo/src/utils/eoFDCStat.h +++ b/eo/src/utils/eoFDCStat.h @@ -135,7 +135,7 @@ public: /** just to be sure the add method is not called further */ virtual void add(const eoParam& ) - { throw std::runtime_error("eoFDCFileSnapshot::add(). Trying to add stats to an eoFDCFileSnapshot"); } + { throw eoException("eoFDCFileSnapshot::add(). Trying to add stats to an eoFDCFileSnapshot"); } private: eoFDCStat & FDCstat; diff --git a/eo/src/utils/eoFileMonitor.cpp b/eo/src/utils/eoFileMonitor.cpp index e1e58ba21..d504305a8 100644 --- a/eo/src/utils/eoFileMonitor.cpp +++ b/eo/src/utils/eoFileMonitor.cpp @@ -10,6 +10,7 @@ #include "eoFileMonitor.h" #include "compatibility.h" #include "eoParam.h" +#include "../eoExceptions.h" using namespace std; @@ -36,8 +37,8 @@ void eoFileMonitor::printHeader() if (!os) { - string str = "eoFileMonitor could not open: " + filename; - throw runtime_error(str); + // string str = "eoFileMonitor could not open: " + filename; + throw eoFileError(filename); } printHeader(os); @@ -54,8 +55,8 @@ eoMonitor& eoFileMonitor::operator()(void) if (!os) { - string str = "eoFileMonitor could not write to: " + filename; - throw runtime_error(str); + // string str = "eoFileMonitor could not write to: " + filename; + throw eoFileError(filename); } if ( diff --git a/eo/src/utils/eoFileMonitor.h b/eo/src/utils/eoFileMonitor.h index 0d23dcbf5..9711d7dcf 100644 --- a/eo/src/utils/eoFileMonitor.h +++ b/eo/src/utils/eoFileMonitor.h @@ -33,6 +33,7 @@ #include "eoMonitor.h" #include "../eoObject.h" +#include "../eoExceptions.h" /** Prints statistics to file @@ -75,8 +76,8 @@ public : std::ofstream os (filename.c_str ()); if (!os) { - std::string str = "Error, eoFileMonitor could not open: " + filename; - throw std::runtime_error (str); + // std::string str = "Error, eoFileMonitor could not open: " + filename; + throw eoFileError(filename); } } // if ! keep } diff --git a/eo/src/utils/eoFileSnapshot.h b/eo/src/utils/eoFileSnapshot.h index c474a9293..3c7095894 100644 --- a/eo/src/utils/eoFileSnapshot.h +++ b/eo/src/utils/eoFileSnapshot.h @@ -67,7 +67,7 @@ public : int res = system(s.c_str()); // test for (unlikely) errors if ( (res==-1) || (res==127) ) - throw std::runtime_error("Problem executing test of dir in eoFileSnapshot"); + throw eoSystemError(s, res); // now make sure there is a dir without any genXXX file in it if (res) // no dir present { @@ -122,8 +122,8 @@ public : if (!os) { - std::string str = "eoFileSnapshot: Could not open " + currentFileName; - throw std::runtime_error(str); + // std::string str = "eoFileSnapshot: Could not open " + currentFileName; + throw eoFileError(currentFileName);; } return operator()(os); @@ -151,7 +151,7 @@ public : ptParam = static_cast >* >(vec[1]); vv[i] = ptParam->value(); if (vv[i].size() != v.size()) - throw std::runtime_error("Dimension error in eoSnapshotMonitor"); + throw eoException("Dimension error in eoSnapshotMonitor"); } for (unsigned k=0; k >*>(&_param)) { - throw std::logic_error(std::string("eoFileSnapshot: I can only monitor std::vectors of doubles, sorry. The offending parameter name = ") + _param.longName()); + throw eoException(std::string("eoFileSnapshot: I can only monitor std::vectors of doubles, sorry. The offending parameter name = ") + _param.longName()); } eoMonitor::add(_param); } diff --git a/eo/src/utils/eoGnuplot.cpp b/eo/src/utils/eoGnuplot.cpp index 2905e6161..2a7fe5229 100644 --- a/eo/src/utils/eoGnuplot.cpp +++ b/eo/src/utils/eoGnuplot.cpp @@ -29,6 +29,7 @@ #include #include "eoGnuplot.h" +#include "../eoExceptions.h" unsigned eoGnuplot::numWindow=0; @@ -82,7 +83,7 @@ void eoGnuplot::initGnuPlot(std::string _title, std::string _extra) args[5] = 0; gpCom = PipeComOpenArgv( GNUPLOT_PROGRAM, args ); if(! gpCom ) - throw std::runtime_error("Cannot spawn gnuplot\n"); + throw eoSystemError(GNUPLOT_PROGRAM); else { PipeComSend( gpCom, "set grid\n" ); PipeComSend( gpCom, _extra.c_str() ); diff --git a/eo/src/utils/eoGnuplot1DMonitor.cpp b/eo/src/utils/eoGnuplot1DMonitor.cpp index ab54b1132..d63d19994 100644 --- a/eo/src/utils/eoGnuplot1DMonitor.cpp +++ b/eo/src/utils/eoGnuplot1DMonitor.cpp @@ -61,7 +61,7 @@ void eoGnuplot1DMonitor::FirstPlot() { if (this->vec.size() < 2) { - throw std::runtime_error("Must have some stats to plot!\n"); + throw eoException("Must have some stats to plot!\n"); } #ifdef HAVE_GNUPLOT std::ostringstream os; diff --git a/eo/src/utils/eoHowMany.h b/eo/src/utils/eoHowMany.h index 56c730f17..780439851 100644 --- a/eo/src/utils/eoHowMany.h +++ b/eo/src/utils/eoHowMany.h @@ -119,7 +119,7 @@ public: { unsigned int combloc = -count; if (_size= _value.size()) // nothing left to read - throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor"); + throw eoException("Syntax error in eoGeneralIntBounds Ctor"); // ending char: next {}() after posDeb size_t posFin = _value.find_first_of(beginOrClose,posDeb+1); if (posFin >= _value.size()) // not found - throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor"); + throw eoException("Syntax error in eoGeneralIntBounds Ctor"); // the bounds std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1); @@ -51,7 +51,7 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value) remove_leading(sBounds, delim); size_t posDelim = sBounds.find_first_of(delim); if (posDelim >= sBounds.size()) - throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor"); + throw eoException("Syntax error in eoGeneralIntBounds Ctor"); bool minBounded=false, maxBounded=false; long int minBound=0, maxBound=0; @@ -85,7 +85,7 @@ eoIntBounds* eoGeneralIntBounds::getBoundsFromString(std::string _value) if (minBounded && maxBounded) { if (maxBound <= minBound) - throw std::runtime_error("Syntax error in eoGeneralIntBounds Ctor"); + throw eoException("Syntax error in eoGeneralIntBounds Ctor"); locBound = new eoIntInterval(minBound, maxBound); } else if (!minBounded && !maxBounded) // no bound at all diff --git a/eo/src/utils/eoIntBounds.h b/eo/src/utils/eoIntBounds.h index 924d0e022..73b18548e 100644 --- a/eo/src/utils/eoIntBounds.h +++ b/eo/src/utils/eoIntBounds.h @@ -29,6 +29,7 @@ #include // std::exceptions! #include "eoRNG.h" +#include "../eoExceptions.h" /** \class eoIntBounds eoIntBounds.h es/eoIntBounds.h @@ -163,29 +164,29 @@ public: virtual long int minimum() const { - throw std::logic_error("Trying to get minimum of unbounded eoIntBounds"); + throw eoException("Trying to get minimum of unbounded eoIntBounds"); } virtual long int maximum() const { - throw std::logic_error("Trying to get maximum of unbounded eoIntBounds"); + throw eoException("Trying to get maximum of unbounded eoIntBounds"); } virtual long int range() const { - throw std::logic_error("Trying to get range of unbounded eoIntBounds"); + throw eoException("Trying to get range of unbounded eoIntBounds"); } virtual double uniform(eoRng & _rng = eo::rng) const { (void)_rng; - throw std::logic_error("Trying to generate uniform values in unbounded eoIntBounds"); + throw eoException("Trying to generate uniform values in unbounded eoIntBounds"); } virtual long int random(eoRng & _rng = eo::rng) const { (void)_rng; - throw std::logic_error("Trying to generate uniform values in unbounded eoIntBounds"); + throw eoException("Trying to generate uniform values in unbounded eoIntBounds"); } // methods from eoPersistent @@ -199,7 +200,7 @@ public: { (void)_is; - throw std::runtime_error("Should not use eoIntBounds::readFrom"); + throw eoException("Should not use eoIntBounds::readFrom"); } /** @@ -244,7 +245,7 @@ public : repMinimum(_min), repMaximum(_max), repRange(_max-_min) { if (repRange<=0) - throw std::logic_error("Void range in eoIntBounds"); + throw eoException("Void range in eoIntBounds"); } // accessors @@ -328,7 +329,7 @@ public : { (void)_is; - throw std::runtime_error("Should not use eoIntInterval::readFrom"); + throw eoException("Should not use eoIntInterval::readFrom"); } /** @@ -374,25 +375,25 @@ public : virtual long int maximum() const { - throw std::logic_error("Trying to get maximum of eoIntBelowBound"); + throw eoException("Trying to get maximum of eoIntBelowBound"); } virtual long int range() const { - throw std::logic_error("Trying to get range of eoIntBelowBound"); + throw eoException("Trying to get range of eoIntBelowBound"); } virtual double uniform(eoRng & _rng = eo::rng) const { (void)_rng; - throw std::logic_error("Trying to generate uniform values in eoIntBelowBound"); + throw eoException("Trying to generate uniform values in eoIntBelowBound"); } virtual long int random(eoRng & _rng = eo::rng) const { (void)_rng; - throw std::logic_error("Trying to generate uniform values in eoIntBelowBound"); + throw eoException("Trying to generate uniform values in eoIntBelowBound"); } // description @@ -437,7 +438,7 @@ public : { (void)_is; - throw std::runtime_error("Should not use eoIntBelowBound::readFrom"); + throw eoException("Should not use eoIntBelowBound::readFrom"); } /** @@ -482,25 +483,25 @@ public : virtual long int minimum() const { - throw std::logic_error("Trying to get minimum of eoIntAboveBound"); + throw eoException("Trying to get minimum of eoIntAboveBound"); } virtual long int range() const { - throw std::logic_error("Trying to get range of eoIntAboveBound"); + throw eoException("Trying to get range of eoIntAboveBound"); } virtual double uniform(eoRng & _rng = eo::rng) const { (void)_rng; - throw std::logic_error("Trying to generate uniform values in eoIntAboveBound"); + throw eoException("Trying to generate uniform values in eoIntAboveBound"); } virtual long int random(eoRng & _rng = eo::rng) const { (void)_rng; - throw std::logic_error("Trying to generate uniform values in eoIntAboveBound"); + throw eoException("Trying to generate uniform values in eoIntAboveBound"); } // description @@ -545,7 +546,7 @@ public : { (void)_is; - throw std::runtime_error("Should not use eoIntAboveBound::readFrom"); + throw eoException("Should not use eoIntAboveBound::readFrom"); } /** diff --git a/eo/src/utils/eoOStreamMonitor.cpp b/eo/src/utils/eoOStreamMonitor.cpp index af2bfcf63..b55cebf17 100644 --- a/eo/src/utils/eoOStreamMonitor.cpp +++ b/eo/src/utils/eoOStreamMonitor.cpp @@ -19,8 +19,8 @@ eoMonitor& eoOStreamMonitor::operator()(void) { if (!out) { - std::string str = "eoOStreamMonitor: Could not write to the output stream"; - throw std::runtime_error(str); + // std::string str = "eoOStreamMonitor: Could not write to the output stream"; + throw eoFileError("output stream"); } if (firsttime) { diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index d2c39efbd..969ea00a8 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -34,6 +34,7 @@ #include #include #include "../eoScalarFitness.h" +#include "../eoExceptions.h" /** @defgroup Parameters Parameters management * @@ -385,14 +386,14 @@ inline void eoValueParam >::setValue(const std: template <> inline std::string eoValueParam >::getValue(void) const { - throw std::runtime_error("I cannot getValue for a std::vector"); + throw eoException("I cannot getValue for a std::vector"); return std::string(""); } template <> inline void eoValueParam >::setValue(const std::string&) { - throw std::runtime_error("I cannot setValue for a std::vector"); + throw eoException("I cannot setValue for a std::vector"); return; } diff --git a/eo/src/utils/eoParser.cpp b/eo/src/utils/eoParser.cpp index 15a66105a..dc615bfa1 100644 --- a/eo/src/utils/eoParser.cpp +++ b/eo/src/utils/eoParser.cpp @@ -96,8 +96,8 @@ eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription, ifs.peek(); // check if it exists if (!ifs) { - string msg = string("Could not open response file: ") + pts; - throw runtime_error(msg); + // string msg = string("Could not open response file: ") + pts; + throw eoFileError(pts); } // read - will be overwritten by command-line readFrom(ifs); diff --git a/eo/src/utils/eoRealBounds.cpp b/eo/src/utils/eoRealBounds.cpp index 89dcb3584..bb3ac11a5 100644 --- a/eo/src/utils/eoRealBounds.cpp +++ b/eo/src/utils/eoRealBounds.cpp @@ -101,7 +101,7 @@ void eoRealVectorBounds::readFrom(std::string _value) size_t posFin = _value.find_first_of(std::string(closeChar)); if (posFin >= _value.size()) - throw std::runtime_error("Syntax error when reading bounds"); + throw eoException("Syntax error when reading bounds"); // y a-t-il un nbre devant unsigned count = 1; @@ -110,7 +110,7 @@ void eoRealVectorBounds::readFrom(std::string _value) std::string sCount = _value.substr(0, posDeb); count = read_int(sCount); if (count <= 0) - throw std::runtime_error("Syntax error when reading bounds"); + throw eoException("Syntax error when reading bounds"); } // the bounds @@ -121,7 +121,7 @@ void eoRealVectorBounds::readFrom(std::string _value) remove_leading(sBounds, delim); size_t posDelim = sBounds.find_first_of(delim); if (posDelim >= sBounds.size()) - throw std::runtime_error("Syntax error when reading bounds"); + throw eoException("Syntax error when reading bounds"); bool minBounded=false, maxBounded=false; double minBound=0, maxBound=0; @@ -192,17 +192,17 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value) std::string delim(",; "); std::string beginOrClose("[(])"); if (!remove_leading(_value, delim)) // only delimiters were left - throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor"); + throw eoException("Syntax error in eoGeneralRealBounds Ctor"); // look for opening char size_t posDeb = _value.find_first_of(beginOrClose); // allow ]a,b] if (posDeb >= _value.size()) // nothing left to read - throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor"); + throw eoException("Syntax error in eoGeneralRealBounds Ctor"); // ending char: next {}() after posDeb size_t posFin = _value.find_first_of(beginOrClose,posDeb+1); if (posFin >= _value.size()) // not found - throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor"); + throw eoException("Syntax error in eoGeneralRealBounds Ctor"); // the bounds std::string sBounds = _value.substr(posDeb+1, posFin-posDeb-1); @@ -212,7 +212,7 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value) remove_leading(sBounds, delim); size_t posDelim = sBounds.find_first_of(delim); if (posDelim >= sBounds.size()) - throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor"); + throw eoException("Syntax error in eoGeneralRealBounds Ctor"); bool minBounded=false, maxBounded=false; double minBound=0, maxBound=0; @@ -246,7 +246,7 @@ eoRealBounds* eoGeneralRealBounds::getBoundsFromString(std::string _value) if (minBounded && maxBounded) { if (maxBound <= minBound) - throw std::runtime_error("Syntax error in eoGeneralRealBounds Ctor"); + throw eoException("Syntax error in eoGeneralRealBounds Ctor"); locBound = new eoRealInterval(minBound, maxBound); } else if (!minBounded && !maxBounded) // no bound at all diff --git a/eo/src/utils/eoRealBounds.h b/eo/src/utils/eoRealBounds.h index 5d28c1741..c76031846 100644 --- a/eo/src/utils/eoRealBounds.h +++ b/eo/src/utils/eoRealBounds.h @@ -161,22 +161,22 @@ public: virtual double minimum() const { - throw std::logic_error("Trying to get minimum of unbounded eoRealBounds"); + throw eoException("Trying to get minimum of unbounded eoRealBounds"); } virtual double maximum() const { - throw std::logic_error("Trying to get maximum of unbounded eoRealBounds"); + throw eoException("Trying to get maximum of unbounded eoRealBounds"); } virtual double range() const { - throw std::logic_error("Trying to get range of unbounded eoRealBounds"); + throw eoException("Trying to get range of unbounded eoRealBounds"); } virtual double uniform(eoRng & _rng = eo::rng) const { (void)_rng; - throw std::logic_error("Trying to generate uniform values in unbounded eoRealBounds"); + throw eoException("Trying to generate uniform values in unbounded eoRealBounds"); } // methods from eoPersistent @@ -190,7 +190,7 @@ public: { (void)_is; - throw std::runtime_error("Should not use eoRealBounds::readFrom"); + throw eoException("Should not use eoRealBounds::readFrom"); } /** @@ -315,7 +315,7 @@ public : { (void)_is; - throw std::runtime_error("Should not use eoRealInterval::readFrom"); + throw eoException("Should not use eoRealInterval::readFrom"); } /** @@ -360,11 +360,11 @@ public : virtual double maximum() const { - throw std::logic_error("Trying to get maximum of eoRealBelowBound"); + throw eoException("Trying to get maximum of eoRealBelowBound"); } virtual double range() const { - throw std::logic_error("Trying to get range of eoRealBelowBound"); + throw eoException("Trying to get range of eoRealBelowBound"); } // random generators @@ -372,7 +372,7 @@ public : { (void)_rng; - throw std::logic_error("Trying to generate uniform values in eoRealBelowBound"); + throw eoException("Trying to generate uniform values in eoRealBelowBound"); } // description @@ -417,7 +417,7 @@ public : { (void)_is; - throw std::runtime_error("Should not use eoRealBelowBound::readFrom"); + throw eoException("Should not use eoRealBelowBound::readFrom"); } /** @@ -459,11 +459,11 @@ public : virtual double minimum() const { - throw std::logic_error("Trying to get minimum of eoRealAboveBound"); + throw eoException("Trying to get minimum of eoRealAboveBound"); } virtual double range() const { - throw std::logic_error("Trying to get range of eoRealAboveBound"); + throw eoException("Trying to get range of eoRealAboveBound"); } // random generators @@ -471,7 +471,7 @@ public : { (void)_rng; - throw std::logic_error("Trying to generate uniform values in eoRealAboveBound"); + throw eoException("Trying to generate uniform values in eoRealAboveBound"); } // description @@ -516,7 +516,7 @@ public : { (void)_is; - throw std::runtime_error("Should not use eoRealAboveBound::readFrom"); + throw eoException("Should not use eoRealAboveBound::readFrom"); } /** diff --git a/eo/src/utils/eoRealVectorBounds.h b/eo/src/utils/eoRealVectorBounds.h index 7fb880f53..d877853c2 100644 --- a/eo/src/utils/eoRealVectorBounds.h +++ b/eo/src/utils/eoRealVectorBounds.h @@ -250,7 +250,7 @@ public: eoRealBaseVectorBounds(), factor(1, _dim), ownedBounds(0) { if (_max-_min<=0) - throw std::logic_error("Void range in eoRealVectorBounds"); + throw eoException("Void range in eoRealVectorBounds"); eoRealBounds *ptBounds = new eoRealInterval(_min, _max); // handle memory once ownedBounds.push_back(ptBounds); @@ -265,7 +265,7 @@ public: factor(_min.size(), 1), ownedBounds(0) { if (_max.size() != _min.size()) - throw std::logic_error("Dimensions don't match in eoRealVectorBounds"); + throw eoException("Dimensions don't match in eoRealVectorBounds"); // the bounds eoRealBounds *ptBounds; for (unsigned i=0; i<_min.size(); i++) @@ -386,20 +386,20 @@ public: // accessors virtual double minimum(unsigned) { - throw std::logic_error("Trying to get minimum of eoRealVectorNoBounds"); + throw eoException("Trying to get minimum of eoRealVectorNoBounds"); } virtual double maximum(unsigned) { - throw std::logic_error("Trying to get maximum of eoRealVectorNoBounds"); + throw eoException("Trying to get maximum of eoRealVectorNoBounds"); } virtual double range(unsigned) { - throw std::logic_error("Trying to get range of eoRealVectorNoBounds"); + throw eoException("Trying to get range of eoRealVectorNoBounds"); } virtual double averageRange() { - throw std::logic_error("Trying to get average range of eoRealVectorNoBounds"); + throw eoException("Trying to get average range of eoRealVectorNoBounds"); } // random generators @@ -407,7 +407,7 @@ public: { (void)_rng; - throw std::logic_error("No uniform distribution on eoRealVectorNoBounds"); + throw eoException("No uniform distribution on eoRealVectorNoBounds"); } // fills a std::vector with uniformly chosen variables in bounds @@ -415,7 +415,7 @@ public: { (void)_rng; - throw std::logic_error("No uniform distribution on eoRealVectorNoBounds"); + throw eoException("No uniform distribution on eoRealVectorNoBounds"); } }; diff --git a/eo/src/utils/eoRndGenerators.h b/eo/src/utils/eoRndGenerators.h index 454845b17..d70143ff6 100644 --- a/eo/src/utils/eoRndGenerators.h +++ b/eo/src/utils/eoRndGenerators.h @@ -29,6 +29,7 @@ #ifndef eoRndGenerators_h #define eoRndGenerators_h +#include "../eoExceptions.h" #include "eoRNG.h" #include "../eoFunctor.h" #include @@ -80,7 +81,7 @@ template class eoUniformGenerator : public eoRndGenerator minim(_min), range(_max-_min), uniform(_rng) { if (_min>_max) - throw std::logic_error("Min is greater than Max in uniform_generator"); + throw eoException("Min is greater than Max in uniform_generator"); } /** diff --git a/eo/src/utils/eoStat.h b/eo/src/utils/eoStat.h index 5610ecbee..9803f66cd 100644 --- a/eo/src/utils/eoStat.h +++ b/eo/src/utils/eoStat.h @@ -251,7 +251,7 @@ public : virtual void operator()(const std::vector& _pop) { if (whichElement > _pop.size()) - throw std::logic_error("fitness requested of element outside of pop"); + throw eoException("fitness requested of element outside of pop"); doit(_pop, Fitness()); } diff --git a/eo/src/utils/eoState.cpp b/eo/src/utils/eoState.cpp index 884549244..0b70f533a 100644 --- a/eo/src/utils/eoState.cpp +++ b/eo/src/utils/eoState.cpp @@ -69,7 +69,7 @@ void eoState::registerObject(eoPersistent& registrant) } else { - throw logic_error("Interval error: object already present in the state"); + throw eoException("Interval error: object already present in the state"); } } @@ -79,8 +79,8 @@ void eoState::load(const string& _filename) if (!is) { - string str = "Could not open file " + _filename; - throw runtime_error(str); + // string str = "Could not open file " + _filename; + throw eoFileError(_filename); } load(is); @@ -96,8 +96,8 @@ void eoState::load(std::istream& is) if (is.fail()) { - string str = "Error while reading stream"; - throw runtime_error(str); + // string str = "Error while reading stream"; + throw eoFileError("stream"); } while(! is.eof()) @@ -127,7 +127,7 @@ void eoState::load(std::istream& is) while (getline(is, str)) { if (is.eof()) - throw runtime_error("No section in load file"); + throw eoException("No section in load file"); if (is_section(str, name)) break; @@ -154,8 +154,8 @@ void eoState::save(const string& filename) const if (!os) { - string msg = "Could not open file: " + filename + " for writing!"; - throw runtime_error(msg); + // string msg = "Could not open file: " + filename + " for writing!"; + throw eoFileError(filename); } save(os); diff --git a/eo/src/utils/eoUniformInit.h b/eo/src/utils/eoUniformInit.h index 8f4cd9d86..d338b2d78 100644 --- a/eo/src/utils/eoUniformInit.h +++ b/eo/src/utils/eoUniformInit.h @@ -82,7 +82,7 @@ template class eoUniformInit : public eoInit minim(_min), range(_max-_min), uniform(_rng) { if (_min>_max) - throw std::logic_error("Min is greater than Max in uniform_generator"); + throw eoParamException("Min is greater than Max in uniform_generator"); } /** diff --git a/eo/src/utils/make_help.cpp b/eo/src/utils/make_help.cpp index 6fb797eea..26644ea02 100644 --- a/eo/src/utils/make_help.cpp +++ b/eo/src/utils/make_help.cpp @@ -85,8 +85,8 @@ bool testDirRes(std::string _dirName, bool _erase=true) // test for (unlikely) errors if ( (res==-1) || (res==127) ) { - s = "Problem executing test of dir " + _dirName; - throw runtime_error(s); + // s = "Problem executing test of dir " + _dirName; + throw eoSystemError(s,res); } // now make sure there is a dir without any file in it - or quit if (res) // no dir present @@ -108,7 +108,7 @@ bool testDirRes(std::string _dirName, bool _erase=true) // WARNING: bug if dir exists and is empty; this says it is not! // shoudl use scandir instead - no time now :-((( MS Aug. 01 s = "Dir " + _dirName + " is not empty"; - throw runtime_error(s); + throw eoException(s); return true; } diff --git a/eo/src/utils/rnd_generators.h b/eo/src/utils/rnd_generators.h index d71caf803..60ff04b3f 100644 --- a/eo/src/utils/rnd_generators.h +++ b/eo/src/utils/rnd_generators.h @@ -31,6 +31,7 @@ #ifndef eoRND_GENERATORS_H #define eoRND_GENERATORS_H +#include "../eoExceptions.h" #include "eoRNG.h" #include @@ -56,7 +57,7 @@ template class uniform_generator minim(_min), range(_max-_min), uniform(_rng) { if (_min>_max) - throw std::logic_error("Min is greater than Max in uniform_generator"); + throw eoParamException("Min is greater than Max in uniform_generator"); } T operator()(void) { return minim+static_cast(uniform.uniform(range)); } @@ -99,7 +100,7 @@ template class random_generator minim(_min), range(_max-_min), random(_rng) { if (_min>_max) - throw std::logic_error("Min is greater than Max in random_generator"); + throw eoParamException("Min is greater than Max in random_generator"); } T operator()(void) { return (T) (minim + random.random(range)); } diff --git a/eo/src/utils/selectors.h b/eo/src/utils/selectors.h index 43992ac3c..8805fb132 100644 --- a/eo/src/utils/selectors.h +++ b/eo/src/utils/selectors.h @@ -89,7 +89,7 @@ double sum_fitness(It begin, It end) { double v = static_cast(begin->fitness()); if (v < 0.0) - throw std::logic_error("sum_fitness: negative fitness value encountered"); + throw eoInvalidFitnessError("sum_fitness: negative fitness value encountered"); sum += v; } diff --git a/eo/test/fitness_traits.cpp b/eo/test/fitness_traits.cpp index 4af0e34bb..2db7ea88f 100644 --- a/eo/test/fitness_traits.cpp +++ b/eo/test/fitness_traits.cpp @@ -133,7 +133,7 @@ public : performance_type performance(void) const { - if(!valid_performance) throw runtime_error("no performance"); + if(!valid_performance) throw eoException("no performance"); return Traits::get_performance(rep_fitness); } @@ -145,8 +145,8 @@ public : worth_type worth(void) const { - if(!valid_worth) throw runtime_error("no worth"); - if(!Traits::needs_mapping) throw runtime_error("no mapping"); + if(!valid_worth) throw eoException("no worth"); + if(!Traits::needs_mapping) throw eoException("no mapping"); return Traits::get_worth(rep_fitness); } @@ -236,14 +236,14 @@ public : { if (!fitness_traits::needs_mapping) { - throw runtime_error("eoPop: no scaling needed, yet a scaling function is defined"); + throw eoException("eoPop: no scaling needed, yet a scaling function is defined"); } (*p2w)(*this); } else if (fitness_traits::needs_mapping) { - throw runtime_error("eoPop: no scaling function attached to the population, while one was certainly called for"); + throw eoException("eoPop: no scaling function attached to the population, while one was certainly called for"); } } diff --git a/eo/test/mpi/t-mpi-distrib-exp.cpp b/eo/test/mpi/t-mpi-distrib-exp.cpp index 46a4efa57..d3278fcad 100644 --- a/eo/test/mpi/t-mpi-distrib-exp.cpp +++ b/eo/test/mpi/t-mpi-distrib-exp.cpp @@ -374,7 +374,7 @@ class Experiment : public eoserial::Persistent } else if( distribName == "exponential" ) { _distribution = & exponentialDistribution; } else { - throw std::runtime_error("When unpacking experience, no distribution found."); + throw eoException("When unpacking experience, no distribution found."); } eoserial::unpackObject( *obj, "distribution", *_distribution ); @@ -503,7 +503,7 @@ int main( int argc, char** argv ) { if( isChosenDistrib ) { - throw std::runtime_error("Only one distribution can be chosen during a launch!"); + throw eoException("Only one distribution can be chosen during a launch!"); } else { isChosenDistrib = true; @@ -517,7 +517,7 @@ int main( int argc, char** argv ) if( !isChosenDistrib ) { - throw std::runtime_error("No distribution chosen. One distribution should be chosen."); + throw eoException("No distribution chosen. One distribution should be chosen."); } Experiment e( pdistrib, size, packet_size, worker_print_waiting_time, seed, fileName ); diff --git a/eo/test/mpi/t-mpi-multipleRoles.cpp b/eo/test/mpi/t-mpi-multipleRoles.cpp index 3a525126b..e0ca7ed68 100644 --- a/eo/test/mpi/t-mpi-multipleRoles.cpp +++ b/eo/test/mpi/t-mpi-multipleRoles.cpp @@ -130,7 +130,7 @@ int main(int argc, char** argv) // eo::log << eo::setlevel( eo::debug ); Node::init( argc, argv ); if( Node::comm().size() != 7 ) { - throw std::runtime_error("World size should be 7."); + throw eoException("World size should be 7."); } SerializableVector< SerializableBase > v; diff --git a/eo/test/mpi/t-mpi-parallelApply.cpp b/eo/test/mpi/t-mpi-parallelApply.cpp index 559505bd1..efe8b2364 100644 --- a/eo/test/mpi/t-mpi-parallelApply.cpp +++ b/eo/test/mpi/t-mpi-parallelApply.cpp @@ -105,7 +105,7 @@ int main(int argc, char** argv) const int ALL = Node::comm().size(); if( ALL < 3 ) { - throw std::runtime_error("Needs at least 3 processes to be launched!"); + throw eoException("Needs at least 3 processes to be launched!"); } // Tests are auto described thanks to member "description" diff --git a/eo/test/t-eoESFull.cpp b/eo/test/t-eoESFull.cpp index 7c5e84d99..d2f84adfb 100644 --- a/eo/test/t-eoESFull.cpp +++ b/eo/test/t-eoESFull.cpp @@ -120,7 +120,7 @@ void runAlgorithm(EOT, eoParser& _parser, eoState& _state, eoRealVectorBounds& _ if (lambda_rate.value() < 1.0f) { - throw logic_error("lambda_rate must be larger than 1 in a comma strategy"); + throw eoParamException("lambda_rate must be larger than 1 in a comma strategy"); } // Initialization diff --git a/eo/test/t-eoGenOp.cpp b/eo/test/t-eoGenOp.cpp index c959a3bb9..7a6f6b7bc 100644 --- a/eo/test/t-eoGenOp.cpp +++ b/eo/test/t-eoGenOp.cpp @@ -174,7 +174,7 @@ void init(eoPop & _pop, unsigned _pSize) } else { - throw std::runtime_error("init pop with 0 size"); + throw eoPopSizeException(_pSize,"init pop with 0 size"); } for (unsigned i=0; i<_pSize; i++) { diff --git a/eo/test/t-eoInitPermutation.cpp b/eo/test/t-eoInitPermutation.cpp index e4a683b15..4b64f3576 100644 --- a/eo/test/t-eoInitPermutation.cpp +++ b/eo/test/t-eoInitPermutation.cpp @@ -32,7 +32,7 @@ bool check_permutation(const Chrom & _chrom) std::cout << " Error: Wrong permutation !" << std::endl; std::string s; s.append( " Wrong permutation in t-eoInitPermutation"); - throw std::runtime_error( s ); + throw eoException( s ); } return true; } diff --git a/eo/test/t-eoOrderXover.cpp b/eo/test/t-eoOrderXover.cpp index 32e44dad9..71453c59b 100644 --- a/eo/test/t-eoOrderXover.cpp +++ b/eo/test/t-eoOrderXover.cpp @@ -23,7 +23,7 @@ bool check_permutation(const Chrom& _chrom){ std::cout << " Error: Wrong permutation !" << std::endl; std::string s; s.append( " Wrong permutation in t-eoShiftMutation"); - throw std::runtime_error( s ); + throw eoException( s ); return false; } } diff --git a/eo/test/t-eoSelect.cpp b/eo/test/t-eoSelect.cpp index 23d76c48c..400f6725d 100644 --- a/eo/test/t-eoSelect.cpp +++ b/eo/test/t-eoSelect.cpp @@ -64,7 +64,7 @@ void testSelectMany(eoSelect & _select, std::string _name) { unsigned trouve = isInPop(offspring[i], parents); if (trouve == parents.size()) // pas trouve - throw std::runtime_error("Pas trouve ds parents"); + throw eoException("Pas trouve ds parents"); nb[trouve]++; } // dump to file so you can plot using gnuplot - dir name is hardcoded! @@ -149,7 +149,7 @@ eoValueParam tournamentSizeParam = parser.createParam(unsigned(2), "to parentsOrg[pSize-1].fitness(10*pSize); } else - throw std::runtime_error("Invalid fitness Type"+fitnessType); + throw eoInvalidFitnessError("Invalid fitness Type"+fitnessType); std::cout << "Initial parents (odd)\n" << parentsOrg << std::endl; diff --git a/eo/test/t-eoSharing.cpp b/eo/test/t-eoSharing.cpp index 86721b098..fee072b75 100644 --- a/eo/test/t-eoSharing.cpp +++ b/eo/test/t-eoSharing.cpp @@ -86,7 +86,7 @@ void testSelectMany(eoSelect & _select, std::string _name) { unsigned trouve = isInPop(offspring[i], parents); if (trouve == parents.size()) // pas trouve - throw std::runtime_error("Pas trouve ds parents"); + throw eoException("Pas trouve ds parents"); nb[trouve]++; } // dump to file so you can plot using gnuplot - dir name is hardcoded! diff --git a/eo/test/t-eoShiftMutation.cpp b/eo/test/t-eoShiftMutation.cpp index 15c4e6b92..2106233d1 100644 --- a/eo/test/t-eoShiftMutation.cpp +++ b/eo/test/t-eoShiftMutation.cpp @@ -32,7 +32,7 @@ bool check_permutation(const Chrom& _chrom){ std::cout << " Error: Wrong permutation !" << std::endl; std::string s; s.append( " Wrong permutation in t-eoShiftMutation"); - throw std::runtime_error( s ); + throw eoException( s ); return false; } } diff --git a/eo/test/t-eoSwapMutation.cpp b/eo/test/t-eoSwapMutation.cpp index 3099d7075..38601fd2d 100644 --- a/eo/test/t-eoSwapMutation.cpp +++ b/eo/test/t-eoSwapMutation.cpp @@ -33,7 +33,7 @@ bool check_permutation(const Chrom& _chrom){ std::cout << " Error: Wrong permutation !" << std::endl; std::string s; s.append( " Wrong permutation in t-eoShiftMutation"); - throw std::runtime_error( s ); + throw eoException( s ); return false; } } diff --git a/eo/test/t-eoTwoOptMutation.cpp b/eo/test/t-eoTwoOptMutation.cpp index 60ef89a15..7d53b77d4 100644 --- a/eo/test/t-eoTwoOptMutation.cpp +++ b/eo/test/t-eoTwoOptMutation.cpp @@ -33,7 +33,7 @@ bool check_permutation(const Chrom& _chrom){ std::cout << " Error: Wrong permutation !" << std::endl; std::string s; s.append( " Wrong permutation in t-eoShiftMutation"); - throw std::runtime_error( s ); + throw eoException( s ); return false; } } diff --git a/eo/tutorial/Lesson5/make_op_OneMax.h b/eo/tutorial/Lesson5/make_op_OneMax.h index e157720fa..d8c5ed853 100644 --- a/eo/tutorial/Lesson5/make_op_OneMax.h +++ b/eo/tutorial/Lesson5/make_op_OneMax.h @@ -182,12 +182,12 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" ); // minimum check if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) ) - throw runtime_error("Invalid pCross"); + throw eoParamException("Invalid pCross"); eoValueParam& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" ); // minimum check if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) ) - throw runtime_error("Invalid pMut"); + throw eoParamException("Invalid pMut"); // the crossover - with probability pCross diff --git a/eo/tutorial/Templates/EO.tpl b/eo/tutorial/Templates/EO.tpl index 959ad56a8..b5cd2a162 100644 --- a/eo/tutorial/Templates/EO.tpl +++ b/eo/tutorial/Templates/EO.tpl @@ -215,12 +215,12 @@ try { double pCross = parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" ).value(); // minimum check if ( (pCross < 0) || (pCross > 1) ) - throw runtime_error("Invalid pCross"); + throw eoParamException("Invalid pCross"); double pMut = parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" ).value(); // minimum check if ( (pMut < 0) || (pMut > 1) ) - throw runtime_error("Invalid pMut"); + throw eoParamException("Invalid pMut"); // now create the generalOp eoSGAGenOp op(cross, pCross, mut, pMut); @@ -827,7 +827,7 @@ eoContinue & do_make_continue(eoParser& _parser, eoState& _state, eoEvalFu // now check that there is at least one! if (!continuator) - throw runtime_error("You MUST provide a stopping criterion"); + throw eoException("You MUST provide a stopping criterion"); // OK, it's there: store in the eoState _state.storeFunctor(continuator); diff --git a/eo/tutorial/Templates/MyStructSEA.cpp b/eo/tutorial/Templates/MyStructSEA.cpp index 5a05169ea..30dd296f0 100644 --- a/eo/tutorial/Templates/MyStructSEA.cpp +++ b/eo/tutorial/Templates/MyStructSEA.cpp @@ -206,12 +206,12 @@ try double pCross = parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" ).value(); // minimum check if ( (pCross < 0) || (pCross > 1) ) - throw runtime_error("Invalid pCross"); + throw eoParamException("Invalid pCross"); double pMut = parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" ).value(); // minimum check if ( (pMut < 0) || (pMut > 1) ) - throw runtime_error("Invalid pMut"); + throw eoParamException("Invalid pMut"); // now create the generalOp eoSGAGenOp op(cross, pCross, mut, pMut); @@ -278,7 +278,7 @@ try // first check the directory (and creates it if not exists already): if (fileMyStructStat || plotMyStructStat) if (! testDirRes(dirName, true) ) - throw runtime_error("Problem with resDir"); + throw eoParamException("Problem with resDir"); // should we write it to a file ? if (fileMyStructStat) diff --git a/eo/tutorial/Templates/make_op_MyStruct.h b/eo/tutorial/Templates/make_op_MyStruct.h index d857e8958..e37dfd6fd 100644 --- a/eo/tutorial/Templates/make_op_MyStruct.h +++ b/eo/tutorial/Templates/make_op_MyStruct.h @@ -182,12 +182,12 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit& pCrossParam = _parser.createParam(0.6, "pCross", "Probability of Crossover", 'C', "Variation Operators" ); // minimum check if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) ) - throw runtime_error("Invalid pCross"); + throw eoParamException("Invalid pCross"); eoValueParam& pMutParam = _parser.createParam(0.1, "pMut", "Probability of Mutation", 'M', "Variation Operators" ); // minimum check if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) ) - throw runtime_error("Invalid pMut"); + throw eoParamException("Invalid pMut"); // the crossover - with probability pCross diff --git a/mo/src/continuator/moVectorMonitor.h b/mo/src/continuator/moVectorMonitor.h index 853096448..67535219d 100644 --- a/mo/src/continuator/moVectorMonitor.h +++ b/mo/src/continuator/moVectorMonitor.h @@ -263,8 +263,8 @@ public: if (!os) { - std::string str = "moVectorMonitor: Could not open " + _filename; - throw std::runtime_error(str); + // std::string str = "moVectorMonitor: Could not open " + _filename; + throw eoFileError(_filename);; } for (unsigned int i = 0; i < size(); i++) { diff --git a/mo/src/problems/bitString/moBitNeighbor.h b/mo/src/problems/bitString/moBitNeighbor.h index 28cda0093..87f124c44 100644 --- a/mo/src/problems/bitString/moBitNeighbor.h +++ b/mo/src/problems/bitString/moBitNeighbor.h @@ -89,7 +89,7 @@ public: int pos = _is.tellg(); _is >> fitness_str; if (fitness_str == "INVALID") { - throw std::runtime_error("invalid fitness"); + throw eoInvalidFitnessError("invalid fitness"); } else { Fitness repFit; _is.seekg(pos); diff --git a/mo/src/sampling/moSampling.h b/mo/src/sampling/moSampling.h index c2db1fa73..90dee4707 100644 --- a/mo/src/sampling/moSampling.h +++ b/mo/src/sampling/moSampling.h @@ -156,8 +156,8 @@ public: os.open(_filename.c_str(), std::ios::app); if (!os) { - std::string str = "moSampling: Could not open " + _filename; - throw std::runtime_error(str); + // std::string str = "moSampling: Could not open " + _filename; + throw eoFileError(_filename); } // set the precision of the output @@ -199,7 +199,7 @@ public: void fileExport(unsigned int _col, std::string _filename, bool _openFile=false) { if (_col >= monitorVec.size()) { std::string str = "moSampling: Could not export into file the vector. The index does not exists (too large)"; - throw std::runtime_error(str); + throw eoException(str); } monitorVec[_col]->precision(precisionOutput); diff --git a/moeo/src/CMakeLists.txt b/moeo/src/CMakeLists.txt index c06351346..e98d91e4e 100644 --- a/moeo/src/CMakeLists.txt +++ b/moeo/src/CMakeLists.txt @@ -1,7 +1,7 @@ ###################################################################################### ### 0) Include directories ###################################################################################### -include_directories(${EO_SRC_DIR}) +include_directories(${EO_SRC_DIR}/src) include_directories(${MO_SRC_DIR}/src) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/moeo/src/algo/moeoEasyEA.h b/moeo/src/algo/moeoEasyEA.h index 8155bfaaa..5169b3c0a 100644 --- a/moeo/src/algo/moeoEasyEA.h +++ b/moeo/src/algo/moeoEasyEA.h @@ -132,8 +132,8 @@ public: bool firstTime = true; do { - try - { + // try + // { unsigned int pSize = _pop.size(); offspring.clear(); // new offspring // fitness and diversity assignment (if you want to or if it is the first generation) @@ -150,19 +150,19 @@ public: replace(_pop, offspring); // after replace, the new pop. is in _pop if (pSize > _pop.size()) { - throw std::runtime_error("Population shrinking!"); + throw eoPopSizeChangeException(_pop.size(), pSize,"Population shrinking!"); } else if (pSize < _pop.size()) { - throw std::runtime_error("Population growing!"); + throw eoPopSizeChangeException(_pop.size(), pSize,"Population growing!"); } - } - catch (std::exception& e) - { - std::string s = e.what(); - s.append( " in moeoEasyEA"); - throw std::runtime_error( s ); - } + // } + // catch (std::exception& e) + // { + // std::string s = e.what(); + // s.append( " in moeoEasyEA"); + // throw std::runtime_error( s ); + // } } while (continuator(_pop)); } diff --git a/moeo/src/comparator/moeoOneObjectiveComparator.h b/moeo/src/comparator/moeoOneObjectiveComparator.h index 32b7ca093..f3543853f 100644 --- a/moeo/src/comparator/moeoOneObjectiveComparator.h +++ b/moeo/src/comparator/moeoOneObjectiveComparator.h @@ -56,7 +56,7 @@ class moeoOneObjectiveComparator : public moeoComparator < MOEOT > { if (obj > MOEOT::ObjectiveVector::nObjectives()) { - throw std::runtime_error("Problem with the index of objective in moeoOneObjectiveComparator"); + throw eoException("Problem with the index of objective in moeoOneObjectiveComparator"); } } diff --git a/moeo/src/core/MOEO.h b/moeo/src/core/MOEO.h index 1a9e1b118..061af300f 100644 --- a/moeo/src/core/MOEO.h +++ b/moeo/src/core/MOEO.h @@ -133,7 +133,7 @@ class MOEO : public EO < MOEOObjectiveVector > { if ( invalidObjectiveVector() ) { - throw std::runtime_error("invalid objective vector in MOEO"); + throw eoInvalidFitnessError("invalid objective vector in MOEO"); } return objectiveVectorValue; } @@ -197,7 +197,7 @@ class MOEO : public EO < MOEOObjectiveVector > { if ( invalidFitness() ) { - throw std::runtime_error("invalid fitness in MOEO"); + throw eoInvalidFitnessError("invalid fitness in MOEO"); } // const_cast< Fitness& >( fitnessValue ).embededDataEx = objectiveVectorValue; @@ -241,7 +241,7 @@ class MOEO : public EO < MOEOObjectiveVector > { if ( invalidDiversity() ) { - throw std::runtime_error("invalid diversity in MOEO"); + throw eoInvalidFitnessError("invalid diversity in MOEO"); } return diversityValue; } diff --git a/moeo/src/core/moeoObjectiveVectorTraits.h b/moeo/src/core/moeoObjectiveVectorTraits.h index bf169371c..517e7bd04 100644 --- a/moeo/src/core/moeoObjectiveVectorTraits.h +++ b/moeo/src/core/moeoObjectiveVectorTraits.h @@ -42,6 +42,8 @@ #include #include +#include + /** * A traits class for moeoObjectiveVector to specify the number of objectives and which ones have to be minimized or maximized. */ @@ -70,7 +72,7 @@ class moeoObjectiveVectorTraits bObj = _bObjectives; // in case the number of objectives and the min/max vector size don't match if (nObj != bObj.size()) - throw std::runtime_error("Number of objectives and min/max size don't match in moeoObjectiveVectorTraits::setup"); + throw eoException("Number of objectives and min/max size don't match in moeoObjectiveVectorTraits::setup"); } @@ -81,7 +83,7 @@ class moeoObjectiveVectorTraits { // in case the number of objectives would not be assigned yet if (! nObj) - throw std::runtime_error("Number of objectives not assigned in moeoObjectiveVectorTraits"); + throw eoException("Number of objectives not assigned in moeoObjectiveVectorTraits"); return nObj; } @@ -94,7 +96,7 @@ class moeoObjectiveVectorTraits { // in case there would be a wrong index if (_i >= bObj.size()) - throw std::runtime_error("Wrong index in moeoObjectiveVectorTraits"); + throw eoException("Wrong index in moeoObjectiveVectorTraits"); return bObj[_i]; } diff --git a/moeo/src/core/moeoVector.h b/moeo/src/core/moeoVector.h index ea4bfc4e0..cf89186df 100644 --- a/moeo/src/core/moeoVector.h +++ b/moeo/src/core/moeoVector.h @@ -89,7 +89,7 @@ class moeoVector : public MOEO < MOEOObjectiveVector, MOEOFitness, MOEODiversity } else { - throw std::runtime_error("Size not initialized in moeoVector"); + throw eoException("Size not initialized in moeoVector"); } } std::copy(_v.begin(), _v.end(), begin()); diff --git a/moeo/src/do/make_continue_moeo.h b/moeo/src/do/make_continue_moeo.h index 84695d7ee..0267ca77a 100644 --- a/moeo/src/do/make_continue_moeo.h +++ b/moeo/src/do/make_continue_moeo.h @@ -121,7 +121,7 @@ eoContinue & do_make_continue_moeo(eoParser& _parser, eoState& _state, eo #endif // now check that there is at least one! if (!continuator) - throw std::runtime_error("You MUST provide a stopping criterion"); + throw eoException("You MUST provide a stopping criterion"); // OK, it's there: store in the eoState _state.storeFunctor(continuator); // and return diff --git a/moeo/src/do/make_ea_moeo.h b/moeo/src/do/make_ea_moeo.h index aa5a38ad9..aee4dcd0d 100644 --- a/moeo/src/do/make_ea_moeo.h +++ b/moeo/src/do/make_ea_moeo.h @@ -127,14 +127,14 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF else { std::string stmp = std::string("Invalid binary quality indicator: ") + indicatorParam; - throw std::runtime_error(stmp.c_str()); + throw eoException(stmp.c_str()); } fitnessAssignment = new moeoExpBinaryIndicatorBasedFitnessAssignment < MOEOT > (*metric, kappa); } else { std::string stmp = std::string("Invalid fitness assignment strategy: ") + fitnessParam; - throw std::runtime_error(stmp.c_str()); + throw eoException(stmp.c_str()); } _state.storeFunctor(fitnessAssignment); @@ -170,7 +170,7 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF else { std::string stmp = std::string("Invalid diversity assignment strategy: ") + diversityParamValue.first; - throw std::runtime_error(stmp.c_str()); + throw eoException(stmp.c_str()); } _state.storeFunctor(diversityAssignment); @@ -194,7 +194,7 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF else { std::string stmp = std::string("Invalid comparator strategy: ") + comparatorParam; - throw std::runtime_error(stmp.c_str()); + throw eoException(stmp.c_str()); } _state.storeFunctor(comparator); @@ -250,7 +250,7 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF else { std::string stmp = std::string("Invalid selection strategy: ") + ppSelect.first; - throw std::runtime_error(stmp.c_str()); + throw eoException(stmp.c_str()); } _state.storeFunctor(select); @@ -274,7 +274,7 @@ moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalF else { std::string stmp = std::string("Invalid replacement strategy: ") + replacementParam; - throw std::runtime_error(stmp.c_str()); + throw eoException(stmp.c_str()); } _state.storeFunctor(replace); diff --git a/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h b/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h index c781b9a92..96f295be4 100644 --- a/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h +++ b/moeo/src/fitness/moeoDominanceDepthFitnessAssignment.h @@ -103,7 +103,7 @@ public: else { // problem with the number of objectives - throw std::runtime_error("Problem with the number of objectives in moeoDominanceDepthFitnessAssignment"); + throw eoInvalidFitnessError("Problem with the number of objectives in moeoDominanceDepthFitnessAssignment"); } // a higher fitness is better, so the values need to be inverted double max = _pop[0].fitness(); diff --git a/moeo/src/scalarStuffs/explorer/moeoHCMoveLoopExpl.h b/moeo/src/scalarStuffs/explorer/moeoHCMoveLoopExpl.h index 79f1b8003..83dd5f737 100644 --- a/moeo/src/scalarStuffs/explorer/moeoHCMoveLoopExpl.h +++ b/moeo/src/scalarStuffs/explorer/moeoHCMoveLoopExpl.h @@ -89,7 +89,7 @@ class moeoHCMoveLoopExpl:public moMoveLoopExpl < M > if( _old_solution.invalid() ) { - throw std::runtime_error("[moHCMoveLoopExpl.h]: The current solution has not been evaluated."); + throw eoInvalidFitnessError("[moHCMoveLoopExpl.h]: The current solution has not been evaluated."); } /* diff --git a/moeo/src/scalarStuffs/explorer/moeoTSMoveLoopExpl.h b/moeo/src/scalarStuffs/explorer/moeoTSMoveLoopExpl.h index 0f51d2a96..3485184fe 100644 --- a/moeo/src/scalarStuffs/explorer/moeoTSMoveLoopExpl.h +++ b/moeo/src/scalarStuffs/explorer/moeoTSMoveLoopExpl.h @@ -94,7 +94,7 @@ class moeoTSMoveLoopExpl:public moMoveLoopExpl < M > if( _old_solution.invalidFitness() || _old_solution.invalid() ) { - throw std::runtime_error("[moTSMoveLoopExpl.h]: The current solution has not been evaluated."); + throw eoInvalidFitnessError("[moTSMoveLoopExpl.h]: The current solution has not been evaluated."); } //At the begining, the new solution is equivalent to the old one. diff --git a/moeo/src/utils/moeoBestObjVecStat.h b/moeo/src/utils/moeoBestObjVecStat.h index 1d8d7294d..604ca90dd 100644 --- a/moeo/src/utils/moeoBestObjVecStat.h +++ b/moeo/src/utils/moeoBestObjVecStat.h @@ -65,7 +65,7 @@ public: */ const MOEOT & bestindividuals(unsigned int which) { typedef typename moeoObjVecStat::Traits traits; - if(which > traits::nObjectives() ) throw std::logic_error("which is larger than the number of objectives"); + if(which > traits::nObjectives() ) throw eoException("which is larger than the number of objectives"); return *(best_individuals[which]); } diff --git a/moeo/tutorial/examples/flowshop/FlowShopBenchmarkParser.cpp b/moeo/tutorial/examples/flowshop/FlowShopBenchmarkParser.cpp index f2de425a0..68059fc43 100644 --- a/moeo/tutorial/examples/flowshop/FlowShopBenchmarkParser.cpp +++ b/moeo/tutorial/examples/flowshop/FlowShopBenchmarkParser.cpp @@ -36,6 +36,7 @@ //----------------------------------------------------------------------------- #include #include +#include #include "FlowShopBenchmarkParser.h" FlowShopBenchmarkParser::FlowShopBenchmarkParser(const std::string _benchmarkFileName) @@ -96,7 +97,7 @@ void FlowShopBenchmarkParser::init(const std::string _benchmarkFileName) std::ifstream inputFile(_benchmarkFileName.data(), std::ios::in); // opening of the benchmark file if (! inputFile) - throw std::runtime_error("*** ERROR : Unable to open the benchmark file"); + throw eoFileError(_benchmarkFileName); // number of jobs (N) getline(inputFile, buffer, '\n'); N = atoi(buffer.data()); diff --git a/moeo/tutorial/examples/flowshop/make_op_FlowShop.h b/moeo/tutorial/examples/flowshop/make_op_FlowShop.h index 4316f7f65..428fe1d3a 100644 --- a/moeo/tutorial/examples/flowshop/make_op_FlowShop.h +++ b/moeo/tutorial/examples/flowshop/make_op_FlowShop.h @@ -104,12 +104,12 @@ eoGenOp & do_make_op(eoParameterLoader& _parser, eoState& _state) eoValueParam& pCrossParam = _parser.createParam(0.25, "pCross", "Probability of Crossover", 'c', "Variation Operators" ); // minimum check if ( (pCrossParam.value() < 0) || (pCrossParam.value() > 1) ) - throw std::runtime_error("Invalid pCross"); + throw eoParamException("Invalid pCross"); eoValueParam& pMutParam = _parser.createParam(0.35, "pMut", "Probability of Mutation", 'm', "Variation Operators" ); // minimum check if ( (pMutParam.value() < 0) || (pMutParam.value() > 1) ) - throw std::runtime_error("Invalid pMut"); + throw eoParamException("Invalid pMut"); // the crossover - with probability pCross eoProportionalOp * propOp = new eoProportionalOp ; diff --git a/problems/eval/maxSATeval.h b/problems/eval/maxSATeval.h index 87a3c4ca6..985b7d74a 100644 --- a/problems/eval/maxSATeval.h +++ b/problems/eval/maxSATeval.h @@ -111,8 +111,8 @@ public: std::fstream file(_fileName.c_str(), std::ios::in); if (!file) { - std::string str = "MaxSATeval: Could not open file [" + _fileName + "]." ; - throw std::runtime_error(str); + // std::string str = "MaxSATeval: Could not open file [" + _fileName + "]." ; + throw eoFileError(_fileName); } std::string s; @@ -128,12 +128,12 @@ public: // parameters if (s[0] != 'p') { std::string str = "MaxSATeval: could not read the parameters of the instance from file [" + _fileName + "]." ; - throw std::runtime_error(str); + throw eoException(_fileName); } file >> s; if (s != "cnf") { std::string str = "MaxSATeval: " + _fileName + " is not a file in cnf format."; - throw std::runtime_error(str); + throw eoException(_fileName); } file >> nbVar >> nbClauses; @@ -187,7 +187,7 @@ public: if (!file) { std::string str = "MaxSATeval: Could not open " + _fileName; - throw std::runtime_error(str); + throw eoFileError(_fileName); } // write some commentaries diff --git a/problems/eval/nkLandscapesEval.h b/problems/eval/nkLandscapesEval.h index f2e243021..cfdaab60a 100644 --- a/problems/eval/nkLandscapesEval.h +++ b/problems/eval/nkLandscapesEval.h @@ -154,13 +154,13 @@ public: // Read the parameters if (s[0] != 'p') { std::string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] at the begining." ; - throw std::runtime_error(str); + throw eoException(str); } file >> s; if (s != "NK") { std::string str = "nkLandscapesEval.load: -- NK -- expected in [" + _fileName + "] at the begining." ; - throw std::runtime_error(str); + throw eoException(str); } // read parameters N and K @@ -170,7 +170,7 @@ public: // read the links if (s[0] != 'p') { std::string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the parameters N and K." ; - throw std::runtime_error(str); + throw eoException(str); } file >> s; @@ -178,13 +178,13 @@ public: loadLinks(file); } else { std::string str = "nkLandscapesEval.load: -- links -- expected in [" + _fileName + "] after the parameters N and K." ; - throw std::runtime_error(str); + throw eoException(str); } // lecture des tables if (s[0] != 'p') { std::string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the links." ; - throw std::runtime_error(str); + throw eoException(str); } file >> s; @@ -193,13 +193,13 @@ public: loadTables(file); } else { std::string str = "nkLandscapesEval.load: -- tables -- expected in [" + _fileName + "] after the links." ; - throw std::runtime_error(str); + throw eoException(str); } file.close(); } else { - std::string str = "nkLandscapesEval.load: Could not open file [" + _fileName + "]." ; - throw std::runtime_error(str); + // std::string str = "nkLandscapesEval.load: Could not open file [" + _fileName + "]." ; + throw eoFileError(_fileName); } }; diff --git a/problems/eval/nkpLandscapesEval.h b/problems/eval/nkpLandscapesEval.h index 5f2a5e932..343d25d68 100644 --- a/problems/eval/nkpLandscapesEval.h +++ b/problems/eval/nkpLandscapesEval.h @@ -115,13 +115,13 @@ public: // Read the parameters if (s[0] != 'p') { string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] at the begining." ; - throw runtime_error(str); + throw eoException(str); } file >> s; if (s != "NKp") { string str = "nkpLandscapesEval.load: -- NKp -- expected in [" + _fileName + "] at the begining." ; - throw runtime_error(str); + throw eoException(str); } // read parameters N, K and p @@ -131,7 +131,7 @@ public: // read the links if (s[0] != 'p') { string str = "nkpLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the parameters N, K, and p." ; - throw runtime_error(str); + throw eoException(str); } file >> s; @@ -139,13 +139,13 @@ public: loadLinks(file); } else { string str = "nkpLandscapesEval.load: -- links -- expected in [" + _fileName + "] after the parameters N, K, and q." ; - throw runtime_error(str); + throw eoException(str); } // lecture des tables if (s[0] != 'p') { string str = "nkpLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the links." ; - throw runtime_error(str); + throw eoException(str); } file >> s; @@ -154,13 +154,13 @@ public: loadTables(file); } else { string str = "nkpLandscapesEval.load: -- tables -- expected in [" + _fileName + "] after the links." ; - throw runtime_error(str); + throw eoException(str); } file.close(); } else { - string str = "nkpLandscapesEval.load: Could not open file [" + _fileName + "]." ; - throw runtime_error(str); + // string str = "nkpLandscapesEval.load: Could not open file [" + _fileName + "]." ; + throw eoFileError(_fileName); } }; diff --git a/problems/eval/nkqLandscapesEval.h b/problems/eval/nkqLandscapesEval.h index d40bf3955..368bae969 100644 --- a/problems/eval/nkqLandscapesEval.h +++ b/problems/eval/nkqLandscapesEval.h @@ -114,13 +114,13 @@ public: // Read the parameters if (s[0] != 'p') { string str = "nkLandscapesEval.load: -- p -- expected in [" + _fileName + "] at the begining." ; - throw runtime_error(str); + throw eoException(str); } file >> s; if (s != "NKq") { string str = "nkqLandscapesEval.load: -- NKq -- expected in [" + _fileName + "] at the begining." ; - throw runtime_error(str); + throw eoException(str); } // read parameters N, K and q @@ -130,7 +130,7 @@ public: // read the links if (s[0] != 'p') { string str = "nkqLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the parameters N, K, and q." ; - throw runtime_error(str); + throw eoException(str); } file >> s; @@ -138,13 +138,13 @@ public: loadLinks(file); } else { string str = "nkqLandscapesEval.load: -- links -- expected in [" + _fileName + "] after the parameters N, K, and q." ; - throw runtime_error(str); + throw eoException(str); } // lecture des tables if (s[0] != 'p') { string str = "nkqLandscapesEval.load: -- p -- expected in [" + _fileName + "] after the links." ; - throw runtime_error(str); + throw eoException(str); } file >> s; @@ -153,13 +153,13 @@ public: loadTables(file); } else { string str = "nkqLandscapesEval.load: -- tables -- expected in [" + _fileName + "] after the links." ; - throw runtime_error(str); + throw eoException(str); } file.close(); } else { - string str = "nkqLandscapesEval.load: Could not open file [" + _fileName + "]." ; - throw runtime_error(str); + // string str = "nkqLandscapesEval.load: Could not open file [" + _fileName + "]." ; + throw eoFileError(_fileName); } }; @@ -192,7 +192,7 @@ public: } else { string fname(_fileName); string str = "nkqLandscapesEval.save: Could not open file [" + fname + "]." ; - throw runtime_error(str); + throw eoFileError(fname); } }; diff --git a/problems/eval/qapEval.h b/problems/eval/qapEval.h index 40d763c9f..df0d79303 100644 --- a/problems/eval/qapEval.h +++ b/problems/eval/qapEval.h @@ -52,8 +52,8 @@ public: std::fstream file(_fileData.c_str(), std::ios::in); if (!file) { - std::string str = "QAPeval: Could not open file [" + _fileData + "]." ; - throw std::runtime_error(str); + // std::string str = "QAPeval: Could not open file [" + _fileData + "]." ; + throw eoFileError(_fileData); } unsigned i, j; diff --git a/problems/eval/ubqpEval.h b/problems/eval/ubqpEval.h index 6061954b9..094030d59 100644 --- a/problems/eval/ubqpEval.h +++ b/problems/eval/ubqpEval.h @@ -65,8 +65,8 @@ public: std::fstream file(_fileName.c_str(), std::ios::in); if (!file) { - std::string str = "UbqpEval: Could not open file [" + _fileName + "]." ; - throw std::runtime_error(str); + // std::string str = "UbqpEval: Could not open file [" + _fileName + "]." ; + throw eoFileError(_fileName); } unsigned int nbInstances; @@ -119,7 +119,7 @@ public: Q[i - 1][j - 1] = v; else { std::string str = "UbqpEval: some indices are 0 in the instance file (in format 0), please check." ; - throw std::runtime_error(str); + throw eoException(str); } } } else { diff --git a/smp/src/MWAlgo/eoEasyEA.cpp b/smp/src/MWAlgo/eoEasyEA.cpp index bf98c534d..6a2eb485c 100644 --- a/smp/src/MWAlgo/eoEasyEA.cpp +++ b/smp/src/MWAlgo/eoEasyEA.cpp @@ -1,3 +1,5 @@ +#include "eoExceptions.h" + template