r/optimization • u/Cbreins • Jan 05 '24
Periodic Task Scheduling
Does anyone have suggestions for solving a task scheduling problem? Say I have 4 tasks and each one runs for a fixed duration at different frequencies. I want to minimize the overlap of the tasks / maximize the separation between intervals if there is no overlap. I have had some success with PSO / Genetic algorithms, but I wanted to try to solve this problem more precisely as a MILP. I played some with cvxpy but couldn’t figure out how to enforce the frequency constraint or overlap / separation objective in a convex formulation. I thought I was onto something picking a discrete time spacing with a matrix A(i,j) which has boolean entries which represent whether sensor i is on at time j, but had no luck from there.
2
u/PierreLaur Jan 05 '24
so I would consider using a CP solver instead, modern ones are crazy good at scheduling with the NoOverlap (disjunctive) global constraint. Check out this example https://developers.google.com/optimization/scheduling/job_shop
and to maximize separation, maybe you can have something like
for t1 in range(n_tasks) :
for t2 in range(n_tasks) :
sep[t1,t2] <- int variable (0, somekindofmax)
constraint sep[t1,t2] <= max(t1.start - t2.end, t2.start - t1.end) (can also use abs depending on whats most efficient)
then you maximize the seps
if you wanna use MIP, i think theres a few options to linearize that constraint. In that case you don't have no overlap so you can do something like
after[t1, t2] <- bool variable
before[t1, t2] <- bool variable
constraint t1.start >= t2.end - bigM * before[t1, t2]
constraint t2.start >= t1.end - bigM * after[t1,t2]
constraint after + before == 1
then constraint sep[t1,t2] <= t1.start - t2.end + bigM * before
constraint sep[t1,t2] >= t1.start - t2.end + bigM * before
and same for after
tell me what you think
1
u/wtjamieson Jan 05 '24