Re: Linearize the "if" in AMPL

28 views
Skip to first unread message

Paul

unread,
Mar 2, 2013, 5:24:31 PM3/2/13
to am...@googlegroups.com
This depends on whether N1 and K are variables or parameters and, if variables, whether they are integer or continuous. You might find some clues in this blog post.

Paul

Paul

unread,
Mar 4, 2013, 4:34:42 PM3/4/13
to am...@googlegroups.com
I'm going to omit indices just to reduce typing. Let M be a parameter giving a valid upper bound for N1 and let z be a new binary variable. Add constraints
NB <= K, NB <= N1, NB >= N1 - M*z and NB >= K*z. (I'm assuming K, N1 and NB are all nonnegative.)

If the rest of the model pushes NB to be as large as possible, you only need the first two constraints (no M, no z).

Paul

Reply all
Reply to author
Forward
0 new messages