2#include "../ECF_base.h"
3#include "Permutation.h"
13 "genotype size: number of indices (mandatory)");
20 size_ = *((uint*) genp.get());
23 ECF_LOG_ERROR(state,
"Error: 'size' must be > 0 for Permutation genotype!");
26 variables.resize(
static_cast<int>(
size_));
28 for(uint i = 0; i <
size_; i++) {
29 variables[i] = (int) i;
34 for(uint i = 0; i <
size_; i++) {
35 ind1 = state->getRandomizer()->getRandomInteger(
size_);
36 ind2 = state->getRandomizer()->getRandomInteger(
size_);
37 temp = variables[ind1];
38 variables[ind1] = variables[ind2];
39 variables[ind2] = temp;
47 xPermutation = XMLNode::createXMLTopNode(
"Permutation");
48 std::stringstream sValue;
50 xPermutation.addAttribute(
"size", sValue.str().c_str());
53 for(uint i = 0; i <
size_; i++)
54 sValue <<
"\t" << variables[i];
55 xPermutation.addText(sValue.str().c_str());
61 XMLCSTR xIndices = xPermutation.getText();
62 std::stringstream sValues;
65 for(uint index = 0; index <
size_; index++) {
66 sValues >> variables[index];
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.
void read(XMLNode &)
Read genotype data from XMLNode.
void write(XMLNode &)
Write genotype data to XMLNode.
uint size_
permutation vector size
bool initialize(StateP state)
Initialize a genotype object (read parameters, perform sanity check, build data).
void registerParameters(StateP state)
Register genotype's parameters (called before Genotype::initialize).