On Thu, 26 Mar 2015, john tass wrote:
Let U, K in {-6, .. , 6} integers Let A in {0, 1} binary Let D in {0, 1} binary What I want to do is to model the condition: D = 1, iff (U > 0 OR K > 0) AND A = 1 Otherwise, D should equal 0. I can not figure out how to model this situation. Can any one give me an answear or even a hint? It would be very welcome.
I'd suggest two binaries to flag U>=1 and K>=1 . Call them Qu and Qk respectively. u want Qu = 1 -> U>=1 U >= 1 - (1-Qu)*M making M big enough will ensure that U can be in -6..0 when Qu=0 -6 >= 1 - (1-0)*M M=7 will work U - 7*Qu >= -6 You want Qu = 0 -> -U>=0 . The same kind of math gives -U + 6*Qu >= 0 Likewise for Qk: U - 7*Qk >= -6 -U +6*Qk >= 0 Another way to get those constraints is to graph the valid values. The extreme points for (Qu, U) are: (0, -6) (0, 0) (1, 1) (1, 6) Now you just need constraints on the binaries A, D, Qu and Qk. Doing it crudely, you could use 8 constraints to cut off each of 8 invalid combinations. Actually, you only need 4 constraints. To help you find them, a Karnaugh Map might help: http://en.wikipedia.org/wiki/Karnaugh_map You will be more interested in zeros than in ones. -- 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