Hi,
I am having some difficulties to spot where does an error comes from regarding a constraint I have designed and implemented in Python.
I would like to implement a affinity constraint where for some request r I have to condition some elements of r to be put within on the same location. Each request contains two sets one embodies the set of all items in r while the second embodies a subset of items of r. Say r = [items = {1,2,3,4} , affinity = {2,4}].
req[r].__getitem__(2) represent the data structure of affinity set while req[r].__getitem__(0)[0] represent the items set.
A[r,k,j] is a decision variable = 1 if element u of r is located on x. So given the request r and the set of affinity items I want to make sure that for a given location x and a request r the number of elements of affinity r are put within the same location x while others wherever.
I implemented the constraint but when looking to the
my_model_before_solving.lp file, it does not appear ! Does it have to do with the len method (I wanted to the concept of cardinality of a set) ? Could anyone shed some lights ?
Here is a piece of a relevant code :
my_model.addConstrs(
(quicksum(A_r_k_j[r - 1, k, j]
for j in phy_server_id) == len(req[r].__getitem__(2))
for r in R
for k in req[r].__getitem__(2) if k not in req[r].__getitem__(0)[0]),
"Constraint10")
Thanks,
Regards