在拉格朗日(SageMath)中定义约束

时间:2018-01-31 22:52:48

标签: constraints mathematical-optimization sage maximize

我试图最大化函数P,约束为x> = 75,000且y> = 200,000。但是,我认为我没有正确定义它们。我试图将它们定义为solve()函数的参数。

var('x','y', 'lam')

P = (0.05*x*(1-(x/150000) - 0.0000008*x*y)) + (0.08*y*(1-(y/200000) - 
0.0000008*x*y))

diff(P, x)
-(4.00000000000000e-8)*x*y - (6.40000000000000e-8)*y^2 - 
(3.33333333333333e-7)*x*(0.120000000000000*y + 1) - (3.33333333333333e-
7)*x + 0.0500000000000000

diff(P, y)
-(4.00000000000000e-8)*x^2 - (6.40000000000000e-8)*x*y - 
(4.00000000000000e-7)*(0.160000000000000*x + 1)*y -  
(4.00000000000000e-7)*y + 0.0800000000000000

solve([diff(P,x) == 0, diff(P,y) == 0, x >= 75000, y >= 200000],
x, y, lam)
[[75000 < x, 200000 < y, -(4e-08)*x*y - (6.4e-08)*y^2 - (3.33333333333333e-07)*x*(0.12*y + 1) - (3.33333333333333e-07)*x + 0.05 == 0, 
-(4e-08)*x^2 - (6.4e-08)*x*y - ((6.4e-08)*x + 4e-07)*y - (4e-07)*y + 0.08 == 0], 
[x == 75000, 200000 < y, -(6.4e-08)*y^2 - 0.006*y == 0, -0.0096008*y - 224.92 == 0], 
[x == 75000, y == 200000, -3760.0 == 0, -2145.08 == 0], [y == 200000, 75000 < x, -0.01600066666666667*x - 2559.949999999999 == 0, -(4e-08)*x^2 - 0.0256*x - 0.08 == 0]]

0 个答案:

没有答案