pennonm_callback_g.m
来自「matlab波形优化算法经常要用到的matlab toolbox工具箱:yalm」· M 代码 · 共 42 行
M
42 行
function gi = pennonm_callback_g(i,x,model_in)
global latest_G
global latest_g
global latest_x_g
persistent model
persistent g
persistent geq
if nargin>2
model = model_in;
return
end
% Compute the nonlinear terms in the constraints
x = x(:);
if ~isequal(latest_x_g,x)
[g,geq,dg,dgeq] = fmincon_con(x,model);
latest_x_g = x;
% Append with linear constraints
g = [g;geq];
if ~isempty(model.A)
g = [g;model.A*x - model.b];
end
if ~isempty(model.Aeq)
g = [g;model.Aeq*x - model.beq];
end
G = [dg';dgeq'];
if ~isempty(model.A)
G = [G;model.A];
end
if ~isempty(model.Aeq)
G = [G;model.Aeq];
end
latest_G = G;
latest_g = g;
else
g = latest_g;
end
gi = full(g(i+1));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?