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. This class is a sub-class of OPT_MODEL and simply adds the 'mpc' field for storing the MATPOWER case struct used to build the object along with the get_mpc() method. 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 .opt_model - the corresponding OPT_MODEL object .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 See also OPT_MODEL.
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 % This class is a sub-class of OPT_MODEL and simply adds the 'mpc' 0012 % field for storing the MATPOWER case struct used to build the object 0013 % along with the get_mpc() method. 0014 % 0015 % The following is the structure of the data in the OPF model object. 0016 % Each field of .idx or .data is a struct whose field names are the names 0017 % of the corresponding blocks of vars, constraints or costs (found in 0018 % order in the corresponding .order field). The description next to these 0019 % fields gives the meaning of the value for each named sub-field. 0020 % E.g. om.var.data.v0.Pg contains a vector of initial values for the 'Pg' 0021 % block of variables. 0022 % 0023 % om 0024 % .opt_model - the corresponding OPT_MODEL object 0025 % .mpc - MATPOWER case struct used to create this model object 0026 % .baseMVA 0027 % .bus 0028 % .branch 0029 % .gen 0030 % .gencost 0031 % .A (if present, must have l, u) 0032 % .l 0033 % .u 0034 % .N (if present, must have fparm, H, Cw) 0035 % .fparm 0036 % .H 0037 % .Cw 0038 % 0039 % See also OPT_MODEL. 0040 0041 % MATPOWER 0042 % Copyright (c) 2008-2016, Power Systems Engineering Research Center (PSERC) 0043 % by Ray Zimmerman, PSERC Cornell 0044 % 0045 % This file is part of MATPOWER. 0046 % Covered by the 3-clause BSD License (see LICENSE file for details). 0047 % See http://www.pserc.cornell.edu/matpower/ for more info. 0048 0049 if nargin == 0 0050 es = struct(); 0051 s = struct('mpc', es); 0052 om = opt_model; 0053 om = class(s, 'opf_model', om); 0054 else 0055 if isa(mpc,'opf_model') 0056 om = mpc; 0057 else 0058 if isfield(mpc, 'om') %% avoid nesting 0059 s = struct('mpc', rmfield(mpc, 'om')); 0060 else 0061 s = struct('mpc', mpc); 0062 end 0063 om = opt_model; 0064 om = class(s, 'opf_model', om); 0065 end 0066 end