help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] [Fwd: need syntax help for parameter statement]


From: Xypron
Subject: Re: [Help-glpk] [Fwd: need syntax help for parameter statement]
Date: Sun, 13 May 2012 16:46:40 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.3) Gecko/20120329 Icedove/10.0.3

Hello,

your mail had to be forwarded manually because you did not subscribe to
the GLPK help list, see
https://lists.gnu.org/mailman/listinfo/help-glpk

You missed to write ":=" after the param statement.

If the value of TP does not depend on i, there is no need to use it in
your if statements.

Best regards

Xypron

set N := {1..4};
set M := {1..288};

param TP{i in N, k in M}, binary :=
  if (k<=96 or k>=216) then 1 else 0;

display TP
end;



On 13.05.2012 15:29, Andrew Makhorin wrote:
> -------- Forwarded Message --------
> From: spiritfire <address@hidden>
> To: address@hidden
> Subject: [Help-glpk] need syntax help for parameter statement
> Date: Sun, 13 May 2012 03:10:20 -0700 (PDT)
>
> Hi, 
>
> I'm trying to declare a parameter of that kind :
>
> param TP 'Time preference' {i in N, k in M}, binary;   # (with N = 1..4 and
> M = 1..288)
>
> The thing is that the values of my TP parameter should be easy to write
> since it looks like this :
>
> 0,...,0,1,...,1,0,...,0
> 0,...,0,1,...,1,0,...,0
> 0,...,0,1,...,1,0,...,0
> 0,...,0,1,...,1,0,...,0
>
> And I really don't want to write the 4x288 values !
>
> Only the number of "1" and the location in the line is different for each
> lines.
>
> I tried this (I know it's quite ugly and wrong) : 
> param TP 'Time preference' {i in N, k in M}, binary : 
> if i=1 then (if (k<=96 or k>=216) then 1 else 0) 
>       else (if i=2 then (if (k<=96 or k>=216) then 1 else 0) 
>               else (if i=3 then (if (k<=96 or k>=216) then 1 else 0) 
>                       else (if i=4 then (if (k<=96 or k>=216) then 1 else 0) 
> ) ) ) 
>
> Any help is welcome,
>
> Thank you.
>
>
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-glpk
>




reply via email to

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