Merge branch 'master' of ssh://eodev.git.sourceforge.net/gitroot/eodev/eodev
This commit is contained in:
commit
d25dc3833b
7 changed files with 139 additions and 25 deletions
|
|
@ -19,6 +19,11 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Authors :
|
||||
todos@geneura.ugr.es
|
||||
Marc Schoenauer
|
||||
Ramón Casero Cañas
|
||||
Johann Dréo
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -40,7 +45,7 @@
|
|||
@ingroup Combination
|
||||
*/
|
||||
template< class EOT>
|
||||
class eoCombinedContinue: public eoContinue<EOT> {
|
||||
class eoCombinedContinue: public eoContinue<EOT>, public std::vector<eoContinue<EOT>* > {
|
||||
public:
|
||||
|
||||
/// Define Fitness
|
||||
|
|
@ -48,45 +53,45 @@ public:
|
|||
|
||||
/// Ctor, make sure that at least on continuator is present
|
||||
eoCombinedContinue( eoContinue<EOT>& _cont)
|
||||
: eoContinue<EOT> ()
|
||||
: eoContinue<EOT>(), std::vector<eoContinue<EOT>* >(1, &_cont)
|
||||
{
|
||||
continuators.push_back(&_cont);
|
||||
}
|
||||
|
||||
/// Ctor - for historical reasons ... should disspear some day
|
||||
eoCombinedContinue( eoContinue<EOT>& _cont1, eoContinue<EOT>& _cont2)
|
||||
: eoContinue<EOT> ()
|
||||
: eoContinue<EOT>(), std::vector<eoContinue<EOT>* >()
|
||||
{
|
||||
continuators.push_back(&_cont1);
|
||||
continuators.push_back(&_cont2);
|
||||
#pragma message "The double continuators constructor of eocombinedContinue is deprecated and will be removed in the next release."
|
||||
|
||||
this->push_back(&_cont1);
|
||||
this->push_back(&_cont2);
|
||||
}
|
||||
|
||||
void add(eoContinue<EOT> & _cont)
|
||||
{
|
||||
continuators.push_back(&_cont);
|
||||
this->push_back(&_cont);
|
||||
}
|
||||
|
||||
///////////// RAMON'S CODE ///////////////
|
||||
void removeLast(void)
|
||||
{
|
||||
continuators.pop_back();
|
||||
#pragma message "The removeLast method of eocombinedContinue is deprecated and will be removed in the next release, use pop_back instead."
|
||||
this->pop_back();
|
||||
}
|
||||
///////////// RAMON'S CODE (end) ///////////////
|
||||
|
||||
|
||||
/** Returns false when one of the embedded continuators say so (logical and)
|
||||
*/
|
||||
virtual bool operator() ( const eoPop<EOT>& _pop )
|
||||
{
|
||||
for (unsigned i = 0; i < continuators.size(); ++i)
|
||||
if ( !(*continuators[i])(_pop) ) return false;
|
||||
for (unsigned i = 0; i < this->size(); ++i)
|
||||
if ( ! (*this->at(i))(_pop) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual std::string className(void) const { return "eoCombinedContinue"; }
|
||||
|
||||
private:
|
||||
std::vector<eoContinue<EOT>*> continuators;
|
||||
//private:
|
||||
// std::vector<eoContinue<EOT>*> continuators;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -103,6 +103,17 @@ public:
|
|||
_is_feasible(dual.second)
|
||||
{}
|
||||
|
||||
// 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<double,std::less<double> > fit;
|
||||
* double val = 1.0;
|
||||
* fit = val;
|
||||
* val = fit;
|
||||
*/
|
||||
operator BaseType(void) const { return _value; }
|
||||
|
||||
|
||||
inline bool is_feasible() const
|
||||
{
|
||||
return _is_feasible;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ private:
|
|||
};
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
An error that signals that a maximum number of evaluations has been reached.
|
||||
|
||||
|
|
@ -80,4 +79,54 @@ private:
|
|||
};
|
||||
|
||||
|
||||
/*!
|
||||
* An error that signals a missing parameter
|
||||
*
|
||||
* Thrown by eoParser::getParam
|
||||
*
|
||||
* @ingroup Parameters
|
||||
*/
|
||||
class eoMissingParamException : public std::exception
|
||||
{
|
||||
public:
|
||||
eoMissingParamException(std::string name) : _name(name){}
|
||||
|
||||
virtual const char* what() const throw()
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "The command parameter " << _name << " has not been declared";
|
||||
return ss.str().c_str();
|
||||
}
|
||||
|
||||
~eoMissingParamException() throw() {}
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
/*!
|
||||
* An error that signals a bad parameter type
|
||||
*
|
||||
* Thrown by eoParser::valueOf
|
||||
*
|
||||
* @ingroup Parameters
|
||||
*/
|
||||
class eoWrongParamTypeException : public std::exception
|
||||
{
|
||||
public:
|
||||
eoWrongParamTypeException(std::string name) : _name(name){}
|
||||
|
||||
virtual const char* what() const throw()
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "You asked for the parameter " << _name << " but it has not been declared under this type";
|
||||
return ss.str().c_str();
|
||||
}
|
||||
|
||||
~eoWrongParamTypeException() throw() {}
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
#endif // __eoExceptions_h__
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ public:
|
|||
|
||||
virtual void add(eoQuadOp<EOT> & _op, const double _rate, bool _verbose)
|
||||
{
|
||||
#pragma message "The use of the verbose parameter in eoPropCombinedQuadOp::add is deprecated and will be removed in the next release."
|
||||
eo::log << eo::warnings << "WARNING: the use of the verbose parameter in eoPropCombinedQuadOp::add is deprecated and will be removed in the next release." << std::endl;
|
||||
add(_op,_rate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ public :
|
|||
{
|
||||
(void)_verbose;
|
||||
eo::log << eo::warnings << "WARNING: the use of the verbose parameter in eoOStreamMonitor constructor is deprecated and will be removed in the next release" << std::endl;
|
||||
#pragma message "WARNING: the use of the verbose parameter in eoOStreamMonitor constructor is deprecated and will be removed in the next release"
|
||||
}
|
||||
|
||||
eoOStreamMonitor( std::ostream & _out, std::string _delim = "\t", unsigned int _width=20, char _fill=' ' ) :
|
||||
|
|
|
|||
|
|
@ -18,9 +18,12 @@
|
|||
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: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@inria.fr
|
||||
mkeijzer@dhi.dk
|
||||
Contact: http://eodev.sourceforge.net
|
||||
Authors:
|
||||
todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -38,6 +41,7 @@
|
|||
#include <utils/eoParser.h>
|
||||
#include <utils/eoLogger.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
std::ostream& printSectionHeader(std::ostream& os, std::string section)
|
||||
|
|
@ -129,6 +133,15 @@ eoParam * eoParser::getParamWithLongName(const std::string& _name) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
eoParam * eoParser::getParam(const std::string& _name) const
|
||||
{
|
||||
eoParam * p = getParamWithLongName( _name );
|
||||
if( p == NULL ) {
|
||||
throw eoMissingParamException(_name );
|
||||
} else {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
void eoParser::processParam(eoParam& param, std::string section)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
|
||||
/* (c) Marc Schoenauer, Maarten Keijzer, GeNeura Team, 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
|
||||
|
|
@ -14,9 +14,11 @@ 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
|
||||
todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
Authors:
|
||||
todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -30,6 +32,7 @@ Contact: http://eodev.sourceforge.net
|
|||
#include "eoParam.h"
|
||||
#include "eoObject.h"
|
||||
#include "eoPersistent.h"
|
||||
#include "eoExceptions.h"
|
||||
|
||||
/** Parameter saving and loading
|
||||
|
||||
|
|
@ -176,15 +179,46 @@ public:
|
|||
eoParam * getParamWithLongName(const std::string& _name) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get a handle on a param from its long name
|
||||
* If not found, raise an eoMissingParamException
|
||||
*/
|
||||
eoParam * getParam(const std::string& _name) const;
|
||||
|
||||
|
||||
/**
|
||||
* 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<unsigned int>("popSize");
|
||||
*
|
||||
* If the template type is not the good one, an eoWrongParamTypeException is raised.
|
||||
*/
|
||||
template<class ValueType>
|
||||
ValueType valueOf(const std::string& _name) const
|
||||
{
|
||||
eoParam* param = getParam(_name);
|
||||
|
||||
// Note: eoParam is the polymorphic base class of eoValueParam, thus we can do a dynamix cast
|
||||
eoValueParam<ValueType>* vparam = dynamic_cast< eoValueParam<ValueType>* >(param);
|
||||
|
||||
if( vparam == NULL ) {
|
||||
// if the dynamic cast has failed, chances are that ValueType
|
||||
// is not the same than the one used at declaration.
|
||||
throw eoWrongParamTypeException( _name );
|
||||
} else {
|
||||
return vparam->value();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Get or create parameter
|
||||
|
||||
It seems finally that the easiest use of the above method is
|
||||
through the following, whose interface is similar to that of the
|
||||
widely-used createParam.
|
||||
|
||||
For some (probably very stupid) reason, I failed to put it in the
|
||||
.cpp. Any hint???
|
||||
*/
|
||||
template <class ValueType>
|
||||
eoValueParam<ValueType>& getORcreateParam(ValueType _defaultValue,
|
||||
|
|
|
|||
Reference in a new issue