如何对除一个 CPLEX 之外的每个值求和

How to sum every value except one CPLEX

我想对除一个值以外的所有值求和,但是当我尝试使用 sum(n-1 按顺序) 时收到错误消息。这是我的代码:

int fixed_cost = 75;
dvar int+ x[truck, order] in 0..1;
dvar float+ expected_fixed_cost[truck];

forall(h in truck) expected_fixed_cost[h] >= sum(n-1 in order) x[h,n]*fixed_cost;

minimize sum(h in truck) expected_fixed_cost[h];

有人可以帮我看看我做错了什么吗?为什么 CPLEX 不支持 sum(n-1 in order) 函数?

提前致谢!!

range truck=1..3;
range order=1..10;

int fixed_cost = 75;
dvar int+ x[truck, order] in 0..1;
dvar float+ expected_fixed_cost[truck];


minimize sum(h in truck) expected_fixed_cost[h];

subject to
{
  // sum(n in order:(n-1) in order) means
  // sum for all i in order such as n-1 belongs to order
  forall(h in truck) expected_fixed_cost[h] >= sum(n in order:(n-1) in order) x[h,n]*fixed_cost;
}

工作正常