Home > matpower7.0 > lib > runuopf.m

runuopf

PURPOSE ^

RUNUOPF Runs an optimal power flow with unit-decommitment heuristic.

SYNOPSIS ^

function [MVAbase, bus, gen, gencost, branch, f, success, et] =runuopf(casedata, mpopt, fname, solvedcase)

DESCRIPTION ^

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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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-2016, Power Systems Engineering Research Center (PSERC)
0054 %   by Ray Zimmerman, PSERC Cornell
0055 %
0056 %   This file is part of MATPOWER.
0057 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0058 %   See https://matpower.org for more info.
0059 
0060 %%-----  initialize  -----
0061 %% default arguments
0062 if nargin < 4
0063     solvedcase = '';                %% don't save solved case
0064     if nargin < 3
0065         fname = '';                 %% don't print results to a file
0066         if nargin < 2
0067             mpopt = mpoption;       %% use default options
0068             if nargin < 1
0069                 casedata = 'case9'; %% default data file is 'case9.m'
0070             end
0071         end
0072     end
0073 end
0074 
0075 %%-----  run the unit de-commitment / optimal power flow  -----
0076 [r, success] = uopf(casedata, mpopt);
0077 
0078 %%-----  output results  -----
0079 if fname
0080     [fd, msg] = fopen(fname, 'at');
0081     if fd == -1
0082         error(msg);
0083     else
0084         if mpopt.out.all == 0
0085             printpf(r, fd, mpoption(mpopt, 'out.all', -1));
0086         else
0087             printpf(r, fd, mpopt);
0088         end
0089         fclose(fd);
0090     end
0091 end
0092 printpf(r, 1, mpopt);
0093 
0094 %% save solved case
0095 if solvedcase
0096     savecase(solvedcase, r);
0097 end
0098 
0099 if nargout == 1 || nargout == 2
0100     MVAbase = r;
0101     bus = success;
0102 elseif nargout > 2
0103     [MVAbase, bus, gen, gencost, branch, f, et] = ...
0104         deal(r.baseMVA, r.bus, r.gen, r.gencost, r.branch, r.f, r.et);
0105 % else  %% don't define MVAbase, so it doesn't print anything
0106 end

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005