add knapsack sol printing alt
@@ -12,7 +12,7 @@ n = 10
np.random.seed(1)
values = np.random.randint(0,10, n)
weights = np.random.randint(1,5, n)
-capacity = np.random.randint(sum(weights)*.3, sum(weights)*.6)
+capacity = np.random.randint(sum(weights)*.2, sum(weights)*.5)
# Construct the model.
x = BoolVar(n)
@@ -28,3 +28,4 @@ stats = model.solve()
# Variables can be asked for their value in the found solution
#print("Value:", objective.value())
print("Solution:", x.value())
+print("In items: ", [i+1 for i,val in enumerate(x.value()) if val])
