简体   繁体   English

Maple的符号二次优化

[英]Symbolic quadratic optimization with Maple

I'm trying to minimize a quadratic energy with linear equality constraints in Maple. 我正在尝试在Maple中使用线性相等约束最小化二次能量。 Currently I'm issuing things like: 目前,我正在发布以下内容:

with(Optimization):
p := (t) -> c3*t^3 + c2*t^2;
m := Minimize(int(diff(p(t),t)^2,t=0..1),{eval(p(t),t=1)=1,eval(diff(p(t),t),t=1)=0});

but this seems to give me a numerically optimized solution complete with floating point error: 但这似乎给了我一个数值优化的解决方案,并带有浮点误差:

m := [1.19999999999997, [c2 = 3.00000000000000, c3 = -2.00000000000000]]

(The correct answer is m:= [6/5,[c2=3,c3=-2]]) (正确答案是m:= [6/5,[c2 = 3,c3 = -2]])

Is there a way to compute the solution symbolically using maple? 有没有办法使用Maple 象征性地计算解决方案?

I'd rather not have to work out the Lagrangian myself. 我宁愿不必自己解决拉格朗日运动。 I'm hoping for a flag like symbolic=true. 我希望有一个像symbolic = true的标志。

Apply Lagrange multipliers step-by-step. 逐步应用拉格朗日乘数。 It's fairly easy to do. 这很容易做到。

p:= t-> c3*t^3+c2*t^2:
Obj:= int(D(p)^2,  0..1):
Con:= {p(1)=1, D(p)(1)=0}:
L:= Obj - l1*lhs(Con[1]) - l2*lhs(Con[2]):
solve(Con union {diff(L,c3), diff(L,c2)});
              /                      12       -1\ 
             { c2 = 3, c3 = -2, l1 = --, l2 = -- }
              \                      5        5 / 
eval(Obj, %);
                               6
                               -
                               5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM