当我解决线性规划问题时,如下面的公式,我希望x all的结果是int类型
请考虑以下问题:
最小化: f = -1*x[0] + 4*x[1]
受制于:
-3*x[0] + 1*x[1] <= 6
1*x[0] + 2*x[1] <= 4
x[1] >= -3
Run Code Online (Sandbox Code Playgroud)
哪里: -inf <= x[0] <= inf
接下来是python编码器
>>> c = [-1, 4]
>>> A = [[-3, 1], [1, 2]]
>>> b = [6, 4]
>>> x0_bounds = (None, None)
>>> x1_bounds = (-3, None)
>>> res = linprog(c, A_ub=A, b_ub=b, bounds=(x0_bounds, x1_bounds),
... options={"disp": True})
>>> print(res)
Optimization terminated successfully.
Current function value: -11.428571
Iterations: 2 …Run Code Online (Sandbox Code Playgroud)