YALMIP INTEGRATION WITH MOSEK: THE TERMINATION CONDITION FAILS TO STOP THE SOLUTION PROCESS #1392
Unanswered
YuenLiSze
asked this question in
General discussion
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Professor,
I'm working on an optimization problem using YALMIP with MOSEK as the solver in MATLAB. Despite setting specific termination conditions in
ops
, the solver doesn't stop as expected when these conditions are met.Environment:
The solver continues past the maximum time I've set (
MSK_DPAR_OPTIMIZER_MAX_TIME
andMSK_DPAR_MIO_MAX_TIME
both set to 300). Not only that, but I tried controlling other parameters of the solver to terminate the code run, and it didn't work either.Here's how I'm setting myops
:ops = sdpsettings('solver','mosek', ...
'mosek.MSK_DPAR_OPTIMIZER_MAX_TIME', 300, ...
'mosek.MSK_DPAR_MIO_MAX_TIME',300, ...
'mosek.MSK_DPAR_MIO_TOL_REL_GAP', 1e-4, ...
'mosek.MSK_IPAR_MIO_MAX_NUM_BRANCHES',500000, ...
'mosek.MSK_IPAR_MIO_MAX_NUM_RELAXS',500000);
Attempted Solutions:
Verified ops settings are correctly applied by inspecting the structure in the workspace.
Checked YALMIP and MOSEK for compatibility issues; both are up to date.
I'm looking for any insights on why these termination conditions might not be respected by the solver, or if there's any known issue with these specific settings in YALMIP's integration with MOSEK.
Thanks in advance for your help!
The entire function code:
function [p_wt,p_pv,p_load,x,UB,p_g,p_ch,p_dis,p_buy,p_sell] = down_layer1_checked(ee_bat_int,p_wt_int,p_pv_int,p_g_int,LB,yita)
optimize_paremeters;
p_bat_int = ee_bat_int0.21;
ee0 = 0.55ee_bat_int;
p_ch = sdpvar(24,4);
p_dis = sdpvar(24,4);
uu_bat = binvar(24,4);
uu_m = binvar(24,4);
p_buy = sdpvar(24,4);
p_sell = sdpvar(24,4);
p_wt = sdpvar(24,4);
p_pv = sdpvar(24,4);
p_load = sdpvar(24,4);
p_g = sdpvar(24,4);
p_l = xlsread('4typicalday.xlsx','0%','B3:E26')*900;
max_p_wt = xlsread('4typicalday.xlsx','0%','H3:K26')*p_wt_int;
max_p_pv = xlsread('4typicalday.xlsx','0%','N3:Q26')*p_pv_int;
price = [0.48;0.48;0.48;0.48;0.48;0.48;0.48;0.9;1.35;1.35;1.35;0.9;0.9;0.9;0.9;0.9;0.9;0.9;1.35;1.35;1.35;1.35;1.35;0.48];
C = [];
load = p_l';
wwt = 0.05;wpv = 0.1;wl = 0.15;
C = [C, (1 - wwt)*max_p_wt <= p_wt,p_wt <= (1 + wwt)*max_p_wt];
C = [C, (1 - wpv)*max_p_pv <= p_pv,p_pv <= (1 + wpv)*max_p_pv];
C = [C, (1 - wl)*load' <= p_load,p_load <= (1 + wl)*load'];
lam1 = sdpvar(96,1);lam11 = sdpvar(96,1);
lam2 = sdpvar(192,1);lam21 = sdpvar(192,1);lam3 = sdpvar(4,1);
lam4 = sdpvar(192,1);lam41 = sdpvar(192,1);lam5 = sdpvar(96,1);
lam51 = sdpvar(96,1);lam6 = sdpvar(96,1);
beta1 = binvar(96,1);beta11 = binvar(96,1);
beta2 = binvar(192,1);beta21 = binvar(192,1);beta3 = binvar(4,1);
beta4 = binvar(192,1);beta41 = binvar(192,1);beta5 = binvar(96,1);
beta51 = binvar(96,1);beta6 = binvar(96,1);beta7 = binvar(480,1);beta8 = binvar(288,1);
x = [p_buy(:,1)' p_sell(:,1)' p_g(:,1)' p_ch(:,1)' p_dis(:,1)' p_buy(:,2)' p_sell(:,2)' p_g(:,2)' p_ch(:,2)' p_dis(:,2)' p_buy(:,3)' p_sell(:,3)' p_g(:,3)' p_ch(:,3)' p_dis(:,3)' p_buy(:,4)' p_sell(:,4)' p_g(:,4)' p_ch(:,4)' p_dis(:,4)']';
u = [p_wt(:,1)' p_pv(:,1)' p_load(:,1)' p_wt(:,2)' p_pv(:,2)' p_load(:,2)' p_wt(:,3)' p_pv(:,3)' p_load(:,3)' p_wt(:,4)' p_pv(:,4)' p_load(:,4)']';
P = [price' -price' (c_g_om+c_fuel).*ones(1,24) c_bat_om.*ones(1,48)...
price' -price' (c_g_om+c_fuel).*ones(1,24) c_bat_om.*ones(1,48)...
price' -price' (c_g_om+c_fuel).*ones(1,24) c_bat_om.*ones(1,48)...
price' -price' (c_g_om+c_fuel).*ones(1,24) c_bat_om.*ones(1,48)]';
Q1 = [ zeros(24,48) eye(24) zeros(24,48) zeros(24,360);
zeros(24,120) zeros(24,48) eye(24) zeros(24,48) zeros(24,240);
zeros(24,240) zeros(24,48) eye(24) zeros(24,48) zeros(24,120);
zeros(24,360) zeros(24,48) eye(24) zeros(24,48)];
Q2 = [zeros(48,72) eye(48) zeros(48,360);
zeros(48,120) zeros(48,72) eye(48) zeros(48,240);
zeros(48,240) zeros(48,72) eye(48) zeros(48,120);
zeros(48,360) zeros(48,72) eye(48)];
Q3 = [zeros(1,72) eta.*ones(1,24) -1/eta.*ones(1,24) zeros(1,360);
zeros(1,120) zeros(1,72) eta.*ones(1,24) -1/eta.*ones(1,24) zeros(1,240);
zeros(1,240) zeros(1,72) eta.*ones(1,24) -1/eta.*ones(1,24) zeros(1,120);
zeros(1,360) zeros(1,72) eta.*ones(1,24) -1/eta.*ones(1,24)];
Q4 = [eye(48) zeros(48,72) zeros(48,360);
zeros(48,120) eye(48) zeros(48,72) zeros(48,240);
zeros(48,240) eye(48) zeros(48,72) zeros(48,120);
zeros(48,360) eye(48) zeros(48,72)];
Q5 = [zeros(24,72) eta.*tril(ones(24,24),0) -1/eta.*tril(ones(24,24),0) zeros(24,360);
zeros(24,120) zeros(24,72) eta.*tril(ones(24,24),0) -1/eta.*tril(ones(24,24),0) zeros(24,240);
zeros(24,240) zeros(24,72) eta.*tril(ones(24,24),0) -1/eta.*tril(ones(24,24),0) zeros(24,120);
zeros(24,360) zeros(24,72) eta.*tril(ones(24,24),0) -1/eta.*tril(ones(24,24),0)];
Q6 = [eye(24) -eye(24) eye(24) -eye(24) eye(24) zeros(24,360);
zeros(24,120) eye(24) -eye(24) eye(24) -eye(24) eye(24) zeros(24,240);
zeros(24,240) eye(24) -eye(24) eye(24) -eye(24) eye(24) zeros(24,120);
zeros(24,360) eye(24) -eye(24) eye(24) -eye(24) eye(24)];
Q10=[eye(48) zeros(48,72) zeros(48,360);
zeros(48,120) eye(48) zeros(48,72) zeros(48,240);
zeros(48,240) eye(48) zeros(48,72) zeros(48,120);
zeros(48,360) eye(48) zeros(48,72)];
G = [eye(24) eye(24) -eye(24) zeros(24,216);
zeros(24,72) eye(24) eye(24) -eye(24) zeros(24,144);
zeros(24,144) eye(24) eye(24) -eye(24) zeros(24,72);
zeros(24,216) eye(24) eye(24) -eye(24)];
T2 = [uu_bat(:,1);(1-uu_bat(:,1));uu_bat(:,2);(1-uu_bat(:,2));uu_bat(:,3);(1-uu_bat(:,3));uu_bat(:,4);(1-uu_bat(:,4))].p_bat_int;
T4 = [uu_m(:,1);1-uu_m(:,1);uu_m(:,2);1-uu_m(:,2);uu_m(:,3);1-uu_m(:,3);uu_m(:,4);1-uu_m(:,4)].pm_max;
T5 = repmat(0.9ee_bat_int-ee0,96,1);
T51 = repmat(0.1ee_bat_int-ee0,96,1);
C = [C, Q1x <= p_g_int];
C = [C, Q1x >= 0];
C = [C, Q2x <= T2];
C = [C, Q2x >= 0];
C = [C, Q3*x == 0];
C = [C, Q4x <= T4];
C = [C, Q4x >= 0];
C = [C, Q5x <= T5];
C = [C, Q5x >= T51];
C = [C, Q6x + Gu == 0];
C = [C, Q1'*lam1-Q1'*lam11+Q2'*lam2-Q2'*lam21+Q3'*lam3+Q4'*lam4-Q4'*lam41+Q5'*lam5-Q5'*lam51+Q6'*lam6>=-P];
C = [C, Q1*x-p_g_int>=-(1-beta1).*M,lam1<=beta1.M];
C = [C, Q1x<=beta11.*M,lam11>=-(1-beta11).*M];
C = [C, Q2*x-T2>=-(1-beta2).*M,lam2<=beta2.M];
C = [C, Q2x<=beta21.*M,lam21>=-(1-beta21).*M];
C = [C, Q4*x-T4>=-(1-beta4).*M,lam4<=beta4.M];
C = [C, Q4x<=beta41.*M,lam41>=-(1-beta41).*M];
C = [C, Q5*x-T5>=-(1-beta5).*M,lam5<=beta5.M];
C = [C, Q5x-T51<=beta51.*M,lam51>=-(1-beta51).*M];
C = [C, lam1>=0,lam11<=0,lam2>=0,lam21<=0,lam4>=0,lam41<=0,lam5>=0,lam51<=0];
C = [C, P+Q1'*lam1-Q1'*lam11+Q2'*lam2-Q2'*lam21+Q3'*lam3+Q4'*lam4-Q4'*lam41+Q5'*lam5-Q5'*lam51+Q6'*lam6<=M.beta7,x<=M.(1-beta7)];
obj_o = sum(sum(repmat(price,1,4).(p_buy(:,:)-p_sell(:,:)))+c_fuelsum(p_g(:,1))+...
sum(c_wt_omp_wt(:,:))+sum(c_pv_omp_pv(:,:))+sum(c_g_omp_g(:,:))+sum(c_bat_omp_dis(:,:))+sum(c_bat_omp_ch(:,:)));
%c_bat(1,1)/3ee_bat_int*k_suo;
Cj = -obj_o;
%ops = sdpsettings('solver','MOSEK','MSK_IPAR_OPTIMIZER',MSK_OPTIMIZER_FREE_SIMPLEX,'mosek.MSK_DPAR_MIO_TOL_REL_GAP', 1.0e-3);
ops=sdpsettings('solver','mosek',...
'mosek.MSK_DPAR_OPTIMIZER_MAX_TIME', 300, ...
'mosek.MSK_DPAR_MIO_MAX_TIME',300,...
'mosek.MSK_DPAR_MIO_TOL_REL_GAP', 1e-4,...
'mosek.MSK_IPAR_MIO_MAX_NUM_BRANCHES',500000,...
'mosek.MSK_IPAR_MIO_MAX_NUM_RELAXS',700000);
%%
reuslt = optimize(C,Cj,ops);
Q=value(Cj);
UB=LB-yita-Q;
p_wt=value(p_wt);
p_pv=value(p_pv);
p_load=value(p_load);
p_g=value(p_g);
p_ch=value(p_ch);
p_dis=value(p_dis);
p_buy=value(p_buy);
p_sell=value(p_sell);
Beta Was this translation helpful? Give feedback.
All reactions