Message Boards Message Boards

Error using Solve[] for a set of inequalities

Dear Members of the community

I am trrying to solve complementarity problems w=Mz+q
with complentarity variables w and z. A way to solve the problem is to transform the original one to a set of inequaities. For instance, for M{{2,1},{1,2}} and q={-5,-6} the set of inequalities to be sol is

{2 z1 + z2 + 10 d1 <= 15, z1 + 2 z2 + 10 d2 <= 16, z1 - 10 d1 <= 0, 
 z2 - 10 d2 <= 0, -2 z1 - z2 <= -5, -z1 - 2 z2 <= -6, -z1 <= 0, -z2 <=
   0}

I have tried to solve with Solve[] like this

Solve[{2 z1 + z2 + 10 d1 <= 15, z1 + 2 z2 + 10 d2 <= 16, 
  z1 - 10 d1 <= 0, 
  z2 - 10 d2 <= 0, -2 z1 - z2 <= -5, -z1 - 2 z2 <= -6, -z1 <= 
   0, -z2 <= 0}, {z1, z2, d1, d2}, {Element[{z1, z2}, Reals], 
  Element[d1, {0, 1}], Element[d2, {0, 1}]}]

getting an error: Solve::ivar: d1[Element]{0,1} is not a valid variable. Can Mathematica solve this type of inequalities?

I´ll appreciate any help given.

Jesus

4 Replies

Gianluca, Thanks for the suggestion. It works great with addition of the "0r" to make d1 and d2 binary.

Cheers

Jesus

This gives a simple solution:

Reduce[{2 z1 + z2 + 10 d1 <= 15, z1 + 2 z2 + 10 d2 <= 16,
  z1 - 10 d1 <= 0, z2 - 10 d2 <= 0, -2 z1 - z2 <= -5,
  -z1 - 2 z2 <= -6, -z1 <= 0, -z2 <= 0,
  Or[d1 == 1, d1 == 0], Or[d2 == 1, d2 == 0]},
 {z1, z2, d1, d2}]
POSTED BY: Gianluca Gorni

Bill Nelson,

Thanks,

The solution is given in regions

(d1 | d2) \[Element] 
  Integers && ((3 z1 == 
      4 && ((d1 == 1 && d2 == 1 && 3 z2 == 7) || (15 d1 >= 2 && 
         10 d2 >= z2 && 9 z2 < 44 && 3 z2 > 7 && 30 d1 + 3 z2 <= 37 &&
          5 d2 + z2 <= 22/3))) || (10 d1 >= 
      z1 && ((6 d1 + z1 <= 29/5 && 30 d2 + z1 == 16 && 
         z1 + 3 z2 == 
          16 && (0 <= z1 < 4/3 || 4/3 < z1 < 29/8)) || (z1 >= 0 && 
         3 z1 < 4 && ((2 z1 + z2 == 5 && 5 d2 + z1 >= 5/2 && d1 <= 1 &&
              10 d2 <= 6 + 3 z1) || (2 z1 + z2 > 5 && 10 d2 >= z2 && 
             z1 + 3 z2 < 16 && 10 d1 + 2 z1 + z2 <= 15 && 
             10 d2 + z1 + 2 z2 <= 16))) || (z1 + 2 z2 == 6 && 
         20 d2 + z1 >= 6 && d2 <= 1 && 
         20 d1 + 3 z1 <= 
          24 && (4/3 < z1 < 29/8 || 29/8 < z1 < 24/5)) || (z1 + 2 z2 >
           6 && 10 d2 >= z2 && 10 d1 + 2 z1 + z2 <= 15 && 
         10 d2 + z1 + 2 z2 <= 
          16 && ((3 z1 > 4 && 8 z1 < 29 && 
             z1 + 3 z2 < 16) || (8 z1 > 29 && 5 z1 < 24 && 
             3 z1 + z2 < 15))))) || (10 d1 == z1 && 
     14/5 + 2 d2 <= z1 && 5 z1 < 24 && 8 z1 > 29 && 
     10 d2 + 3 z1 >= 15 && 3 z1 + z2 == 15) || (80 d1 >= 29 && 
     8 z1 == 29 && 10 d2 >= z2 && 8 z2 < 33 && 16 z2 > 19 && 
     40 d1 + 4 z2 <= 31 && 5 d2 + z2 <= 99/16))

but I can see they are as expected.

I actually solved the same problem using the LinearProgramming functions obtaining easy to read solutions.

Great help!

Jesus

Posted 3 years ago

Try

Simplify[Reduce[{2 z1 + z2 + 10 d1 <= 15, z1 + 2 z2 + 10 d2 <= 16,z1 - 10 d1 <= 0,
   z2 - 10 d2 <= 0, -2 z1 - z2 <= -5, -z1 - 2 z2 <= -6, -z1<=0, -z2<=0, 0<=d1<=1,
   0<=d2<=1, Element[{z1,z2}, Reals], Element[{d1,d2}, Integers]}, {z1,z2,d1,d2}]]
POSTED BY: Bill Nelson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract