diff --git a/__pycache__/offline.cpython-310.pyc b/__pycache__/offline.cpython-310.pyc index 4dd9a21145e090d04192f57cd797a3b09012def5..7f71398fdfcc8e06aa9ac3f7d82ed10fc8a4be84 100644 Binary files a/__pycache__/offline.cpython-310.pyc and b/__pycache__/offline.cpython-310.pyc differ diff --git a/main.py b/main.py index 0a6220c62c11c226a840a6c9544097e3ce3aae49..b22ff5a49720c47be2e39c87df21772bd5b38add 100644 --- a/main.py +++ b/main.py @@ -55,7 +55,7 @@ def PrintOutput(filename : str, endTime : float, imageTimes : List[float]): OUTPUT_FILE.writelines(reduce(lambda x, y: x + "\n" + f"{str(y)}", imageTimes, "")) if __name__ == "__main__": - testcase = 5 + testcase = 4 parsedIn = ParseInput(f"t{testcase}_in.txt") res = LP.Solve(parsedIn[0], parsedIn[1]) output_file = "t{}_out.txt".format(testcase) diff --git a/offline.py b/offline.py index 4e2890e44c731cc52261d2e26095e4a06c3ba0b6..2cd2a402210d14114107f8cc45e7f8b71f8b0b70 100644 --- a/offline.py +++ b/offline.py @@ -13,6 +13,7 @@ def Solve(images, blackouts): for image in range(image_count): times.append(endtime) endtime += images[image] + print(f"No blackboxes, easy solving: end time = {endtime}, startingtimes = {times}.") return (endtime, times) whitebox_count = blackout_count+1 @@ -41,6 +42,7 @@ def Solve(images, blackouts): """CONSTRAINTS""" # (1) minimize makespan model.setObjective(ms, GRB.MINIMIZE) + # (3) make sure the starttime and endtime are exactly image size apart model.addConstrs((Tf_j[j] - Ts_j[j] == js[j] for j in range(image_count)), @@ -58,7 +60,7 @@ def Solve(images, blackouts): for t in range(whitebox_count)), name="Eq(17)") - # Xfree_t should be 0 if there is at least one image being processed in whitebox t + # (17.2) Xfree_t should be 0 if there is at least one image being processed in whitebox t model.addConstrs((gp.quicksum(X_j_t[j,t] for j in range(image_count)) * Xfree_t[t] == 0 @@ -76,10 +78,10 @@ def Solve(images, blackouts): for j in range(image_count)) for t in range(whitebox_count)), name="Eq(20)") - # (20.1) but is upperbounded by the length of the whitebox + # (20.2) but is upperbounded by the length of the whitebox model.addConstrs((PV_t[t] <= white_boxes[t][1] for t in range(whitebox_count)), - name="Eq(20.1)") + name="Eq(20.2)") # SOLVE AND PRINT THE RESULTS model.optimize() @@ -94,9 +96,8 @@ def Solve(images, blackouts): for (j,t) in X_j_t: if X_j_t[j,t].X > 0: print(f"(im{j},wb{t}) = {X_j_t[j,t].X}") - print("All else are 0") + print("All other X_j_t are 0") - print('\nFinish time: %g' % time) print('Whitebox contains:') for t in PV_t: print(f"wb{t} is {Xfree_t[t].X} empty and holds length {PV_t[t].X} of images") @@ -120,6 +121,7 @@ def Solve(images, blackouts): print(f"Timers after={timers}") print(f"Starts={starts}") + print('Finish time: %g' % time) else: print('\nNo solution, Check input or constraints! Reason:') diff --git a/t2_out.txt b/t2_out.txt index 4c06077ca316f1c130b14b1df9135387b2ad5df9..8698d04290be9a353dfaab53d9dfaa49c9e2d0a2 100644 --- a/t2_out.txt +++ b/t2_out.txt @@ -1,5 +1,5 @@ 6.0 +0 1.0 -2.0 -4.5 -6.0 \ No newline at end of file +3.0 +4.5 \ No newline at end of file