【发布时间】:2017-01-27 23:32:02
【问题描述】:
问题的简要描述。 我有许多对象,我们称这个对象为 X。 每个 X 可以分配给多个容器 Y。 每个 Y,需要两个 X。 每个 X 都有一个属性 L。 每个 Y 都有其 L 级别的最小规格,即分配给特定 Y 的两个 X 必须等于或超过 Y 的 L 规格。
X is an array of structs with field L (single value) with values 0 to 5
Y is an array of structs with field L (single value) with values 0 to 8
CP cp = new CP();
IIntVar[] dies = cp.IntVarArray(X.size(), 0, 10);
IIntVar[] YvarL= cp.IntVarArray(Y.size(), 0, 10);
for (int i = 1; i <= Y.Lenth; i++)
{
IIntExpr tempL = cp.IfThen(cp.Eq(dies[0], i), cp.Sum(YvarL[i], X[0].L));
for (int j = 1; j < X.Length(); j++)
cp.IfThen(cp.Eq(dies[j], i), cp.Sum(YvarL[i], X[j].L);
cp.Add(cp.Ge(YvarL[i], Y[i].L)
}
但我在第 5 行得到一个错误说 参数 2:无法从 'ILOG.Concert.IIntExpr' 转换为 'ILOG.Constraint.IConstraint'
我想要完成的是,对于所有值为“i”的“死”决策变量,它们对应的 X 变量的“L”属性字段的总和必须超过 Y[的“L”字段属性i] (这里 dies 对应于 X)
【问题讨论】:
标签: c# constraint-programming ilog cp-optimizer