Problem is infeasible unexpectedly with using MIP-CBC
- Dominant language
- Linear Programming
- Stars
- 600
- Forks
- 108
- PR merge metrics
- No merged PRs in 30d
Description
I created a Bin Packing Problem with a quite small number of items. Then I added symmetry constraints in order to solve the problem faster. Unfortunately, the problem gets infeasible although it should be feasible. I'm using MIP 1.13.0 with Python 3.10.1 on Windows.
I added my code for reproducing the problem. Thanks for your help!
```
from typing import Dict
import mip
def bin_packing(weights: Dict[int, float], capacity: float, symmetry_constraints: bool) -> mip.OptimizationStatus:
bins = list(range(4))
model = mip.Model('Bin Packing Problem')
model.verbose = 0
x = {(i, j): model.add_var(f'x({i},{j})', var_type=mip.BINARY) for i in weights.keys() for j in bins}
y = {j: model.add_var(f'y({j})', obj=1, var_type=mip.BINARY) for j in bins}
load = {j: mip.xsum(x[(i, j)] * w for i, w in weights.items()) for j in bins}
for j in bins:
model += load[j] <= y[j] * capacity, f'Capacity({j})'
for i in weights.keys():
model += mip.xsum(x[(i, j)] for j in bins) == 1, f'Item({i})'
if symmetry_constraints:
for j1, j2 in [(j1, j2) for j1 in bins for j2 in bins if j1 < j2]:
model += load[j1] >= load[j2], f'Symmetry({j1},{j2})'
return model.optimize()
if __name__ == '__main__':
weights = {0: 307, 1: 191, 2: 87.4, 3: 465.5339, 4: 273, 5: 106, 6: 385}
print(bin_packing(weights, 480, True))
print(bin_packing(weights, 480, False))
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.