Home > matpower4.1 > 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 vector 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 vector 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 %   $Id: runuopf.m,v 1.15 2010/04/26 19:45:25 ray Exp $
0054 %   by Ray Zimmerman, PSERC Cornell
0055 %   Copyright (c) 1996-2010 by Power System Engineering Research Center (PSERC)
0056 %
0057 %   This file is part of MATPOWER.
0058 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0059 %
0060 %   MATPOWER is free software: you can redistribute it and/or modify
0061 %   it under the terms of the GNU General Public License as published
0062 %   by the Free Software Foundation, either version 3 of the License,
0063 %   or (at your option) any later version.
0064 %
0065 %   MATPOWER is distributed in the hope that it will be useful,
0066 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0067 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0068 %   GNU General Public License for more details.
0069 %
0070 %   You should have received a copy of the GNU General Public License
0071 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0072 %
0073 %   Additional permission under GNU GPL version 3 section 7
0074 %
0075 %   If you modify MATPOWER, or any covered work, to interface with
0076 %   other modules (such as MATLAB code and MEX-files) available in a
0077 %   MATLAB(R) or comparable environment containing parts covered
0078 %   under other licensing terms, the licensors of MATPOWER grant
0079 %   you additional permission to convey the resulting work.
0080 
0081 %%-----  initialize  -----
0082 %% default arguments
0083 if nargin < 4
0084     solvedcase = '';                %% don't save solved case
0085     if nargin < 3
0086         fname = '';                 %% don't print results to a file
0087         if nargin < 2
0088             mpopt = mpoption;       %% use default options
0089             if nargin < 1
0090                 casedata = 'case9'; %% default data file is 'case9.m'
0091             end
0092         end
0093     end
0094 end
0095 
0096 %%-----  run the unit de-commitment / optimal power flow  -----
0097 [r, success] = uopf(casedata, mpopt);
0098 
0099 %%-----  output results  -----
0100 if fname
0101     [fd, msg] = fopen(fname, 'at');
0102     if fd == -1
0103         error(msg);
0104     else
0105         printpf(r, fd, mpopt);
0106         fclose(fd);
0107     end
0108 end
0109 printpf(r, 1, mpopt);
0110 
0111 %% save solved case
0112 if solvedcase
0113     savecase(solvedcase, r);
0114 end
0115 
0116 if nargout == 1 || nargout == 2
0117     MVAbase = r;
0118     bus = success;
0119 elseif nargout > 2
0120     [MVAbase, bus, gen, gencost, branch, f, et] = ...
0121         deal(r.baseMVA, r.bus, r.gen, r.gencost, r.branch, r.f, r.et);
0122 % else  %% don't define MVAbase, so it doesn't print anything
0123 end

Generated on Mon 26-Jan-2015 15:00:13 by m2html © 2005