Constraint formulation

12 views
Skip to first unread message

AlisonT

unread,
Nov 1, 2009, 12:09:29 PM11/1/09
to AMPL Modeling Language
Hi,

Can someone please advise me how I should formulate a constraint that
represents the following:

IF( "decision variable A" > 0, then 0, else "decision variable B")

I also need to formulate a similar constraint, where "decision
variable B" is 1 and is therefore a binary decision variable i.e.
IF( "decision variable C" > 0, then 0, else 1)

Thank you so much.
Alison

Robert Fourer

unread,
Nov 4, 2009, 7:30:24 PM11/4/09
to am...@googlegroups.com, AlisonT
Alison,

Your "IF ..." looks like an expression that you would like to have in your
constraint, but it is not the whole constraint -- there is no "=" or ">=" or
"<=" in it. You would need to state the whole constraint in order for
someone to say how it could be reformulated for a solver. Also you would
need to specify for every decision variable whether it is integer or
continuous, and what its lower and upper bounds are.

Bob Fourer
4...@ampl.com

Paul

unread,
Nov 5, 2009, 6:06:18 PM11/5/09
to AMPL Modeling Language
I agree with Bob that your question could use some refinement, but I
think I know what you're getting at, so I'll take a shot.

I don't think you can do exactly what you want, but you may come
close. Let M be a sufficiently large positive constant and epsilon a
sufficiently small (but strictly positive) constant, and let Y (a
variable) be the output of your first IF. Introduce a new binary
variable Z together with the following constraints:

(1) epsilon*Z <= A <= M*Z
(2) B - M*Z <= Y <= B + M*Z
(3) -M*(1-Z) <= Y <= M*(1-Z).

A <= 0 forces Z = 0 in the left part of (1), which forces Y = B in (2)
and makes (3) vacuous. A >= epsilon forces Z = 1 in the right side of
(1), which forces Y = 0 in (3) and makes (2) vacuous. Besides
introducing a binary variable, there is one catch: 0 < A < epsilon has
been excised from the feasible region. So this won't work if
arbitrarily small but positive values of A are legitimate contenders
for an optimal solution.

Incidentally, I used the same M in every constraint because I'm too
lazy to type subscripts, but you can (and probably should) use a
distinct M (the tightest value you can find that is guaranteed not to
cut off an optimal solution) in each constraint.

/Paul

AlisonT

unread,
Nov 8, 2009, 2:07:17 PM11/8/09
to AMPL Modeling Language
Hi Bob and Paul,

thank you both for the replies. I should have expressed my question
with more clarity - sorry for that.

Thank you Paul for your answer and explanation, which answers my
question perfectly.

Is there a list available of piece-meal linearisations such as this?

Thank you so much.
Alison

> > Alison- Hide quoted text -
>
> - Show quoted text -

Paul

unread,
Nov 10, 2009, 5:43:17 PM11/10/09
to AMPL Modeling Language

AlisonT wrote:

>
> Thank you Paul for your answer and explanation, which answers my
> question perfectly.

You're welcome. First thing I've done perfectly in ages. ;-)
>
> Is there a list available of piece-meal linearisations such as this?

I'm not sure. The closest I can come is a rather interesting paper by
John Hooker that you can get from his web site (http://
web.tepper.cmu.edu/jnh/milpmodeling2.pdf). I downloaded it a while
back and have been meaning to read it, but <sigh>work keeps
interfering</sigh>. It's somewhat mathematical, so if you are looking
for a "cheat sheet", this is definitely not the place to look.

/Paul
Reply all
Reply to author
Forward
0 new messages