0

I need to schedule a set of rectangles in a big rectangle (named bin) using the constraint programming.

As I'm using CPLEX, i found out the square sched example (I'm in fact new to CPLEX and PPC). When I have adapted the example for rectangle case, it doesn't find any feasible solution, and I don't understand why this happens?

Here is my code where I have replaced my variable with sample values:

import docplex

#Size of the englobing rectangle 
size_bin = 100

mdl = docplex.cp.model.CpoModel()
vx = [mdl.interval_var(size=[1, 4], name="X" + str(i), end=(0,
    size_bin)) for i in range(7)]
vy = [mdl.interval_var(size=[1, 4], name="X" + str(i), end=(0, SIZE_bin))
    for i in range(7)]

#Create dependencies between variables 
for i in range(7):
    for j in range(i):
        mdl.add((mdl.end_of(vx[i]) <= mdl.start_of(vx[j])) | (mdl.end_of(vx[j]) >= mdl.start_of(vx[i])) | (mdl.end_of(vy[i]) <=
            mdl.start_of(vy[j])) | (mdl.end_of(vy[j]) <= mdl.start_of(vy[i])))

#To speed-up the search, create cumulative expressions on each dimension 
rx = mdl.sum([mdl.pulse(vx[i], vx[i].size) for i in range(len(vx))])
print(vx[0],rx) 

mdl.add(mdl.always_in(rx, (0,size_bin), size_bin, size_bin))
ry = mdl.sum([mdl.pulse(vy[i], vy[i].size) for i in range(len(vy))])
mdl.add(mdl.always_in(ry, (0, size_bin), size_bin, size_bin))

#Define search phases, also to speed-up the search 
mdl.set_search_phases([mdl.search_phase(vx), mdl.search_phase(vy)])  

#Solve model 
msol = mdl.solve(TimeLimit=50)
msol.print_solution()
user2653663
  • 2,818
  • 1
  • 18
  • 22

1 Answers1

0

Your model is infeasible. Probably that means your rectangles do not fit or there is a bug in your code. For further analysis you can export your model to a file using mdl.export_model('model.cpo') and then use the interactive cpoptimizer tool to anaylze the conflict. That will produce the constraints in conflict.

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22