0

I'm new to CPlex Python. Actually I am modeling a scheduling problem where I have to select only activities or tasks (has specific points in terms of efforts requires) from a large list for different Time Intervals and that should sum up to the given capacity. So I am using Step_at (name it capacity) function and stepping up it according to the Given capacity first. For resource usage I use another step_at_start (name it workUsage) cumul function and stepping it when the interval variable start in the solution. And I substract step_at_start (workUsage) from step_at (capacity) function. i.e. capacity -= workUsage.

For exaplme,

  • I have a list of tasks t = [t1, t2, ..., tn]
  • Each Task has Points, p = [p1,p2,...,pn]
  • There are 2 different time intervals as Spints (of 2 weeks), NB_Sprints = 2
  • Given Capacity for 2 sprints, c1 = 20, c2 = 50

Goal: To select tasks from list where sum of points p is equal to the Given Capacity C1(=20) for first 2 weeks & C2(=50) for another 2 points

Constrain: Can't repeat tasks (or work) in the solution

Mu current problem is Step_at function adds on remaining capacity from first sprint1 to sprint2. For Example, If Model only selected tasks whose total is 15 out of 20 (Given Capacity), then remaining 5 points will add up to next Sprint. So in Sprint2, I will have Given Capacity = 5+50. Which I don't want as Given Capacity should not change.

So here How can I make step_at function to be at 0 after first Time Interval (Let's say after first week) or any other work-around? I using Cplex Python API in my jupyter notebook. Any suggestion would be appreciated.

Gops
  • 1
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 11 '22 at 23:53

1 Answers1

2

I came accross a similar issue, and resolved it as follow (I am new to Cplex too so any feedback from an experienced user is welcome):

  • For each task define a "transition" task
  • When the transition task begins, retrieve 1 capacity
  • Add a no-overlap constraint bewteen all the tasks / transitions pairs

In practice:

transitions = mdl.interval_var_list(asize=len(tasks), size=1, optional=True)
capacity = step_at(0, 0)
for task in tasks:
    capacity += mdl.step_at_start(task, 1)
    for transition in transitions:
        mdl.add(mdl.equal(mdl.overlap_length(task, transition), 0))
for transition in transitions:
    capacity -= mdl.step_at_start(transition, 1)
mdl.add(capacity <= MAX_CAPACITY)
mdl.add(capacity >= 0) # to avoid accumulating capacity for the next sprint

Hope it helps