google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
10.84k stars 2.09k forks source link

I want understand shiftConstraints and weeklySumConstraints parameters #1751

Closed asooft closed 4 years ago

asooft commented 4 years ago

Hello,

I use ortools shift scheduling and i want understand parameters of two variables shiftConstraints and weeklySumConstraints in detail:

// Shift constraints on continuous sequence : // (shift, hard_min, soft_min, min_penalty, // soft_max, hard_max, max_penalty) var shiftConstraints = new(int Shift, int HardMin, int SoftMin, int MinPenalty, int SoftMax, int HardMax, int MaxPenalty)[] { // One or two consecutive days of rest, this is a hard constraint. (0, 1, 1, 0, 2, 2, 0), // Between 2 and 3 consecutive days of night shifts, 1 and 4 are // possible but penalized. (3, 1, 2, 20, 3, 4, 5), };

and

// Weekly sum constraints on shifts days: // (shift, hardMin, softMin, minPenalty, // softMax, hardMax, maxPenalty) var weeklySumConstraints = new(int Shift, int HardMin, int SoftMin, int MinPenalty, int SoftMax, int HardMax, int MaxPenalty)[] { // Constraints on rests per week. (0, 1, 2, 7, 2, 2, 0), // At least 1 night shift per week (penalized). At most 4 (hard). (3, 0, 1, 3, 4, 4, 0), };

I want to increase "o" shift but keep the number of shifts per employee.

lperron commented 4 years ago

1st one:

you look at maximum sequences of true variables (bounded by the array bounds, or by variables assigned to false)

if len is the length of this sequence.

Then hard_min <= len <= hard_max if len < soft_min, you incur a penalty of (soft_min - len) min_penalty if len > soft_max, you incur a penalty of (len - soft_max) max_penalty

2nd one: same thing, but you count the number of variables assigned to 1 instead of the maximum sequence of variables assigned to one. I hope this helps. Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53 00

Le mer. 27 nov. 2019 à 15:20, asooft notifications@github.com a écrit :

Hello,

I use ortools shift scheduling and i want understand parameters of two variables shiftConstraints and weeklySumConstraints in detail:

// Shift constraints on continuous sequence : // (shift, hard_min, soft_min, min_penalty, // soft_max, hard_max, max_penalty) var shiftConstraints = new(int Shift, int HardMin, int SoftMin, int MinPenalty, int SoftMax, int HardMax, int MaxPenalty)[] { // One or two consecutive days of rest, this is a hard constraint. (0, 1, 1, 0, 2, 2, 0), // Between 2 and 3 consecutive days of night shifts, 1 and 4 are // possible but penalized. (3, 1, 2, 20, 3, 4, 5), };

and

// Weekly sum constraints on shifts days: // (shift, hardMin, softMin, minPenalty, // softMax, hardMax, maxPenalty) var weeklySumConstraints = new(int Shift, int HardMin, int SoftMin, int MinPenalty, int SoftMax, int HardMax, int MaxPenalty)[] { // Constraints on rests per week. (0, 1, 2, 7, 2, 2, 0), // At least 1 night shift per week (penalized). At most 4 (hard). (3, 0, 1, 3, 4, 4, 0), };

I want to increase "o" shift but keep the number of shifts per employee.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/1751?email_source=notifications&email_token=ACUPL3MMHHP56FOOTEZN7D3QVZ6ZDA5CNFSM4JSHPXV2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H4NUNGQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3JMABLDKRG4CRZL2KDQVZ6ZDANCNFSM4JSHPXVQ .

asooft commented 4 years ago

1st one: you look at maximum sequences of true variables (bounded by the array bounds, or by variables assigned to false) if len is the length of this sequence. Then hard_min <= len <= hard_max if len < soft_min, you incur a penalty of (soft_min - len) min_penalty if len > soft_max, you incur a penalty of (len - soft_max) max_penalty 2nd one: same thing, but you count the number of variables assigned to 1 instead of the maximum sequence of variables assigned to one. I hope this helps. Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53 00 Le mer. 27 nov. 2019 à 15:20, asooft notifications@github.com a écrit : Hello, I use ortools shift scheduling and i want understand parameters of two variables shiftConstraints and weeklySumConstraints in detail: // Shift constraints on continuous sequence : // (shift, hard_min, soft_min, min_penalty, // soft_max, hard_max, max_penalty) var shiftConstraints = new(int Shift, int HardMin, int SoftMin, int MinPenalty, int SoftMax, int HardMax, int MaxPenalty)[] { // One or two consecutive days of rest, this is a hard constraint. (0, 1, 1, 0, 2, 2, 0), // Between 2 and 3 consecutive days of night shifts, 1 and 4 are // possible but penalized. (3, 1, 2, 20, 3, 4, 5), }; and // Weekly sum constraints on shifts days: // (shift, hardMin, softMin, minPenalty, // softMax, hardMax, maxPenalty) var weeklySumConstraints = new(int Shift, int HardMin, int SoftMin, int MinPenalty, int SoftMax, int HardMax, int MaxPenalty)[] { // Constraints on rests per week. (0, 1, 2, 7, 2, 2, 0), // At least 1 night shift per week (penalized). At most 4 (hard). (3, 0, 1, 3, 4, 4, 0), }; I want to increase "o" shift but keep the number of shifts per employee. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1751?email_source=notifications&email_token=ACUPL3MMHHP56FOOTEZN7D3QVZ6ZDA5CNFSM4JSHPXV2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H4NUNGQ>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3JMABLDKRG4CRZL2KDQVZ6ZDANCNFSM4JSHPXVQ .

thank you for u answer

but i'm reading this in the documentation but not understand it

can you understand me by some examples