help: error executing solve command

91 views
Skip to first unread message

Tayup Leets

unread,
Dec 11, 2021, 2:39:33 PM12/11/21
to AMPL Modeling Language
Hello! I wonder if you could help me  correct my mistake in the code shown below.

model.pngdata.png
Upon trying to solve the model, ampl show me the following:
ampl: model Term3.mod;
ampl: data Term3.dat;
ampl: solve;
Error executing "solve" command:
error processing param cost:
    2 invalid subscripts discarded:
    cost[100,150,210]
    cost[204,208,207]
Error executing "solve" command:
error processing objective Total_distance_cost:
    invalid subscript cost[0,0,1]
ampl:

How could I possibly correct said error? Thank you very much for your help.

AMPL Google Group

unread,
Dec 12, 2021, 3:37:26 PM12/12/21
to AMPL Modeling Language
You defined the parameter cost and its data like this:

param cost {i in I, j in I, v in V};
.......
data;
param cost := 100 150 210 205 204 208 207 200 ;


This assigns the value 205 to cost[100,150,210], and the value 200 to cost[204,208,207]. That is clearly not what you wanted, and it is the cause of the first "invalid subscript" message. To see some ways of correctly giving data for a param indexed over 3 sets, see Chapter 9 of the AMPL book, particularly "Lists of higher-dimensional sets and parameters" on page 148, and "Two-dimensional slices of higher-dimensional data" on page 156.

The second "invalid subscript" message says that you refer to cost[0,0,1] in the objective function expression. So when you enter the correct data for parameter cost, you should be sure to include a value for cost[0,0.1].


--
Robert Fourer
am...@googlegroups.com
{#HS:1724223114-107615#}
Reply all
Reply to author
Forward
0 new messages