|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
[AMPL 2939] Constraint formulationHi,
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 -- You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to ampl@.... For more options, visit this group at http://groups.google.com/group/ampl?hl=en. |
|
|
RE: [AMPL 2956] Constraint formulationAlison,
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 4er@... > -----Original Message----- > From: AlisonT [mailto:alisonthomas@...] > Sent: Sunday, November 01, 2009 11:09 AM > To: AMPL Modeling Language > Subject: [AMPL 2939] Constraint formulation > > 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 > -- You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to ampl@.... For more options, visit this group at http://groups.google.com/group/ampl?hl=en. |
|
|
[AMPL 2959] Re: Constraint formulationI 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 On Nov 1, 12:09 pm, AlisonT <alisontho...@...> wrote: > 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 -- You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to ampl@.... For more options, visit this group at http://groups.google.com/group/ampl?hl=en. |
|
|
[AMPL 2974] Re: Constraint formulationHi 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 On Nov 5, 11:06 pm, Paul <ru...@...> wrote: > 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 > > On Nov 1, 12:09 pm, AlisonT <alisontho...@...> wrote: > > > > > 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- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to ampl@.... For more options, visit this group at http://groups.google.com/group/ampl?hl=en. |
|
|
[AMPL 2988] Re: Constraint formulationAlisonT 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 -- You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to ampl@.... To unsubscribe from this group, send email to ampl+unsubscribe@.... For more options, visit this group at http://groups.google.com/group/ampl?hl=. |
| Free embeddable forum powered by Nabble | Forum Help |