help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] [Fwd: Conditional objective function structure]


From: glpk xypron
Subject: Re: [Help-glpk] [Fwd: Conditional objective function structure]
Date: Fri, 10 Feb 2012 01:43:45 +0100

Hello Dong-John,

your message had to be forwarded manually because you are not subscribed to the 
list, see
https://lists.gnu.org/mailman/listinfo/help-glpk

I guess this is what you are looking for:

param flag := 2;
var x1, >= 0, <= 3;
var x2, >= 0, <= 4;
maximize obj :
  ( if flag == 1 then  .3 * x1 + .4 * x2 else 0 ) +
  ( if flag == 2 then  .5 * x1 + .3 * x2 else 0 ) +
  ( if flag == 3 then -.3 * x1 - .4 * x2 else 0 );
s.t. c1 : x1 + x2 <= 5;
solve;
end;

Best regards

Xypron

> -------- Forwarded Message --------
> Subject: Conditional objective function structure
> Date: Wed, 8 Feb 2012 21:23:31 -0800
> 
> Hello,
> 
> Can I make a code structure like following,,?
> 
> (if flag = 1 then
>  (
>   minimize ~~
>   s.t. ~~
>  )
>  else if flag = 2 then
>  (
>   maximize ~~
>   s.t. ~~
>  )
>  else
>  (
>    ~~
>  )
> );
> 
> solve;
> 
> Best,
> TGno3

-- 
Follow me at http://twitter.com/#!/xypron

Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de



reply via email to

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