Complete the code to import the integer linear programming solver from scipy.
from scipy.optimize import [1]
The linprog function from scipy.optimize is used for linear programming, including integer programming when specifying integer constraints.
Complete the code to define the objective function coefficients for minimization.
c = [1]The objective function coefficients must be a list or array. Here, a list [1, 2, 3] is used.
Fix the error in the code to specify the integer constraint for the variables.
bounds = [(0, None), (0, None), (0, None)] integrality = [1]
The integrality parameter expects a list of 1s and 0s indicating which variables are integers (1) or continuous (0). Here, all variables are integers, so [1, 1, 1] is correct.
Fill both blanks to define inequality constraints matrices and vectors.
A_ub = [1] b_ub = [2]
A_ub is a 2x3 matrix representing coefficients of inequality constraints, and b_ub is a vector with the upper bounds for these constraints.
Fill all three blanks to call the solver with integer constraints and print the solution.
result = linprog(c=[1], A_ub=[2], b_ub=[3], bounds=bounds, integrality=integrality, method='highs') print(result.x)
The linprog function requires the objective coefficients c, inequality matrix A_ub, and inequality bounds b_ub as arguments. Passing these correctly allows the solver to find the integer solution.