mpcCustomSolverにおけるスラッグ変数の扱い
Afficher commentaires plus anciens
こんにちは。
通常、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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Controller Creation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!