[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Error : multiplication of linear forms not allowed
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] Error : multiplication of linear forms not allowed |
Date: |
Mon, 5 Apr 2010 22:01:22 +0400 |
> In my previous post I have been wrong in identifying the constraint.
> What I actually need is something like XOR operator, not AND operator,
> i.e. z[i] = p[i] xor p[i+1]
> I tried to write this as follows, s.t. cntr1{i in PROCESSES}: z[i] =
> ((p[i] + (if i < 6 then p[i+1] else 1)) mod (2));
> This gives me an error "operand preceding mod has invalid type",
> please help me to get this corrected.
Let x and y be binary variables. Imagine that you add them that gives
a two-bit sum cs. Then:
x + y = 2 * c + s,
where c = (x AND y) is the carry bit, and s = (x XOR y) is the sum bit.