help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] [GLPK] not-equal constraints


From: Andrew Makhorin
Subject: Re: [Help-glpk] [GLPK] not-equal constraints
Date: Fri, 6 Feb 2009 22:56:35 +0300

> I would like to ask a quick question.
> Is it possible to specify a "not-equal" constraint, for example,
> A != B+3, in GLPK or other LP/ILP solvers ?

You cannot specify such constraint directly, but you can model it
using binary variables.

Assuming that x and y are integer (in your case x = A and y = B+3),
the condition x != y is equivalent to |x - y| >= 1. To describe the
latter constraint, which is non-linear, it is sufficient to describe
the absolute value. Let |s| <= u, where s = x - y and u is a known
constant. Then

   |s| = s1 + s2,

where:

   s = s1 - s2,

   0 <= s1 <= u * z,

   0 <= s2 <= u * (1 - z),

   z is binary.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]