本文整理汇总了C++中Plan类的典型用法代码示例。如果您正苦于以下问题:C++ Plan类的具体用法?C++ Plan怎么用?C++ Plan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void PodgladPostepu::update( evol::Population& population )
{
Plan* best = evol::EvolFunctions::ptr_cast<evol::SubjectPtr, Plan>(
population.getSubjects().at( population.getBestId() )
);
++populationCounter;
CzasWykonania czas;
czas.calculate(*best);
unsigned int current = czas.getTimeTotal();
if( !bestTime || current < bestTime )
{
bestTime = current;
lastBetter = populationCounter;
std::cout << "Poprawil sie wynik najlepszego osobnika."<< std::endl;
std::cout << "Obecny wynik (pokolenie nr. " << populationCounter << ") to: " << std::endl;
best->print();
std::cout << std::endl;
}
else if( populationCounter%100 == 0 )
{
std::cout << "Pokolenie nr. "<< populationCounter << std::endl << std::endl;
}
if( timeLimit != 0 )
{
if( (time(NULL) - startTime) > timeLimit )
population.stopLoop();
}
}
示例2: main_plan
int main_plan(int argc, char* argv[]) {
if (argc != 2)
return -1;
Plan p;
p.fromFile(argv[1]);
p.print(std::cout);
return 0;
}
示例3: return
constexpr
bool operator ==(const Plan<I, J, T>& _lhs,
const Plan<I, J, T>& _rhs) noexcept
{
return (_lhs.id() == _rhs.id())
&& (_lhs.job() == _rhs.job())
&& (_lhs.times == _rhs.times);
}
示例4: Action
lionheart::Action lionheart::MathewWarenski::wait(Plan p)
{
if (p.hasAttack())
{
return p.attackEnemy();
}
return Action();
}
示例5: locker
void Worklist::rememberCodeBlocks(VM& vm)
{
LockHolder locker(m_lock);
for (PlanMap::iterator iter = m_plans.begin(); iter != m_plans.end(); ++iter) {
Plan* plan = iter->value.get();
if (&plan->vm != &vm)
continue;
plan->rememberCodeBlocks();
}
}
示例6: turn
lionheart::Action lionheart::MathewWarenski::playInFortDefend(
Unit const &u, SituationReport report, Plan p)
{
auto dir = setdefdir(u, report);
if (dir != u.getFacing())
return turn(dir);
if (p.hasAttack())
{
return p.attackEnemy();
}
return Action();
}
示例7: GetIntersectionPoint
Point InterceptorPlans::GetIntersectionPoint(const Plan & a, const Plan & b, const Vector & direction){
Vector AB = b.Origin()-a.Origin();
Basis baseA = a.Position();
Basis baseB = b.Position();
if((baseA.AxisZ()^direction) != Vector(0,0,0)){
double beta = ( (baseA.AxisY()*baseB.AxisY())*(AB*baseB.AxisY()) + ((baseA.AxisY()*baseB.AxisZ())*(AB*baseB.AxisZ()) - AB*baseA.AxisY()) )
/ ( (baseA.AxisY()*baseB.AxisY())*(baseA.AxisZ()*baseB.AxisY()) + (baseA.AxisY()*baseB.AxisZ())*(baseA.AxisZ()*baseB.AxisZ()));
return baseA.Origin() + beta*baseA.AxisZ();
}
else{
double beta = ( (baseA.AxisZ()*baseB.AxisY())*(AB*baseB.AxisY()) + ((baseA.AxisZ()*baseB.AxisZ())*(AB*baseB.AxisZ()) - AB*baseA.AxisZ()) )
/ ( (baseA.AxisZ()*baseB.AxisY())*(baseA.AxisY()*baseB.AxisY()) + (baseA.AxisY()*baseB.AxisZ())*(baseA.AxisZ()*baseB.AxisZ()));
return baseA.Origin() + beta*baseA.AxisY();
}
}
示例8: update
void CommandCreator::update(const Plan &plan, const GlobalMap &gMap)
{
// make vector from current position to destination
const Vector2DCont &vp=plan.getDst().getDstVect();
// get vector of direction of robot
const Vector2DCont &vd=gMap.getDir();
// get angle between robot's direcion vector and destination in
// radians (clock-wise)
double angle=vd.getAngle(vp);
TIERproto::Speed spd(0,0); // speed to set
if( angle<_params._tolerance ||
2*M_PI-_params._tolerance<angle) // misdirection is suficiently
spd=TIERproto::Speed( 250, 250); // small not to change dir?
else
if(angle<M_PI) // turn right?
spd=TIERproto::Speed( 250, -250);
//spd=TIERproto::Speed( 0,-250);
else // turn left?
spd=TIERproto::Speed(-250, 250);
//spd=TIERproto::Speed(-250, 0);
// critical section - set new speed
{
Lock lock(_mutex);
_spdSet=spd;
};
};
示例9: addR_Cent
void addR_Cent(ADDvector& r_t, Plan& P, ADDvector& x, ADDvector& lambda, bool phase1 = false) {
int t = 1;
ADDvector R_Cent = -diag(lambda)*P.F(x, phase1) - ConstVector(1/t, lambda.count());
for(int i = 0; i < R_Cent.count(); i++) {
r_t[x.count() + i] = R_Cent[i];
}
}
示例10: addDiagFx
void addDiagFx(int offset, ADDvector x, SparceMatrix& lhs, Plan& P, bool phase1 = false) {
ADDvector f_x = P.F(x, phase1);
for(int i = 0; i < x.count(); i++) {
lhs.set(offset, offset, -f_x[i]);
offset++;
}
}
示例11:
bool operator<(const Plan &lhs,const Plan &rhs){
std::vector<double> lhsP, rhsP;
lhsP=lhs.getPriority();
rhsP=rhs.getPriority();
int counter=0;
while(true){
if(lhsP.size()<counter+1)
return true;
if(rhsP.size()<counter+1)
return false;
if(lhsP[counter]<rhsP[counter])
return true;
if(rhsP[counter]<lhsP[counter])
return false;
counter++;
}
}
示例12: evaluate
double evaluate(Plan& P) {
//Compute Phase One
ADDvector xPhase1(P.getNumStepsWithUnknownDurration() + P.getNumSteps() + P.getNumSlackVars() + 1);
for(int i = 0; i < xPhase1.count(); i++) {
xPhase1[i] = mgr.addZero();
}
xPhase1[xPhase1.count()-1] = mgr.constant(10000); //inital value for s
ADDvector lambda(P.getNumFunctions());
for(int i = 0; i < lambda.count(); i++) {
lambda[i] = mgr.addZero();
}
ADDvector nu(P.getNumFunctions());
for(int i = 0; i < nu.count(); i++) {
nu[i] = mgr.addZero();
}
while(checkTeminationConditions(P, xPhase1, lambda, nu, true)) {
ADDvector DxPhase1(xPhase1.count());
ADDvector Dlambda(lambda.count());
ADDvector Dnu(nu.count());
calcStepDirection( xPhase1, lambda, nu,
DxPhase1, Dlambda, Dnu,
P, true);
takeStep( xPhase1, lambda, nu,
DxPhase1, Dlambda, Dnu);
}
//Compute Phase two
ADDvector x(xPhase1.count() -1);
for(int i = 0; i < x.count(); i++) {
x[i] = xPhase1[i];
}
while(checkTeminationConditions(P, x, lambda, nu, false)) {
ADDvector Dx(x.count());
ADDvector Dlambda(lambda.count());
ADDvector Dnu(nu.count());
calcStepDirection( x, lambda, nu,
Dx, Dlambda, Dnu,
P, false);
takeStep( x, lambda, nu,
Dx, Dlambda, Dnu);
}
//Really I need to do some max's and sum's here but that can be added later.
//Right now I need to add something to test all of this code.
return 0;
}
示例13: addR_Pri
void addR_Pri(ADDvector& r_t, Plan& P, ADDvector& x, ADDvector& lambda, bool phase1 = false) {
//note phase 1 and 2 are the same here but the parameter is added for
//symetry with the other calls
int offset = lambda.count() + x.count();
ADDvector R_Pri = *(P.A()) * x; // - b?
for(int i = 0; i < lambda.count(); i++) {
r_t[i+offset] = R_Pri[i];
}
}
示例14: Intercept
Interception InterceptorPlans::Intercept(Plan& a, Plan& b) {
Interception interception;
Vector direction = a.Normal() ^ b.Normal();
if(direction == Vector(0,0,0)){
if(a == b){
interception.Type(InterceptionPlan);
interception.SetPlan(a);
return interception;
}
else{
return interception;
}
}
Line solution(GetIntersectionPoint(a,b,direction),direction);
interception.Type(InterceptionLine);
interception.SetLine(solution);
return interception;
}
示例15:
Safepoint::Safepoint(Plan& plan, Result& result)
: m_vm(plan.vm())
, m_plan(plan)
, m_didCallBegin(false)
, m_result(result)
{
RELEASE_ASSERT(result.m_wasChecked);
result.m_wasChecked = false;
result.m_didGetCancelled = false;
}