当前位置: 首页>>代码示例>>C++>>正文


C++ Ordering::Pre方法代码示例

本文整理汇总了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;
	}
}
开发者ID:danmorwood,项目名称:Miriad,代码行数:69,代码来源:plan.cpp


注:本文中的Ordering::Pre方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。