Created
September 5, 2022 19:44
-
-
Save francoisstamant/21f400eda458d7e069c953071d412fd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Add constraints to the model | |
#The values | |
x = knapsack_model.addVars(N, vtype = GRB.INTEGER, name="x") | |
#The total cost must be inferior to our budget | |
knapsack_model.addConstr(sum(cost_dollars[i]*x[i] for i in range(N)) <= total_budget) | |
#Minimum for each aspect must be filled | |
knapsack_model.addConstrs(x[i] >= minimum_time[i] for i in range(N)) | |
#Maximum for each aspect must be respected | |
knapsack_model.addConstrs(x[i] <= maximum_time[i] for i in range(N)) | |
#Sum of hours must be equal to total possible hours | |
knapsack_model.addConstr(sum(x[i] for i in range(N)) == total_hours) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment