Ejemplo n.º 1
0
/*!
 *  \brief Register the parameters of the GP expand operator for evolutionary module acquisition.
 *  \param ioSystem Evolutionary system.
 */
void GP::ModuleExpandOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();
	Beagle::Operator::registerParams(ioSystem);
	{
		Register::Description lDescription(
		    "Module primitive name for EMA",
		    "String",
		    "MODULE",
		    "Name of the GP primitive to use as module reference in the GP trees"
		);
		mModulePrimitName = castHandleT<String>(
		                        ioSystem.getRegister().insertEntry("gp.ema.modulename", new String("MODULE"), lDescription));
	}
	{
		std::ostringstream lOSS;
		lOSS << "Probability of an individual being expanded. Expansion randomly selects a ";
		lOSS << "module primitive and inserts it back into the tree.";
		Register::Description lDescription(
		    "Probability of an individual being expanded",
		    "Float",
		    "0.2",
		    lOSS.str()
		);
		mExpandProba = castHandleT<Float>(
		                   ioSystem.getRegister().insertEntry("gp.ema.expandpb", new Float(0.2f), lDescription));
	}
	Beagle_StackTraceEndM();
}
void Beagle::GP::MutationEphemeralOpT<T>::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();

	{
		std::ostringstream lOSS;
		lOSS << "Ephemeral mutation probability for an individual. ";
		lOSS << "A ephemeral mutation change the value of a specific primitive.";
		Register::Description lDescription(
		    "Ephemeral mutation probability",
		    "Double",
		    "0.05",
		    lOSS.str()
		);
		mMutationProba = castHandleT<Double>(
		                     ioSystem.getRegister().insertEntry(mMutationPbName, new Double(0.05f), lDescription));
	}
	Beagle::MutationOp::registerParams(ioSystem);
	{
		std::ostringstream lOSS;
		lOSS << "Name of the ephemeral primitive for which the values are modified ";
		lOSS << "by the ephemeral mutation operator.";
		Register::Description lDescription(
		    "Ephemeral primitive name",
		    "String",
		    "E",
		    lOSS.str()
		);
		mEphemeralName = castHandleT<String>(
		                     ioSystem.getRegister().insertEntry(mEphemeralNameParamName, new String("E"), lDescription));
	}
	Beagle_StackTraceEndM("void Beagle::GP::MutationEphemeralOpT<T>::registerParams(Beagle::System&)");
}
Ejemplo n.º 3
0
/*!
 *  \brief register the parameters of this logger.
 *  \param ioSystem Reference to the system to use for initialization.
 *
 *  This method registers the following parameter:
 *   - hpc.node.nbevolver
 */
void HPC::MPICommunication::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();
	{
		Register::Description lDescription(
		"Number of Evolver nodes.",
		"UInt",
		"1",
		"Determine the number of evolver nodes that will be used. This number must be between 1 and the number of demes."
		);
		mNbEvolvers = castHandleT<UInt>(
		ioSystem.getRegister().insertEntry("hpc.evolver.nb", new UInt(1), lDescription));
	}
#ifdef BEAGLE_HAVE_LIBZ
	{
		std::ostringstream lOSS;
		lOSS << "Determine the zlib compression level of every messages. 0 = no compression, 9 = max. compression.";
		Register::Description lDescription(
		  "Compression level of messages.",
		  "UInt",
		  "0",
		  lOSS.str()
		);
		mCompressionLevel = castHandleT<UInt>(
		ioSystem.getRegister().insertEntry("hpc.compression.level", new UInt(0), lDescription));
	}
#endif //BEAGLE_HAVE_LIBZ
	Beagle_HPC_StackTraceEndM("void HPC::MPICommunication::registerParams(System& ioSystem)");
}
/*!
 *  \brief Register the parameters of the GP crossover operator.
 *  \param ioSystem System of the evolution.
 */
void GP::CrossoverOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();
	{
		Register::Description lDescription(
		    "Individual crossover probability",
		    "Double",
		    "0.8",
		    "Individual crossover probability at each generation."
		);
		mMatingProba = castHandleT<Double>(
		                   ioSystem.getRegister().insertEntry(mMatingProbaName, new Double(0.8f), lDescription));
	}
	Beagle::CrossoverOp::registerParams(ioSystem);
	{
		std::ostringstream lOSS;
		lOSS << "Probability that a crossover point is a branch ";
		lOSS << "(node with sub-trees). Value of 1.0 means that all crossover points are ";
		lOSS << "branches, and value of 0.0 means that all crossover points are leaves.";
		Register::Description lDescription(
		    "Crossover distribution prob.",
		    "Float",
		    "0.9",
		    lOSS.str()
		);
		mDistributionProba = castHandleT<Float>(
		                         ioSystem.getRegister().insertEntry(mDistribPbName, new Float(0.9f), lDescription));
	}
	{
		Register::Description lDescription(
		    "Maximum tree depth",
		    "UInt",
		    "17",
		    "Maximum allowed depth for the trees."
		);
		mMaxTreeDepth = castHandleT<UInt>(
		                    ioSystem.getRegister().insertEntry("gp.tree.maxdepth", new UInt(17), lDescription));
	}
	{
		std::ostringstream lOSS;
		lOSS << "Maximum number of attempts to modify a GP tree in a genetic ";
		lOSS << "operation. As there is topological constraints on GP trees (i.e. tree ";
		lOSS << "depth limit), it is often necessary to try a genetic operation several times.";
		Register::Description lDescription(
		    "Max number of attempts",
		    "UInt",
		    "2",
		    lOSS.str()
		);
		mNumberAttempts = castHandleT<UInt>(
		                      ioSystem.getRegister().insertEntry("gp.try", new UInt(2), lDescription));
	}
	Beagle_StackTraceEndM("void GP::CrossoverOp::registerParams(Beagle::System&)");
}
void LogIndividualDataOp::initialize(Beagle::System& ioSystem) {
	LogIndividualOp::initialize(ioSystem);
	
	if(ioSystem.getRegister().isRegistered("log.individual.keepdata")) {
		mKeepData = castHandleT<Bool>(ioSystem.getRegister().getEntry("log.individual.keepdata"));
	} else {
		mKeepData = new Bool(1);
		std::string lLongDescrip("Keep data associated to the individual when logging. ");
		Register::Description lDescription(
										   "Keep individual data",
										   "Bool",
										   mNumberIndividualPerDem->serialize(),
										   lLongDescrip
										   );
		ioSystem.getRegister().addEntry("log.individual.keepdata", mKeepData, lDescription);
	}
}
/*!
 *
 */
void SharedLibEvalOp::registerParams(Beagle::System& ioSystem)
{
    Beagle_StackTraceBeginM();

    Beagle::GP::EvaluationOp::registerParams(ioSystem);

    if (!ioSystem.getRegister().isRegistered("icu.trainingset.size"))
    {
        // 'icu.trainingset.size', training set size.
        Register::Description lDescription(
            "Training set size",
            "Integer",
            "30000",
            "The number of rows in the training set."
        );
        ioSystem.getRegister().insertEntry("icu.trainingset.size", new Int(30000), lDescription);
    }
    mTrainingSetSize= castHandleT<Int>(ioSystem.getRegister()["icu.trainingset.size"])->getWrappedValue();
    
    Beagle_StackTraceEndM("void SharedLibEvalOp::registerParams(System&)");
}
/*!
 *  \brief Register the parameters of the GP "full" intialization operator.
 *  \param ioSystem System of the evolution.
 */
void GP::InitFullConstrainedOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();
	InitFullOp::registerParams(ioSystem);
	std::ostringstream lOSS;
	lOSS << "Maximum number of attempts to modify a GP tree in a genetic ";
	lOSS << "operation. As there is topological constraints on GP trees (i.e. tree ";
	lOSS << "depth limit), it is often necessary to try a genetic operation several times.";
	Register::Description lDescription("Max number of attempts", "UInt", "2", lOSS.str());
	mNumberAttempts =
	    castHandleT<UInt>(ioSystem.getRegister().insertEntry("gp.try", new UInt(2), lDescription));
	Beagle_StackTraceEndM("void GP::InitFullConstrainedOp::registerParams(Beagle::System&)");
}
Ejemplo n.º 8
0
/*!
 *  \brief Register the parameters of this operator.
 *  \param ioSystem Evolutionary system.
 */
void TSPEvalOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();
	Beagle::HPC::EvaluationOp::registerParams(ioSystem);
	Register::Description lDescription(
		"Initial integer vectors sizes",
		"UInt",
		"0",
		"Integer vector size of initialized individuals."
	);
	mIntVectorSize = castHandleT<UInt>(
	    ioSystem.getRegister().insertEntry("ga.init.vectorsize", new UInt(0), lDescription));
	Beagle_StackTraceEndM("void TSPEvalOp::registerParams(Beagle::System&)");
}
/*!
 *
 */
void SharedLibCompileOp::registerParams(Beagle::System& ioSystem)
{
    Beagle_StackTraceBeginM();

    Beagle::Operator::registerParams(ioSystem);

    // 'icu.compiler.tmp-directory', place all files generated during compiling in this directory.
    {
		std::ostringstream lOSS;
		lOSS << "Place all files generated during compilation in this directory, ";
		lOSS << "e.g. C source files (*.c) and shared libraries (*.so).";
		Register::Description lDescription(
		    "Directory for temporary files",
		    "String",
		    "./tmp",
		    lOSS.str()
		);
        ioSystem.getRegister().insertEntry("icu.compiler.tmp-directory", new String("./tmp"), lDescription);
    }

    // 'icu.compiler.lib-path', register an entry updated with the path of the shared library after each compilation.
    {
		std::ostringstream lOSS;
		lOSS << "Path to the shared library to use for fitness evaluation. ";
		lOSS << "After each compilation step, this paramter will contain the ";
		lOSS << "path to the shared library for the current generation and deme.";
		Register::Description lDescription(
		    "Path to shared library for current generation and deme",
		    "String",
		    "",
		    lOSS.str()
		);
        ioSystem.getRegister().insertEntry("icu.compiler.lib-path", new String(""), lDescription);
    }
        
    Beagle_StackTraceEndM("void SharedLibCompileOp::registerParams(System&)");
}
/*!
 *  \brief Register the parameters of this operator.
 *  \param ioSystem System of the evolution.
 */
void GP::MutationSwapOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();

	{
		std::ostringstream lOSS;
		lOSS << "Swap mutation probability for an individual. ";
		lOSS << "Swap mutation consists in exchanging the primitive associated to a ";
		lOSS << "node by one having the same number of arguments.";
		Register::Description lDescription(
		    "Individual swap mutation prob.",
		    "Double",
		    "0.05",
		    lOSS.str()
		);
		mMutationProba = castHandleT<Double>(
		                     ioSystem.getRegister().insertEntry(mMutationPbName, new Double(0.05f), lDescription));
	}
	Beagle::MutationOp::registerParams(ioSystem);
	{
		std::ostringstream lOSS;
		lOSS << "Probability that a swap mutation point is a branch (node with sub-trees). ";
		lOSS << "Value of 1.0 means that all swap mutation points are branches, ";
		lOSS << "and value of 0.0 means that all swap mutation points are leaves. ";
		lOSS << "Swap mutation consists in exchanging the primitive associated to a ";
		lOSS << "node by one having the same number of arguments.";
		Register::Description lDescription(
		    "Swap mutation distrib. prob.",
		    "Float",
		    "0.5",
		    lOSS.str()
		);
		mDistributionProba = castHandleT<Float>(
		                         ioSystem.getRegister().insertEntry(mDistribPbName, new Float(0.5f), lDescription));
	}
	Beagle_StackTraceEndM("void GP::MutationSwapOp::registerParams(Beagle::System&)");
}
Ejemplo n.º 11
0
/*!
 *  \brief Register parameters of the linear GP mutation operator.
 *  \param ioSystem System of the evolution.
 */
void LinGP::MutationOp::registerParams(Beagle::System& ioSystem)
{
	{
		Register::Description lDescription(
		    "Individual linear GP mutation prob.",
		    "Float",
		    "1.0",
		    "Linear GP mutation probability for each individual."
		);
		mMutationProba = castHandleT<Double>(
		                     ioSystem.getRegister().insertEntry(mMutationPbName, new Double(1.0f), lDescription));
	}
	EC::MutationOp::registerParams(ioSystem);
	{
		Register::Description lDescription(
		    "Instruction mutation probability",
		    "Float",
		    "0.05",
		    "Probability for each instruction inverted by mutation, when an individual is mutated."
		);
		mInstructMutateProba = castHandleT<Float>(
		                           ioSystem.getRegister().insertEntry(mInstructMutatePbName, new Float(0.05f), lDescription));
	}
}
/*!
 *  \brief Register the parameters of the GA partialy matched crossover operator.
 *  \param ioSystem System of the evolution.
 */
void Beagle::GA::CrossoverPMXOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();
	{
		Register::Description lDescription(
										   "Individual partialy matched crossover pb.",
										   "Double",
										   "0.3",
										   "GA partialy matched crossover probability of a single individual."
										   );
		mMatingProba = castHandleT<Double>(ioSystem.getRegister().insertEntry(mMatingProbaName, new Double(0.3f), lDescription));
	}
	CrossoverOp::registerParams(ioSystem);
	Beagle_StackTraceEndM("void GA::CrossoverPMXOp::registerParams(System&)");
}
Ejemplo n.º 13
0
/*!
 *  \brief Register the parameters of this operator.
 *  \param ioSystem System to use to initialize the operator.
 */
void SelectWorstTournOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();

	Beagle::EC::SelectionOp::registerParams(ioSystem);
	Register::Description lDescription(
	    "Selection tournaments size",
	    "UInt",
	    "2",
	    "Number of participants for worst tournament selection."
	);
	mNumberParticipants =
	    castHandleT<UInt>(ioSystem.getRegister().insertEntry("ec.sel.worsttournsize", new UInt(2), lDescription));

	Beagle_StackTraceEndM();
}
Ejemplo n.º 14
0
/*!
 *  \brief Register the parameters of the constrained GP tree "grow" intialization operator.
 *  \param ioSystem System of the evolution.
 */
void GP::InitGrowOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();
	GP::InitializationOp::registerParams(ioSystem);
	{
		Register::Description lDescription(
		    "Flag for whether the 'grow' method works as defined by Koza",
		    "Bool",
		    "0",
		    "Set this flag if you wish to initialize individuals using the 'grow' method as defined by Koza in GPI (and as used in GPII, GPIII, and probably GPIV---although it is not made entirely clear).  If this flag is set to true then individuals are grown with a minimum depth of 2.  If this flag is set to false then the minimum depth of individuals is paired to the register variable 'gp.init.mindepth'.  Irrespective of this flag, maximum depth of individuals will range according to the values of 'gp.init.mindepth' and 'gp.init.maxdepth'; note that if you wish to entirely replicate Koza's method then mindepth and maxdepth should be set to the same value."
		);
		mKozaGrow = castHandleT<Bool>
		            (ioSystem.getRegister().insertEntry("gp.init.kozagrow", new Bool(false), lDescription));
	}

	Beagle_StackTraceEndM("void GP::InitGrowOp::registerParams(Beagle::System&)");
}
/*!
 *  \brief Register the parameters of this operator.
 *  \param ioSystem System used to initialize the operator.
 */
void GP::TermMaxHitsOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();
	TerminationOp::registerParams(ioSystem);
	std::ostringstream lOSS;
	lOSS << "Number of hits required in an individual ";
	lOSS << "in order for the evolution process to terminate. ";
	lOSS << "If 0, termination criteria is ignored.";
	Register::Description lDescription(
	    "Max hits term criterion",
	    "UInt",
	    uint2str(mMaxHitsDefault),
	    lOSS.str()
	);
	mMaxHits = castHandleT<UInt>(
	               ioSystem.getRegister().insertEntry("gp.term.maxhits", new UInt(mMaxHitsDefault), lDescription));
	Beagle_StackTraceEndM("void GP::TermMaxHitsOp::registerParams(Beagle::System&)");
}
Ejemplo n.º 16
0
/*!
 *  \brief Register parameters of the MilestoneWrite operator.
 *  \param ioSystem Reference to the system.
 */
void Master::MilestoneWriteOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();

	Beagle::MilestoneWriteOp::registerParams(ioSystem);
	{
		Register::Description lDescription(
		    "Application name",
		    "String",
		    std::string("'")+mDefaultAppName+std::string("'"),
		    "Name of the application, as registered in the server."
		);
		mAppName = castHandleT<Beagle::String>(
		               ioSystem.getRegister().insertEntry("db.app.name", new Beagle::String(mDefaultAppName), lDescription));
	}
	{
		Register::Description lDescription(
		    "IP server address",
		    "String",
		    "127.0.0.1",
		    "IP address of the master-slave server."
		);
		mServerIP = castHandleT<Beagle::String>(
		                ioSystem.getRegister().insertEntry("db.server.ip", new Beagle::String("127.0.0.1"), lDescription));
	}
	{
		Register::Description lDescription(
		    "IP server port",
		    "UInt",
		    "9123",
		    "IP port of the master-slave server."
		);
		mServerPort = castHandleT<UInt>(
		                  ioSystem.getRegister().insertEntry("db.server.port", new UInt(9123), lDescription));
	}
	{
		Register::Description lDescription(
		    "Compression level",
		    "UInt",
		    "3",
		    "Evolver communication compression."
		);
		mCompressionLevel = castHandleT<UInt>(
		                        ioSystem.getRegister().insertEntry("db.evolver.compression", new UInt(0), lDescription));
	}
#ifdef BEAGLE_HAVE_LIBZ
	{
		std::ostringstream lOSS;
		lOSS << "If true, this flag indicates that milestones will be ";
		lOSS << "compressed with gzip. Otherwise, each milestone are kept plain text.";
		Register::Description lDescription(
		    "Milestone compression flag",
		    "Bool",
		    "1",
		    lOSS.str()
		);
		mCompressMilestone = castHandleT<Bool>(
		                         ioSystem.getRegister().insertEntry("ms.write.compress", new Bool(true), lDescription));
	}
#endif // BEAGLE_HAVE_LIBZ

	Beagle_StackTraceEndM();
}
Ejemplo n.º 17
0
/*!
 *  \brief Register the parameters of the generic GP intialization operator.
 *  \param ioSystem System of the evolution.
 */
void GP::InitializationOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();
	Beagle::InitializationOp::registerParams(ioSystem);
	{
		Register::Description lDescription(
		    "Maximum initial tree depth",
		    "UInt",
		    "5",
		    "Maximum depth for newly initialized trees."
		);
		mMaxTreeDepth = castHandleT<UInt>(
		                    ioSystem.getRegister().insertEntry("gp.init.maxdepth", new UInt(5), lDescription));
	}
	{
		Register::Description lDescription(
		    "Minimum initial tree depth",
		    "UInt",
		    "2",
		    "Minimum depth for newly initialized trees."
		);
		mMinTreeDepth = castHandleT<UInt>(
		                    ioSystem.getRegister().insertEntry("gp.init.mindepth", new UInt(2), lDescription));
	}
	{
		std::ostringstream lOSS;
		lOSS << "Maximum number of GP tree in newly initialized individuals. More than one tree ";
		lOSS << "is usually useful with ADFs (and other ADx).";
		Register::Description lDescription(
		    "Maximum number of trees",
		    "UInt",
		    "1",
		    lOSS.str()
		);
		mMaxNumberTrees = castHandleT<UInt>(
		                      ioSystem.getRegister().insertEntry("gp.init.maxtree", new UInt(1), lDescription));
	}
	{
		std::ostringstream lOSS;
		lOSS << "Minimum number of GP tree in newly initialized individuals. More than one tree ";
		lOSS << "is usually useful with ADFs (and other ADx).";
		Register::Description lDescription(
		    "Minimum number of trees",
		    "UInt",
		    "1",
		    lOSS.str()
		);
		mMinNumberTrees = castHandleT<UInt>(
		                      ioSystem.getRegister().insertEntry("gp.init.mintree", new UInt(1), lDescription));
	}
	{
		std::ostringstream lOSS;
		lOSS << "Maximum number of arguments in GP tree.  The first element in the array "
		<< "specifies the maximum number of arguments in the first tree of an individual, "
		<< "the second element specifies the second tree and so on.  If there are more "
		<< "trees in an individual than elements in the array then the last element is "
		<< "recycled.  Tree arguments are usually useful with ADFs (and similar).";
		Register::Description lDescription(
		    "Max. number of tree arguments",
		    "UIntArray",
		    "0/2",
		    lOSS.str()
		);
		mMaxTreeArgs = new UIntArray;
		mMaxTreeArgs->push_back(0);
		mMaxTreeArgs->push_back(2);
		mMaxTreeArgs = castHandleT<UIntArray>(
		                   ioSystem.getRegister().insertEntry("gp.tree.maxargs", mMaxTreeArgs, lDescription));
	}
	{
		std::ostringstream lOSS;
		lOSS << "Minimum number of arguments in GP tree.  The first element in the array "
		<< "specifies the minimum number of arguments in the first tree of an individual, "
		<< "the second element specifies the second tree and so on.  If there are more "
		<< "trees in an individual than elements in the array then the last element is "
		<< "recycled.  Tree arguments are usually useful with ADFs (and similar).";
		Register::Description lDescription(
		    "Min. number of tree arguments",
		    "UIntArray",
		    "0/2",
		    lOSS.str()
		);
		mMinTreeArgs = new UIntArray;
		mMinTreeArgs->push_back(0);
		mMinTreeArgs->push_back(2);
		mMinTreeArgs = castHandleT<UIntArray>(
		                   ioSystem.getRegister().insertEntry("gp.tree.minargs", mMinTreeArgs, lDescription));
	}
	Beagle_StackTraceEndM();
}
Ejemplo n.º 18
0
/*!
 * \brief Initialize this MPICommunication component.
 * \param ioSystem System reference.
 */
void HPC::MPICommunication::init(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();
	void* lValue;
	if(!MPI::COMM_WORLD.Get_attr( MPI::TAG_UB, &lValue ))
		throw RunTimeException("HPC::MPICommunication::init(Beagle::System&) the MPI::TAG_UB couldn't be retrieve.",__FILE__,__LINE__);
	mTagUpperBound = *(int*)lValue;

	unsigned int lSize = MPI::COMM_WORLD.Get_size();
	mNodeRank = new UInt(MPI::COMM_WORLD.Get_rank());
	int lRank = (*mNodeRank);
	UIntArray::Handle lPopulationSize = castHandleT<UIntArray>(ioSystem.getRegister().getEntry("ec.pop.size"));

	unsigned int lNbEvolvers = (*mNbEvolvers);
	int lNbEvaluators = lSize - lNbEvolvers - 1;

	Beagle_ValidateParameterM( lNbEvolvers <= lPopulationSize->size() && lNbEvolvers > 0,
					"hpc.evolver.nb",
					"The number of evolver must between 1 and the number of deme");

	Beagle_ValidateParameterM( lNbEvolvers <= lNbEvaluators  &&  lNbEvaluators > 0,
					"Number of nodes.",
					"There is not enough node for each evolver node to have at least one evaluator node each.");

	mTopology["Supervisor"] = new IntArray;
	mTopology["Any"] = new IntArray;
	mTopology["Parent"] = new IntArray;
	mTopology["Sibling"] = new IntArray;
	mTopology["Child"] = new IntArray;

	mTopology["Supervisor"]->push_back(0);
	mTopology["Any"]->push_back(MPI::ANY_SOURCE);

	mTypesMap["Supervisor"] = 1;
	mTypesMap["Evolver"] = lNbEvolvers;
	mTypesMap["Evaluator"] = lSize - lNbEvolvers - 1;

	if( lRank == 0 ){
		mNodeType = "Supervisor";
		for(int i = 0; i < lPopulationSize->size(); ++i){
			mTopology["Child"]->push_back((i % lNbEvolvers) + 1);
		}
	}
	else if( lRank <= lNbEvolvers){
		mNodeType = "Evolver";
		mTopology["Parent"]->push_back(0);
		int i = lRank + 1;
		for(;  i <= lNbEvolvers; ++i)
			mTopology["Sibling"]->push_back(i);
		for(i = 1; i < lRank; ++i)
			mTopology["Sibling"]->push_back(i);

		for(int j = lRank + lNbEvolvers; j < lSize; j += lNbEvolvers){
			mTopology["Child"]->push_back(j);
		}

		UIntArray::Handle lNewPopulationSize = new UIntArray;
		for(unsigned int k =  lRank - 1; k < lPopulationSize->size(); k += lNbEvolvers){
			lNewPopulationSize->push_back( (*lPopulationSize)[k] );
		}
		(*lPopulationSize) = (*lNewPopulationSize);
	}
	else{
		mNodeType = "Evaluator";
		UIntArray::Handle lNewPopulationSize = new UIntArray;

		if(lRank % lNbEvolvers != 0 ){
			mTopology["Parent"]->push_back(lRank % lNbEvolvers);
		} else {
			mTopology["Parent"]->push_back(lNbEvolvers);
		}
		for(unsigned int i = (*mTopology["Parent"])[0] - 1; i < lPopulationSize->size(); i+= lNbEvolvers){
			lNewPopulationSize->push_back( (*lPopulationSize)[i] );
		}
		(*lPopulationSize) = (*lNewPopulationSize);
	}

	Beagle_HPC_StackTraceEndM("void HPC::MPICommunication::init(System& ioSystem)");
}
Ejemplo n.º 19
0
/*!
 *  \brief Register the parameters of this operator.
 *  \param ioSystem System of the evolution.
 */
void GP::MutationSwapSubtreeOp::registerParams(Beagle::System& ioSystem)
{
	Beagle_StackTraceBeginM();

	{
		std::ostringstream lOSS;
		lOSS << "Swap subtree mutation probability for an individual. ";
		lOSS << "A swap subtree mutation consists to swap two subtrees of a tree in an ";
		lOSS << "individual.";
		Register::Description lProbaDescription(
		    "Swap subtree mutation prob.",
		    "Double",
		    "0.0",
		    lOSS.str()
		);
		mMutationProba = castHandleT<Double>(
		                     ioSystem.getRegister().insertEntry(mMutationPbName, new Double(0.0f), lProbaDescription));
	}
	Beagle::MutationOp::registerParams(ioSystem);
	{
		std::ostringstream lOSS;
		lOSS << "Probability that a swap subtree is internal ";
		lOSS << "(the mutation occurs between three points, where the 2nd point is in the ";
		lOSS << "1st point's subtree, and the 3rd point is in the 2nd point's subtree) vs ";
		lOSS << "being external (the mutation occurs between two points, ";
		lOSS << "where both points are not within the other's subtree). ";
		lOSS << "Value of 1.0 means that the swap subtrees mutations are all internal ";
		lOSS << "while value of 0.0 means that swap subtrees mutations are all external.";
		Register::Description lDescription(
		    "Swap subtree mut. distrib. prob.",
		    "Float",
		    "0.5",
		    lOSS.str()
		);
		mDistributionProba = castHandleT<Float>(
		                         ioSystem.getRegister().insertEntry(mDistribPbName, new Float(0.5f), lDescription));
	}
	{
		Register::Description lDescription(
		    "Maximum tree depth",
		    "UInt",
		    "17",
		    "Maximum allowed depth for the trees."
		);
		mMaxTreeDepth = castHandleT<UInt>(
		                    ioSystem.getRegister().insertEntry("gp.tree.maxdepth", new UInt(17), lDescription));
	}
	{
		std::ostringstream lOSS;
		lOSS << "Maximum number of attempts to modify a GP tree in a genetic ";
		lOSS << "operation. As there is topological constraints on GP trees (i.e. tree ";
		lOSS << "depth limit), it is often necessary to try a genetic operation several times.";
		Register::Description lDescription(
		    "Max number of attempts",
		    "UInt",
		    "2",
		    lOSS.str()
		);
		mNumberAttempts = castHandleT<UInt>(
		                      ioSystem.getRegister().insertEntry("gp.try", new UInt(2), lDescription));
	}
	Beagle_StackTraceEndM();
}