ampl error: sum is reserved

243 views
Skip to first unread message

hanxu1...@gmail.com

unread,
Oct 29, 2018, 11:28:24 PM10/29/18
to AMPL Modeling Language
This is my model, it always says "sum is reserved" I don't know how to fix it. Anyone knows how to do? THANKS!

ampl: param n;
set I={1..n};   #set of subscript i
param L{I};
param a{I};
param b{I};
param A;
param Cship;
param Vmin;
param Vmax;
param Umin;
param Umax;
var m integer >=1;
var u{I};
var q{I};
minimize cost:
sum{i in I}
a[i]*q[i]*L[i]*A/24+Cship*m;
ampl: subject to 
sum{i in I}

sum is reserved
context:   >>> sum{ <<< i in I}
ampl? 

AMPL Google Group

unread,
Oct 30, 2018, 5:02:00 PM10/30/18
to Ampl Modeling Language
The constraint is written in AMPL as follows.
subject to <Constraint_name>: <Constraint Expression>;

For example:

subject to c{i in I}:u[i]>=0;

You have written subject to sum... The AMPL thinks that you used sum as the constraint name. However, the sum is a reserved keyword and thus AMPL throws "sum is reserved" error message. You should follow the above syntax for writing a constraint in AMPL.

--
Dr. Paras Tiwari
am...@googlegroups.com
{#HS:696606177-27351#}
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



XU HAN

unread,
Nov 5, 2018, 10:03:01 AM11/5/18
to am...@googlegroups.com
thanks a lot!

AMPL Google Group <am...@googlegroups.com>于2018年10月31日 周三上午5:01写道:
Reply all
Reply to author
Forward
0 new messages