PiecewiseLinearFunctionData
(class from pyomo.contrib.piecewise.piecewise_linear_function
)
- class pyomo.contrib.piecewise.piecewise_linear_function.PiecewiseLinearFunctionData(component=None)[source]
Bases:
BlockData
Methods
__init__
([component])activate
()Set the active attribute to True
active_blocks
(*args, **kwargs)DEPRECATED.
active_component_data
(*args, **kwargs)DEPRECATED.
active_components
(*args, **kwargs)DEPRECATED.
add_component
(name, val)Add a component 'name' to the block.
all_blocks
(*args, **kwargs)DEPRECATED.
all_component_data
(*args, **kwargs)DEPRECATED.
all_components
(*args, **kwargs)DEPRECATED.
block_data_objects
([active, sort, ...])Returns this block and any matching sub-blocks.
clear
()clear_suffix_value
(suffix_or_name[, expand])Set the suffix value for this component data
clone
([memo])TODO
cname
(*args, **kwds)DEPRECATED.
collect_ctypes
([active, descend_into])Count all component types stored on or under this block.
component
(name_or_object)Return a child component of this block.
component_data_iterindex
([ctype, active, ...])DEPRECATED.
component_data_objects
([ctype, active, ...])Return a generator that iterates through the component data objects for all components in a block.
component_map
([ctype, active, sort])Returns a PseudoMap of the components in this block.
component_objects
([ctype, active, sort, ...])Return a generator that iterates through the component objects in a block.
contains_component
(ctype)Return True if the component type is in _ctypes and .
Set the active attribute to False
del_component
(name_or_object)Delete a component from this block.
display
([filename, ostream, prefix])Print the Pyomo model in a verbose format.
find_component
(label_or_component)Returns a component in the block given a name.
fix_all_vars
()get_suffix_value
(suffix_or_name[, default])Get the suffix value for this component data
get_transformation_var
(pw_expr)Returns the Var that replaced the PiecewiseLinearExpression 'pw_expr' after transformation, or None if 'pw_expr' has not been transformed.
getname
([fully_qualified, name_buffer, ...])Return a string with the component name and index
index
()Returns the index of this ComponentData instance relative to the parent component index set.
Return True if this class is a Pyomo component
A boolean indicating whether or not all active components of the input model have been properly constructed.
is_expression_type
([expression_system])Return True if this numeric value is an expression
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
Return False unless this class is a parameter object
Return True if this object is a reference.
Return False unless this class is a variable object
map_transformation_var
(pw_expr, v)Records on the PiecewiseLinearFunction object that the transformed form of the PiecewiseLinearExpression object pw_expr is the Var v.
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.
pprint
([ostream, verbose, prefix])Print component information
private_data
([scope])reclassify_component_type
(name_or_object, ...)TODO
set_suffix_value
(suffix_or_name, value[, expand])Set the suffix value for this component data
set_value
(val)Transfer user-defined attributes from src to this block
type
()DEPRECATED.
unfix_all_vars
()This method allows the pyomo.opt convert function to work with a Model object.
write
([filename, format, solver_capability, ...])Write the model to a file, with a given format.
Attributes
Return the active attribute
Return the class type for this component
Get the component name only within the context of the immediate parent container.
Get the fully qualified component name.
triangulation
Member Documentation
- activate()
Set the active attribute to True
- active_blocks(*args, **kwargs)
DEPRECATED.
Deprecated since version 4.1.10486: The active_blocks method is deprecated. Use the Block.block_data_objects() method.
- active_component_data(*args, **kwargs)
DEPRECATED.
Deprecated since version 4.1.10486: The active_component_data method is deprecated. Use the Block.component_data_objects() method.
- active_components(*args, **kwargs)
DEPRECATED.
Deprecated since version 4.1.10486: The active_components method is deprecated. Use the Block.component_objects() method.
- add_component(name, val)
Add a component ‘name’ to the block.
This method assumes that the attribute is not in the model.
- all_blocks(*args, **kwargs)
DEPRECATED.
Deprecated since version 4.1.10486: The all_blocks method is deprecated. Use the Block.block_data_objects() method.
- all_component_data(*args, **kwargs)
DEPRECATED.
Deprecated since version 4.1.10486: The all_component_data method is deprecated. Use the Block.component_data_objects() method.
- all_components(*args, **kwargs)
DEPRECATED.
Deprecated since version 4.1.10486: The all_components method is deprecated. Use the Block.component_objects() method.
- block_data_objects(active=None, sort=False, descend_into=True, descent_order=None)
Returns this block and any matching sub-blocks.
This is roughly equivalent to
iter(block for block in itertools.chain( [self], self.component_data_objects(descend_into, ...)) if block.active == active)
Notes
The self block is always returned, regardless of the types indicated by descend_into.
The active flag is enforced on all blocks, including self.
- Parameters:
active (None or bool) – If not None, filter components by the active flag
sort (None or bool or SortComponents) – Iterate over the components in a specified sorted order
descend_into (None or type or iterable) – Specifies the component types (ctypes) to return and to descend into. If True or None, defaults to (Block,). If False, only self is returned.
descent_order (None or TraversalStrategy) – The strategy used to walk the block hierarchy. Defaults to TraversalStrategy.PrefixDepthFirstSearch.
- Return type:
tuple or generator
- clear_suffix_value(suffix_or_name, expand=True)
Set the suffix value for this component data
- clone(memo=None)
TODO
- 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.
- collect_ctypes(active=None, descend_into=True)
Count all component types stored on or under this block.
- Parameters:
active (True/None) – Set to True to indicate that only active components should be counted. The default value of None indicates that all components (including those that have been deactivated) should be counted.
descend_into (bool) – Indicates whether or not component types should be counted on sub-blocks. Default is True.
Returns: A set of component types.
- component(name_or_object)
Return a child component of this block.
If passed a string, this will return the child component registered by that name. If passed a component, this will return that component IFF the component is a child of this block. Returns None on lookup failure.
- component_data_iterindex(ctype=None, active=None, sort=False, descend_into=True, descent_order=None)
DEPRECATED.
Return a generator that returns a tuple for each component data object in a block. By default, this generator recursively descends into sub-blocks. The tuple is
((component name, index value), ComponentData)
Deprecated since version 6.6.0: The component_data_iterindex method is deprecated. Components now know their index, so it is more efficient to use the Block.component_data_objects() method followed by .index().
- component_data_objects(ctype=None, active=None, sort=False, descend_into=True, descent_order=None)
Return a generator that iterates through the component data objects for all components in a block. By default, this generator recursively descends into sub-blocks.
- component_map(ctype=None, active=None, sort=False)
Returns a PseudoMap of the components in this block.
- Parameters:
ctype (None or type or iterable) –
Specifies the component types (ctypes) to include in the resulting PseudoMap
None
All components
type
A single component type
iterable
All component types in the iterable
active (None or bool) –
Filter components by the active flag
None
Return all components
True
Return only active components
False
Return only inactive components
sort (bool) –
Iterate over the components in a sorted order
True
Iterate using Block.alphabetizeComponentAndIndex
False
Iterate using Block.declarationOrder
- component_objects(ctype=None, active=None, sort=False, descend_into=True, descent_order=None)
Return a generator that iterates through the component objects in a block. By default, the generator recursively descends into sub-blocks.
- contains_component(ctype)
Return True if the component type is in _ctypes and … TODO.
- deactivate()
Set the active attribute to False
- del_component(name_or_object)
Delete a component from this block.
- display(filename=None, ostream=None, prefix='')
Print the Pyomo model in a verbose format.
- find_component(label_or_component)
Returns a component in the block given a name.
- Parameters:
label_or_component (str, Component, or ComponentUID) – The name of the component to find in this block. String or Component arguments are first converted to ComponentUID.
- Returns:
Component on the block identified by the ComponentUID. If a matching component is not found, None is returned.
- Return type:
- get_suffix_value(suffix_or_name, default=None)
Get the suffix value for this component data
- get_transformation_var(pw_expr)[source]
Returns the Var that replaced the PiecewiseLinearExpression ‘pw_expr’ after transformation, or None if ‘pw_expr’ has not been transformed.
- getname(fully_qualified=False, name_buffer=None, relative_to=None)
Return a string with the component name and index
- 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.
- is_component_type()
Return True if this class is a Pyomo component
- is_constructed()
A boolean indicating whether or not all active components of the input model have been properly constructed.
- is_expression_type(expression_system=None)
Return True if this numeric value is an expression
- 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()
Return False unless this class is a parameter object
- is_reference()
Return True if this object is a reference.
- is_variable_type()
Return False unless this class is a variable object
- map_transformation_var(pw_expr, v)[source]
Records on the PiecewiseLinearFunction object that the transformed form of the PiecewiseLinearExpression object pw_expr is the Var v.
- 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.
- pprint(ostream=None, verbose=False, prefix='')
Print component information
Note that this method is generally only reachable through ComponentData objects in an IndexedComponent container. Components, including unindexed Component derivatives and both scalar and indexed IndexedComponent derivatives will see
Component.pprint()
- reclassify_component_type(name_or_object, new_ctype, preserve_declaration_order=True)
TODO
- set_suffix_value(suffix_or_name, value, expand=True)
Set the suffix value for this component data
- transfer_attributes_from(src)
Transfer user-defined attributes from src to this block
This transfers all components and user-defined attributes from the block or dictionary src and places them on this Block. Components are transferred in declaration order.
If a Component on src is also declared on this block as either a Component or attribute, the local Component or attribute is replaced by the incoming component. If an attribute name on src matches a Component declared on this block, then the incoming attribute is passed to the local Component’s set_value() method. Attribute names appearing in this block’s _Block_reserved_words set will not be transferred (although Components will be).
- 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_problem_types()
This method allows the pyomo.opt convert function to work with a Model object.
- write(filename=None, format=None, solver_capability=None, io_options={}, int_marker=False)
Write the model to a file, with a given format.
- 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.