


RUNUOPF Runs an optimal power flow with unit-decommitment heuristic.
[RESULTS, SUCCESS] = RUNUOPF(CASEDATA, MPOPT, FNAME, SOLVEDCASE)
Runs an optimal power flow (AC OPF by default) with a heuristic which
allows it to shut down "expensive" generators, optionally returning
a RESULTS struct and SUCCESS flag.
Inputs (all are optional):
CASEDATA : either a MATPOWER case struct or a string containing
the name of the file with the case data (default is 'case9')
(see also CASEFORMAT and LOADCASE)
MPOPT : MATPOWER options struct to override default options
can be used to specify the solution algorithm, output options
termination tolerances, and more (see also MPOPTION).
FNAME : name of a file to which the pretty-printed output will
be appended
SOLVEDCASE : name of file to which the solved case will be saved
in MATPOWER case format (M-file will be assumed unless the
specified name ends with '.mat')
Outputs (all are optional):
RESULTS : results struct, with the following fields:
(all fields from the input MATPOWER case, i.e. bus, branch,
gen, etc., but with solved voltages, power flows, etc.)
order - info used in external <-> internal data conversion
et - elapsed time in seconds
success - success flag, 1 = succeeded, 0 = failed
(additional OPF fields, see OPF for details)
SUCCESS : the success flag can additionally be returned as
a second output argument
Calling syntax options:
results = runuopf;
results = runuopf(casedata);
results = runuopf(casedata, mpopt);
results = runuopf(casedata, mpopt, fname);
results = runuopf(casedata, mpopt, fname, solvedcase);
[results, success] = runuopf(...);
Alternatively, for compatibility with previous versions of MATPOWER,
some of the results can be returned as individual output arguments:
[baseMVA, bus, gen, gencost, branch, f, success, et] = runuopf(...);
Example:
results = runuopf('case30');
See also RUNOPF, RUNDUOPF.

0001 function [MVAbase, bus, gen, gencost, branch, f, success, et] = ... 0002 runuopf(casedata, mpopt, fname, solvedcase) 0003 %RUNUOPF Runs an optimal power flow with unit-decommitment heuristic. 0004 % [RESULTS, SUCCESS] = RUNUOPF(CASEDATA, MPOPT, FNAME, SOLVEDCASE) 0005 % 0006 % Runs an optimal power flow (AC OPF by default) with a heuristic which 0007 % allows it to shut down "expensive" generators, optionally returning 0008 % a RESULTS struct and SUCCESS flag. 0009 % 0010 % Inputs (all are optional): 0011 % CASEDATA : either a MATPOWER case struct or a string containing 0012 % the name of the file with the case data (default is 'case9') 0013 % (see also CASEFORMAT and LOADCASE) 0014 % MPOPT : MATPOWER options struct to override default options 0015 % can be used to specify the solution algorithm, output options 0016 % termination tolerances, and more (see also MPOPTION). 0017 % FNAME : name of a file to which the pretty-printed output will 0018 % be appended 0019 % SOLVEDCASE : name of file to which the solved case will be saved 0020 % in MATPOWER case format (M-file will be assumed unless the 0021 % specified name ends with '.mat') 0022 % 0023 % Outputs (all are optional): 0024 % RESULTS : results struct, with the following fields: 0025 % (all fields from the input MATPOWER case, i.e. bus, branch, 0026 % gen, etc., but with solved voltages, power flows, etc.) 0027 % order - info used in external <-> internal data conversion 0028 % et - elapsed time in seconds 0029 % success - success flag, 1 = succeeded, 0 = failed 0030 % (additional OPF fields, see OPF for details) 0031 % SUCCESS : the success flag can additionally be returned as 0032 % a second output argument 0033 % 0034 % Calling syntax options: 0035 % results = runuopf; 0036 % results = runuopf(casedata); 0037 % results = runuopf(casedata, mpopt); 0038 % results = runuopf(casedata, mpopt, fname); 0039 % results = runuopf(casedata, mpopt, fname, solvedcase); 0040 % [results, success] = runuopf(...); 0041 % 0042 % Alternatively, for compatibility with previous versions of MATPOWER, 0043 % some of the results can be returned as individual output arguments: 0044 % 0045 % [baseMVA, bus, gen, gencost, branch, f, success, et] = runuopf(...); 0046 % 0047 % Example: 0048 % results = runuopf('case30'); 0049 % 0050 % See also RUNOPF, RUNDUOPF. 0051 0052 % MATPOWER 0053 % Copyright (c) 1996-2015 by Power System Engineering Research Center (PSERC) 0054 % by Ray Zimmerman, PSERC Cornell 0055 % 0056 % $Id: runuopf.m 2644 2015-03-11 19:34:22Z ray $ 0057 % 0058 % This file is part of MATPOWER. 0059 % Covered by the 3-clause BSD License (see LICENSE file for details). 0060 % See http://www.pserc.cornell.edu/matpower/ for more info. 0061 0062 %%----- initialize ----- 0063 %% default arguments 0064 if nargin < 4 0065 solvedcase = ''; %% don't save solved case 0066 if nargin < 3 0067 fname = ''; %% don't print results to a file 0068 if nargin < 2 0069 mpopt = mpoption; %% use default options 0070 if nargin < 1 0071 casedata = 'case9'; %% default data file is 'case9.m' 0072 end 0073 end 0074 end 0075 end 0076 0077 %%----- run the unit de-commitment / optimal power flow ----- 0078 [r, success] = uopf(casedata, mpopt); 0079 0080 %%----- output results ----- 0081 if fname 0082 [fd, msg] = fopen(fname, 'at'); 0083 if fd == -1 0084 error(msg); 0085 else 0086 if mpopt.out.all == 0 0087 printpf(r, fd, mpoption(mpopt, 'out.all', -1)); 0088 else 0089 printpf(r, fd, mpopt); 0090 end 0091 fclose(fd); 0092 end 0093 end 0094 printpf(r, 1, mpopt); 0095 0096 %% save solved case 0097 if solvedcase 0098 savecase(solvedcase, r); 0099 end 0100 0101 if nargout == 1 || nargout == 2 0102 MVAbase = r; 0103 bus = success; 0104 elseif nargout > 2 0105 [MVAbase, bus, gen, gencost, branch, f, et] = ... 0106 deal(r.baseMVA, r.bus, r.gen, r.gencost, r.branch, r.f, r.et); 0107 % else %% don't define MVAbase, so it doesn't print anything 0108 end