I have an assignment problem where I want to allocate a number of balls to different containers. Every ball has a certain size - small, medium and large. I want to add a constraint that balls with 2 different colours should be in different containers.
I am using google-OR-tools linear solver. And apparently, I cannot express !=
constraint in the modelling construct.
I was able to get started like below :
from ortools.linear_solver import pywraplp
import itertools
s = pywraplp.Solver("", pywraplp.Solver.SCIP_MIXED_INTEGER_PROGRAMMING)
balls_size = ["s", "m", "s", "m", "l", "s", "m"]
balls_id_size = {i: j for i, j in zip(range(len(balls_size)), balls_size)}
bins = ["a", "b", "c"]
dv = {(i, j): s.BoolVar("") for i, j in itertools.product(balls_id_size, bins)}
what I want all bins should be homogenous in terms of what sizes of the ball it keeps
Per Laurent's suggestion, below is my attempt with CP-SAT solver. Certainly with
AddAllDifferent
constraint, code becomes more simpler and easy to read and understand.