|
24 | 24 | import numpy as np |
25 | 25 | import os |
26 | 26 |
|
27 | | -wordy = 1 # level of verbosity for print statements |
| 27 | +wordy = 2 # level of verbosity for print statements |
28 | 28 |
|
29 | 29 | class Scheduler: |
30 | 30 |
|
@@ -255,6 +255,15 @@ def set_up_optimizer(self, goal : str = "cost"): |
255 | 255 | A_ub_0 = np.ones((1, len(decision_vars)), dtype=int) # Every period assigned to a task counts as 1 towards the total assigned periods. This assumes one pair per period |
256 | 256 | b_ub_0 = np.array([self.num_periods]) |
257 | 257 |
|
| 258 | + if wordy > 1: |
| 259 | + print("A_ub_0^T:") |
| 260 | + for i in range(A_ub_0.transpose().shape[0]): |
| 261 | + pstring = str(self.x_indices[i]) |
| 262 | + for column in A_ub_0.transpose()[i]: |
| 263 | + pstring += f"{ column:5}" |
| 264 | + print(pstring) |
| 265 | + print("b_ub_0: ", b_ub_0) |
| 266 | + |
258 | 267 | A_ub_list.append(A_ub_0) |
259 | 268 | b_ub_list.append(b_ub_0) |
260 | 269 |
|
@@ -282,9 +291,21 @@ def set_up_optimizer(self, goal : str = "cost"): |
282 | 291 | for i in range(len(self.x_indices)): |
283 | 292 | print(f" {self.x_indices[i]}: {A_eq_1[0, i]}") |
284 | 293 |
|
| 294 | + if wordy > 1: |
| 295 | + print("A_eq_1^T:") |
| 296 | + for i in range(A_eq_1.transpose().shape[0]): |
| 297 | + pstring = str(self.x_indices[i]) |
| 298 | + for column in A_eq_1.transpose()[i]: |
| 299 | + pstring += f"{ column:5}" |
| 300 | + print(pstring) |
| 301 | + print("b_eq_1: ", b_eq_1) |
| 302 | + |
285 | 303 | A_eq_list.append(A_eq_1) |
286 | 304 | b_eq_list.append(b_eq_1) |
287 | 305 |
|
| 306 | + if wordy > 0: |
| 307 | + print("Constraint 1 built.") |
| 308 | + |
288 | 309 | # 2) task dependencies must be respected (i.e., a task cannot start until all its dependencies have been satisfied) |
289 | 310 | # ''' |
290 | 311 | # This enforces task dependencies by ensuring that a task can only be assigned to a time period if all its dependencies have been completed in previous periods. |
@@ -325,7 +346,7 @@ def set_up_optimizer(self, goal : str = "cost"): |
325 | 346 | # A_lb_2[index, :] = mask.flatten() |
326 | 347 | # index += 1 |
327 | 348 |
|
328 | | - # if wordy > 2: |
| 349 | + # if wordy > 1: |
329 | 350 | # print("A_lb_2^T:") |
330 | 351 | # print(" T1 T2 ") # Header for 2 tasks |
331 | 352 | # for i in range(A_lb_2.transpose().shape[0]): |
@@ -366,9 +387,9 @@ def set_up_optimizer(self, goal : str = "cost"): |
366 | 387 | A_ub_4[index, :] = mask.flatten() |
367 | 388 | index += 1 |
368 | 389 |
|
369 | | - if wordy > 2: |
| 390 | + if wordy > 1: |
370 | 391 | print("A_ub_4^T:") |
371 | | - print(" P1A1 P1A2 P2A1") # Header for 2 tasks and 2 assets example with T2A2 invalid |
| 392 | + print(" P1A1 P1A2 P2A1 P2A2 P3A1 P3A2 P4A1 P4A2 P5A1 P5A2") # header for 5 periods and 2 assets example |
372 | 393 | for i in range(A_ub_4.transpose().shape[0]): |
373 | 394 | pstring = str(self.x_indices[i]) |
374 | 395 | for column in A_ub_4.transpose()[i]: |
@@ -420,6 +441,16 @@ def set_up_optimizer(self, goal : str = "cost"): |
420 | 441 | for i in range(len(self.x_indices)): |
421 | 442 | print(f" {self.x_indices[i]}: {A_lb_8[t, i]}") |
422 | 443 |
|
| 444 | + if wordy > 1: |
| 445 | + print("A_lb_8^T:") |
| 446 | + print(" T1 T2") # Header for 2 tasks |
| 447 | + for i in range(A_lb_8.transpose().shape[0]): |
| 448 | + pstring = str(self.x_indices[i]) |
| 449 | + for column in A_lb_8.transpose()[i]: |
| 450 | + pstring += f"{ column:5}" |
| 451 | + print(pstring) |
| 452 | + print("b_lb_8: ", b_lb_8) |
| 453 | + |
423 | 454 | A_lb_list.append(A_lb_8) |
424 | 455 | b_lb_list.append(b_lb_8) |
425 | 456 |
|
@@ -455,7 +486,7 @@ def set_up_optimizer(self, goal : str = "cost"): |
455 | 486 | # A_eq_9[pair_i, :] = mask.flatten() |
456 | 487 | # pair_i += 1 |
457 | 488 |
|
458 | | - # if wordy > 0: |
| 489 | + # if wordy > 1: |
459 | 490 | # # Print out the constraint matrix for debugging |
460 | 491 | # print("A_eq_9^T:") |
461 | 492 | # print(" T1A1 T1A2 T2A1") # Header for 2 tasks and 2 assets example with T2A2 invalid |
@@ -502,6 +533,17 @@ def set_up_optimizer(self, goal : str = "cost"): |
502 | 533 | print(f" {self.x_indices[i]}: {A_ub_10[p, i]}") |
503 | 534 | print("Upper bound limit: ", b_ub_10[p]) |
504 | 535 |
|
| 536 | + |
| 537 | + if wordy > 1: |
| 538 | + print("A_ub_10^T:") |
| 539 | + print(" P1 P2 P3 P4 P5") # Header for 5 periods |
| 540 | + for i in range(A_ub_10.transpose().shape[0]): |
| 541 | + pstring = str(self.x_indices[i]) |
| 542 | + for column in A_ub_10.transpose()[i]: |
| 543 | + pstring += f"{ column:5}" |
| 544 | + print(pstring) |
| 545 | + print("b_ub_10: ", b_ub_10) |
| 546 | + |
505 | 547 | A_ub_list.append(A_ub_10) |
506 | 548 | b_ub_list.append(b_ub_10) |
507 | 549 |
|
|
0 commit comments