-
Notifications
You must be signed in to change notification settings - Fork 148
/
dme_shared_opf.m
141 lines (125 loc) · 4.62 KB
/
dme_shared_opf.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
classdef (Abstract) dme_shared_opf < handle
% mp.dme_shared_opf - Mixin class for OPF **data model element** objects.
%
% For all elements of mp.data_model_opf, adds shared functionality for
% pretty-printing of **lim** sections.
% MATPOWER
% Copyright (c) 2022-2024, Power Systems Engineering Research Center (PSERC)
% by Ray Zimmerman, PSERC Cornell
%
% This file is part of MATPOWER.
% Covered by the 3-clause BSD License (see LICENSE file for details).
% See https://matpower.org for more info.
properties
ctol % constraint violation tolerance
ptol % shadow price tolerance
end %% properties
methods
function obj = pp_set_tols_lim(obj, mpopt)
%
obj.ctol = mpopt.opf.violation;
obj.ptol = 1e-4;
end
function TorF = pp_have_section_other(obj, section, mpopt, pp_args)
%
switch section
case 'lim'
TorF = obj.pp_have_section_lim(mpopt, pp_args);
otherwise
error('mp.dme_shared_opf:pp_have_section_other: unknown section ''%s''', section);
end
end
function rows = pp_rows_other(obj, dm, section, out_e, mpopt, pp_args)
%
switch section
case 'lim'
if isempty(obj.ptol)
obj.pp_set_tols_lim(mpopt);
end
rows = obj.pp_rows_lim(dm, out_e, mpopt, pp_args);
otherwise
error('mp.dme_shared_opf:pp_rows_other: unknown section ''%s''', section);
end
end
function h = pp_get_headers_other(obj, dm, section, out_e, mpopt, pp_args)
%
switch section
case 'lim'
h = obj.pp_get_headers_lim(dm, out_e, mpopt, pp_args);
otherwise
error('mp.dme_shared_opf:pp_get_headers_other: unknown section ''%s''', section);
end
end
function f = pp_get_footers_other(obj, dm, section, out_e, mpopt, pp_args)
%
switch section
case 'lim'
f = obj.pp_get_footers_lim(dm, out_e, mpopt, pp_args);
otherwise
error('mp.dme_shared_opf:pp_get_footers_other: unknown section ''%s''', section);
end
end
function obj = pp_data_other(obj, dm, section, rows, out_e, mpopt, fd, pp_args)
%
switch section
case 'lim'
obj.pp_data_lim(dm, rows, out_e, mpopt, fd, pp_args);
otherwise
error('mp.dme_shared_opf:pp_data_other: unknown section ''%s''', section);
end
end
function TorF = pp_have_section_lim(obj, mpopt, pp_args)
%
TorF = false;
end
function rows = pp_rows_lim(obj, dm, out_e, mpopt, pp_args)
%
if out_e == 2 %% all rows
rows = -1;
elseif out_e == 1 %% binding rows
rows = obj.pp_binding_rows_lim(dm, out_e, mpopt, pp_args);
else %% no rows
rows = 0;
end
end
function rows = pp_binding_rows_lim(obj, dm, out_e, mpopt, pp_args)
%
rows = 0; %% no rows
end
function str = pp_get_title_lim(obj, mpopt, pp_args)
%
str = sprintf('%s Constraints', obj.label);
end
function h = pp_get_headers_lim(obj, dm, out_e, mpopt, pp_args)
%
str = obj.pp_get_title_lim(mpopt, pp_args);
if isempty(str)
h = {};
else
h = dm.pp_section_label(str);
end
end
function f = pp_get_footers_lim(obj, dm, out_e, mpopt, pp_args)
%
f = {};
end
function obj = pp_data_lim(obj, dm, rows, out_e, mpopt, fd, pp_args)
%
if ~isempty(rows) && rows(1) == -1 %% all rows
for k = 1:obj.nr
fprintf(fd, '%s\n', ...
obj.pp_data_row_lim(dm, k, out_e, mpopt, fd, pp_args));
end
else
for k = 1:length(rows)
fprintf(fd, '%s\n', ...
obj.pp_data_row_lim(dm, rows(k), out_e, mpopt, fd, pp_args));
end
end
end
function str = pp_data_row_lim(obj, dm, k, out_e, mpopt, fd, pp_args)
%
str = '';
end
end %% methods
end %% classdef