error at infinity

11 views
Skip to first unread message

sahebe...@gmail.com

unread,
Apr 19, 2017, 3:06:16 PM4/19/17
to AMPL Modeling Language
Hi Bob
First of all I thank you for your help. but I have a problem. I receive cp02=infinity because there is not any node there and I wrote this code and received this error.
what can I do ? please help me
param CP02=first (snb2);
if (CP02 = Infinity) then let CP02:= 0 ;

Error at _cmdno 417 executing "let" command
(file first_poll.mod, line 15, offset 664):

    CP02 has an = assignment in the model.

thanks for your previous help
WBR

Robert Fourer

unread,
Apr 19, 2017, 11:01:29 PM4/19/17
to am...@googlegroups.com
When you write "param CP02 = first(snb2);" you define CP02 to have the value of the expression first(snb2). After that AMPL will not let you change the value of CP02 with a "let" statement, and that is why you are getting the message "CP02 has an = assignment in the model" when you specify "let CP02 := 0;". Instead you can write

param CP02;
let CP02 := first(snb2);
if (CP02 = Infinity) then let CP02 := 0;

Bob Fourer
am...@googlegroups.com

=======
Reply all
Reply to author
Forward
0 new messages