本文整理汇总了C++中beagle::Context::getDeme方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::getDeme方法的具体用法?C++ Context::getDeme怎么用?C++ Context::getDeme使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beagle::Context
的用法示例。
在下文中一共展示了Context::getDeme方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lArrayA
/*!
* \brief Evaluate the fitness of the given individual.
* \param inIndividual Current individual to evaluate.
* \param ioContext Evolutionary context.
* \return Handle to the fitness value of the individual.
*/
Beagle::Fitness::Handle AnalogFilterParameterEvalOp::evaluate(Beagle::Individual& inIndividual, Beagle::Context& ioContext) {
Beagle_AssertM(inIndividual.size() == 1);
Beagle_LogVerboseM(
ioContext.getSystem().getLogger(),
"evaluation", "AnalogFilterParameterEvalOp",
std::string("Evaluating individual: ")+
inIndividual.serialize()
);
BGFitness *lFitness = new BGFitness(0);
GrowingBondGraph::Handle lBondGraph;
GA::FloatVector::Handle lParametersVector = castHandleT<GA::FloatVector>(inIndividual[0]);
BGContext& lBGContext = castObjectT<BGContext&>(ioContext);
SpeciesGA& lSpecies = castObjectT<SpeciesGA&>(ioContext.getDeme());
RepresentantGP::Handle lIndividual = castHandleT<RepresentantGP>(lSpecies.getRepresentant());
TreeSTag::Handle lTree = castHandleT<TreeSTag>((*lIndividual)[0]);
// lTree->assignNewParameterVector(lParametersVector, lBGContext);
lBondGraph = lTree->getBondGraph();
lBondGraph->assignParameters(*lParametersVector);
lIndividual->getFitness()->setInvalid();
Beagle_LogDebugM(
ioContext.getSystem().getLogger(),
"evaluation", "AnalogFilterParameterEvalOp",
std::string("Individual after parameter assignment: ")+
lIndividual->serialize()
);
try {
vector<double> lInitial;
//Run the individual to create the bond graph.
// RootReturn lResult;
//
// lBGContext.setIndividualHandle(lIndividual);
// lIndividual->run(lResult, lBGContext);
// lBondGraph = lBGContext.getBondGraph();
// lTree->setBondGraph(lBondGraph);
//
// //Set output bond
// Bond* lOutputBond = lBondGraph->getComponents()[lResult.getValue()-1]->getPorts()[0]->getBond();
// lBondGraph->setOutputBonds(lOutputBond, 0);
Beagle_LogDebugM(
ioContext.getSystem().getLogger(),
"evaluation", "AnalogFilterParameterEvalOp",
std::string("Evaluating bondgrap: ")+
lBondGraph->BondGraph::serialize()
);
//lBondGraph->simplify();
//Get state equations
lBondGraph->assignCausality();
lBondGraph->computeStateEquation();
PACC::Matrix lA,lB,lB2,lC,lD,lD2;
lBondGraph->getStateMatrix(lA,lB,lB2);
lBondGraph->getOutputMatrix(lC,lD,lD2);
lFitness->addStateMatrix(lA);
lFitness->addStateMatrix(lB);
lFitness->addStateMatrix(lC);
lFitness->addStateMatrix(lD);
//Check to see if the system is LTI
if(lBondGraph->hasDeferentialCausality()) {
//lFitness->setValue(ioContext.getSystem().getRandomizer().getFloat());
lFitness->setValue(0);
//delete lBondGraph;
return lFitness;
} else {
#ifndef DEBUG_NOMATLAB
//Evalute the response in Matlab.
// Cast the state matrix as input data
// The mwArray::SetData is copying in column major order and the PACC::Matrix is a row major order
// Therefore, the matrix need to be transposed.
PACC::Matrix lAt,lBt,lCt,lDt;
if(!lA.empty())
lAt = lA.transpose();
if(!lB.empty())
lBt = lB.transpose();
if(!lC.empty())
lCt = lC.transpose();
if(!lD.empty())
lDt = lD.transpose();
double *lValueA = new double[lAt.size()];
//.........这里部分代码省略.........
开发者ID:ComputationalIntelligenceAndMechatronics,项目名称:HBGGP,代码行数:101,代码来源:AnalogFilterParameterEvalOp.cpp