mpcCustomSolverにおけるスラッグ変数の扱い
显示 更早的评论
こんにちは。
通常、MPCでQP問題を解いていく際、
MPC tool boxにてスラッグ変数の設定が行われていますが、
MPCにCustom QP Solverを適用し、(Obj.Optimizer.CustomSolver = true;)
自作QPソルバーにてシミュレーションを行う際にはスラッグ変数は
どのように扱われるのでしょうか?通常通りMPC tool boxのスラッグ変数が適用されているのでしょうか?
以下は自分が作成したコードになります。
本コードでは、CVXを用いて二次計画法を解いています。
function [X, status] = mpcCustomSolver(H,f,A,b,x0)
%% cvxで解く
persistent n; %Keep variable 'n' in memory
if isempty(n)
% Run just first time step
n = evalin('base','Obj.ControlHorizon'); %Extract variable from base workspace
end
cvx_begin quiet
variable X(n+1)
% 二次計画問題
minimize (0.5*X'*H*X+f'*X)
subject to
A*X >= b;
cvx_end
% % Get cvx status
str = cvx_status;
if strcmp('Solved',str)
status = 1; % Feasible solution
else
status = -1; % Infeasible solution
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Controller Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!