-
Notifications
You must be signed in to change notification settings - Fork 11
/
most_ex7_suc.m
121 lines (113 loc) · 5.07 KB
/
most_ex7_suc.m
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
118
119
120
121
function most_ex7_suc(quiet)
% most_ex7_suc - Examples of secure and stochastic unit commitment problems.
% MOST
% Copyright (c) 2015-2024, Power Systems Engineering Research Center (PSERC)
% by Ray Zimmerman, PSERC Cornell
%
% This file is part of MOST.
% Covered by the 3-clause BSD License (see LICENSE file for details).
% See https://github.com/MATPOWER/most for more info.
%% set up options
define_constants;
verbose = 1;
mpopt = mpoption('verbose', verbose);
mpopt = mpoption(mpopt, 'out.gen', 1);
mpopt = mpoption(mpopt, 'model', 'DC');
mpopt = mpoption(mpopt, 'most.solver', 'DEFAULT');
if ~verbose
mpopt = mpoption(mpopt, 'out.all', 0);
end
mpopt = mpoption(mpopt, 'most.price_stage_warn_tol', 10);
%% solver options
if have_feature('cplex')
%mpopt = mpoption(mpopt, 'cplex.lpmethod', 0); %% automatic
%mpopt = mpoption(mpopt, 'cplex.lpmethod', 1); %% primal simplex
mpopt = mpoption(mpopt, 'cplex.lpmethod', 2); %% dual simplex
%mpopt = mpoption(mpopt, 'cplex.lpmethod', 3); %% network simplex
%mpopt = mpoption(mpopt, 'cplex.lpmethod', 4); %% barrier
mpopt = mpoption(mpopt, 'cplex.opts.mip.tolerances.mipgap', 0);
mpopt = mpoption(mpopt, 'cplex.opts.mip.tolerances.absmipgap', 0);
mpopt = mpoption(mpopt, 'cplex.opts.threads', 2);
end
if have_feature('glpk')
mpopt = mpoption(mpopt, 'glpk.opts.mipgap', 0);
mpopt = mpoption(mpopt, 'glpk.opts.tolint', 1e-10);
mpopt = mpoption(mpopt, 'glpk.opts.tolobj', 1e-10);
end
if have_feature('gurobi')
%mpopt = mpoption(mpopt, 'gurobi.method', -1); %% automatic
%mpopt = mpoption(mpopt, 'gurobi.method', 0); %% primal simplex
mpopt = mpoption(mpopt, 'gurobi.method', 1); %% dual simplex
%mpopt = mpoption(mpopt, 'gurobi.method', 2); %% barrier
mpopt = mpoption(mpopt, 'gurobi.threads', 2);
mpopt = mpoption(mpopt, 'gurobi.opts.MIPGap', 0);
mpopt = mpoption(mpopt, 'gurobi.opts.MIPGapAbs', 0);
end
if have_feature('mosek')
sc = mosek_symbcon;
%mpopt = mpoption(mpopt, 'mosek.lp_alg', sc.MSK_OPTIMIZER_FREE); %% default
%mpopt = mpoption(mpopt, 'mosek.lp_alg', sc.MSK_OPTIMIZER_INTPNT); %% interior point
%mpopt = mpoption(mpopt, 'mosek.lp_alg', sc.MSK_OPTIMIZER_PRIMAL_SIMPLEX); %% primal simplex
mpopt = mpoption(mpopt, 'mosek.lp_alg', sc.MSK_OPTIMIZER_DUAL_SIMPLEX); %% dual simplex
%mpopt = mpoption(mpopt, 'mosek.lp_alg', sc.MSK_OPTIMIZER_FREE_SIMPLEX); %% automatic simplex
%mpopt = mpoption(mpopt, 'mosek.opts.MSK_DPAR_MIO_TOL_X', 0);
mpopt = mpoption(mpopt, 'mosek.opts.MSK_IPAR_MIO_NODE_OPTIMIZER', sc.MSK_OPTIMIZER_DUAL_SIMPLEX);
mpopt = mpoption(mpopt, 'mosek.opts.MSK_IPAR_MIO_ROOT_OPTIMIZER', sc.MSK_OPTIMIZER_DUAL_SIMPLEX);
mpopt = mpoption(mpopt, 'mosek.opts.MSK_DPAR_MIO_TOL_ABS_RELAX_INT', 1e-9);
%mpopt = mpoption(mpopt, 'mosek.opts.MSK_DPAR_MIO_TOL_REL_RELAX_INT', 0);
mpopt = mpoption(mpopt, 'mosek.opts.MSK_DPAR_MIO_TOL_REL_GAP', 0);
mpopt = mpoption(mpopt, 'mosek.opts.MSK_DPAR_MIO_TOL_ABS_GAP', 0);
end
if have_feature('intlinprog')
%mpopt = mpoption(mpopt, 'linprog.Algorithm', 'interior-point');
%mpopt = mpoption(mpopt, 'linprog.Algorithm', 'active-set');
%mpopt = mpoption(mpopt, 'linprog.Algorithm', 'simplex');
mpopt = mpoption(mpopt, 'linprog.Algorithm', 'dual-simplex');
%mpopt = mpoption(mpopt, 'intlinprog.RootLPAlgorithm', 'primal-simplex');
mpopt = mpoption(mpopt, 'intlinprog.RootLPAlgorithm', 'dual-simplex');
mpopt = mpoption(mpopt, 'intlinprog.TolCon', 1e-9);
mpopt = mpoption(mpopt, 'intlinprog.TolGapAbs', 0);
mpopt = mpoption(mpopt, 'intlinprog.TolGapRel', 0);
mpopt = mpoption(mpopt, 'intlinprog.TolInteger', 1e-6);
%% next line is to work around a bug in intlinprog
% (Technical Support Case #01841662)
mpopt = mpoption(mpopt, 'intlinprog.LPPreprocess', 'none');
end
casefile = 'ex_case3b';
mpc = loadcase(casefile);
xgd = loadxgendata('ex_xgd_uc', mpc);
[iwind, mpc, xgd] = addwind('ex_wind_uc', mpc, xgd);
profiles = getprofiles('ex_wind_profile', iwind);
profiles = getprofiles('ex_load_profile', profiles);
nt = size(profiles(1).values, 1); % number of periods
%%----- Individual Trajectories -----
transmat_s = cell(1, nt);
I = speye(3);
[transmat_s{:}] = deal(I);
transmat_s{1} = [ 0.158655253931457; 0.682689492137086; 0.158655253931457 ];
mdi = loadmd(mpc, transmat_s, xgd, [], [], profiles);
mdi = filter_ramp_transitions(mdi, 0.1);
mdo = most(mdi, mpopt);
if verbose
ms = most_summary(mdo);
end
%%----- Full Transition Probabilities -----
transmat = ex_transmat(nt);
mdi = loadmd(mpc, transmat, xgd, [], [], profiles);
mdo = most(mdi, mpopt);
if verbose
ms = most_summary(mdo);
end
%%----- Full Transition Probabilities + Contingencies -----
mdi = loadmd(mpc, transmat, xgd, [], 'ex_contab', profiles);
mdo = most(mdi, mpopt);
if verbose
ms = most_summary(mdo);
end
%%----- Plus Storage -----
[iess, mpc, xgd, sd] = addstorage('ex_storage', mpc, xgd);
mdi = loadmd(mpc, transmat, xgd, sd, 'ex_contab', profiles);
mdo = most(mdi, mpopt);
if verbose
ms = most_summary(mdo);
end