Home | Trees | Indices | Help |
|
---|
|
object --+ | opf_model
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.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
Inherited from |
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
String representation of the object.
|
Adds a set of constraints to the model. Linear constraints are of the form For nonlinear constraints, the 3rd argument, |
Adds a set of user costs to the model. Adds a named block of user-defined costs to the model. Each set is
defined by the Let N - nw x nx sparse matrix Cw - nw x 1 vector H - nw x nw sparse matrix (optional, all zeros by default) dd, mm - nw x 1 vectors (optional, all ones by default) rh, kk - nw x 1 vectors (optional, all zeros by default) These parameters are used as follows to compute R = N*x - rh / kk(i), R(i) < -kk(i) K(i) = < 0, -kk(i) <= R(i) <= kk(i) \ -kk(i), R(i) > kk(i) RR = R + K U(i) = / 0, -kk(i) <= R(i) <= kk(i) \ 1, otherwise DDL(i) = / 1, dd(i) = 1 \ 0, otherwise DDQ(i) = / 1, dd(i) = 2 \ 0, otherwise Dl = diag(mm) * diag(U) * diag(DDL) Dq = diag(mm) * diag(U) * diag(DDQ) w = (Dl + Dq * diag(RR)) * RR f_u(x, CP) = 1/2 * w'*H*w + Cw'*w |
Adds a set of variables to the model. Adds a set of variables to the model, where N is the number of
variables in the set, |
Builds and saves the full generalized cost parameters. Builds the full set of cost parameters from the individual named sub-sets added via add_costs. Skips the building process if it has already been done, unless a second input argument is present. These cost parameters can be retrieved by calling get_cost_params and the user-defined costs evaluated by calling compute_cost. |
Computes a user-defined cost. Computes the value of a user defined cost, either for all user defined costs or for a named set of costs. Requires calling build_cost_params first to build the full set of parameters. Let N - nw x nx sparse matrix Cw - nw x 1 vector H - nw x nw sparse matrix (optional, all zeros by default) dd, mm - nw x 1 vectors (optional, all ones by default) rh, kk - nw x 1 vectors (optional, all zeros by default) These parameters are used as follows to compute R = N*x - rh / kk(i), R(i) < -kk(i) K(i) = < 0, -kk(i) <= R(i) <= kk(i) \ -kk(i), R(i) > kk(i) RR = R + K U(i) = / 0, -kk(i) <= R(i) <= kk(i) \ 1, otherwise DDL(i) = / 1, dd(i) = 1 \ 0, otherwise DDQ(i) = / 1, dd(i) = 2 \ 0, otherwise Dl = diag(mm) * diag(U) * diag(DDL) Dq = diag(mm) * diag(U) * diag(DDQ) w = (Dl + Dq * diag(RR)) * RR F_U(X, CP) = 1/2 * w'*H*w + Cw'*w |
Returns the cost parameter struct for user-defined costs. Requires calling build_cost_params first to build the full set of
parameters. Returns the full cost parameter struct for all user-defined
costs that incorporates all of the named cost sets added via add_costs, or, if a name is provided it returns the cost
dict corresponding to the named set of cost rows ( The cost parameters are returned in a dict with the following fields: N - nw x nx sparse matrix Cw - nw x 1 vector H - nw x nw sparse matrix (optional, all zeros by default) dd, mm - nw x 1 vectors (optional, all ones by default) rh, kk - nw x 1 vectors (optional, all zeros by default) |
Returns the idx struct for vars, lin/nln constraints, costs. Returns a structure for each with the beginning and ending index value and the number of elements for each named block. The 'i1' field (that's a one) is a dict with all of the starting indices, 'iN' contains all the ending indices and 'N' contains all the sizes. Each is a dict whose keys are the named blocks. Examples: [vv, ll, nn] = get_idx(om) For a variable block named 'z' we have: vv['i1']['z'] - starting index for 'z' in optimization vector x vv['iN']['z'] - ending index for 'z' in optimization vector x vv["N"] - number of elements in 'z' To extract a 'z' variable from x: z = x(vv['i1']['z']:vv['iN']['z']) To extract the multipliers on a linear constraint set named 'foo', where mu_l and mu_u are the full set of linear constraint multipliers: mu_l_foo = mu_l(ll['i1']['foo']:ll['iN']['foo']) mu_u_foo = mu_u(ll['i1']['foo']:ll['iN']['foo']) The number of nonlinear constraints in a set named 'bar': nbar = nn["N"].bar (note: the following is preferable : nbar = getN(om, 'nln', 'bar') ... if you haven't already called get_idx to get |
Returns the number of variables, constraints or cost rows. Returns either the total number of variables/constraints/cost rows or the number corresponding to a specified named block. Examples: N = getN(om, 'var') : total number of variables N = getN(om, 'lin') : total number of linear constraints N = getN(om, 'nln') : total number of nonlinear constraints N = getN(om, 'cost') : total number of cost rows (in N) N = getN(om, 'var', name) : number of variables in named set N = getN(om, 'lin', name) : number of linear constraints in named set N = getN(om, 'nln', name) : number of nonlinear cons. in named set N = getN(om, 'cost', name) : number of cost rows (in N) in named set |
Returns initial value, lower bound and upper bound for opt variables. Returns the initial value, lower bound and upper bound for the full optimization variable vector, or for a specific named variable set. Examples: x, xmin, xmax = getv(om) Pg, Pmin, Pmax = getv(om, 'Pg') |
Builds and returns the full set of linear constraints. Builds the full set of linear constraints based on those added by add_constraints: L <= A * x <= U |
Used to save or retrieve values of user data. This function allows the user to save any arbitrary data in the object for later use. This can be useful when using a user function to add variables, constraints, costs, etc. For example, suppose some special indexing is constructed when adding some variables or constraints. This indexing data can be stored and used later to "unpack" the results of the solved case. |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Jul 29 18:21:26 2011 | http://epydoc.sourceforge.net |