简体   繁体   English

如何创建一个没有边界的整数数组?

[英]How to create an array of integers without the bounds?

I need an array for the integer variables of an optimization problem.我需要一个优化问题的 integer 变量的数组。 When I use当我使用

IloNumVarArray x = CreateNumVarArray (env, 100, "x");

I have x1 to x100 but they are not integers.我有 x1 到 x100 但它们不是整数。

Changed the code to将代码更改为

IloIntVarArray x = CreateIntVarArray (env, 100, "x");

and I tried to add an objective function using these variables with我尝试使用这些变量添加一个目标 function

IloObjective obj = IloMinimize(env, IloSum(x));
model.add(obj);

The objective function is fine, all my variables are integers too, but now i have bounds like目标 function 很好,我所有的变量也是整数,但现在我有像

x1=0
x2=0
...
x100=0

Any help on how to get those integer variables in an array without the bounds?关于如何在没有边界的数组中获取这些 integer 变量的任何帮助?

but which status do you get for cplex?但是您获得 cplex 的哪个状态? Unbounded?无界?

Let me replicate your model in OPL:让我在 OPL 中复制您的 model:

range r=1..100;

dvar int x[r];

minimize sum(i in r) x[i];
subject to
{
  
}

execute
{
  writeln(x[1].LB);
  writeln(cplex.status);
}

which gives这使

-2147483647
2

The status 2 means unbounded.状态 2 表示无界。 And you see the Lower Bound of x[1] is very low So what you did is fine and does not set any bounds你看到 x[1] 的下界非常低所以你所做的很好并且没有设置任何界限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM