help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] min() & max() functions alternatives to use non numeric


From: Suleyman Demirel
Subject: Re: [Help-glpk] min() & max() functions alternatives to use non numeric parameters
Date: Wed, 27 Apr 2011 15:53:58 -0400

You cannot use direct if-then-else statements in an LP formulation. This is not a problem of GLPK. You would face the same issue with any other solver.

You should refer to an integer-programming textbook for linearizing z=min(x,y) and or z=max(x,y).

In a maximization problem, like yours,  z=max(x,y) is simple. You need to add z<=x and z<=y. For example:

Your objective function includes a term (max(0,ScorteIniziali+PrimoStd+PrimoStra-120)*6). Replace this some other variable, sat W. And add the following constraint:

W<=0
W<= (ScorteIniziali+PrimoStd+PrimoStra-120)*6

That's it. However, this is more tricky with min(,) under maximization problem. You will need a binary variable. It is very likely that you can work around this with a binary variable only if you are pretty sure that all your variables are bounded above by a sufficiently large number (Big M).



On Wed, Apr 27, 2011 at 3:42 PM, nikel90 <address@hidden> wrote:

unfortunately i knew it...

i dont really know glpk... its possible to do something like

var a;

if (b==1) a=b;
else
a= c;


?? ty

Nikel


nikel90 wrote:
>
> Good evining!
>
> I've got a problem with the max() and min() functions...
>
> i need to do something like this:
> min(120,ScorteIniziali+PrimoStd+PrimoStra)*70
> in my "objective function"
>
> but min() accepts only numeric parameters..
>
> is there any alternatives?
>
> thank you!
>
> Nikel
>
> the entire model:
>
> #
> #
> /* Trimestri*/
> var PrimoStd >=0, integer;
> var SecondoStd >=0, integer;
> var TerzoStd >=0, integer;
> var QuartoStd >=0, integer;
> var PrimoStra >=0, integer;
> var SecondoStra >=0, integer;
> var TerzoStra >=0, integer;
> var QuartoStra >=0, integer;
> var ScorteIniziali >=0, integer;
> #
> /* Objective function */
> maximize z:
> (min(120,ScorteIniziali+PrimoStd+PrimoStra)*70)-(((max(PrimoStd,SecondoStd,TerzoStd)*3*10)+(PrimoStra*3*15))+(max(0,ScorteIniziali+PrimoStd+PrimoStra-120)*6)+((PrimoStd+PrimoStra)*15))
> +
> (min(310,ScorteIniziali+PrimoStd+PrimoStra-120+SecondoStd+SecondoStra)*70)-(((max(PrimoStd,SecondoStd,TerzoStd)*3*10)+(SecondoStra*3*15))+(max(0,ScorteIniziali+PrimoStd+PrimoStra-120+SecondoStd+SecondoStra-310)*6)+((SecondoStd+SecondoStra)*15))
> + (min(180,ScorteIniziali+PrimoStd+PrimoStra-120 +
> SecondoStd+SecondoStra-310+TerzoStd+TerzoStra)*70)-(((max(PrimoStd,SecondoStd,TerzoStd)*3*10)+(TerzoStra*3*15))+(max(0,ScorteIniziali+PrimoStd+PrimoStra-120
> +
> SecondoStd+SecondoStra-310+TerzoStd+TerzoStra-180)*6)+((TerzoStd+TerzoStra)*15))
> + (min(120,ScorteIniziali+PrimoStd+PrimoStra-120 +
> SecondoStd+SecondoStra-310 +
> TerzoStd+TerzoStra-180+QuartoStd+QuartoStra)*70)-(((max(PrimoStd,SecondoStd,TerzoStd)*3*10)+(QuartoStra*3*15))+(max(0,ScorteIniziali+PrimoStd+PrimoStra-120
> + SecondoStd+SecondoStra-310 +
> TerzoStd+TerzoStra-180+QuartoStd+QuartoStra-120)*6)+((QuartoStd+QuartoStra)*15))
> - (ScorteIniziali*45 + ScorteIniziali+PrimoStd+PrimoStra-120 +
> SecondoStd+SecondoStra-310 + TerzoStd+TerzoStra-180 +
> QuartoStd+QuartoStra-120*45);
>
> /* Constraints */
> #
> s.t. a: ScorteIniziali - ScorteIniziali+PrimoStd+PrimoStra-120 +
> SecondoStd+SecondoStra-310 + TerzoStd+TerzoStra-180 +
> QuartoStd+QuartoStra-120  <= 0;
> end;
>
>

--
View this message in context: http://old.nabble.com/min%28%29---max%28%29-functions-alternatives-to-use-non-numeric-parameters-tp31489922p31490622.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.


_______________________________________________
Help-glpk mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-glpk



--
_________________________________________
Sent via my good, old desktop.
_________________________________________
Suleyman Demirel - Office: (734) 647-3167

PhD Candidate in Operations Management
Stephen M. Ross School of Business
University of Michigan, Ann Arbor
Web: http://www.umich.edu/~sdemirel
_________________________________________

reply via email to

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