|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
[AMPL 1826] Seemingly incorrect behavior: AMPL if block evaluationHello all, It seems to me that AMPL is evaluating `if' blocks even when the condition is false. Example: 1) I have an `if' block that looks like this if (time >= 2) then { include process.run; } 2) However, I've found that even when time = 0, the block still executes and AMPL quits on this error: Can't find file "process.run" context: include >>> process.run; <<< Well, the process.run file isn't generated at the conditions time = 0 or time = 1. The `if' statement is supposed to prevent that block from executing. Therefore my question is: How can I force AMPL to avoid throwing an error? Thanks for your help! David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to ampl@... To unsubscribe from this group, send email to ampl-unsubscribe@... For more options, visit this group at http://groups.google.com/group/ampl?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
[AMPL 1828] Re: Seemingly incorrect behavior: AMPL if block evaluationDavid, "include" takes a copy of the specified file and makes it a part of the current file, regardless of any surrounding conditional statements. (It's like a "macro" in programming languages.) To get the effect you want, write if (time >= 2) then { commands process.run; } "commands" is an ordinary command that causes all of the statements in the specified file to be executed, and then returns control to the current file. Bob Fourer 4er@... > -----Original Message----- > From: ampl@... [mailto:ampl@...] On Behalf Of > David Veerasingam > Sent: Thursday, June 12, 2008 2:40 PM > To: AMPL Modeling Language > Subject: [AMPL 1826] Seemingly incorrect behavior: AMPL if block > evaluation > > > Hello all, > > It seems to me that AMPL is evaluating `if' blocks even when the > condition is false. > > Example: > 1) I have an `if' block that looks like this > > if (time >= 2) then { > include process.run; > } > > 2) However, I've found that even when time = 0, the block still > executes and AMPL quits on this error: > > Can't find file "process.run" > context: include >>> process.run; <<< > > Well, the process.run file isn't generated at the conditions time = 0 > or time = 1. The `if' statement is supposed to prevent that block from > executing. > > Therefore my question is: How can I force AMPL to avoid throwing an > error? > > Thanks for your help! > > David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to ampl@... To unsubscribe from this group, send email to ampl-unsubscribe@... For more options, visit this group at http://groups.google.com/group/ampl?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
[AMPL 1831] Re: Seemingly incorrect behavior: AMPL if block evaluationThanks, Bob for being ever so helpful! 'commands' works great. David On Jun 12, 7:07 pm, "Robert Fourer" <4...@...> wrote: > David, > > "include" takes a copy of the specified file and makes it a part of the > current file, regardless of any surrounding conditional statements. (It's > like a "macro" in programming languages.) > > To get the effect you want, write > > if (time >= 2) then { > commands process.run; > } > > "commands" is an ordinary command that causes all of the statements in the > specified file to be executed, and then returns control to the current file. > > Bob Fourer > 4...@... > > > -----Original Message----- > > From: ampl@... [mailto:ampl@...] On Behalf Of > > David Veerasingam > > Sent: Thursday, June 12, 2008 2:40 PM > > To: AMPL Modeling Language > > Subject: [AMPL 1826] Seemingly incorrect behavior: AMPL if block > > evaluation > > > Hello all, > > > It seems to me that AMPL is evaluating `if' blocks even when the > > condition is false. > > > Example: > > 1) I have an `if' block that looks like this > > > if (time >= 2) then { > > include process.run; > > } > > > 2) However, I've found that even when time = 0, the block still > > executes and AMPL quits on this error: > > > Can't find file "process.run" > > context: include >>> process.run; <<< > > > Well, the process.run file isn't generated at the conditions time = 0 > > or time = 1. The `if' statement is supposed to prevent that block from > > executing. > > > Therefore my question is: How can I force AMPL to avoid throwing an > > error? > > > Thanks for your help! > > > David You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group. To post to this group, send email to ampl@... To unsubscribe from this group, send email to ampl-unsubscribe@... For more options, visit this group at http://groups.google.com/group/ampl?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free Forum Powered by Nabble | Forum Help |