* make_genotype_real.h (eoEsChromInit): Rewrite vecSigmaInit-handling:

If sigmaInit is relative (%), do not read vecSigmaInit. Otherwise
always use vecSigmaInit with default all values of sigmaInit.

* eoParser.h (eoParser::getORcreateParam): Make this a real if-then-else
clause around ptParam (found or not).

* eoParam.h (eoValueParam::setValue): Document.
(eoValueParam<std::vector<double> >::setValue): Allow delimiters ',' and
';'. A plain ' ' does not work, as it is not correctly read by
eoParser::readFrom.
This commit is contained in:
kuepper 2006-11-16 12:35:46 +00:00
commit d7b935b645
8 changed files with 95 additions and 46 deletions

15
eo/src/utils/ChangeLog Normal file
View file

@ -0,0 +1,15 @@
2006-11-16 Jochen Küpper <jochen@fhi-berlin.mpg.de>
* eoParser.h (eoParser::getORcreateParam): Make this a real if-then-else
clause around ptParam (found or not).
* eoParam.h (eoValueParam::setValue): Document.
(eoValueParam<std::vector<double> >::setValue): Allow delimiters ',' and
';'. A plain ' ' does not work, as it is not correctly read by
eoParser::readFrom.
* Local Variables:
* coding: iso-8859-1
* mode: flyspell
* fill-column: 80
* End:

View file

@ -184,6 +184,19 @@ public :
}
/** @brief Set value according to the speciied string
For scalar types the textual represenation is typically quite
straigtforward.
For vector<double> we expect a list of numbers, where the first is
an unsigned integer taken as the length ot the vector and then
successively the vector elements. Vector elements can be separated
by ',', ';', or ' '. Note, however, that eoParser does not deal
correctly with parameter values contianing spaces (' ').
@param _value Textual representation of the new value
*/
void setValue(const std::string& _value)
{
std::istringstream is(_value);
@ -290,11 +303,18 @@ inline std::string eoValueParam<std::vector<double> >::getValue(void) const
template <>
inline void eoValueParam<std::vector<double> >::setValue(const std::string& _value)
{
static const std::string delimiter(",;");
std::istringstream is(_value);
unsigned sz;
is >> sz;
repValue.resize(sz);
std::copy(std::istream_iterator<double>(is), std::istream_iterator<double>(), repValue.begin());
for(unsigned i=0; i<repValue.size(); ++i) {
char c;
do {
is >> c;
} while((std::string::npos != delimiter.find(c)) && (! is.eof()));
is >> repValue[i];
}
}
// The std::vector<eoMinimizingFitness>

View file

@ -218,7 +218,6 @@ void eoParser::readFrom(istream& is)
string name(str.begin() + 2, equalLocation);
longNameMap[name] = value;
}
else // it should be a char
{

View file

@ -180,13 +180,14 @@ public:
eoParam* ptParam = getParamWithLongName(_longName);
if (ptParam) {
// found
eoValueParam<ValueType>* ptTypedParam =
dynamic_cast<eoValueParam<ValueType>*>(ptParam);
eoValueParam<ValueType>* ptTypedParam(
dynamic_cast<eoValueParam<ValueType>*>(ptParam));
return *ptTypedParam;
} else {
// not found -> create it
return createParam(_defaultValue, _longName, _description,
_shortHand, _section, _required);
}
// not found -> create it
return createParam (_defaultValue, _longName, _description,
_shortHand, _section, _required);
}