From 53ba6aee499c0eccc7c52c6fb8e543bfb5b50efd Mon Sep 17 00:00:00 2001 From: jripolles <jripolles@yahoo.fr> Date: Wed, 11 Dec 2024 17:48:38 +0100 Subject: [PATCH] Fixed categorical data example #932 --- examples/finished/categorical_data.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/finished/categorical_data.py b/examples/finished/categorical_data.py index 07f122aa..325e38c5 100644 --- a/examples/finished/categorical_data.py +++ b/examples/finished/categorical_data.py @@ -51,6 +51,10 @@ for s in shift_to_int.values(): model.addCons(sum(x[e, s] for e in employees) == 1) +# Each employee must be assigned to exactly one shift +for e in employees: + model.addCons(sum(x[e, s] for s in shift_to_int.values()) == 1) + # Employees can only work shifts they are available for for e in employees: for s in shift_to_int.values():