Filter löschen
Filter löschen

Creating an optimization constraint - how to only schedule one employee per time slot

2 Ansichten (letzte 30 Tage)
I'm trying to add a constraint to my linear programming problem but am not sure how to form it. Instead of showing all of my code, I will give you an example of a solution that is expected as an output with this constraint implemented.
The program is a nurse scheduling problem. It works correctly now given the constraints I have implemented, but it is scheduling all employees during the same shift (because that maximizes the reward -- which is the objective function). An example of what x could be is this:
x = [
0
0
0
0
1
0
0
0
1
0
1
0
0
0
0
0
1
0
0
0]
What I don't know is what I should add to the A/b matrices to ensure this kind of a result (to expalin further, each 5 rows are the 5 options of where an employee can work. As you can see from this output, the employees are working in time slots 5, 4, 1 and 2 respectively i.e. not in the same time slot).
  1 Kommentar
Dave Campbell
Dave Campbell am 8 Dez. 2019
Maybe another way to form this question is, how do I find A/b such that the sum of every corresponding row is <= 1? i.e. the 1st row value + 6th row value + 11th row value + 16th row value <= 1 and so on

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Matt J
Matt J am 13 Dez. 2019
Bearbeitet: Matt J am 13 Dez. 2019
The problem-based optimization workflow is especially handy for matrix-valued optimization variables. It lets you write constraints using literal row/column summation commands, and doesn't require you to find equivalent A,b matrices at all. For this problem, the skeleton of it would be,
x=optimvar('x',[5,4],'type','integer','LowerBound',0,'UpperBound',1);
prob=optimproblem;
prob.Constraints.rowsum = ( sum(x,2)<=1 );
prob.Objective=...
solution=solve(problem)

Christian Schumacher
Christian Schumacher am 13 Dez. 2019
Bearbeitet: Christian Schumacher am 13 Dez. 2019
I need more code to help here, but i general: you must formulate a maximum nurses per shift. it should be something like this
i = 1:length(shift)
nursing_problem.Constraints.max_nurses = shift(i) == max_nurses;

Kategorien

Mehr zu Linear Programming and Mixed-Integer Linear Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by