help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] If-then expression: invalid use of reserved keyword if


From: Nilo Cesar Teixeira
Subject: Re: [Help-glpk] If-then expression: invalid use of reserved keyword if
Date: Wed, 2 Nov 2011 19:46:59 -0200

Regarding the compiler error below, I spent 15 minutes trying to figure out and recall this exact problem in another model!

Could glpk state clearly in this case that 'solve;' should be called before referring to variables values ? That would be nice =)

Thanks.

2011/11/1 Nilo Cesar Teixeira <address@hidden>
Try this:

for {r in R, s in S, i in 1..fr[r] : x[s, r, i] = 1} printf "x[%s,%s,%i] = %i\n", s,r,i,x[s,r,i];

Note that if x is a variable, you have to invoke 'solve;' before that line, or a compilation error will happen: "operand preceding = has invalid type".

2011/11/1 Kasper Tordrup <address@hidden>
Hi guys

I was trying to make a simple if-then statement as below, but failed with the error: "invalid use of reserved keyword if".
I then tried searching the archive but the closest I got to an answer, was that it is not allowed to use if-then like this.
Anyone know a workaround for that?
I got a lot of 0-entries in 'x' and i simply just want to print the ones that is set to 1

for {r in R} {
 for {s in S} {
  for {i in 1..fr[r]} {
   if x[s,r,i] = 1 then printf "x[%s,%s,%i] = %i\n", s,r,i,x[s,r,i]
  }
 }
}

Best regards,
Kasper

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




--
Nilo Cesar Teixeira
address@hidden




--
Nilo Cesar Teixeira
address@hidden


reply via email to

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