ScalarParam
(class from pyomo.core.base.param
)
- class pyomo.core.base.param.ScalarParam(*args, **kwds)[source]
-
Methods
__init__
(*args, **kwds)clear
()Clear the data in this component
clear_suffix_value
(suffix_or_name[, expand])Set the suffix value for this component data
cname
(*args, **kwds)DEPRECATED.
construct
([data])Initialize this component.
default
()Return the value of the parameter default.
dim
()Return the dimension of the index
display
([ostream, verbose, prefix])A utility to extract all index-value pairs defined for this parameter, returned as a dictionary.
A utility to extract all index-value pairs defined with non-default values, returned as a dictionary.
get_suffix_value
(suffix_or_name[, default])Get the suffix value for this component data
Return the units for this ParamData
getname
([fully_qualified, name_buffer, ...])Return a string with the component name and index
Return an dictionary id->index for all ComponentData instances.
index
()Returns the index of this ComponentData instance relative to the parent component index set.
Return the index set
Return True if this class is a Pyomo component
Determine if this ScalarParam is constant (and can be eliminated)
Return True if this class has been constructed
is_expression_type
([expression_system])Return True if this numeric value is an expression
is_fixed
()Returns True because this value is fixed.
Return true if this component is indexed
Return True if this class is a Pyomo Boolean object.
Return True if this numeric value is a named expression
Return True if this class is a Pyomo numeric object
Returns True because this is a parameter object.
Return True if variables can appear in this expression
Return True if this component is a reference, where "reference" is interpreted as any component that does not own its own data.
DEPRECATED.
Return False unless this class is a variable object
items
([sort, ordered])Return an iterator of (index,data) component data tuples
DEPRECATED.
iterkeys
()DEPRECATED.
DEPRECATED.
keys
([sort, ordered])Return an iterator over the component data keys
model
()Return the model of the component that owns this data.
Return the parent of the component that owns this data.
Returns the component associated with this object.
Return the polynomial degree of the expression.
pprint
([ostream, verbose, prefix])Print component information
reconstruct
([data])REMOVED: reconstruct() was removed in Pyomo 6.0.
Return self.model()
set_default
(val)Perform error checks and then set the default value for this parameter.
set_suffix_value
(suffix_or_name, value[, expand])Set the suffix value for this component data
set_value
(value[, index])Set the value of this ParamData object, performing unit conversion and validation as necessary.
Return a list (index,data) tuples for defined parameters
Return an iterator of (index,data) tuples for defined parameters
Return an iterator for the keys in the defined parameters
Return an iterator for the defined param data objects
Return a list of keys in the defined parameters
Return a list of the defined param data objects
store_values
(new_values[, check])A utility to update a Param with a dictionary or scalar.
TODO
to_string
([verbose, labeler, smap, ...])Return a string representation of the expression tree.
type
()DEPRECATED.
Return True if this can be used as a model component.
values
([sort, ordered])Return an iterator of the component data objects
Attributes
DefaultMutable
Return the active attribute
Return the class type for this component
Get the component name only within the context of the immediate parent container.
mutable
Get the fully qualified component name.
Return the value for this variable.
Member Documentation
- class NoValue
Bases:
object
A dummy type that is pickle-safe that we can use as the default value for Params to indicate that no valid value is present.
- clear()
Clear the data in this component
- clear_suffix_value(suffix_or_name, expand=True)
Set the suffix value for this component data
- cname(*args, **kwds)
DEPRECATED.
Deprecated since version 5.0: The cname() method has been renamed to getname(). The preferred method of obtaining a component name is to use the .name property, which returns the fully qualified component name. The .local_name property will return the component name only within the context of the immediate parent container.
- construct(data=None)
Initialize this component.
A parameter is constructed using the initial data or the data loaded from an external source. We first set all the values based on self._rule, and then allow the data dictionary to overwrite anything.
Note that we allow an undefined Param value to be constructed. We throw an exception if a user tries to use an uninitialized Param.
- default()
Return the value of the parameter default.
- Possible values:
- Param.NoValue
No default value is provided.
- Numeric
A constant value that is the default value for all undefined parameters.
- Function
f(model, i) returns the value for the default value for parameter i
- dim()
Return the dimension of the index
- extract_values()
A utility to extract all index-value pairs defined for this parameter, returned as a dictionary.
This method is useful in contexts where key iteration and repeated __getitem__ calls are too expensive to extract the contents of a parameter.
- extract_values_sparse()
A utility to extract all index-value pairs defined with non-default values, returned as a dictionary.
This method is useful in contexts where key iteration and repeated __getitem__ calls are too expensive to extract the contents of a parameter.
- get_suffix_value(suffix_or_name, default=None)
Get the suffix value for this component data
- get_units()
Return the units for this ParamData
- getname(fully_qualified=False, name_buffer=None, relative_to=None)
Return a string with the component name and index
- id_index_map()
Return an dictionary id->index for all ComponentData instances.
- index()
Returns the index of this ComponentData instance relative to the parent component index set. None is returned if this instance does not have a parent component, or if - for some unknown reason - this instance does not belong to the parent component’s index set.
- index_set()
Return the index set
- is_component_type()
Return True if this class is a Pyomo component
- is_constant()[source]
Determine if this ScalarParam is constant (and can be eliminated)
Returns False if either unconstructed or mutable, as it must be kept in expressions (as it either doesn’t have a value yet or the value can change later.
- is_constructed()
Return True if this class has been constructed
- is_expression_type(expression_system=None)
Return True if this numeric value is an expression
- is_fixed()
Returns True because this value is fixed.
- is_indexed()
Return true if this component is indexed
- is_logical_type()
Return True if this class is a Pyomo Boolean object.
Boolean objects include constants, variables, or logical expressions.
- is_named_expression_type()
Return True if this numeric value is a named expression
- is_numeric_type()
Return True if this class is a Pyomo numeric object
- is_parameter_type()
Returns True because this is a parameter object.
- is_potentially_variable()
Return True if variables can appear in this expression
- is_reference()
Return True if this component is a reference, where “reference” is interpreted as any component that does not own its own data.
- is_relational()
DEPRECATED.
Return True if this numeric value represents a relational expression.
Deprecated since version 6.4.3: is_relational() is deprecated in favor of is_expression_type(ExpressionType.RELATIONAL)
- is_variable_type()
Return False unless this class is a variable object
- items(sort=<SortComponents.UNSORTED: 0>, ordered=NOTSET)
Return an iterator of (index,data) component data tuples
- Parameters:
sort (bool or SortComponents) – Iterate over the declared component items in a specified sorted order. See
SortComponents
for valid options and descriptions.ordered (bool) – DEPRECATED: Please use sort=SortComponents.ORDERED_INDICES. If True, then the items are returned in a deterministic order (using the underlying set’s ordered_iter().
- iteritems()
DEPRECATED.
Return a list (index,data) tuples from the dictionary
Deprecated since version 6.0: The iteritems method is deprecated. Use dict.items().
- iterkeys()
DEPRECATED.
Return a list of keys in the dictionary
Deprecated since version 6.0: The iterkeys method is deprecated. Use dict.keys().
- itervalues()
DEPRECATED.
Return a list of the component data objects in the dictionary
Deprecated since version 6.0: The itervalues method is deprecated. Use dict.values().
- keys(sort=<SortComponents.UNSORTED: 0>, ordered=NOTSET)
Return an iterator over the component data keys
This method sets the ordering of component data objects within this IndexedComponent container. For consistency,
__init__()
,values()
, anditems()
all leverage this method to ensure consistent ordering.- Parameters:
sort (bool or SortComponents) – Iterate over the declared component keys in a specified sorted order. See
SortComponents
for valid options and descriptions.ordered (bool) – DEPRECATED: Please use sort=SortComponents.ORDERED_INDICES. If True, then the keys are returned in a deterministic order (using the underlying set’s ordered_iter()).
- model()
Return the model of the component that owns this data.
- parent_block()
Return the parent of the component that owns this data.
- parent_component()
Returns the component associated with this object.
- polynomial_degree()
Return the polynomial degree of the expression.
- Returns:
None
- pprint(ostream=None, verbose=False, prefix='')
Print component information
- reconstruct(data=None)
REMOVED: reconstruct() was removed in Pyomo 6.0.
Re-constructing model components was fragile and did not correctly update instances of the component used in other components or contexts (this was particularly problemmatic for Var, Param, and Set). Users who wish to reproduce the old behavior of reconstruct(), are comfortable manipulating non-public interfaces, and who take the time to verify that the correct thing happens to their model can approximate the old behavior of reconstruct with:
component.clear() component._constructed = False component.construct()
- root_block()
Return self.model()
- set_default(val)
Perform error checks and then set the default value for this parameter.
NOTE: this test will not validate the value of function return values.
- set_suffix_value(suffix_or_name, value, expand=True)
Set the suffix value for this component data
- set_value(value, index=NOTSET)[source]
Set the value of this ParamData object, performing unit conversion and validation as necessary.
- sparse_items()
Return a list (index,data) tuples for defined parameters
- sparse_iteritems()
Return an iterator of (index,data) tuples for defined parameters
- sparse_iterkeys()
Return an iterator for the keys in the defined parameters
- sparse_itervalues()
Return an iterator for the defined param data objects
- sparse_keys()
Return a list of keys in the defined parameters
- sparse_values()
Return a list of the defined param data objects
- store_values(new_values, check=True)
A utility to update a Param with a dictionary or scalar.
If check=True, then both the index and value are checked through the __getitem__ method. Using check=False should only be used by developers!
- to_dense_data()
TODO
- to_string(verbose=None, labeler=None, smap=None, compute_values=False)
Return a string representation of the expression tree.
- Parameters:
verbose (bool) – If
True
, then the string representation consists of nested functions. Otherwise, the string representation is an infix algebraic equation. Defaults toFalse
.labeler – An object that generates string labels for non-constant in the expression tree. Defaults to
None
.smap – A SymbolMap instance that stores string labels for non-constant nodes in the expression tree. Defaults to
None
.compute_values (bool) – If
True
, then fixed expressions are evaluated and the string representation of the resulting value is returned.
- Returns:
A string representation for the expression tree.
- type()
DEPRECATED.
Return the class type for this component
Deprecated since version 5.7: Component.type() method has been replaced by the .ctype property.
- valid_model_component()
Return True if this can be used as a model component.
- values(sort=<SortComponents.UNSORTED: 0>, ordered=NOTSET)
Return an iterator of the component data objects
- Parameters:
sort (bool or SortComponents) – Iterate over the declared component values in a specified sorted order. See
SortComponents
for valid options and descriptions.ordered (bool) – DEPRECATED: Please use sort=SortComponents.ORDERED_INDICES. If True, then the values are returned in a deterministic order (using the underlying set’s ordered_iter().
- property active
Return the active attribute
- property ctype
Return the class type for this component
- property local_name
Get the component name only within the context of the immediate parent container.
- property name
Get the fully qualified component name.
- property value
Return the value for this variable.