Natalia,
I applied your suggested change and made a few additional ones of my own. The error thrown by "create data solution" undoubtedly reflects the fact that I don't know how to create a data solution. The desired output is a list of cameras with the optimal orientation. Can you help with that? Below is the log from the code.
Thanks,
Gene
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73
74 Proc optmodel;
75 /* Read CoverageMatrix data into index sets*/
76 set <str> CAMERAS;
77 read data optmodel.cameraorientations into CAMERAS=[station];
NOTE: There were 22 observations read from the data set OPTMODEL.CAMERAORIENTATIONS.
78 set <str> ORIENTATIONS=/'NHI' 'NLO' 'EHI' 'ELO' 'SHI' 'SLO' 'WHI' 'WLO'/;
79 set <num> TARGETS;
80 read data optmodel.targets into TARGETS=[target];
NOTE: There were 49 observations read from the data set OPTMODEL.TARGETS.
81 num Matrix {CAMERAS, ORIENTATIONS, TARGETS};
82 read data optmodel.CoverageMatrix into [camera orientation target] Matrix=k;
NOTE: There were 8624 observations read from the data set OPTMODEL.COVERAGEMATRIX.
83
84 /* Set Constants*/
85
86 %Let N=22; /*number of cameras*/
87 num N=&N;
88
89
90 /*Declare Variables*/
91 /* Sadik Equation 11--Sets CHI as binary variable that is 1 when using CAMERA i and POSITION j else 0.*/
92
93 var CHI {CAMERAS,ORIENTATIONS} binary;
94
95 /*Sadik Equation 9 modified to maintain optimal coverage between 3 and 5 cameras*/
96
97 var PSI{TARGETS} integer >=3 <=5;
98
99 /* Declare Model*/
100
101 /*Sadik Equation 7--the function to be maximized*/
102
103 max OptCoverage=sum{target in TARGETS} Psi[target]
104 -sum{camera in CAMERAS, orientation in ORIENTATIONS}Chi[camera,orientation];
105
106 /*Subject to Following Constraints*/
107
108 /*As corrected by Natalia*/
109 con CHI_constraint {camera in CAMERAS}:
110 sum{orientation in ORIENTATIONS}CHI[camera,orientation] <=1;
111
112 /* Sadik Equation 8*/
113
114 /* Sadik: Syntax for expression XIT and XIT_N for use in Sadik Equation 8 below*/
115
116 var XIT{TARGETS} integer;
117
118
119 /*Natalia's suggestion*/
120 con XIT_CON1{target in TARGETS}:
121 XIT[target]=sum{camera in CAMERAS, orientation in ORIENTATIONS}
122 matrix[camera, orientation, target] * Chi[camera,orientation];
123
124 /*What I had originally coded and replaced with Natalia's suggestion*/
125 /*XIT[target]=sum{camera in CAMERAS, orientation in ORIENTATIONS}
126 matrix[camera, orientation, target] * Chi[camera,orientation];*/
127
128
129 /*XIT_N[target]= XIT[target]/N;*/
130
131 con XIT_CON2{target in TARGETS}:XIT[target]/N <= PSI[target];
132
133
134 /* Call Solver and Save Results*/
135
136 solve;
NOTE: Problem generation will use 2 threads.
NOTE: The problem has 274 variables (49 free, 0 fixed).
NOTE: The problem has 176 binary and 98 integer variables.
NOTE: The problem has 120 linear constraints (71 LE, 49 EQ, 0 GE, 0 range).
NOTE: The problem has 626 linear constraint coefficients.
NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range).
NOTE: The OPTMODEL presolver is disabled for linear problems.
NOTE: The initial MILP heuristics are applied.
NOTE: Optimal.
NOTE: Objective = 245.
137 create data solution
138 from [camera orientation target]={camera in CAMERAS, orientation in ORIENTATIONS, target in TARGETS}:
_
22
200
139 OptCoverage[camera,orientation,target];
_
616
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, COL, {.
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR 616-782: The name 'OptCoverage' must be an array.
140 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE OPTMODEL used (Total process time):
real time 0.09 seconds
user cpu time 0.10 seconds
system cpu time 0.00 seconds
memory 24099.43k
OS Memory 53792.00k
Timestamp 03/26/2021 07:02:18 PM
Step Count 102 Switch Count 6
Page Faults 0
Page Reclaims 1484
Page Swaps 0
Voluntary Context Switches 77
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 16
141
142 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
154
... View more