[AMPL 1850] How to model inequility constraint

View: New views
2 Messages — Rating Filter:   Alert me  

[AMPL 1850] How to model inequility constraint

by Chien-Chung Huang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,
  Recently, I am trying to solve a mixed integer quadratic model.
However, in the model, we have the constraints which some boolean is
not the same as the input variables.
For example,  b1,b2 are the variables.   c1,c2 is the input parameters.
(True or False)
if b1=c1, then b2<> c2.
We model as 2*b1+b2<>2*c1+c2. It doesn't work because it will take
this as a nonquardratic nonlinear constraint.
We also model as abs(b1-c1)+abs(b2-c2)>=1 or using "if" statement. The
result is still the same.
Did anyone solve the same problem before? If you can give me some
suggestion, I will appreciate so much.

Thanks,
Edward Huang
--

--~--~---------~--~----~------------~-------~--~----~
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=en
-~----------~----~----~----~------~----~------~--~---


[AMPL 1853] Re: How to model inequility constraint

by Paul A. Rubin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Chien-Chung Huang wrote:
> However, in the model, we have the constraints which some boolean is
> not the same as the input variables.
> For example,  b1,b2 are the variables.   c1,c2 is the input parameters.
> (True or False)
> if b1=c1, then b2<> c2.

I'm not positive I understand this.  If you are saying that b1 and b2
are 0-1 variables, c1 and c2 are 0-1 parameters, and you want to
enforce (b1 == c1) => (b2 <> c2), you can do it by introducing a new
binary variable y and the following constraints:

y <= b1 + c1 <= 2 - y;
1 - y <= b2 + c2 <= 1 + y.

The key is that if b1, b2, c1 and c2 are all 0-1, then b1 <> c1 iff b1
+ c2 = 1 and similarly for b2 and c2.  Looking that the first
constraint, if b1 = c1 then b1 + c1 is either 0 or 2, either of which
forces y = 0, which in the second constraint forces b2 + c2 = 1 (so b2
<> c2).  On the other hand, if b1 = c1 then y can be either 0 or 1 in
the first constraint, and y = 1 makes the second constraint vacuous.

/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=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price!