Dear Paige and Jackie, Thank you very much for fast response. Here is the log of when I run the code. Please do let me know if I'm not pasting the right thing. I am fairly new to SAS and the community. 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 /* Patient data: duration of treatment and revenue */
70 data patient_data;
71 input i duration revenue;
72 datalines;
NOTE: The data set WORK.PATIENT_DATA has 10 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 666.03k
OS Memory 19620.00k
Timestamp 09/17/2024 12:23:14 AM
Step Count 24 Switch Count 2
Page Faults 0
Page Reclaims 136
Page Swaps 0
Voluntary Context Switches 11
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
83 ;
84 run;
85
86 /* Travel times between patients (symmetric for simplicity) */
87 data travel_times;
88 input i j t;
89 datalines;
NOTE: The data set WORK.TRAVEL_TIMES has 55 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 666.03k
OS Memory 19620.00k
Timestamp 09/17/2024 12:23:14 AM
Step Count 25 Switch Count 2
Page Faults 0
Page Reclaims 91
Page Swaps 0
Voluntary Context Switches 11
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
145 ;
146 run;
147
148 /* Generate full travel time matrix */
149 data travel_times_full;
150 set travel_times;
151 output;
152 t_temp = t;
153 t = t_temp;
154 i_temp = i;
155 i = j;
156 j = i_temp;
157 output;
158 run;
NOTE: There were 55 observations read from the data set WORK.TRAVEL_TIMES.
NOTE: The data set WORK.TRAVEL_TIMES_FULL has 110 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 947.40k
OS Memory 19880.00k
Timestamp 09/17/2024 12:23:14 AM
Step Count 26 Switch Count 2
Page Faults 0
Page Reclaims 122
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272
159
160 /* Add diagonal elements (travel time to self = 0) */
161 data travel_times_final;
162 set travel_times_full;
163 do i = 1 to 10;
164 j = i;
165 t = 0;
166 output;
167 end;
168 run;
NOTE: There were 110 observations read from the data set WORK.TRAVEL_TIMES_FULL.
NOTE: The data set WORK.TRAVEL_TIMES_FINAL has 1100 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 941.93k
OS Memory 19880.00k
Timestamp 09/17/2024 12:23:14 AM
Step Count 27 Switch Count 2
Page Faults 0
Page Reclaims 109
Page Swaps 0
Voluntary Context Switches 12
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
169
170 /* Nurse and vehicle data */
171 data nurse_data;
172 input H_t H_c c_t c_c c_v n_t;
173 datalines;
NOTE: The data set WORK.NURSE_DATA has 1 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 668.03k
OS Memory 19620.00k
Timestamp 09/17/2024 12:23:14 AM
Step Count 28 Switch Count 2
Page Faults 0
Page Reclaims 85
Page Swaps 0
Voluntary Context Switches 12
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
175 ;
176 run;
177
178 /* Macro to set the number of telehealth nurses */
179 %let n_t = 20;
180
181 /* Use PROC OPTMODEL to solve the problem */
182 proc optmodel;
183 /* Define sets */
184 set PATIENTS = 1..10;
185 set TELEHEALTH_NURSES = 1..&n_t;
186 set TRAVEL_CAREGIVERS = 1..8;
187 set VEHICLES = 1..4;
188
189 /* Define parameters */
190 number d{PATIENTS};
191 number travel_time{PATIENTS, PATIENTS};
192 number H_t;
193 number H_c;
194 number r{PATIENTS};
195 number c_t;
196 number c_c;
197 number c_v;
198
199 /* Read data */
200 read data patient_data into [i] d=duration r=revenue;
NOTE: There were 10 observations read from the data set WORK.PATIENT_DATA.
201 read data travel_times_final into [i j] travel_time=t;
WARNING: Duplicate key <1,1> was read at observation 11.
WARNING: Duplicate key <2,2> was read at observation 12.
WARNING: Duplicate key <3,3> was read at observation 13.
WARNING: Duplicate key <4,4> was read at observation 14.
WARNING: Duplicate key <5,5> was read at observation 15.
WARNING: Duplicate key <6,6> was read at observation 16.
WARNING: Duplicate key <7,7> was read at observation 17.
WARNING: Duplicate key <8,8> was read at observation 18.
WARNING: Duplicate key <9,9> was read at observation 19.
WARNING: Duplicate key <10,10> was read at observation 20.
WARNING: Duplicate key <1,1> was read at observation 21.
WARNING: Duplicate key <2,2> was read at observation 22.
WARNING: Duplicate key <3,3> was read at observation 23.
WARNING: Duplicate key <4,4> was read at observation 24.
WARNING: Duplicate key <5,5> was read at observation 25.
WARNING: Duplicate key <6,6> was read at observation 26.
WARNING: Duplicate key <7,7> was read at observation 27.
WARNING: Duplicate key <8,8> was read at observation 28.
WARNING: Duplicate key <9,9> was read at observation 29.
WARNING: Duplicate key <10,10> was read at observation 30.
WARNING: Duplicate key <1,1> was read at observation 31.
WARNING: Duplicate key <2,2> was read at observation 32.
WARNING: Duplicate key <3,3> was read at observation 33.
WARNING: Duplicate key <4,4> was read at observation 34.
WARNING: Duplicate key <5,5> was read at observation 35.
NOTE: 1090 duplicate keys were read.
NOTE: There were 1100 observations read from the data set WORK.TRAVEL_TIMES_FINAL.
NOTE: The maximum message limit was reached during execution of the statement block. 1065 notes and warnings were not displayed.
202 read data nurse_data into H_t H_c c_t c_c c_v;
NOTE: There were 1 observations read from the data set WORK.NURSE_DATA.
203
204 /* Define variables */
205 var X{PATIENTS, TELEHEALTH_NURSES} binary;
206 var Y{PATIENTS, TRAVEL_CAREGIVERS} binary;
207 var Z{PATIENTS, PATIENTS, TRAVEL_CAREGIVERS, VEHICLES} binary;
208 var U{PATIENTS} integer >= 1 <= card(PATIENTS);
209
210 /* Objective function */
211 max Profit = sum{i in PATIENTS} (r[i] * (sum{tn in TELEHEALTH_NURSES} X[i,tn] +
212 sum{c in TRAVEL_CAREGIVERS} Y[i,c]))
213 - sum{tn in TELEHEALTH_NURSES} (c_t * sum{i in PATIENTS} d[i] * X[i,tn])
214 - sum{c in TRAVEL_CAREGIVERS} (c_c * (sum{i in PATIENTS} d[i] * Y[i,c] +
215 sum{i in PATIENTS, j in PATIENTS, v in VEHICLES} travel_time[i,j] * Z[i,j,c,v]))
216 - sum{v in VEHICLES} (c_v * sum{c in TRAVEL_CAREGIVERS, i in PATIENTS, j in PATIENTS}
217 travel_time[i,j] * Z[i,j,c,v]);
218
219 /* Constraints */
220 con Patient_Assignment{i in PATIENTS}:
221 sum{tn in TELEHEALTH_NURSES} X[i,tn] + sum{c in TRAVEL_CAREGIVERS} Y[i,c] = 1;
222
223 con Telehealth_Hours{tn in TELEHEALTH_NURSES}:
224 sum{i in PATIENTS} d[i] * X[i,tn] <= H_t;
225
226 con Travel_Caregiver_Hours{c in TRAVEL_CAREGIVERS}:
227 sum{i in PATIENTS} d[i] * Y[i,c] +
228 sum{i in PATIENTS, j in PATIENTS, v in VEHICLES} travel_time[i,j] * Z[i,j,c,v] <= H_c;
229
230 con Vehicle_Capacity{v in VEHICLES}:
231 sum{c in TRAVEL_CAREGIVERS, i in PATIENTS, j in PATIENTS} Z[i,j,c,v] <= 2;
232
233
234 con Flow_Conservation{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
235 sum{j in PATIENTS, v in VEHICLES} Z[i,j,c,v] = Y[i,c];
236
237 con Flow_Conservation_Reverse{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
238 sum{j in PATIENTS, v in VEHICLES} Z[j,i,c,v] = Y[i,c];
239
240 con Subtour_Elimination{i in PATIENTS, j in PATIENTS, c in TRAVEL_CAREGIVERS: i ne j}:
241 U[i] - U[j] + 1 <= card(PATIENTS) * (1 - sum{v in VEHICLES} Z[i,j,c,v]);
242
243 con Ordering_Link{i in PATIENTS, c in TRAVEL_CAREGIVERS}:
244 U[i] >= 1 + card(PATIENTS) * (Y[i,c] - 1);
245
246 /* Solve the model */
247 solve;
NOTE: Problem generation will use 2 threads.
ERROR: The array element 'travel_time[1,2]' has no value at line 228 column 57.
ERROR: The array element 'travel_time[1,2]' has no value at line 228 column 57.
NOTE: Unable to create problem instance due to previous errors.
248
249 /* Print results */
250 print X Y Z U;
251 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE OPTMODEL used (Total process time):
real time 1.61 seconds
user cpu time 1.59 seconds
system cpu time 0.01 seconds
memory 3191.06k
OS Memory 22456.00k
Timestamp 09/17/2024 12:23:16 AM
Step Count 29 Switch Count 5
Page Faults 0
Page Reclaims 1146
Page Swaps 0
Voluntary Context Switches 52
Involuntary Context Switches 3
Block Input Operations 0
Block Output Operations 1816
252
253
254
255 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
265
... View more