You can use the Individual's toString() method:
std::cout << individual->toString();
Alternatively, you can use the Individual's write method for output to XMLNode, then convert XML to string:
XMLNode xInd; individual->write(xInd); char *s = xInd.createXMLString(); logger->log(1, "Individual: \n" + std::string(s)); // or just output with std::cout freeXMLString(s); // NOTE: XMLNode::createXMLString requires manual deletion!
Use the predefined ECF_LOG macro; it requires a pointer to State object, log level and string message, e.g.:
ECF_LOG(state, 1, "message: " + uint2str(4) + dlb2str(3.14));
Level 1 is the highest (always logs), all the other (up to 5) depend on the "log.level" parameter (the default is 3).
Write and add a minimal operator (for more complex ones, see Adding the components) that does... something, e.g.:
class MyOp : public Operator { public: bool operate(StateP state) { std::cout << state->getRandomizer()->getRandomDouble() << std::endl; return true; } }; typedef boost::shared_ptr<MyOp> MyOpP;
and add it to State before State::initialize():
MyOpP myOp = (MyOpP) new MyOp; state->addOperator(myOp);
All of those are available through the (local) copy of StateP pointer:
state->getPopulation(); // population (vector of demes)
state->getStats(); // population statistics
state->getHoF(); // population hall of fame
state->getAlgorithm(); // current algorithm
state->getIndividualObject(); // initialized individual
state->getFitnessObject(); // initialized fitness object
state->getGenerationNo(); // current generation
state->getGenotypes(); // current genotypes (vector)
state->getRegistry(); // parameter repository
state->getRandomizer(); // current randomizer
state->getTerminateCond(); // is evolution terminating
state->getElapsedTime(); // since start, in seconds
state->getCommunicator(); // communicator (parallel ECF)