/*! * \brief Configure steady-state evolutionary algorithm in evolver. * \param ioEvolver Evolver modified by setting the algorithm. * \param ioSystem Evolutionary system. * */ void AlgoSteadyState::configure(Evolver& ioEvolver, System& ioSystem) { Beagle_StackTraceBeginM(); // Get reference to the factory const Factory& lFactory = ioSystem.getFactory(); // Get name and allocator of used operators std::string lEvalOpName = lFactory.getConceptTypeName("EvaluationOp"); EvaluationOp::Alloc::Handle lEvalOpAlloc = castHandleT<EvaluationOp::Alloc>(lFactory.getAllocator(lEvalOpName)); std::string lSelectOpName = lFactory.getConceptTypeName("SelectionOp"); SelectionOp::Alloc::Handle lSelectOpAlloc = castHandleT<SelectionOp::Alloc>(lFactory.getAllocator(lSelectOpName)); std::string lInitOpName = lFactory.getConceptTypeName("InitializationOp"); InitializationOp::Alloc::Handle lInitOpAlloc = castHandleT<InitializationOp::Alloc>(lFactory.getAllocator(lInitOpName)); std::string lCxOpName = lFactory.getConceptTypeName("CrossoverOp"); CrossoverOp::Alloc::Handle lCxOpAlloc = castHandleT<CrossoverOp::Alloc>(lFactory.getAllocator(lCxOpName)); std::string lMutOpName = lFactory.getConceptTypeName("MutationOp"); MutationOp::Alloc::Handle lMutOpAlloc = castHandleT<MutationOp::Alloc>(lFactory.getAllocator(lMutOpName)); std::string lMigOpName = lFactory.getConceptTypeName("MigrationOp"); MigrationOp::Alloc::Handle lMigOpAlloc = castHandleT<MigrationOp::Alloc>(lFactory.getAllocator(lMigOpName)); std::string lStatsCalcOpName = lFactory.getConceptTypeName("StatsCalculateOp"); StatsCalculateOp::Alloc::Handle lStatsCalcOpAlloc = castHandleT<StatsCalculateOp::Alloc>(lFactory.getAllocator(lStatsCalcOpName)); std::string lTermOpName = lFactory.getConceptTypeName("TerminationOp"); TerminationOp::Alloc::Handle lTermOpAlloc = castHandleT<TerminationOp::Alloc>(lFactory.getAllocator(lTermOpName)); std::string lMsWriteOpName = "MilestoneWriteOp"; MilestoneWriteOp::Alloc::Handle lMsWriteOpAlloc = castHandleT<MilestoneWriteOp::Alloc>(lFactory.getAllocator(lMsWriteOpName)); std::string lSSOpName = "SteadyStateOp"; SteadyStateOp::Alloc::Handle lSSOpAlloc = castHandleT<SteadyStateOp::Alloc>(lFactory.getAllocator(lSSOpName)); // Clear bootstrap and mainloop sets ioEvolver.getBootStrapSet().clear(); ioEvolver.getMainLoopSet().clear(); // Set the boostrap operator set InitializationOp::Handle lInitOpBS = castHandleT<InitializationOp>(lInitOpAlloc->allocate()); lInitOpBS->setName(lInitOpName); ioEvolver.getBootStrapSet().push_back(lInitOpBS); EvaluationOp::Handle lEvalOpBS = castHandleT<EvaluationOp>(lEvalOpAlloc->allocate()); lEvalOpBS->setName(lEvalOpName); ioEvolver.getBootStrapSet().push_back(lEvalOpBS); StatsCalculateOp::Handle lStatsCalcOpBS = castHandleT<StatsCalculateOp>(lStatsCalcOpAlloc->allocate()); lStatsCalcOpBS->setName(lStatsCalcOpName); ioEvolver.getBootStrapSet().push_back(lStatsCalcOpBS); TerminationOp::Handle lTermOpBS = castHandleT<TerminationOp>(lTermOpAlloc->allocate()); lTermOpBS->setName(lTermOpName); ioEvolver.getBootStrapSet().push_back(lTermOpBS); MilestoneWriteOp::Handle lMsWriteOpBS = castHandleT<MilestoneWriteOp>(lMsWriteOpAlloc->allocate()); lMsWriteOpBS->setName(lMsWriteOpName); ioEvolver.getBootStrapSet().push_back(lMsWriteOpBS); // Set the mainloop operator set SteadyStateOp::Handle lSSOp = castHandleT<SteadyStateOp>(lSSOpAlloc->allocate()); lSSOp->setName(lSSOpName); // Set crossover branch BreederNode::Handle lCxBranchNode = new BreederNode; lSSOp->setRootNode(lCxBranchNode); lCxBranchNode->setBreederOp(castHandleT<EvaluationOp>(lEvalOpAlloc->allocate())); lCxBranchNode->getBreederOp()->setName(lEvalOpName); BreederNode::Handle lCxNode = new BreederNode; lCxBranchNode->setFirstChild(lCxNode); lCxNode->setBreederOp(castHandleT<CrossoverOp>(lCxOpAlloc->allocate())); lCxNode->getBreederOp()->setName(lCxOpName); BreederNode::Handle lSelectCxNode1 = new BreederNode; lCxNode->setFirstChild(lSelectCxNode1); lSelectCxNode1->setBreederOp(castHandleT<SelectionOp>(lSelectOpAlloc->allocate())); lSelectCxNode1->getBreederOp()->setName(lSelectOpName); BreederNode::Handle lSelectCxNode2 = new BreederNode; lSelectCxNode1->setNextSibling(lSelectCxNode2); lSelectCxNode2->setBreederOp(castHandleT<SelectionOp>(lSelectOpAlloc->allocate())); lSelectCxNode2->getBreederOp()->setName(lSelectOpName); // Set mutation branch BreederNode::Handle lMutBranchNode = new BreederNode; lCxBranchNode->setNextSibling(lMutBranchNode); lMutBranchNode->setBreederOp(castHandleT<EvaluationOp>(lEvalOpAlloc->allocate())); lMutBranchNode->getBreederOp()->setName(lEvalOpName); BreederNode::Handle lMutNode = new BreederNode; lMutBranchNode->setFirstChild(lMutNode); lMutNode->setBreederOp(castHandleT<MutationOp>(lMutOpAlloc->allocate())); lMutNode->getBreederOp()->setName(lMutOpName); BreederNode::Handle lSelectMutNode = new BreederNode; lMutNode->setFirstChild(lSelectMutNode); lSelectMutNode->setBreederOp(castHandleT<SelectionOp>(lSelectOpAlloc->allocate())); lSelectMutNode->getBreederOp()->setName(lSelectOpName); // Set reproduction branch BreederNode::Handle lReproBranchNode = new BreederNode; lMutBranchNode->setNextSibling(lReproBranchNode); lReproBranchNode->setBreederOp(castHandleT<SelectionOp>(lSelectOpAlloc->allocate())); lReproBranchNode->getBreederOp()->setName(lSelectOpName); // Set remaining operators of mainloop MigrationOp::Handle lMigOpML = castHandleT<MigrationOp>(lMigOpAlloc->allocate()); lMigOpML->setName(lMigOpName); ioEvolver.getMainLoopSet().push_back(lMigOpML); StatsCalculateOp::Handle lStatsCalcOpML = castHandleT<StatsCalculateOp>(lStatsCalcOpAlloc->allocate()); lStatsCalcOpML->setName(lStatsCalcOpName); ioEvolver.getMainLoopSet().push_back(lStatsCalcOpML); TerminationOp::Handle lTermOpML = castHandleT<TerminationOp>(lTermOpAlloc->allocate()); lTermOpML->setName(lTermOpName); ioEvolver.getMainLoopSet().push_back(lTermOpML); MilestoneWriteOp::Handle lMsWriteOpML = castHandleT<MilestoneWriteOp>(lMsWriteOpAlloc->allocate()); lMsWriteOpML->setName(lMsWriteOpName); ioEvolver.getMainLoopSet().push_back(lMsWriteOpML); Beagle_StackTraceEndM("void AlgoSteadyState::configure(Evolver&,System&)"); }
/*! * \brief Configure master-slave cruncher evolutionary algorithm in evolver. * \param ioEvolver Evolver modified by setting the algorithm. * \param ioSystem Evolutionary system. * */ void Distrib::Master::AlgoSequential::configure(Evolver& ioEvolver, System& ioSystem) { Beagle_StackTraceBeginM(); // Get reference to the factory const Factory& lFactory = ioSystem.getFactory(); // Get name and allocator of used operators std::string lEvalOpName = "DBMS-DistribEvalOp"; Distrib::Master::DistribEvalOp::Alloc::Handle lEvalOpAlloc = castHandleT<Distrib::Master::DistribEvalOp::Alloc>(lFactory.getAllocator(lEvalOpName)); std::string lSelectOpName = lFactory.getConceptTypeName("SelectionOp"); SelectionOp::Alloc::Handle lSelectOpAlloc = castHandleT<SelectionOp::Alloc>(lFactory.getAllocator(lSelectOpName)); std::string lInitOpName = lFactory.getConceptTypeName("InitializationOp"); InitializationOp::Alloc::Handle lInitOpAlloc = castHandleT<InitializationOp::Alloc>(lFactory.getAllocator(lInitOpName)); std::string lCxOpName = lFactory.getConceptTypeName("CrossoverOp"); CrossoverOp::Alloc::Handle lCxOpAlloc = castHandleT<CrossoverOp::Alloc>(lFactory.getAllocator(lCxOpName)); std::string lMutOpName = lFactory.getConceptTypeName("MutationOp"); MutationOp::Alloc::Handle lMutOpAlloc = castHandleT<MutationOp::Alloc>(lFactory.getAllocator(lMutOpName)); std::string lMigOpName = lFactory.getConceptTypeName("MigrationOp"); MigrationOp::Alloc::Handle lMigOpAlloc = castHandleT<MigrationOp::Alloc>(lFactory.getAllocator(lMigOpName)); std::string lStatsCalcOpName = lFactory.getConceptTypeName("StatsCalculateOp"); StatsCalculateOp::Alloc::Handle lStatsCalcOpAlloc = castHandleT<StatsCalculateOp::Alloc>(lFactory.getAllocator(lStatsCalcOpName)); std::string lTermOpName = lFactory.getConceptTypeName("TerminationOp"); TerminationOp::Alloc::Handle lTermOpAlloc = castHandleT<TerminationOp::Alloc>(lFactory.getAllocator(lTermOpName)); std::string lITEOpName = "IfThenElseOp"; IfThenElseOp::Alloc::Handle lITEOpAlloc = castHandleT<IfThenElseOp::Alloc>(lFactory.getAllocator(lITEOpName)); std::string lMsWriteOpName = "DBMS-MilestoneWriteOp"; Distrib::Master::MilestoneWriteOp::Alloc::Handle lMsWriteOpAlloc = castHandleT<MilestoneWriteOp::Alloc>(lFactory.getAllocator(lMsWriteOpName)); std::string lBSBeginOpName = "DBMS-BootStrapBeginOp"; BootStrapBeginOp::Alloc::Handle lBSBeginOpAlloc = castHandleT<BootStrapBeginOp::Alloc>(lFactory.getAllocator(lBSBeginOpName)); std::string lBSEndOpName = "DBMS-BootStrapEndOp"; BootStrapEndOp::Alloc::Handle lBSEndOpAlloc = castHandleT<BootStrapEndOp::Alloc>(lFactory.getAllocator(lBSEndOpName)); std::string lMLBeginOpName = "DBMS-MainLoopBeginOp"; MainLoopBeginOp::Alloc::Handle lMLBeginOpAlloc = castHandleT<MainLoopBeginOp::Alloc>(lFactory.getAllocator(lMLBeginOpName)); std::string lMLEndOpName = "DBMS-MainLoopEndOp"; MainLoopEndOp::Alloc::Handle lMLEndOpAlloc = castHandleT<MainLoopEndOp::Alloc>(lFactory.getAllocator(lMLEndOpName)); // Clear bootstrap and mainloop sets ioEvolver.getBootStrapSet().clear(); ioEvolver.getMainLoopSet().clear(); // Set the boostrap operator set BootStrapBeginOp::Handle lBSBeginOpBS = castHandleT<BootStrapBeginOp>(lBSBeginOpAlloc->allocate()); lBSBeginOpBS->setName(lBSBeginOpName); ioEvolver.getBootStrapSet().push_back(lBSBeginOpBS); IfThenElseOp::Handle lITEOp = castHandleT<IfThenElseOp>(lITEOpAlloc->allocate()); lITEOp->setName(lITEOpName); ioEvolver.getBootStrapSet().push_back(lITEOp); lITEOp->setConditionTag("db.restart"); lITEOp->setConditionValue("1"); InitializationOp::Handle lInitOpBS = castHandleT<InitializationOp>(lInitOpAlloc->allocate()); lInitOpBS->setName(lInitOpName); lITEOp->insertNegativeOp(lInitOpBS); EvaluationOp::Handle lEvalOpBS = castHandleT<EvaluationOp>(lEvalOpAlloc->allocate()); lEvalOpBS->setName(lEvalOpName); lITEOp->insertNegativeOp(lEvalOpBS); MigrationOp::Handle lMigOpBS = castHandleT<MigrationOp>(lMigOpAlloc->allocate()); lMigOpBS->setName(lMigOpName); lITEOp->insertNegativeOp(lMigOpBS); StatsCalculateOp::Handle lStatsCalcOpBS = castHandleT<StatsCalculateOp>(lStatsCalcOpAlloc->allocate()); lStatsCalcOpBS->setName(lStatsCalcOpName); lITEOp->insertNegativeOp(lStatsCalcOpBS); TerminationOp::Handle lTermOpBS = castHandleT<TerminationOp>(lTermOpAlloc->allocate()); lTermOpBS->setName(lTermOpName); lITEOp->insertNegativeOp(lTermOpBS); MilestoneWriteOp::Handle lMsWriteOpBS = castHandleT<MilestoneWriteOp>(lMsWriteOpAlloc->allocate()); lMsWriteOpBS->setName(lMsWriteOpName); lITEOp->insertNegativeOp(lMsWriteOpBS); BootStrapEndOp::Handle lBSEndOpBS = castHandleT<BootStrapEndOp>(lBSEndOpAlloc->allocate()); lBSEndOpBS->setName(lBSEndOpName); ioEvolver.getBootStrapSet().push_back(lBSEndOpBS); // Set the mainloop operator set MainLoopBeginOp::Handle lMLBeginOpML = castHandleT<MainLoopBeginOp>(lMLBeginOpAlloc->allocate()); lMLBeginOpML->setName(lMLBeginOpName); ioEvolver.getMainLoopSet().push_back(lMLBeginOpML); SelectionOp::Handle lSelectOpML = castHandleT<SelectionOp>(lSelectOpAlloc->allocate()); lSelectOpML->setName(lSelectOpName); ioEvolver.getMainLoopSet().push_back(lSelectOpML); CrossoverOp::Handle lCxOpML = castHandleT<CrossoverOp>(lCxOpAlloc->allocate()); lCxOpML->setName(lCxOpName); ioEvolver.getMainLoopSet().push_back(lCxOpML); MutationOp::Handle lMutOpML = castHandleT<MutationOp>(lMutOpAlloc->allocate()); lMutOpML->setName(lMutOpName); ioEvolver.getMainLoopSet().push_back(lMutOpML); EvaluationOp::Handle lEvalOpML = castHandleT<EvaluationOp>(lEvalOpAlloc->allocate()); lEvalOpML->setName(lEvalOpName); ioEvolver.getMainLoopSet().push_back(lEvalOpML); MigrationOp::Handle lMigOpML = castHandleT<MigrationOp>(lMigOpAlloc->allocate()); lMigOpML->setName(lMigOpName); ioEvolver.getMainLoopSet().push_back(lMigOpML); StatsCalculateOp::Handle lStatsCalcOpML = castHandleT<StatsCalculateOp>(lStatsCalcOpAlloc->allocate()); lStatsCalcOpML->setName(lStatsCalcOpName); ioEvolver.getMainLoopSet().push_back(lStatsCalcOpML); TerminationOp::Handle lTermOpML = castHandleT<TerminationOp>(lTermOpAlloc->allocate()); lTermOpML->setName(lTermOpName); ioEvolver.getMainLoopSet().push_back(lTermOpML); MilestoneWriteOp::Handle lMsWriteOpML = castHandleT<MilestoneWriteOp>(lMsWriteOpAlloc->allocate()); lMsWriteOpML->setName(lMsWriteOpName); ioEvolver.getMainLoopSet().push_back(lMsWriteOpML); MainLoopEndOp::Handle lMLEndOpML = castHandleT<MainLoopEndOp>(lMLEndOpAlloc->allocate()); lMLEndOpML->setName(lMLEndOpName); ioEvolver.getMainLoopSet().push_back(lMLEndOpML); Beagle_StackTraceEndM(); }
/*! * \brief Configure evolver with CMA-ES evolutionary algorithm. * \param ioEvolver Evolver modified by setting the algorithm. * \param ioSystem Evolutionary system. * */ void GA::AlgoCMAES::configure(Evolver& ioEvolver, System& ioSystem) { Beagle_StackTraceBeginM(); // Get reference to the factory const Factory& lFactory = ioSystem.getFactory(); // Get name and allocator of used operators std::string lEvalOpName = lFactory.getConceptTypeName("EvaluationOp"); EvaluationOp::Alloc::Handle lEvalOpAlloc = castHandleT<EvaluationOp::Alloc>(lFactory.getAllocator(lEvalOpName)); std::string lSelectOpName = "SelectRandomOp"; SelectionOp::Alloc::Handle lSelectOpAlloc = castHandleT<SelectionOp::Alloc>(lFactory.getAllocator(lSelectOpName)); std::string lInitOpName = lFactory.getConceptTypeName("InitializationOp"); InitializationOp::Alloc::Handle lInitOpAlloc = castHandleT<InitializationOp::Alloc>(lFactory.getAllocator(lInitOpName)); std::string lMutOpName = "GA-MutationCMAFltVecOp"; MutationOp::Alloc::Handle lMutOpAlloc = castHandleT<MutationOp::Alloc>(lFactory.getAllocator(lMutOpName)); std::string lMigOpName = lFactory.getConceptTypeName("MigrationOp"); MigrationOp::Alloc::Handle lMigOpAlloc = castHandleT<MigrationOp::Alloc>(lFactory.getAllocator(lMigOpName)); std::string lStatsCalcOpName = lFactory.getConceptTypeName("StatsCalculateOp"); StatsCalculateOp::Alloc::Handle lStatsCalcOpAlloc = castHandleT<StatsCalculateOp::Alloc>(lFactory.getAllocator(lStatsCalcOpName)); std::string lTermOpName = lFactory.getConceptTypeName("TerminationOp"); TerminationOp::Alloc::Handle lTermOpAlloc = castHandleT<TerminationOp::Alloc>(lFactory.getAllocator(lTermOpName)); std::string lMsWriteOpName = "MilestoneWriteOp"; MilestoneWriteOp::Alloc::Handle lMsWriteOpAlloc = castHandleT<MilestoneWriteOp::Alloc>(lFactory.getAllocator(lMsWriteOpName)); std::string lMCLOpName = "GA-MuWCommaLambdaCMAFltVecOp"; GA::MuWCommaLambdaCMAFltVecOp::Alloc::Handle lMCLOpAlloc = castHandleT<GA::MuWCommaLambdaCMAFltVecOp::Alloc>(lFactory.getAllocator(lMCLOpName)); // Clear bootstrap and mainloop sets ioEvolver.getBootStrapSet().clear(); ioEvolver.getMainLoopSet().clear(); // Set the boostrap operator set InitializationOp::Handle lInitOpBS = castHandleT<InitializationOp>(lInitOpAlloc->allocate()); lInitOpBS->setName(lInitOpName); ioEvolver.getBootStrapSet().push_back(lInitOpBS); EvaluationOp::Handle lEvalOpBS = castHandleT<EvaluationOp>(lEvalOpAlloc->allocate()); lEvalOpBS->setName(lEvalOpName); ioEvolver.getBootStrapSet().push_back(lEvalOpBS); StatsCalculateOp::Handle lStatsCalcOpBS = castHandleT<StatsCalculateOp>(lStatsCalcOpAlloc->allocate()); lStatsCalcOpBS->setName(lStatsCalcOpName); ioEvolver.getBootStrapSet().push_back(lStatsCalcOpBS); TerminationOp::Handle lTermOpBS = castHandleT<TerminationOp>(lTermOpAlloc->allocate()); lTermOpBS->setName(lTermOpName); ioEvolver.getBootStrapSet().push_back(lTermOpBS); MilestoneWriteOp::Handle lMsWriteOpBS = castHandleT<MilestoneWriteOp>(lMsWriteOpAlloc->allocate()); lMsWriteOpBS->setName(lMsWriteOpName); ioEvolver.getBootStrapSet().push_back(lMsWriteOpBS); // Set the mainloop operator set GA::MuWCommaLambdaCMAFltVecOp::Handle lMCLOp = castHandleT<GA::MuWCommaLambdaCMAFltVecOp>(lMCLOpAlloc->allocate()); lMCLOp->setName(lMCLOpName); ioEvolver.getMainLoopSet().push_back(lMCLOp); // Set breeder tree BreederNode::Handle lEvalNode = new BreederNode; lMCLOp->setRootNode(lEvalNode); lEvalNode->setBreederOp(castHandleT<EvaluationOp>(lEvalOpAlloc->allocate())); lEvalNode->getBreederOp()->setName(lEvalOpName); BreederNode::Handle lMutNode = new BreederNode; lEvalNode->setFirstChild(lMutNode); lMutNode->setBreederOp(castHandleT<MutationOp>(lMutOpAlloc->allocate())); lMutNode->getBreederOp()->setName(lMutOpName); BreederNode::Handle lSelectMutNode = new BreederNode; lMutNode->setFirstChild(lSelectMutNode); lSelectMutNode->setBreederOp(castHandleT<SelectionOp>(lSelectOpAlloc->allocate())); lSelectMutNode->getBreederOp()->setName(lSelectOpName); // Set remaining operators of mainloop MigrationOp::Handle lMigOpML = castHandleT<MigrationOp>(lMigOpAlloc->allocate()); lMigOpML->setName(lMigOpName); ioEvolver.getMainLoopSet().push_back(lMigOpML); StatsCalculateOp::Handle lStatsCalcOpML = castHandleT<StatsCalculateOp>(lStatsCalcOpAlloc->allocate()); lStatsCalcOpML->setName(lStatsCalcOpName); ioEvolver.getMainLoopSet().push_back(lStatsCalcOpML); TerminationOp::Handle lTermOpML = castHandleT<TerminationOp>(lTermOpAlloc->allocate()); lTermOpML->setName(lTermOpName); ioEvolver.getMainLoopSet().push_back(lTermOpML); MilestoneWriteOp::Handle lMsWriteOpML = castHandleT<MilestoneWriteOp>(lMsWriteOpAlloc->allocate()); lMsWriteOpML->setName(lMsWriteOpName); ioEvolver.getMainLoopSet().push_back(lMsWriteOpML); Beagle_StackTraceEndM("void AlgoCMAES::configure(Evolver&,System&)"); }