[AMPL 2085] Question : how to describe "K is not equal to L" in ampl mod file?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[AMPL 2085] Question : how to describe "K is not equal to L" in ampl mod file?

jason-254

Can anyone help me with this?

In a constratint, i want to describe  "K is not equal to L" in ampl
mod file. But, how?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

[AMPL 2086] Re: Question : how to describe "K is not equal to L" in ampl mod file?

Paul A. Rubin



On Nov 18, 10:15 am, jason <[hidden email]> wrote:
> Can anyone help me with this?
>
> In a constratint, i want to describe  "K is not equal to L" in ampl
> mod file. But, how?

I assume K and L are variables?  Introduce a binary variable Y.  If K
and L are both integer variables (so that the minimum absolute
difference would be 1), you can add the constraints

K >= L + 1 - m*Y
L >= K + 1 - m*(1-Y)

where m is an upper bound on |K-L|+1.

If K and L are divisible variables, I think you'll have to introduce a
parameter d > 0 which is the minimum difference you will tolerate.
(You cannot require |K-L| > 0; that would make the feasible region
open.  What you can require is |K-L| >= d > 0.)  Again, add the binary
variable Y and compute an upper bound m on |K-L| + d, and repeat the
constraints above replacing 1 with d.

/Paul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/ampl?hl=en
-~----------~----~----~----~------~----~------~--~---