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!