diff --git a/offline.py b/offline.py
index 32b587cf5ca681c652f37ccc2dbee0b27b5b7578..6949ca0da7f0e613cca627b08872afc330eafe37 100644
--- a/offline.py
+++ b/offline.py
@@ -12,8 +12,8 @@ def Solve(images, blackouts):
     """Refer to the Google Docs file for full explanation
     SETS / INDICES"""
     br = blackouts # tuples (b^L_br, b^U_br) = [start, end)
-    j = images # real number p_j = image size
-    t = calculate_whiteboxes(blackouts) # tuples (time_t, δ_t) = [start, end)
+    js = images # real number p_j = image size
+    ts = calculate_whiteboxes(blackouts) # tuples (time_t, δ_t) = [start, end)
 
     """PARAMETERS"""
     h = float('inf') # time horizon = infinite
@@ -23,13 +23,13 @@ def Solve(images, blackouts):
 
     """"DECISION VARIABLES"""
     # makespan
-    ms = model.addVar(0,vtype=GRB.CONTINUOUS) # makespan, objective function minimization value, bounded with constraints
-    P_j_br = model.addVars((image_count, blackout_count),0,vtype=GRB.CONTINUOUS) # preemption time, will be set to 0 in Eq (33)
-    PV_t = model.addVars(whitebox_count,0,vtype=GRB.CONTINUOUS) # sum of length of images in whitebox t
-    Tf_j = model.addVars(image_count,0,vtype=GRB.CONTINUOUS) # finish of image j
-    Tf_t  = model.addVars(whitebox_count,0,vtype=GRB.CONTINUOUS) # finish of all images is whitebox t
-    Ts_j = model.addVars(image_count,0,vtype=GRB.CONTINUOUS) # start of image j
-    Ts_t = model.addVars(whitebox_count,0,vtype=GRB.CONTINUOUS) # start of timeslot t, probably redundant
+    ms = model.addVar(lb=0,vtype=GRB.CONTINUOUS) # makespan, objective function minimization value, bounded with constraints
+    P_j_br = model.addVars((image_count, blackout_count),lb=0,vtype=GRB.CONTINUOUS) # preemption time, will be set to 0 in Eq (33)
+    PV_t = model.addVars(whitebox_count,lb=0,vtype=GRB.CONTINUOUS) # sum of length of images in whitebox t
+    Tf_j = model.addVars(image_count,lb=0,vtype=GRB.CONTINUOUS) # finish of image j
+    Tf_t  = model.addVars(whitebox_count,lb=0,vtype=GRB.CONTINUOUS) # finish of all images is whitebox t
+    Ts_j = model.addVars(image_count,lb=0,vtype=GRB.CONTINUOUS) # start of image j
+    Ts_t = model.addVars(whitebox_count,lb=0,vtype=GRB.CONTINUOUS) # start of timeslot t, probably redundant
     X_j_t = model.addVars((image_count, whitebox_count),vtype=GRB.BINARY) # order j in whitebox t
     Xfree_t = model.addVars(whitebox_count,vtype=GRB.BINARY) # whitebox t has no images in it
     Y_j_jprime = model.addVars((image_count, image_count),vtype=GRB.BINARY) # image j comes before image j' in the global order
@@ -37,12 +37,64 @@ def Solve(images, blackouts):
     YB_j_br = model.addVars((image_count, blackout_count),vtype=GRB.BINARY) # order j finishes before blackbox br
 
     """CONSTRAINTS"""
-
     # (1) minimize makespan
     model.setObjective(ms, GRB.MINIMIZE)
-
+    # (3) 
+    model.addConstrs(Tf_j[j] - Ts_j[j] == js[j] 
+        for j in range(image_count))
+    # (4)
+    model.addConstrs(Tf_j[j] * Y_j_jprime[j,jprime] <= Ts_j[j] * Y_j_jprime[j,jprime] 
+        for j in range(image_count) 
+        for jprime in range(image_count))
+    # (9)
+    model.addConstrs(ms >= Tf_j[j] 
+        for j in range(image_count))
+    # (11)
+    model.addConstrs(Ts_t[t+1] >= Tf_t[t] 
+        for t in range(whitebox_count - 1))
+    # (13)
+    model.addConstrs(Tf_t[t] - Ts_t[t] == PV_t[t] 
+        for t in range(whitebox_count))
+    # (17)
+    model.addConstrs(gp.quicksum(X_j_t[j,t] for j in range(image_count))
+        + Xfree_t[t] == 1
+        for t in range(whitebox_count))
+    # (19)
+    model.addConstrs(gp.quicksum(X_j_t[j,t] 
+        for t in range (whitebox_count)) == 1 
+        for j in range (image_count))
+    # (20)
+    model.addConstrs(PV_t[t] == gp.quicksum(js[j] * X_j_t[j,t] 
+        for j in range(image_count))
+        for t in range(whitebox_count))
+    # (32)
+    model.addConstrs(YB_j_br[j,br_index] + YA_j_br[j,br_index] == X_j_t[j,t] 
+        for j in range(image_count) 
+        for t in range (whitebox_count) 
+        for br_index in range(blackout_count))
+    # (33)
+    model.addConstrs(P_j_br[j,br_index] == 0 for j in range(image_count) 
+        for br_index in range(blackout_count))
+    # (34)
+    model.addConstrs(br[br_index][1] * YA_j_br[j,br_index] <= Ts_j[j] 
+        for br_index in range(blackout_count) for j in range(image_count))
+    # (35)
+    model.addConstrs(Ts_j[j] <= br[br_index][0] * YB_j_br[j, br_index] + YA_j_br[j, br_index] * float('inf')
+        for j in range(image_count) 
+        for br_index in range(blackout_count))
+    # (36)
+    model.addConstrs(br[br_index][1] * YA_j_br[j,br_index] <= Tf_j 
+        for br_index in range(blackout_count) 
+        for j in range(image_count))
+    # (37)
+    model.addConstrs(Tf_j[j] <= br[br_index][0] * YB_j_br[j, br_index]
+        for j in range(image_count) 
+        for br_index in range(blackout_count))
+        
     # SOLVE AND PRINT THE RESULTS
     model.optimize()
+    print(f"model.status = {model.status}; MS = {model.ObjVal}")
+    # printSolution(model)
 
 
 def printSolution(model):
@@ -50,13 +102,14 @@ def printSolution(model):
     timeSteps = []
     if model.status == GRB.OPTIMAL:
         time = None
+        
         # TODO: loop over decision variables
         # i.e. for all images in whitebox j:
         # their order does not matter
         # so just paste them behind each other
 
         # timeSteps.append(decVariables[x_ij].X)
-        timeSteps.append(1234)
+        # timeSteps.append(1234)
     else:
         time = "No solution"