ams.core.param.RParam#

class ams.core.param.RParam(name: str | None = None, tex_name: str | None = None, info: str | None = None, src: str | None = None, unit: str | None = None, model: str | None = None, v: ndarray | None = None, indexer: str | None = None, imodel: str | None = None, horizon: RParam | None = None, hindexer: str | None = None, expand_dims: int | None = None, no_parse: bool | None = False, nonneg: bool | None = False, nonpos: bool | None = False, cplx: bool | None = False, imag: bool | None = False, symmetric: bool | None = False, diag: bool | None = False, hermitian: bool | None = False, boolean: bool | None = False, integer: bool | None = False, pos: bool | None = False, neg: bool | None = False, sparse: list | None = None)[source]#

Class for parameters used in a routine. This class is developed to simplify the routine definition.

RParm is further used to define Parameter in the optimization model.

no_parse is used to skip parsing the RParam in optimization model. It means that the RParam will not be added to the optimization model. This is useful when the RParam contains non-numeric values, or it is not necessary to be added to the optimization model.

Parameters:
namestr, optional

Name of this parameter. If not provided, name will be set to the attribute name.

tex_namestr, optional

LaTeX-formatted parameter name. If not provided, tex_name will be assigned the same as name.

infostr, optional

A description of this parameter

srcstr, optional

Source name of the parameter.

unitstr, optional

Unit of the parameter.

modelstr, optional

Name of the owner model or group.

vnp.ndarray, optional

External value of the parameter.

indexerstr, optional

Primary-axis indexer of the parameter — name of an IdxParam on the row-owner model whose values get matched against imodel.get_all_idxes() to sort / position rows.

imodelstr, optional

Name of the owner model or group of the (primary) indexer.

horizonams.core.param.RParam, optional

Secondary-axis indexer. Mirrors the ams.opt.var.Var.horizon convention used for output Vars: when set together with indexer / imodel, the param's v returns a 2D matrix shaped (imodel.n, horizon.n) built by pivoting the long-format rows on hindexer (secondary) and indexer (primary). Cells with no matching row fall back to the source NumParam.default.

hindexerstr, optional

Name of the IdxParam on the row-owner model that carries the secondary key, matched against horizon.v. Required when horizon is set; ignored otherwise.

no_parse: bool, optional

True to skip parsing the parameter.

nonneg: bool, optional

True to set the parameter as non-negative.

nonpos: bool, optional

True to set the parameter as non-positive.

cplx: bool, optional

True to set the parameter as complex.

imag: bool, optional

True to set the parameter as imaginary.

symmetric: bool, optional

True to set the parameter as symmetric.

diag: bool, optional

True to set the parameter as diagonal.

hermitian: bool, optional

True to set the parameter as hermitian.

boolean: bool, optional

True to set the parameter as boolean.

integer: bool, optional

True to set the parameter as integer.

pos: bool, optional

True to set the parameter as positive.

neg: bool, optional

True to set the parameter as negative.

sparse: bool, optional

True to set the parameter as sparse.

Examples

Example 1: Define a routine parameter from a source model or group.

In this example, we define the parameter cru from the source model SFRCost with the parameter cru. Note since this parameter comes from model SFRCost, but it is used to multiply on generator output powers, we need to ensure the value is sorted in the same order as generators. gen is the indexer that comes from model SFR itself, and imodel is the indexer model, i.e., the model that has idx as its attribute. Then, we can ensure the value of cru is sorted in the same order as the indexer StaticGen.

>>> self.cru = RParam(info='RegUp reserve coefficient',
>>>                   tex_name=r'c_{r,u}',
>>>                   unit=r'$/(p.u.)',
>>>                   name='cru',
>>>                   src='cru',
>>>                   model='SFRCost',
>>>                   indexer='gen',
>>>                   imodel='StaticGen',
>>>                   )

Example 2: Define a routine parameter with a user-defined value.

In this example, we define the parameter with a user-defined value. TODO: Add example

__init__(name: str | None = None, tex_name: str | None = None, info: str | None = None, src: str | None = None, unit: str | None = None, model: str | None = None, v: ndarray | None = None, indexer: str | None = None, imodel: str | None = None, horizon: RParam | None = None, hindexer: str | None = None, expand_dims: int | None = None, no_parse: bool | None = False, nonneg: bool | None = False, nonpos: bool | None = False, cplx: bool | None = False, imag: bool | None = False, symmetric: bool | None = False, diag: bool | None = False, hermitian: bool | None = False, boolean: bool | None = False, integer: bool | None = False, pos: bool | None = False, neg: bool | None = False, sparse: list | None = None)[source]#

Methods

evaluate(*args, **kwargs)

get_all_idxes()

Get all the indexes of the parameter.

get_idx()

Get the index of the parameter.

parse(*args, **kwargs)

update()

Update the Parameter value.

Attributes

class_name

Return the class name

dtype

Return the data type of the parameter value.

e

Return the calculated numerical value of the underlying expression.

formulation_source

Where the live CVXPY object for this item came from.

n

Return the szie of the parameter.

shape

Return the shape of the parameter.

size

Return the size.

v

The value of the parameter.