Skip to content

Instantly share code, notes, and snippets.

View sorooshafiee's full-sized avatar

Soroosh Shafiee sorooshafiee

View GitHub Profile
@sorooshafiee
sorooshafiee / knapsack.py
Created August 22, 2022 17:07 — forked from jhelgert/knapsack.py
[Python3] Finds all optimal feasible Solutions for the knapsack problem with Gurobi. Works similar for all binary integer programs.
#!/usr/bin/env python3
from gurobipy import *
def addBinaryCut(j):
B, NB = [], []
for i in range(n):
B.append(i) if (x[i].x == 1) else NB.append(i)
# Add binary cut to Model