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


C++ Gate::id方法代码示例

本文整理汇总了C++中Gate::id方法的典型用法代码示例。如果您正苦于以下问题:C++ Gate::id方法的具体用法?C++ Gate::id怎么用?C++ Gate::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gate的用法示例。


在下文中一共展示了Gate::id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: solveX

bool IterativeTimeHorizonMath::solveX()
{
	int *solution = 0;
	bool controlPrevious = false;
	ptime p_prev = _opening;
	ptime p_curr;
	_clock_begin = clock();
	int interval = 0;
	/* Per ogni ogni intervallo di pianificazione */
	for (p_curr = _opening; p_curr < _closing; p_prev = p_curr, p_curr += minutes(60), interval++) {
		ptime end = p_curr + minutes(120);
		// cout << "   Pianifico in [" << p_curr << ", " << end << "] considerando [" << p_prev << ", " << end << "]" << endl;

		/* genera il nuovo insieme delle soste */
		Buses dwellsWithinPeriod;
		Gates platformsWithinPeriod;
		int id = 0;
		for (Gates::const_iterator gitr = _graphs.G().begin(); gitr != _graphs.G().end(); gitr++) {
			Gate *g = new Gate(*(*gitr));
			g->id(id++);
			platformsWithinPeriod.push_back(g);
		}
		vector <int> mapVectorId;
		id = 0;
		for (Buses::const_iterator bitr = _graphs.B().begin(); bitr != _graphs.B().end(); bitr++) {
			if ( ((*bitr)->departure() >= p_prev) && ((*bitr)->arrival() <= end)) {
				// rimappa i gates
				Gates *gates = new Gates();
				for (Gates::const_iterator gitr = (*bitr)->gates().begin(); gitr != (*bitr)->gates().end(); gitr++) {
					int gateVectorIndex = (*gitr)->id() - _graphs.B().size();
					gates->push_back(platformsWithinPeriod[gateVectorIndex]);
				}
				Bus *dwell = new Bus(*(*bitr), id, gates);
				// aggiungilo alle soste correnti
				dwellsWithinPeriod.push_back(dwell);
				// mappa le corrispondenze
				mapVectorId.push_back((*bitr)->id());
				id++;
			}
		}

		if (dwellsWithinPeriod.size() == 0) {
			controlPrevious = true;
			continue;
		}

		SetModel pSet(dwellsWithinPeriod, platformsWithinPeriod);
		GraphModel pGraph(pSet);
		MathModel *mPconflictModel = new MathModelMinPConflict(pGraph);

		/*
		if (controlPrevious) {
			// Forza gli assegnamenti generati all'iterazione precedente
		}
		*/
		
		//cout << "MathModel generato" << endl;
		// Risolvi il modello
		mPconflictModel->verbose(IMPORTANT); // NORMAL);
		mPconflictModel->setTimeout(5);

		char itrNo[4];
		char fn[40];
		sprintf(itrNo, "%03d", interval); 
		strcpy(fn, "modelIterativeMPC_");
		strcat(fn, itrNo);
		strcat(fn, ".lp");
		mPconflictModel->writeModelLP_solve(fn);
		mPconflictModel->solveX();

		if (mPconflictModel->solved()) {
			// Imposta gli assegnamenti determinati nell'iterazione corrente
			int *pSolution = 0;
			mPconflictModel->solution(pSolution);
			for (int i = 0; i < dwellsWithinPeriod.size(); i++) {
				_graphs.B()[mapVectorId[i]]->assigned(true);
				_graphs.B()[mapVectorId[i]]->platform(pSolution[i]);
			}
		} else
			return false;
	}

	_clock_end = clock();
	
	return true;
}
开发者ID:gionata,项目名称:bus2platform,代码行数:86,代码来源:IterativeTimeHorizonMath.cpp


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