matlab - 在 MATLAB 中使用 prob2struct 将基于问题的模型转换为基于求解器的模型
问题描述
我正在尝试将基于问题的模型转换为基于求解器的模型,以便我可以使用其他求解器来解决我的问题。该prob2struct
函数返回一个结构,该结构使用一些矩阵定义模型,如Aeq
和beq
。我对矩阵C
和d
返回结构的含义感到困惑。下面附上演示代码。
clc
clear
qprob = optimproblem;
var_x = optimvar('var_x',2);
constr = var_x >= 5;
qprob.Constraints.x_range = constr;
qprob.Constraints.xs = var_x(1) >= var_x(2) + 10;
qprob.Objective = sum((var_x - [2,3]').^2)+8;
opts = optimoptions('lsqlin','Algorithm','interior-point');
[sol,fval,exitflag,output,lambda] = solve(qprob,'options',opts);
problem = prob2struct(qprob);
解决方案
C 和 d 是线性系统 C*x = d 中的参数。
请参阅“lsqlin”求解器的文档https://www.mathworks.com/help/optim/ug/lsqlin.html