本文整理汇总了C++中Ordering::Pre方法的典型用法代码示例。如果您正苦于以下问题:C++ Ordering::Pre方法的具体用法?C++ Ordering::Pre怎么用?C++ Ordering::Pre使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ordering
的用法示例。
在下文中一共展示了Ordering::Pre方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalcEncoding
void Plan::CalcEncoding() {
int n = mOrderings.size() + mSteps.size() + 1;
if(mA)
delete mA;
mA = new SparceMatrix(n, mSteps.size()*3 + n);
int row = 0; //The current equation
int k = 0; //The current slack variable
for(vector<Step*>::iterator it = mSteps.begin();
it != mSteps.end(); it++) {
Step* curStep = *it;
if(curStep->getAction()->LBDurration() ==
curStep->getAction()->UBDurration()) {
//If they are the same we don't need slack variables
//s_end - s_start = dur
mA->set(row, getStepCol(curStep, StepTime::End), mgr.addOne());
mA->set(row, getStepCol(curStep, StepTime::Start), -mgr.addOne());
(*mb)[row] = mgr.constant(curStep->getAction()->UBDurration());
row++;
} else {
//Other wise we do
//s_end - s_start - s_k = ub;
mA->set(row, getStepCol(curStep, StepTime::End), mgr.addOne());
mA->set(row, getStepCol(curStep, StepTime::Start), -mgr.addOne());
mA->set(row, getSlackVar(k), -mgr.addOne());
(*mb)[row] = mgr.constant(curStep->getAction()->UBDurration());
row++;
k++;
//s_start - s_end - s_k+1 = -lb;
mA->set(row, getStepCol(curStep, StepTime::Start), mgr.addOne());
mA->set(row, getStepCol(curStep, StepTime::End), -mgr.addOne());
mA->set(row, getSlackVar(k), -mgr.addOne());
(*mb)[row] = mgr.constant(curStep->getAction()->LBDurration());
row++;
k++;
}
}
for(vector<Ordering*>::iterator it = mOrderings.begin();
it != mOrderings.end(); it++) {
Ordering* curOrdering = *it;
//Post_time - Pre_time - s_k = epsilon
mA->set(row, getStepCol(curOrdering->Post(), curOrdering->PostTime()), mgr.addOne());
mA->set(row, getStepCol(curOrdering->Pre(), curOrdering->PreTime()), -mgr.addOne());
mA->set(row, getSlackVar(k), -mgr.addOne());
(*mb)[row] = mgr.constant(epsilon);
row++;
k++;
}
mA->set(row, getStepCol(FrameStep, StepTime::Start), -mgr.addOne());
mA->set(row, getStepCol(FrameStep, StepTime::End), mgr.addOne());
mA->set(row, getSlackVar(k), -mgr.addOne());
(*mb)[row] = mgr.constant(Deadline);
row++;
k++;
int index = 0;
mf.resize(k+mA->getNumCols());
for(int i = 0; i < k; i++) {
mf[index].index = getSlackVar(i);
mf[index].inverted = false;
index++;
}
for(int i = 0; i < mA->getNumCols(); i++) {
mf[i].index = i;
}
}