3#include "../ECF_base.h"
4#include "IntGenotype.h"
21 ECF_LOG_ERROR(state,
"Error: required parameters for IntGenotype genotype not defined (lbound, ubound, size)!");
26 minValue_ = *((
int*)genp.get());
29 maxValue_ = *((
int*)genp.get());
31 if (minValue_ >= maxValue_) {
32 ECF_LOG_ERROR(state,
"Error: 'lbound' must be smaller than 'ubound' for IntGenotype genotype!");
37 nSize_ = *((uint*)genp.get());
40 ECF_LOG_ERROR(state,
"Error: 'size' must be > 0 for IntGenotype genotype!");
44 intValues.resize(nSize_);
46 for (uint i = 0; i < nSize_; i++){
47 intValues[i] = state->getRandomizer()->getRandomInteger(minValue_, maxValue_);
55 xIntGenotype = XMLNode::createXMLTopNode(
"IntGenotype");
56 std::stringstream sValue;
57 sValue << intValues.size();
58 xIntGenotype.addAttribute(
"size", sValue.str().c_str());
61 for (uint iVar = 0; iVar < intValues.size(); iVar++)
62 sValue <<
" " << intValues[iVar];
63 xIntGenotype.addText(sValue.str().c_str());
69 XMLCSTR values = xIntGenotype.getText();
70 std::stringstream sValues;
73 for (uint iVar = 0; iVar < intValues.size(); iVar++)
74 sValues >> intValues[iVar];
voidP getParameterValue(StateP state, std::string name)
Read single parameter value from Registry.
bool registerParameter(StateP state, std::string name, voidP value, enum ECF::type T, std::string description="")
Register a single parameter.
bool isParameterDefined(StateP state, std::string name)
Check if parameter is defined in the configuration.
void write(XMLNode &xIntGenotype)
Write genotype data to XMLNode.
bool initialize(StateP state)
Initialize a genotype object (read parameters, perform sanity check, build data).
void read(XMLNode &xIntGenotype)
Read genotype data from XMLNode.
void registerParameters(StateP state)
Register genotype's parameters (called before Genotype::initialize).