SAS Optimization, and SAS Simulation Studio

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-19-2017 05:40 PM - last edited on 05-19-2017 06:49 PM by Reeza

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}UM{J IN DISTCENTER}X[I,J]>=DEMAND[I];

87 CON LINKING {J IN DISTCENTER}UM{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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-19-2017 06:09 PM

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.

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-19-2017 05:54 PM

i dont understand the error

Solution

05-20-2017
05:52 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-19-2017 06:09 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-19-2017 06:32 PM

thank you yea that was it!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-19-2017 07:01 PM

@elienaba Please mark BallardW solution as correct.