-
Notifications
You must be signed in to change notification settings - Fork 0
/
opf_lag.run
117 lines (113 loc) · 3.2 KB
/
opf_lag.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
model opf_lag.mod;
#data WB2.dat;
#data LMBM3.dat;
data WB5.dat;
#data case9mod.dat;
#data case14mod.dat;
#data case39mod3.dat;
option presolve_eps 1e-6;
option master.solver cplexamp;
option master.presolve 0;
option master.cplex_options 'outlev=1';
option master.solver_msg 0;
option subproblem.solver_msg 0;
option subproblem.presolve 0;
param USE_HEURISTIC default 1;
param USE_IPS_KNITRO default 0;
param USE_IPS_COUENNE default 1;
param ORACLE symbolic default "KNITRO";
set set_basis;
param lb;
param ZERO_RC_TOL := 1e-6;
repeat{
###
#
###
problem master;
option presolve_eps 1e-16;
unfix lambda;
#expand;
solve>cplex.log;
let lb := master_obj;
let set_basis := {ite in 1..nIte: lambda[ite].sstatus == 'bas'};
#display master_basis;
let{bus in bus_i} dual_p[bus] := p_balance[bus].dual;
let{bus in bus_i} dual_q[bus] := q_balance[bus].dual;
#let{bus in bus_i} dual_vmin[bus] := ctr_v_min[bus];
#let{bus in bus_i} dual_vmax[bus] := ctr_v_max[bus];
let dual_convexity := convexity.dual;
#display master_obj;
#display dual_p, dual_q;
#display dual_convexity;
#display lambda;
###
#
###
problem subproblem;
option presolve_eps 1e-16;
option reset_initial_guesses 0;
option presolve 0;
if nIte > 0 then{
let{bus in bus_i} v_re[bus] := V_re[nIte,bus];
let{bus in bus_i} v_im[bus] := V_im[nIte,bus];
}
unfix lambda;
fix{ite in 1..nIte diff master_basis} lambda[ite];
#display sub_obj;
if USE_HEURISTIC == 1 then {
let ORACLE := "KNITRO";
option subproblem.solver knitroampl;
option subproblem.knitro_options 'outlev=3 ms_enable=0 presolve=0 scale=0 opttol=1 opttolabs=1e-6';
close knitro.log;
if USE_IPS_KNITRO == 1 then let master_basis := set_basis;
solve>knitro.log;
#display sub_obj;
let master_basis := {};
if sub_obj>=-ZERO_RC_TOL then{
if USE_IPS_KNITRO == 1 then let master_basis := set_basis;
let ORACLE := "KNITRO2";
option subproblem.solver knitroampl;
option subproblem.knitro_options 'outlev=0 ms_enable=1 ms_maxsolves=20 presolve=0 scale=0 opttol=1 opttolabs=1e-6';
solve>knitro.log;
close knitro.log;
let master_basis := {};
}
};
if USE_HEURISTIC == 0 or sub_obj>=-ZERO_RC_TOL then{
if USE_IPS_COUENNE == 1 then let master_basis := set_basis;
option subproblem.solver couenne;
option subproblem.couenne_options 'outlev=1';
#expand;
#display lambda.sstatus;
#display set_basis;
#solve>couenne.log;
solve;
let ORACLE := "COUENNE";
let master_basis := {};
}
#display sub_obj;
let nIte := nIte +1;
let{bus in bus_i} V_re[nIte,bus] := v_re[bus];
let{bus in bus_i} V_im[nIte,bus] := v_im[bus];
#display v_re, v_im;
if sub_obj>=-ZERO_RC_TOL then{
if FEASIBILITY == 0 then {
printf "\n*** OPTIMAL SOLUTION ***\n";
printf "LowerBound : %q\n", master_obj;
printf "Min reduced cost : %q\n", sub_obj;
display card(master_basis);
fix;
break;
}else {
if master_obj > ZERO_RC_TOL then{
printf "\n*** NO FEASIBLE SOLUTION ***\n";
break;
}else{
printf "\n*** PHASE 2 ***\n";
let FEASIBILITY := 0;
}
}
};
#display FEASIBILITY;
printf "%6d%10s%20.6f%20.6f%10s\n", if FEASIBILITY == 1 then "PHASE1" else "PHASE2", nIte, lb, sub_obj, ORACLE;
};