newsgroups-index (beta)

Current group: sci.op-research

Help in writing a particular constraint in a Linear way

Help in writing a particular constraint in a Linear way  
JPC
 Re: Help in writing a particular constraint in a Linear way  
Steve
 Re: Help in writing a particular constraint in a Linear way  
JPC
 Re: Help in writing a particular constraint in a Linear way  
Jerome Rogerie
 Re: Help in writing a particular constraint in a Linear way  
Erwin Kalvelagen
 Re: Help in writing a particular constraint in a Linear way  
Steve
 Re: Help in writing a particular constraint in a Linear way  
Erwin Kalvelagen
 Re: Help in writing a particular constraint in a Linear way  
JPC
 Re: Help in writing a particular constraint in a Linear way  
Steve
 Re: Help in writing a particular constraint in a Linear way  
Steve
 Re: Help in writing a particular constraint in a Linear way  
Erwin Kalvelagen
 Re: Help in writing a particular constraint in a Linear way  
Steve
 Re: Help in writing a particular constraint in a Linear way  
JPC
From:JPC
Subject:Help in writing a particular constraint in a Linear way
Date:Thu, 13 Jan 2005 15:47:58 +0100
Here again to ask your help!

I've to write this constraint:

VARIABLE1 must be 0(zero) OR, if VARIABLE1 >= 0, then VARIABLE1 must be >=
CONSTANT1.

Is there a way to write it in a linear form??
I tried but I found only an ILP implementation, using BINARY variable.

Thanks for any suggestion.

JPC
From:Steve
Subject:Re: Help in writing a particular constraint in a Linear way
Date:13 Jan 2005 09:51:03 -0800
E-

Right. I did not notice the > part of the sign. Thanks for the
correction.

JPC: I don't know if LINGO has semi-continuous capability. If it
doesn't you can replicate semi-continuous behavior using a binary
formulation with auxillary variables.

Steve
From:JPC
Subject:Re: Help in writing a particular constraint in a Linear way
Date:Thu, 13 Jan 2005 20:11:23 +0100
Ok, thanks!

I think this is the right way, isn't it ?

VAR1 >= 0;
BINVAR = IF(VAR1 > 0 , 1,0)

--> this IF function is a Lingo facility, it means that if
the VAR1 is positive > 0 then BINVAR=1 else BINVAR= 0; Is there a way to
write this IF condition in another format avoiding using the IF lingo
function?

VAR1 >= BINVAR * CONSTANT1;

Is it correct?
From:Jerome Rogerie
Subject:Re: Help in writing a particular constraint in a Linear way
Date:Fri, 14 Jan 2005 12:02:34 +0100


JPC wrote:

> Ok, thanks!
>
> I think this is the right way, isn't it ?
>
> VAR1 >= 0;
> BINVAR = IF(VAR1 > 0 , 1,0)
>
> --> this IF function is a Lingo facility, it means that if
> the VAR1 is positive > 0 then BINVAR=1 else BINVAR= 0; Is there a way to
> write this IF condition in another format avoiding using the IF lingo
> function?
>
> VAR1 >= BINVAR * CONSTANT1;
>
> Is it correct?
>
>
>
>
>
>
>
>
>
From:Erwin Kalvelagen
Subject:Re: Help in writing a particular constraint in a Linear way
Date:Thu, 13 Jan 2005 16:58:53 GMT

Such a variable is called "semi-continuous". Many
MIP solvers support this directly. Otherwise
you can simulate them with binary variables.

----------------------------------------------------------------
Erwin Kalvelagen
GAMS Development Corp., http://www.gams.com
erwin@gams.com, http://www.gams.com/~erwin
----------------------------------------------------------------

On Thu, 13 Jan 2005 15:47:58 +0100, JPC wrote:

> Here again to ask your help!
>
> I've to write this constraint:
>
> VARIABLE1 must be 0(zero) OR, if VARIABLE1 >= 0, then VARIABLE1 must be >=
> CONSTANT1.
>
> Is there a way to write it in a linear form??
> I tried but I found only an ILP implementation, using BINARY variable.
>
> Thanks for any suggestion.
>
> JPC
From:Steve
Subject:Re: Help in writing a particular constraint in a Linear way
Date:13 Jan 2005 12:19:44 -0800
JPC,

Generally, you can't use an IF statement in an LP because it makes
the problem non linear and the solver will reject the formulation when
it sees it.

You can use auxiliary variables to mimic semi-continuous types like
this.

Say you want define a semi-continuous variable that is either 0 or
between 32 and 100.

Then define two auxiliary BINARY variables AUX1 and AUX1. Also define
a CONTINUOUS variable VAR1.

Now define the constraints::

32 AUX1 <= VAR1 <= 100 AUX2

and

AUX1 - AUX2 = 0

VAR1 is now semi-continuous. If AUX1 and AUX2 = 0, then VAR1 = 0. If
AUX1 and AUX2 = 1, then VAR1 is bounded by 32 and 100.

Steve
From:Erwin Kalvelagen
Subject:Re: Help in writing a particular constraint in a Linear way
Date:Thu, 13 Jan 2005 20:37:34 GMT

There is no need for two binary variables. Just
one is enough:

32*AUX1 <= VAR1 <= 100*AUX1
aux1 binary

----------------------------------------------------------------
Erwin Kalvelagen
GAMS Development Corp., http://www.gams.com
erwin@gams.com, http://www.gams.com/~erwin
----------------------------------------------------------------

On Thu, 13 Jan 2005 12:19:44 -0800, Steve wrote:

> JPC,
>
> Generally, you can't use an IF statement in an LP because it makes
> the problem non linear and the solver will reject the formulation when
> it sees it.
>
> You can use auxiliary variables to mimic semi-continuous types like
> this.
>
> Say you want define a semi-continuous variable that is either 0 or
> between 32 and 100.
>
> Then define two auxiliary BINARY variables AUX1 and AUX1. Also define
> a CONTINUOUS variable VAR1.
>
> Now define the constraints::
>
> 32 AUX1 <= VAR1 <= 100 AUX2
>
> and
>
> AUX1 - AUX2 = 0
>
> VAR1 is now semi-continuous. If AUX1 and AUX2 = 0, then VAR1 = 0. If
> AUX1 and AUX2 = 1, then VAR1 is bounded by 32 and 100.
>
> Steve
From:JPC
Subject:Re: Help in writing a particular constraint in a Linear way
Date:Fri, 14 Jan 2005 11:41:24 +0100
Fantastic solution(s)!

thanks to both of you!!

I'm now very close to the modelling completion of my problem.
From:Steve
Subject:Re: Help in writing a particular constraint in a Linear way
Date:13 Jan 2005 08:34:13 -0800
JPC,

I don't know LINGO but here is a simple example.

First declare only the variable VAR1 as a BINARY type in LINGO.

Now suppose you have a simple model where VAR1 is binary and VAR2 is
continuous.

Max 2VAR1 + 6VAR2
s.t.
VAR1 + 3VAR2 <= 100

And also suppose that in the linear equations the value represented by
VAR1 can only be 0 or 32.

So convert the formulation to:

Max 32*2VAR1 + 6VAR2
s.t.
32VAR1 + 3VAR2 <= 100

or

Max 64VAR1 + 6VAR2
s.t.
32VAR1 + 3 VAR2 <=100

Then if VAR1 = 0 the VAR1 terms = 0
If VAR1 = 1 the VAR1 term = 32 * VAR1 term
I think this will work.

Steve
From:Steve
Subject:Re: Help in writing a particular constraint in a Linear way
Date:13 Jan 2005 09:27:53 -0800
Erwin,

I don't think the variable JPC is considering here is semi-continuous
in this case. It appears he needs a binary switch that equals either 0
or the constant.

For JPC's sake:

A semi-continuous variable has a domain that is defined as a continuous
range, say 32 to 100 or 0. So if it's not 0 it has to be at least 32
but no more than 100. Semi-continuous variables are useful when you
can purchase items and the vendor offers volume discounts. In the
example above the semi-continuous variable for the 32-100 price break
would be active if you purchased a volume within that window and 0
otherwise.

Steve
From:Erwin Kalvelagen
Subject:Re: Help in writing a particular constraint in a Linear way
Date:Thu, 13 Jan 2005 17:43:24 GMT

I don't understand your reasoning. Here is the required
behavior from the original posting:

> VARIABLE1 must be 0(zero) OR, if VARIABLE1 >= 0, then VARIABLE1
> must be >= CONSTANT1.

i.e. x = 0 or x in [constant,+infinity].

This is semi-continuous with an upperbound of +infinity.

----------------------------------------------------------------
Erwin Kalvelagen
GAMS Development Corp., http://www.gams.com
erwin@gams.com, http://www.gams.com/~erwin
----------------------------------------------------------------

On Thu, 13 Jan 2005 09:27:53 -0800, Steve wrote:

> Erwin,
>
> I don't think the variable JPC is considering here is semi-continuous
> in this case. It appears he needs a binary switch that equals either 0
> or the constant.
>
> For JPC's sake:
>
> A semi-continuous variable has a domain that is defined as a continuous
> range, say 32 to 100 or 0. So if it's not 0 it has to be at least 32
> but no more than 100. Semi-continuous variables are useful when you
> can purchase items and the vendor offers volume discounts. In the
> example above the semi-continuous variable for the 32-100 price break
> would be active if you purchased a volume within that window and 0
> otherwise.
>
> Steve
From:Steve
Subject:Re: Help in writing a particular constraint in a Linear way
Date:13 Jan 2005 07:14:00 -0800
JPC,

I think that you are stuck with a binary MIP formulation. If you don't
have many VARIABLE1'S , then you can treat them as paramenters and set
them equal to 0 or the CONSTANT and examine the outputs in a series of
LP excursions. Whatever solver you are using probably has integer
capability, so why don't you at least try it?

You can can formulate the above as a MIP by creating the binary
variable VARIABLE1 and then multiplying it by the constant wherever it
is found in the formulation. Then if VARIABLE1 is 0, the value in the
equation is 0 and it it 1 the value is the constant.

Steve
From:JPC
Subject:Re: Help in writing a particular constraint in a Linear way
Date:Thu, 13 Jan 2005 16:32:42 +0100
--

"Steve" wrote in message
news:1105629240.632885.305880@f14g2000cwb.googlegroups.com...


So are you confirming that it is an Integer Linear Problem?

Can you give me a pratical example of the method you suggested?
> You can can formulate the above as a MIP by creating the binary
> variable VARIABLE1 and then multiplying it by the constant wherever it
> is found in the formulation. Then if VARIABLE1 is 0, the value in the
> equation is 0 and it it 1 the value is the constant.
>

For example, I simply wrote:

VAR1 >= 0;
BINVAR = IF(VAR1 > 0 , 1,0) --> this is a Lingo facility, it means that if
the VAR1 is positive > 0 then BINVAR=1 else BINVAR= 0; Is there a way to
write this IF condition in another format avoiding using the IF lingo
function?

VAR1 >= BINVAR * CONSTANT1;

It is correct?
   

Copyright © 2006 newsgroups-index   -   All rights reserved   -   Impressum