[Top][All Lists]

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

Re: Constraint on a binary variable

From: Michael Hennebry
Subject: Re: Constraint on a binary variable
Date: Thu, 1 Jul 2021 15:56:06 -0500 (CDT)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)

On Wed, 30 Jun 2021, Philippe Jugla wrote:

In my model, I have a variable "p" which has an upper bound pmax := 2.5 and a 
lower bound pmin := -2.5.
I would simply like to add a binary variable "sign" which takes the values :

1 if variable p is positive
0 if variable p is negative (or vice-versa)

A solution is the convex hull of two line segments in (sign, x)-space:
(0, -2.5) (0, 0) and
(1,    0) (1, 2.5)

This is 2-dimensional and the parallelogram is easily drawn.
Two of the sides are 0<=sgn<=1 .
The other two are -2.5 <= p - 2.5*sign <= 2.5 .

No need to play games with the objective function.

"Sorry but your password must contain an uppercase letter, a number,
a haiku, a gang sign, a heiroglyph, and the blood of a virgin."
                                                             --  someeecards

reply via email to

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