Variables already defined

34 views
Skip to first unread message

Angela Lee

unread,
Sep 19, 2017, 9:19:38 PM9/19/17
to am...@googlegroups.com
Hi, 

Whenever I run Q2.mod, I get an error that a variable is already defined. I am unsure as to what this means and how I can fix it. Further, when I input “show;” it only shows constraint 1. Why are my other four constraints invalid/not being considered? 

I have attached a picture of my screen.

Thanks in advance,
Angela

Robert Fourer

unread,
Sep 20, 2017, 11:34:27 AM9/20/17
to am...@googlegroups.com
Your model contains "var c2;" and then also "subject to c2: ...". You cannot use the same name for both a variable and a constraint, so when AMPL's processor reaches the constraint you get a "c2 is already defined" error.

After the error, the AMPL processor has stopped in the middle of a command, as shown by the "ampl?" prompt. As a result the rest of the commands were not processed, and also your "reset;" was not processed. This was the source of all the subsequent errors, which you should not see again once the first error is fixed.

Bob Fourer
am...@googlegroups.com

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