I'm completely new to constraint programming and am having trouble setting up this problem. Using the below dataset, which is a simple representation of a much larger problem, I would like to generate every combination subject to a set of constraints. The constraints are:
- Use 1 employee from each group, except for group A, which should have 2 employees
- An employee can only be used once in each combination (i.e. Michelle can only be in group B or C)
- Total Salary should be between 25 and 30
I've gotten this far with the code, but I'm having trouble setting up the constraints.
from ortools.sat.python import cp_model
import pandas as pd
model = cp_model.CpModel()
# sample data set
df = pd.DataFrame([['John', 'A',5], ['Andy', 'A/C', 10], ['Michelle', 'B/C', 15],
['Jennifer', 'B', 5], ['Frank', 'C',10], ['Zack','A',5]],
columns=['Employee','Group','Salary'])
# add employee variable
employees = [model.NewBoolVar(x) for x in df['Employee']]
# constraint: 2 employees for group A, 1 employee otherwise
code
# use employee only once
code
# total salary between 25 and 30
code