Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

Error - Proc OPTMODEL Array out of range

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Error - Proc OPTMODEL Array out of range

[ Edited ]
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
59
60 proc optmodel;
61
62 set CLIENT={'BO','BR','CO','HA','MN','NA','NH','NL','PO','PR','SP','WO'};
63 SET DISTCENTER={'BO','NA','PR','SP','WO'};
64
65 NUMBER DEMAND{CLIENT}=[425 12 43 125 110 86 129 28 66 320 220 182];
66 NUMBER COST{CLIENT,DISTCENTER}=[
67 0 37 42 82 34
68 93 65 106 59 68
69 69 33 105 101 72
70 98 103 73 27 66
71 55 20 92 93 60
72 37 0 72 79 41
73 128 137 94 63 98
74 95 113 57 57 71
75 62 48 104 127 85
76 42 72 0 68 38
77 82 79 68 0 47
78 34 41 38 47 0];
79 NUMBER FCOST{DISTCENTER}=[10000 10000 10000 10000 10000];
80
81 VAR X{CLIENT,DISTCENTER} INTEGER>=0;
82 VAR Y{DISTCENTER}BINARY;
83
84 MINIMIZE TOTALCOST=SUM{I IN CLIENT}SUM{J IN DISTCENTER}X[I,J]*COST[I,J]+SUM{J IN CLIENT}Y[J]*FCOST[J];
85
86 CON DEMANDCONST {I IN CLIENT}Smiley FrustratedUM{J IN DISTCENTER}X[I,J]>=DEMAND[I];
87 CON LINKING {J IN DISTCENTER}Smiley FrustratedUM{I IN CLIENT}X[I,J]-20000*Y[J]<=0;
88 CON MIN: SUM{J IN DISTCENTER}Y[J]>=1;
89 CON MAX: SUM{J IN DISTCENTER}Y[J]<=1;
90
91 SOLVE;
NOTE: Problem generation will use 2 threads.
ERROR: The array subscript 'Y[BR]' is invalid at line 84 column 89.
NOTE: Unable to create problem instance due to previous errors.
92
93 PRINT Y X TOTALCOST;
ERROR: The array subscript 'Y[BR]' is invalid at line 84 column 89.
94
95 QUIT;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE OPTMODEL used (Total process time):
real time 0.04 seconds
user cpu time 0.05 seconds
system cpu time 0.00 seconds
memory 2081.15k
OS Memory 27040.00k
Timestamp 05/19/2017 09:32:35 PM
Step Count 64 Switch Count 163
Page Faults 0
Page Reclaims 181
Page Swaps 0
Voluntary Context Switches 641
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 344
 
96
97
98 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

Accepted Solutions
Solution
‎05-20-2017 05:52 AM
Grand Advisor
Posts: 10,051

Re: guys i need your help why am i getting an error?

I don't have access to OPTMODEL so not sure about specifics.

In general a statement like:

ERROR: The array subscript 'Y[BR]' is invalid at line 84 column 89.
 
Means that an array , which is a collection of a specified number of values, has been asked to use a value that would be pointed to by a position number that is too big (most of the time) or too small.
 
A very brief example. Suppose you have an array named Y that has elements with values of (5 98 33 16). Then y[1] is a way to reference the first value, in this case 5. Y[2] would reference the value 98 in the second position. That value that references the position is called an "array subscript" which if you remember any math class that did summation of 1 to n of variables where they had subscripts under the variable for reference you might see the connection.
If i ask for Y[8] we have a problem because we have only defined 4 elements in this example. So using 8 exceeds the specified number an is an "invalid subscript".
 
I am going to guess that
ERROR: The array subscript 'Y[BR]' is invalid at line 84 column 89.
may come from the definition of
 VAR Y{DISTCENTER}BINARY; which looks like Y wants to use the values of DISTCENTER as the array subscript.
and using
SUM{J IN CLIENT}Y[J]*
is asking to find a J value from the Client list  not Distcenter.

 

View solution in original post


All Replies
New Contributor
Posts: 3

Re: guys i need your help why am i getting an error?

i dont understand the error
Solution
‎05-20-2017 05:52 AM
Grand Advisor
Posts: 10,051

Re: guys i need your help why am i getting an error?

I don't have access to OPTMODEL so not sure about specifics.

In general a statement like:

ERROR: The array subscript 'Y[BR]' is invalid at line 84 column 89.
 
Means that an array , which is a collection of a specified number of values, has been asked to use a value that would be pointed to by a position number that is too big (most of the time) or too small.
 
A very brief example. Suppose you have an array named Y that has elements with values of (5 98 33 16). Then y[1] is a way to reference the first value, in this case 5. Y[2] would reference the value 98 in the second position. That value that references the position is called an "array subscript" which if you remember any math class that did summation of 1 to n of variables where they had subscripts under the variable for reference you might see the connection.
If i ask for Y[8] we have a problem because we have only defined 4 elements in this example. So using 8 exceeds the specified number an is an "invalid subscript".
 
I am going to guess that
ERROR: The array subscript 'Y[BR]' is invalid at line 84 column 89.
may come from the definition of
 VAR Y{DISTCENTER}BINARY; which looks like Y wants to use the values of DISTCENTER as the array subscript.
and using
SUM{J IN CLIENT}Y[J]*
is asking to find a J value from the Client list  not Distcenter.

 

New Contributor
Posts: 3

Re: guys i need your help why am i getting an error?

thank you yea that was it!
Grand Advisor
Posts: 16,905

Re: guys i need your help why am i getting an error?

@elienaba Please mark BallardW solution as correct. 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 116 views
  • 0 likes
  • 3 in conversation