'how can i use optimization toolbox(matlab) in a right way?
my code:
q0 = [10,20];
qv0 = [0,0];
qa0 = [0,0];
qf = [60,100];
qvf = [0,0];
qaf = [0,0];
%syms tf;% 没有解析解
tf = optimvar('tf');
prob = optimproblem;
prob.Objective = tf;
x.tf=0;
nn = length(q0);
for i=1:nn
a0(i) = q0(i);
a1(i) = qv0(i);
a2(i) = qa0(i)/2.0;
a3(i) = (20*(qf(i) - q0(i)) - (8*qvf(i) + 12*qv0(i))*tf + (qaf(i) - 3*qa0(i))*tf^2)/(2*tf^3);
a4(i) = (-30*(qf(i) - q0(i)) + (14*qvf(i) + 16*qv0(i))*tf - (2*qaf(i) - 3*qa0(i))*tf^2)/(2*tf^4);
a5(i) = (12*(qf(i) - q0(i)) - (60*qvf(i) + 6*qv0(i))*tf + (qaf(i) - qa0(i))*tf^2)/(2*tf^5);
end
for j=1:nn
prob.Constraints.cons1 = a1(j) + 2*a2(j)*tf + 3*a3(j)*tf^2 + 4*a4(j)*tf^3 + 5*a5(j)*tf^4 <= 5;
prob.Constraints.cons2 = 2*a2(j) + 6*a3(j)*tf + 12*a4(j)*tf^2 + 20*a5(j)*tf^3 <= 0.5;
sol = solve(prob,x) end
Content of the error report:
Solving problem using fmincon.
错误使用 optim.problemdef.OptimizationProblem/solve
Nonlinear constraint function is undefined at initial point. Fmincon cannot continue.
出错 main (第 28 行)
sol = solve(prob,x)
Problem Background.
I know the starting angle, the velocity, the acceleration, and I want to use a fifth polynomial planning to find the time under the constraints using the optimizatiom toolbox.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
