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


C++ Movement::parent方法代码示例

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


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

示例1: addCollisions

/*
 * s_j + r CT + 2*|R| CT (3-c_{i,j}^{k1,k2,r}-m_i^k1-m_j^k2) \geq s_i + d_i (16)
 * s_i + 2*|R| CT (2+c_{i,j}^{k1,k2,r}-m_i^k1-m_j^k2) \geq s_j + d_j + r CT (17)
 */
void ConstraintsGenerator::addCollisions(const map1to1& s, const map1to1& d, const map2to1& x, const map2to1& y, const map4toN& c)	{
	assert(mRobots.size() > 1 && mLine != nullptr && "More than one robot expected!");
	for (const pair<ActivityMode*, ActivityMode*>& col : mLine->collisions())	{
		int32_t numberOfRobots = mRobots.size();
		for (int32_t r = -numberOfRobots; r <= numberOfRobots; ++r)	{
			Operator op = GREATER_EQUAL;
			SparseMatrix<double>::Row row;
			double constVal = 2.0*numberOfRobots*mCycleTime;
			double b1 = -3.0*constVal-r*mCycleTime, b2 = -2.0*constVal+r*mCycleTime;

			uint32_t a[2], m[2], i = 0;
			for (ActivityMode* mode : {col.first, col.second})	{
				Movement *mv = dynamic_cast<Movement*>(mode);
				if (mv != nullptr)	{
					DynamicActivity *da = mv->parent();
					a[i] = da->aid(); m[i] = mv->mid();
					row.emplace_back(getValue(y, {a[i], m[i]}, caller()), -constVal);
				}

				Location *loc = dynamic_cast<Location*>(mode);
				if (loc != nullptr)	{
					StaticActivity *sa = loc->parent();
					a[i] = sa->aid(); m[i] = loc->lid();
					row.emplace_back(getValue(x, {a[i], loc->point()}, caller()), -constVal);
				}

				++i;
			}

			SparseMatrix<double>::Row row1 = row, row2 = row;
			const vector<uint32_t>& v = getValue(c, {pack(a[0], m[0]), pack(a[1], m[1])}, caller());
			row1.insert(row1.end(), {{getValue(s, a[1], caller()), 1.0}, {getValue(s, a[0], caller()), -1.0}, {getValue(d, a[0], caller()), -1.0}, {v[r+numberOfRobots], -constVal}});
			row2.insert(row2.end(), {{getValue(s, a[0], caller()), 1.0}, {getValue(s, a[1], caller()), -1.0}, {getValue(d, a[1], caller()), -1.0}, {v[r+numberOfRobots], constVal}});

			addConstraint(row1, op, b1, "(16$"+to_string(mConstraintsCounter++)+")");
			addConstraint(row2, op, b2, "(17$"+to_string(mConstraintsCounter++)+")");
		}
	}
}
开发者ID:CTU-IIG,项目名称:EnergyOptimizatorOfRoboticCells,代码行数:43,代码来源:ConstraintsGenerator.cpp


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