Instantiate a parameterized constraint

16 views
Skip to first unread message

cvan...@gmail.com

unread,
May 23, 2017, 12:42:34 PM5/23/17
to AMPL Modeling Language
Hi,

I am trying to write a set of AMPL commands to modify the definition of a problem.

The following problem describes a robust optimization problem, in which the constraint c1 must hold for any value of u (uncertain variable) within the range [-eps, eps].
We chose to declare u with a suffix "uncertain", while x are standard decision variables.

suffix uncertain binary IN;

param
true := 1;
param
false := 0;

model
;
param eps
{1..2};
var x{1..4} >= 0;
var u{1..2} suffix uncertain true;

minimize f
: 100*x[1] + 199.9*x[2] - 5500*x[3] - 6100*x[4];
subject to
c1
: (-0.01 + u[1])*x[1] + (-0.02 + u[2])*x[2] + 0.5*x[3] + 0.6*x[4] <= 0;
c_u
{i in 1..2}: -eps[i] <= u[i] <= eps[i];

data
;
param eps
:=
   
1 0.00005
   
2 0.0004;

I would like to process this problem before solving it. A basic idea would be to remove u, c1 and c_u (I read about the "drop" command) and to add instantiations of c1 with n different (random) values for u.
The reformulated problem would look like this, with n = 2:

model;
var x{1..4} >= 0;

minimize f
: 100*x[1] + 199.9*x[2] - 5500*x[3] - 6100*x[4];
subject to
c1
_1: (-0.01 + -0.0000432)*x[1] + (-0.02 + 0.000017)*x[2] + 0.5*x[3] + 0.6*x[4] <= 0;
c1_2: (-0.01 + 0.0000216)*x[1] + (-0.02 + 0.000381)*x[2] + 0.5*x[3] + 0.6*x[4] <= 0;

So far, what I can do is:
- find out which are the uncertain variables: display {i in 1.._nvars: _var[i].uncertain = 1} _var[i] ;
- generate random values ;
- determine which constraints depend on x, u, or both (using xref).

But these commands merely display information, and I can't figure out how to define the new optimization problem.
Note: would declaring u as a param instead of a variable help?

Thanks for your help,

Charlie

Robert Fourer

unread,
May 25, 2017, 7:03:21 PM5/25/17
to am...@googlegroups.com
Perhaps you are looking for a formulation like this:

param const {1..4};
param eps {1..4} default 0;
var x {1..4} >= 0;

subject to c1u {k in 1..n}:
sum {j in 1..4} (const[j] + if eps[j] > 0 then Uniform(-eps[j],eps[j])) * x[j] <= 0;

Every evaluation of Uniform() will make a fresh sample from the distribution. In the data you would set eps to a positive value for the j values where there is uncertainty. In this case, since a sample from Uniform(0,0) will always be 0, you could actually write the constraint more simply:

subject to c1u {k in 1..n}:
sum {j in 1..4} (const[j] + Uniform(-eps[j],eps[j])) * x[j] <= 0;

Bob Fourer
am...@googlegroups.com

=======
Reply all
Reply to author
Forward
0 new messages