I have a constraint problem that I am trying to solve with python-constraint
So let's say I have 3 places: loc1,...loc3
In addition, I have 7 devices: device1,...device7
The maximum number of devices in each location: loc1:3, loc2:4, loc3:2 (for example, a maximum of 3 devices in loc1 , etc.)
And some restrictions regarding locations and devices:
loc1: device1, device3, device7 ,
loc2: device1, device3, device4, device5, device6, device7
loc3: device2, device4, device5, device6
(for example, only device1 , device3 and device7 can be in loc1 .)
I am trying to get a set of possible parameters for devices in places.
from constraint import * problem = Problem() for key in locations_devices_dict: problem.addVariable(key,locations_devices_dict[key])
and I was fixated on how to make restrictions. I tried:
problem.addConstraint(MaxSumConstraint(3), 'loc1')
but it does not work, MaxSumConstraint does not summarize what I need.
All devices must be placed somewhere
Possible Solution:
loc1: device1, device3 loc2: device4, device6, device7 loc3: device2, device5
Does anyone have an idea?
(another python package / not using any package, also a good idea if anyone has suggestions ...)