I've just check the simple linear programming problem with scipy.optimize.linprog:
1*x[1] + 2x[2] -> max
1*x[1] + 0*x[2] <= 5
0*x[1] + 1*x[2] <= 5
1*x[1] + 0*x[2] >= 1
0*x[1] + 1*x[2] >= 1
1*x[1] + 1*x[2] <= 6
And got the very strange result, I expected that x[1] will be 1 and x[2] will be 5, but:
>>> print optimize.linprog([1, 2], A_ub=[[1, 1]], b_ub=[6], bounds=(1, 5), method='simplex')
status: 0
slack: array([ 4., 4., 4., 0., 0.])
success: True
fun: 3.0
x: array([ 1., 1.])
message: 'Optimization terminated successfully.'
nit: 2
Can anyone explain, why I got this strange result?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…