Is it possible to get the slack on a constraint that has been dropped?

22 views
Skip to first unread message

Benoît Martin

unread,
Dec 5, 2016, 5:42:55 AM12/5/16
to AMPL Modeling Language
Hello,

I want to implement a 'constraint generation' scheme with ampl where the problem is soled iteratively. In this scheme, I would like at each iteration to consider only a subset of all the constraints, solve the corresponding relaxed problem, then check the most violated constraints in the ones that were not included in the current iteration and add them to the problem for the next iteration. Then, I would proceed like that till there is no more violated constraints.
I thought about using the 'drop' command to drop the constraints, and I wondered if I could use something like 'slack' to check the violation (and its amplitude) of constraints that have been dropped. I am interfacing Ampl through Matlab/Ampl API, it would thus allow me to treat this in Ampl rather than treating this in the Matlab environment.

Thank you,

Benoît

Robert Fourer

unread,
Dec 6, 2016, 11:40:47 AM12/6/16
to am...@googlegroups.com
The .slack suffix on a constraint-name gives a negative value when the constraint is violated. You can check the slack even on constraints that were dropped in the previous solve.

Bob Fourer
am...@googlegroups.com

=======

Benoît Martin

unread,
Dec 7, 2016, 5:15:57 AM12/7/16
to AMPL Modeling Language, 4...@ampl.com
Thanks Bob!
Message has been deleted

Benoît Martin

unread,
Dec 7, 2016, 11:15:09 AM12/7/16
to AMPL Modeling Language
Another question related to it:

I am writing my constraints in the form 
a<=b or a>=b with b representing the physical min and max limit of some equipments. I would like to compute the relative violation of the dropped constraints, and by relative I mean slack/b. This corresponds to the percentage of constraint violation, as I am handling several processes with different orders of magnitude and I would like to see the ones that are the most violated in relative value.

My question is: Is there a command that lets you evaluate in an automated way the right hand side of a constraint?My goal would be to write a loop such as:


for i in 1..n_constraints
rel_violation[i]=cons[i].slack/evaluation of right hand side of cons[i]
end

Thanks,

Benoît

Robert Fourer

unread,
Dec 7, 2016, 10:23:50 PM12/7/16
to am...@googlegroups.com
For a <= constraint "cons" AMPL moves all terms involving variables to the left, and all constant terms to the right. The value of the resulting left side is cons.body, and the value of the right side is cons.ub (and the right minus the left gives cons.slack).

For a >= constraint AMPL moves the terms in the same way. The value of the resulting left side is cons.body, and the value of the right side is cons.lb (and the left minus the right gives cons.slack).

Thus in particular the right-hand side is cons.ub or cons.lb, depending on how you write the constraint.

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of Benoît Martin
Sent: Wednesday, December 7, 2016 10:15 AM
To: AMPL Modeling Language
Reply all
Reply to author
Forward
0 new messages