Home > matpower4.1 > @opf_model > opf_model.m

opf_model

PURPOSE ^

OPF_MODEL Constructor for OPF model class.

SYNOPSIS ^

function om = opf_model(mpc)

DESCRIPTION ^

OPF_MODEL  Constructor for OPF model class.
   OM = OPF_MODEL(MPC)

   This class implements the OPF model object used to encapsulate
   a given OPF problem formulation. It allows for access to optimization
   variables, constraints and costs in named blocks, keeping track of the
   ordering and indexing of the blocks as variables, constraints and costs
   are added to the problem.

   Below are the list of available methods for use with the OPF Model class.
   Please see the help on each individual method for more details:

   Retrieve the MATPOWER case struct used to build the object:
       get_mpc

   Modify the OPF formulation by adding named blocks of constraints, costs
   or variables:
       add_constraints
       add_costs
       add_vars

   Return the number of linear constraints, nonlinear constraints,
   variables or cost rows, optionally for a single named block:
       getN

   Return the intial values and bounds for optimization variables:
       get_v

   Build and return full set of linear constraints:
       linear_constraints

   Return index structure for variables, linear and nonlinear constraints
   and costs:
       get_idx

   Build and return cost parameters and evaluate user-defined costs:
       build_cost_params
       get_cost_params
       compute_cost

   Save/retreive user data in the model object:
       userdata

   Display the object (called automatically when you omit the semicolon
   at the command-line):
       display

   Return the value of an individual field:
       get

   The following is the structure of the data in the OPF model object.
   Each field of .idx or .data is a struct whose field names are the names
   of the corresponding blocks of vars, constraints or costs (found in
   order in the corresponding .order field). The description next to these
   fields gives the meaning of the value for each named sub-field.
   E.g. om.var.data.v0.Pg contains a vector of initial values for the 'Pg'
   block of variables.

   om
       .var        - data for optimization variable sets that make up
                     the full optimization variable x
           .idx
               .i1 - starting index within x
               .iN - ending index within x
               .N  - number of elements in this variable set
           .N      - total number of elements in x
           .NS     - number of variable sets or named blocks
           .data   - bounds and initial value data
               .v0 - vector of initial values
               .vl - vector of lower bounds
               .vu - vector of upper bounds
           .order  - cell array of names for variable blocks in the order
                     they appear in x
       .nln        - data for nonlinear constraints that make up the
                     full set of nonlinear constraints ghn(x)
           .idx
               .i1 - starting index within ghn(x)
               .iN - ending index within ghn(x)
               .N  - number of elements in this constraint set
           .N      - total number of elements in ghn(x)
           .NS     - number of nonlinear constraint sets or named blocks
           .order  - cell array of names for nonlinear constraint blocks
                     in the order they appear in ghn(x)
       .lin        - data for linear constraints that make up the
                     full set of linear constraints ghl(x)
           .idx
               .i1 - starting index within ghl(x)
               .iN - ending index within ghl(x)
               .N  - number of elements in this constraint set
           .N      - total number of elements in ghl(x)
           .NS     - number of linear constraint sets or named blocks
           .data   - data for l <= A*xx <= u linear constraints
               .A  - sparse linear constraint matrix
               .l  - left hand side vector, bounding A*x below
               .u  - right hand side vector, bounding A*x above
               .vs - cell array of variable sets that define the xx for
                     this constraint block
           .order  - cell array of names for linear constraint blocks
                     in the order they appear in ghl(x)
       .cost       - data for user-defined costs
           .idx
               .i1 - starting row index within full N matrix
               .iN - ending row index within full N matrix
               .N  - number of rows in this cost block in full N matrix
           .N      - total number of rows in full N matrix
           .NS     - number of cost blocks
           .data   - data for each user-defined cost block
               .N  - see help for ADD_COSTS for details
               .H  -               "
               .Cw -               "
               .dd -               "
               .rr -               "
               .kk -               "
               .mm -               "
               .vs - cell array of variable sets that define xx for this
                     cost block, where the N for this block multiplies xx
           .order  - cell array of names for cost blocks in the order they
                     appear in the rows of the full N matrix
       .mpc        - MATPOWER case struct used to create this model object
           .baseMVA
           .bus
           .branch
           .gen
           .gencost
           .A  (if present, must have l, u)
           .l
           .u
           .N  (if present, must have fparm, H, Cw)
           .fparm
           .H
           .Cw
       .userdata   - any user defined data added via USERDATA
           .(user defined fields)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function om = opf_model(mpc)
0002 %OPF_MODEL  Constructor for OPF model class.
0003 %   OM = OPF_MODEL(MPC)
0004 %
0005 %   This class implements the OPF model object used to encapsulate
0006 %   a given OPF problem formulation. It allows for access to optimization
0007 %   variables, constraints and costs in named blocks, keeping track of the
0008 %   ordering and indexing of the blocks as variables, constraints and costs
0009 %   are added to the problem.
0010 %
0011 %   Below are the list of available methods for use with the OPF Model class.
0012 %   Please see the help on each individual method for more details:
0013 %
0014 %   Retrieve the MATPOWER case struct used to build the object:
0015 %       get_mpc
0016 %
0017 %   Modify the OPF formulation by adding named blocks of constraints, costs
0018 %   or variables:
0019 %       add_constraints
0020 %       add_costs
0021 %       add_vars
0022 %
0023 %   Return the number of linear constraints, nonlinear constraints,
0024 %   variables or cost rows, optionally for a single named block:
0025 %       getN
0026 %
0027 %   Return the intial values and bounds for optimization variables:
0028 %       get_v
0029 %
0030 %   Build and return full set of linear constraints:
0031 %       linear_constraints
0032 %
0033 %   Return index structure for variables, linear and nonlinear constraints
0034 %   and costs:
0035 %       get_idx
0036 %
0037 %   Build and return cost parameters and evaluate user-defined costs:
0038 %       build_cost_params
0039 %       get_cost_params
0040 %       compute_cost
0041 %
0042 %   Save/retreive user data in the model object:
0043 %       userdata
0044 %
0045 %   Display the object (called automatically when you omit the semicolon
0046 %   at the command-line):
0047 %       display
0048 %
0049 %   Return the value of an individual field:
0050 %       get
0051 %
0052 %   The following is the structure of the data in the OPF model object.
0053 %   Each field of .idx or .data is a struct whose field names are the names
0054 %   of the corresponding blocks of vars, constraints or costs (found in
0055 %   order in the corresponding .order field). The description next to these
0056 %   fields gives the meaning of the value for each named sub-field.
0057 %   E.g. om.var.data.v0.Pg contains a vector of initial values for the 'Pg'
0058 %   block of variables.
0059 %
0060 %   om
0061 %       .var        - data for optimization variable sets that make up
0062 %                     the full optimization variable x
0063 %           .idx
0064 %               .i1 - starting index within x
0065 %               .iN - ending index within x
0066 %               .N  - number of elements in this variable set
0067 %           .N      - total number of elements in x
0068 %           .NS     - number of variable sets or named blocks
0069 %           .data   - bounds and initial value data
0070 %               .v0 - vector of initial values
0071 %               .vl - vector of lower bounds
0072 %               .vu - vector of upper bounds
0073 %           .order  - cell array of names for variable blocks in the order
0074 %                     they appear in x
0075 %       .nln        - data for nonlinear constraints that make up the
0076 %                     full set of nonlinear constraints ghn(x)
0077 %           .idx
0078 %               .i1 - starting index within ghn(x)
0079 %               .iN - ending index within ghn(x)
0080 %               .N  - number of elements in this constraint set
0081 %           .N      - total number of elements in ghn(x)
0082 %           .NS     - number of nonlinear constraint sets or named blocks
0083 %           .order  - cell array of names for nonlinear constraint blocks
0084 %                     in the order they appear in ghn(x)
0085 %       .lin        - data for linear constraints that make up the
0086 %                     full set of linear constraints ghl(x)
0087 %           .idx
0088 %               .i1 - starting index within ghl(x)
0089 %               .iN - ending index within ghl(x)
0090 %               .N  - number of elements in this constraint set
0091 %           .N      - total number of elements in ghl(x)
0092 %           .NS     - number of linear constraint sets or named blocks
0093 %           .data   - data for l <= A*xx <= u linear constraints
0094 %               .A  - sparse linear constraint matrix
0095 %               .l  - left hand side vector, bounding A*x below
0096 %               .u  - right hand side vector, bounding A*x above
0097 %               .vs - cell array of variable sets that define the xx for
0098 %                     this constraint block
0099 %           .order  - cell array of names for linear constraint blocks
0100 %                     in the order they appear in ghl(x)
0101 %       .cost       - data for user-defined costs
0102 %           .idx
0103 %               .i1 - starting row index within full N matrix
0104 %               .iN - ending row index within full N matrix
0105 %               .N  - number of rows in this cost block in full N matrix
0106 %           .N      - total number of rows in full N matrix
0107 %           .NS     - number of cost blocks
0108 %           .data   - data for each user-defined cost block
0109 %               .N  - see help for ADD_COSTS for details
0110 %               .H  -               "
0111 %               .Cw -               "
0112 %               .dd -               "
0113 %               .rr -               "
0114 %               .kk -               "
0115 %               .mm -               "
0116 %               .vs - cell array of variable sets that define xx for this
0117 %                     cost block, where the N for this block multiplies xx
0118 %           .order  - cell array of names for cost blocks in the order they
0119 %                     appear in the rows of the full N matrix
0120 %       .mpc        - MATPOWER case struct used to create this model object
0121 %           .baseMVA
0122 %           .bus
0123 %           .branch
0124 %           .gen
0125 %           .gencost
0126 %           .A  (if present, must have l, u)
0127 %           .l
0128 %           .u
0129 %           .N  (if present, must have fparm, H, Cw)
0130 %           .fparm
0131 %           .H
0132 %           .Cw
0133 %       .userdata   - any user defined data added via USERDATA
0134 %           .(user defined fields)
0135 
0136 %   MATPOWER
0137 %   $Id: opf_model.m,v 1.15 2010/06/09 14:56:58 ray Exp $
0138 %   by Ray Zimmerman, PSERC Cornell
0139 %   Copyright (c) 2008-2010 by Power System Engineering Research Center (PSERC)
0140 %
0141 %   This file is part of MATPOWER.
0142 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0143 %
0144 %   MATPOWER is free software: you can redistribute it and/or modify
0145 %   it under the terms of the GNU General Public License as published
0146 %   by the Free Software Foundation, either version 3 of the License,
0147 %   or (at your option) any later version.
0148 %
0149 %   MATPOWER is distributed in the hope that it will be useful,
0150 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0151 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0152 %   GNU General Public License for more details.
0153 %
0154 %   You should have received a copy of the GNU General Public License
0155 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0156 %
0157 %   Additional permission under GNU GPL version 3 section 7
0158 %
0159 %   If you modify MATPOWER, or any covered work, to interface with
0160 %   other modules (such as MATLAB code and MEX-files) available in a
0161 %   MATLAB(R) or comparable environment containing parts covered
0162 %   under other licensing terms, the licensors of MATPOWER grant
0163 %   you additional permission to convey the resulting work.
0164 
0165 % es = struct();    %% doesn't work in MATLAB 6
0166 es = struct('tmp', 0);
0167 es = rmfield(es, 'tmp');
0168 if nargin == 0
0169     om.var.idx.i1 = es;
0170     om.var.idx.iN = es;
0171     om.var.idx.N = es;
0172     om.var.N = 0;
0173     om.var.NS = 0;
0174     om.var.order = {};
0175     om.var.data.v0 = es;
0176     om.var.data.vl = es;
0177     om.var.data.vu = es;
0178 
0179     om.nln.idx.i1 = es;
0180     om.nln.idx.iN = es;
0181     om.nln.idx.N = es;
0182     om.nln.N = 0;
0183     om.nln.NS = 0;
0184     om.nln.order = {};
0185 
0186     om.lin.idx.i1 = es;
0187     om.lin.idx.iN = es;
0188     om.lin.idx.N = es;
0189     om.lin.N = 0;
0190     om.lin.NS = 0;
0191     om.lin.order = {};
0192     om.lin.data.A = es;
0193     om.lin.data.l = es;
0194     om.lin.data.u = es;
0195     om.lin.data.vs = es;
0196     
0197     om.cost.idx.i1 = es;
0198     om.cost.idx.iN = es;
0199     om.cost.idx.N = es;
0200     om.cost.N = 0;
0201     om.cost.NS = 0;
0202     om.cost.order = {};
0203     om.cost.data.N = es;
0204     om.cost.data.H = es;
0205     om.cost.data.Cw = es;
0206     om.cost.data.dd = es;
0207     om.cost.data.rh = es;
0208     om.cost.data.kk = es;
0209     om.cost.data.mm = es;
0210     om.cost.data.vs = es;
0211     om.cost.params = es;
0212     
0213     om.mpc = es;
0214     om.userdata = es;
0215 
0216     om = class(om, 'opf_model');
0217 elseif isa(mpc,'opf_model') 
0218     om = mpc;
0219 else 
0220     om = opf_model;
0221     om.mpc = mpc;
0222 end

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