[AMPL NEWBIE PLS HELP] INVALID SUBSCRIPT DISCARDED ERROR

460 views
Skip to first unread message

Jasmine Czarina Chua

unread,
Feb 19, 2021, 12:01:35 AM2/19/21
to AMPL Modeling Language
Hi! Currently trying to code the work of Guy Desauliners' literature but I'm encountering an error of invalid subscript discarded. Can someone help me with this error? 
Error executing "solve" command:
error processing param distance:
6 invalid subscripts discarded:
distance[0,1]
distance[0,2]
distance[3,1]
and 3 more.
Error executing "solve" command:
error processing param tt:
6 invalid subscripts discarded:
tt[0,1]
tt[0,2]
tt[3,1]
and 3 more.
Error executing "solve" command:
error processing objective fuelcost:
no value for tt[0,5]

Here is the code:

param n >= 0;
param b >= 0;

set B := {1..b};
set P := {1..n};
set D := {n+1..2*n};
set N := {0..2*n};

set ARC := {i in 0..n,j in n+1..2*n:i<>j};

param distance{ARC} >= 0;
param tt{ARC} >= 0;
param demand {P} >= 0;

var x{ARC,B} binary;

minimize fuelcost: sum{i in 0..n,j in n+1..2*n:i<>j} sum{k in B}
x[i,j,j] * (distance[i,j] * 0.5) * (tt[i,j] * 0.8);

Here is the data:

data;
param n := 4;
param b := 3;

param demand := 1 2, 2,5;

param distance: 1 2 :=
0 4.1 6.8
3 6.8 2
4 7.5 7
;

param tt: 1 2 :=
0 20 40
3 23 25
4 25 50
;

Thank you in advance.
Jasmine

Mikhail

unread,
Feb 19, 2021, 12:58:15 AM2/19/21
to AMPL Modeling Language
In your model, param distance is defined as param distance {i in 0..n ...} this means that data must be specified for every i in (0,1,2,3,4). However, in the data, you only give data for i = 0,3,4. {j in n + 1..2 * n: i <> j} to my mind is also described incorrectly because for i = 0 the expression {j in n + 1..2 * n: i <> j} gives the value j = 1..0; and for i = 4, j = 5..8. The distance and tt data for values j> 4 is missing from your data file.

пятница, 19 февраля 2021 г. в 08:01:35 UTC+3, jczari...@gmail.com:
Message has been deleted

Jasmine Czarina Chua

unread,
Feb 19, 2021, 2:45:47 AM2/19/21
to AMPL Modeling Language
Thank you for that, but I have a follow up sir Mikhail:
guys.png
I'm now trying to code (font color blue) the let lamda i=di and lamda n+i=-di from the photo abovebut I'm having trouble with it. Can you help me with this?
Here's the code:

param n >= 0; 
param b >= 0;
set B := {1..b}; 
set P := {1..n}; 
set D := {n+1..2*n}; 
set N := {0..2*n}; 
set ARC := {i in 0..n,j in n+1..2*n:i<>j}; 

param distance{ARC} >= 0; 
param tt{ARC} >= 0;
param supply {P} >= 0; 
param demand {D} >= 0; 
let P = supply{P} and D = demand{D}; 

var x{ARC,B} binary; 
minimize fuelcost: sum{i in 0..n,j in n+1..2*n:i<>j} sum{k in B} x[i,j,k] * (distance[i,j] * 0.5) * (tt[i,j] * 0.8);

Thank you!

AMPL Google Group

unread,
Feb 19, 2021, 2:00:39 PM2/19/21
to AMPL Modeling Language
To answer this question, it is necessary to have more information: (1) The formulation mentions "request i" so you need to say which set in your model is the set of requests. (2) You need to say which parameter in your model corresponds to the parameter d_i (d-sub-i) in the formulation; this parameter should be indexed over the set of requests.

With this information, a parameter l_i (letter "ell" sub i) could be defined by a statement like this:

param l {i in REQUESTS} = if i <= n then d_i else -d_i;

Here REQUESTS has to be replaced by the name of your set of requests; I would guess that it is 1..2*n.


--
Robert Fourer
am...@googlegroups.com
{#HS:1430366969-101055#}
On Fri, Feb 19, 2021 at 7:45 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Thank you for that, but I have a follow up sir Mikhail:
[image: guys.png]
I'm now trying to code (font color blue) the *let lamda i=di and lamda
n+i=-di *from the photo above*, *but I'm having trouble with it. Can you

help me with this?
Here's the code:

param n >= 0;
param b >= 0;
set B := {1..b};
set P := {1..n};
set D := {n+1..2*n};
set N := {0..2*n};
set ARC := {i in 0..n,j in n+1..2*n:i<>j};

param distance{ARC} >= 0;
param tt{ARC} >= 0;
param supply {P} >= 0;
param demand {D} >= 0;
*let P = supply{P} and D = demand{D}; *


var x{ARC,B} binary;
minimize fuelcost: sum{i in 0..n,j in n+1..2*n:i<>j} sum{k in B} x[i,j,k] *
(distance[i,j] * 0.5) * (tt[i,j] * 0.8);

Thank you!

On Fri, Feb 19, 2021 at 6:45 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Thank you for that sir Mikhail!
But I have a follow-up:
[image: guys.png]
I'm now trying to code (font color blue) the *let lamda i=di and lamda
n+i=-di *from the photo above*, *but I'm having trouble with it. Can you

help me with this?
Here's the code:

param n >= 0;
param b >= 0;
set B := {1..b};
set P := {1..n};
set D := {n+1..2*n};
set N := {0..2*n};
set ARC := {i in 0..n,j in n+1..2*n:i<>j};

param distance{ARC} >= 0;
param tt{ARC} >= 0;
param supply {P} >= 0;
param demand {D} >= 0;
*let P = supply{P} and D = demand{D}; *


var x{ARC,B} binary;
minimize fuelcost: sum{i in 0..n,j in n+1..2*n:i<>j} sum{k in B} x[i,j,k] *
(distance[i,j] * 0.5) * (tt[i,j] * 0.8);

Thank you!

On Fri, Feb 19, 2021 at 5:58 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
In your model, param distance is defined as *param distance {i in 0..n ...}*
this means that data must be specified for every *i* in (0,1,2,3,4).
However, in the data, you only give data for *i = 0,3,4*. *{j in n + 1..2 *
n: i <> j}* to my mind is also described incorrectly because for *i = 0*
the expression *{j in n + 1..2 * n: i <> j}* gives the value* j = 1..0*;
and for *i = 4, j = 5..8*. The *distance* and *tt* data for values j> 4 is

missing from your data file.

пятница, 19 февраля 2021 г. в 08:01:35 UTC+3, jczari...@gmail.com:
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ampl/f490d632-3b9f-41fa-97a5-f9767a2a63e2n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages