1

我正在做一个优化项目,为此我正在使用 AMPL 和 CPLEX。我的问题有点简单,但如果不使用一些额外的“无用”变量,我就无法做到。

所以假设我有以下代码:

set A:= a b c;
set B:= 1 2 3;
var x{A,B} binary;

现在我希望在 2 个条件下处理一个约束,例如:

if x[a,1] = 1 and x[a,2] = 1 then (some constraint).

不幸的是,CPLEX 不允许我使用以下语法:

s.t const: x[a,1] = 1 and x[a,2] = 1 ==> (some constraint)

它说“逻辑约束 _slogcon[1] 不是指标约束。

现在我这样做的方式是引入一个新变量。

var dummyVar{A,A,B,B} binary;

如果 x[a,1] = 1 和 x[a,2] = 1,则此变量等于 1。

subject to condition: 2*dummyVar[a,a,1,2] <= x[a,1] + x[a,2]

我的问题是我正在使用的大型模型。就我而言,这个 dummyVar 不仅仅是一个小集合,它包含一组集合。当 AMPL 处理代码(将其转换为由 CPLEX 读取)时,由于内存不足而崩溃。

有没有简单的方法来写类似的东西

s.t const: x[a,1] = 1 and x[a,2] = 1 ==> (some constraint)

不引入任何额外的变量?提前致谢。

4

1 回答 1

2

To model this effectively, you should consider two things

  1. 'some-constraint' is linear or quadratic.
  2. if either x[a,1] or x[a,2] are 1, then the constraint can be violated.

On point 1, your some-constraint is of the form

l <= f(x) <= u

where f(x) is a quadratic of linear function and l and u are constraints. If you let f_max and f_min be the upper and lower bounds of the function f(x) over all feasible values of x then you can write your conditional constraint as

l - (l - f_min) (x[a,1] + x[a,2]) <= f(x) <= u + (f_max - u)(x[a,1] + x[a,2])

If either x[a,1] or x[a,2] are 1 then the constraint becomes

f_min <= f(x) <= f_max

or looser if both x[a,1] and x[a,2] are both 1. If both are 0, then the original constraint is enforced.

于 2014-12-15T03:03:29.637 回答