资源简介
简单地内点法程序,使用matlab语言编写,可以直接运行。有助于理解内点法
代码片段和文件信息
%%
%%%%%%% 以下开始内点
clc;
clear;
[ N T alpha_wan beta_wan gamma_wan c_qp_MIQP F_qp_MIQP A_h b_h A_gg b_gg A_Gb_G A_g b_g] = Prob_set();
length_l = size(A_G1);
length_z = length_l;
length_w = size(A_g1);
length_u = length_w;
length_ll = size(A_gg1);
length_zz = length_ll;
length_y = size(A_h1);
w = -ones(length_w1);
u = ones(length_u1);
z = ones(length_z1);
l = ones(length_l1);
zz = ones(length_zz1);
ll = ones(length_ll1);
y = sparse(length_y1);
x = [ 0.5*ones(T*N1);
0.5*ones(T*N1);
0.001*ones(T*N1);
0.5*ones(T*N1)]; % 初始值
length_x = 4*T*N;
k=0;
sigema = 0.1;
disp(‘k optimalF Gap mu‘);
tic
Gap=full(-w‘*u+z‘*l + zz‘*ll);
while k<10000 && Gap >= 1e-4
if k == 50
disp(‘----------‘);
end
Gap=full(-w‘*u+z‘*l + zz‘*ll);
optimalF = full(c_qp_MIQP‘* x + 1/2 * x‘* F_qp_MIQP * x);
mu=sigema*Gap/((length_l+length_u+length_ll)*2);
fprintf(‘%d %8.5d %8.5d %8.5d\n‘koptimalFGapmu);
coeMatr = [ F_qp_MIQP -A_G‘ -A_g‘ sparse(length_xlength_l) sparse(length_xlength_u) -A_h‘ -A_gg‘ sparse(length_xlength_zz);...
-A_G sparse(length_zlength_z) sparse(length_zlength_w) sparse(diag(ones(1length_z))) sparse(length_zlength_u) sparse(length_z length_y+length_zz+length_ll);...
-A_g sparse(length_w length_z + length_w + length_l) -sparse(diag(ones(1length_w))) sparse(length_w length_y+length_zz+length_ll);...
sparse(length_llength_x ) sparse(diag(l)) sparse(length_l length_w) sparse(diag(z)) sparse(length_l length_u+ length_y+length_zz+length_ll);...
sparse(length_u length_x + length_z) -sparse(diag(u)) sparse(length_ulength_l) -sparse(diag(w)) sparse(length_u length_y+length_zz+length_ll);...
-A_h sparse(length_y length_z + length_w + length_l + length_u+ length_y+length_zz+length_ll);...
-A_gg sparse(length_zz length_z + length_w + length_l + length_u+ length_y+length_zz) sparse(diag(ones(1length_ll )));...
sparse(length_ll length_x + length_z + length_w + length_l + length_u+ length_y) sparse(diag(ll)) sparse(diag(zz));...
];
L_x = c_qp_MIQP - A_h‘ * y - A_G‘*z - A_g‘* w - A_gg‘* zz;
L_z = - (A_G * x - l - b_G);
L_w = -(A_g * x + u - b_g);
L_l = z.*l - mu;
L_u = -w.*u -mu;
L_y = -A_h*x + b_h;
L_zz = -(A_gg * x - ll -b_gg);
L_ll = zz.*ll - mu;
K_X_miu = -[L_x; L_z; L_w; L_l; L_u; L_y; L_zz; L_ll ];
deltaX = coeMatr\K_X_miu;
delta_x = deltaX(1:length_x);
delta_z = delta
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4605 2018-11-12 14:47 main2.m
- 上一篇:智能优化算法及其MATLAB
- 下一篇:随机森林工具包
评论
共有 条评论