Re: [Help-glpk] Modeling exclusive OR in Mathprog language

2015-04-02 Thread Michael Hennebry

I'm a bit fuzzy on what you want.
If you want to express x=a XOR b, where a, b and x are binaries,
you just need four constraints,
the constraints that cut off 001, 010, 100 and 111.
That will give you the convex hull, which is as good as can be done.

   n
To express, x=XOR a[j]  ,  for some large n,
  j=1
 n
note that 0 = x XOR XOR a[j]  .
j=1

Add another integer variable:
 n
0 = x + SUM a[j] - 2*s
j=1

The range of s in 0..floor((n+1)/2)

--
Michael   henne...@web.cs.ndsu.nodak.edu
"SCSI is NOT magic. There are *fundamental technical
reasons* why it is necessary to sacrifice a young
goat to your SCSI chain now and then."   --   John Woods

___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


[Help-glpk] Modeling exclusive OR in Mathprog language

2015-04-02 Thread john tass
Hi, everybody,
I am facing the following situation:
Let
X[t, c] binary variable, H[t] binary variable, where t in T, c in C (1)
I want to write a formula like sum{c in C}X[t, c] <= H[t], which will work
for:
1. t = 1 or t = 30
2. t = 2 or t = 40
3. t = 3 or t = 50
..
...

One way, I think, is to repeat  formula (1) so many times as the number of
conditions (here, 3 times).
The problem is that actually the above conditions are not only three, as I
describe here just for example, but much more. So, I would like to avoid
enumerating all these cases.
Obviously, the way of linking the tree conditions by OR is not suitable in
my case, since I don want the formula (1) to work for the case where (t =1
or t =2).
I probably have to link the 3 conditions via an XOR operator. But I am not
sure if such an operator exists in Mathprog language.
Does anybody know if XOR exists in Mathprog? Or, if not, how can I model
the above situation in an elegant way?
Thanks for your time.

-- 
Ioannis X. Tassopoulos
___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk