Closed dreinon closed 3 years ago
Closed by error
ok, reading your code I see what you want to achieve. Can you try this:
all_ctr = []
for j in availability:
ctr1 = ps.TaskStartAfterLax(students_tasks[-1], j[0],optional=True)
ctr2 = ps.TaskEndBeforeLax(students_tasks[-1], j[1],optional=True)
all_ctr.append(ctr1)
all_ctr.append(ctr2)
av_list.append(ps.and_([ctr1, ctr2]))
# force both ctr1 and ctr2 to be applied or not applied simultaneously
constraints.append(ctr1.applied == ctr2.applied) # the double equal is important
constraints.append(ps.ForceApplyNOptionalConstraints(all_ctr, 2)) # force 2 optional constraints to True
Thanks for answering. I don't get the av_list
part, I mean, where do I add the av_list to the general constraints.
You can do without the av_list parameter:
all_ctr = []
for j in availability:
ctr1 = ps.TaskStartAfterLax(students_tasks[-1], j[0],optional=True)
ctr2 = ps.TaskEndBeforeLax(students_tasks[-1], j[1],optional=True)
all_ctr.append(ctr1)
all_ctr.append(ctr2)
constraints.append(ps.and_([ctr1, ctr2]))
# force both ctr1 and ctr2 to be applied or not applied simultaneously
constraints.append(ctr1.applied == ctr2.applied) # the double equal is important
constraints.append(ps.ForceApplyNOptionalConstraints(all_ctr, 2)) # force 2 optional constraints to True
My code works fine using this constraints!
Now, what doesn't let my script end is usage optimization. When I add that, it takes forever and doesn't end.
Nevertheless, I have used ForceScheduleNOptionalTasks
a couple times and estimated the number of optional tasks to be scheduled that maximize ocupation, but this depends on the number of tasks created, and I need a general way to maximize ocupation which should be achieved with optimization.
Any thoughts of what might be causing this? Do you think this is actually due to the high computational cost?
Thank you!
It might come from the computational cost, yes, hard to say without a deeper look. Did you try an incremental approach? it is quite effective to estimate the computational complexity: start with 3 students and 3 buses, then 4 and 5, you may foresee the complexity for a higher number of inputs
What do you mean with buses Thomas?
I mean scholar bus, it is what I understood from your problem, both scholar bus and students are to be handled
Oh okay! Haha actually, I'm dealing with cars and students, in a driving school (where you get your driver's license) such that cars are working as much as possible and students get their practices scheduled in the time periods they specified they were available. Moreover, now I'm dealing with a unique resource, only one car, so I guess what I should do is to reduce the number of practices, try to increase this every time and see how the time scales, and hence, the computational complexity.
What I also think is that this depends a lot on the availability of the students whose practices are used in the problem. I understand that, for the same number of practices (tasks), the time would depend a lot on the constraints of those practices (availability of student), right?
Opening a new issue to continue with this new topic.
Thanks again!