The description says, "We define variables Rk . . ." but the expression for CAL refers to Rkt. The index "t" is not defined in the CAL expression, so maybe Rk should be used in that expression instead. Then the AMPL expression for minimizing calories could be written
minimize CAL: (sum {k in COMMOD} nutval[k,"energy"] * R[k]) / card(T);
(The function "card" computes the cardinality of the set T, which is just the number of members in the set.) Alternatively, if Rkt is correct, then you need to define t by, for example by summing over all t in T:
minimize CAL: (sum {k in COMMOD, t in T} nutval[k,"energy"] * R[k,t]) / card(T);
You will need to use your knowledge of the problem to determine which expression is correct.
--
Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at
discuss.ampl.com.