ipopt 使用总结

options.auxdata = struct( ...
    'om',       om, ...
    'Ybus',     Ybus, ...
    'Yf',       Yf(il,:), ...
    'Yt',       Yt(il,:), ...
    'mpopt',    mpopt, ...
    'il',       il, ...
    'A',        A, ...
    'nA',       nA, ...
    'neqnln',   neqnlnnumber, ...
    'niqnln',   niqnlnnumber, ...
    'Js',       Js, ...
    'Hs',       Hs    );

%% define variable and constraint bounds
options.lb = xmin;
options.ub = xmax;
if gTOTAL_Scenarios==1
    options.cl = [zeros(2*nb*gTOTAL_Scenarios, 1); -Inf*ones(2*nl2*gTOTAL_Scenarios, 1); l];
    options.cu = [zeros(2*nb*gTOTAL_Scenarios, 1);     zeros(2*nl2*gTOTAL_Scenarios, 1); u];
else
    options.cl = [zeros(2*nb*gTOTAL_Scenarios, 1); -Inf*ones(2*nl2*gTOTAL_Scenarios+2, 1); l];
    options.cu = [zeros(2*nb*gTOTAL_Scenarios, 1);     zeros(2*nl2*gTOTAL_Scenarios+2, 1); u];   
end
%% assign function handles
%需要提供目标函数,目标函数梯度,约束,约束雅克比矩阵,约束海森矩阵

最重要的是Js Hs ,雅克比和海森矩阵中不为0的元素指示矩阵,一定要对应,不然会导致不收敛的出现

funcs.objective = @objective; funcs.gradient = @gradient; funcs.constraints = @constraints; funcs.jacobian = @jacobian; funcs.hessian = @hessian; funcs.jacobianstructure = @(d) Js; funcs.hessianstructure = @(d) Hs; %funcs.jacobianstructure = @jacobianstructure; %funcs.hessianstructure = @hessianstructure; %% run the optimization [x, info] = ipopt(x0,funcs,options);

另外相关的使用知识 参照目录下的example

 
  
 
  


你可能感兴趣的:(Tools)