Skip to content
Snippets Groups Projects
Commit b1e197dc authored by Hamers,G.C.A. (Glenn)'s avatar Hamers,G.C.A. (Glenn)
Browse files

martijn wants another push (small name changes)

parent f37ae65f
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -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)
......
......@@ -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:')
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment