DerivativeVar

(class from pyomo.dae.diffvar)

class pyomo.dae.diffvar.DerivativeVar(*args, **kwargs)[source]

Bases: Var

Represents derivatives in a model and defines how a Var is differentiated

The DerivativeVar component is used to declare a derivative of a Var. The constructor accepts a single positional argument which is the Var that’s being differentiated. A Var may only be differentiated with respect to a ContinuousSet that it is indexed by. The indexing sets of a DerivativeVar are identical to those of the Var it is differentiating.

Parameters:
  • sVar (pyomo.environ.Var) – The variable being differentiated

  • wrt (pyomo.dae.ContinuousSet or tuple) – Equivalent to withrespectto keyword argument. The ContinuousSet that the derivative is being taken with respect to. Higher order derivatives are represented by including the ContinuousSet multiple times in the tuple sent to this keyword. i.e. wrt=(m.t, m.t) would be the second order derivative with respect to m.t

__init__(sVar, **kwds)[source]

Methods

__init__(sVar, **kwds)

add(index)

Add a variable with a particular index.

clear()

Clear the data in this component

clear_suffix_value(suffix_or_name[, expand])

Clear the suffix value for this component data

cname(*args, **kwds)

DEPRECATED.

construct([data])

Construct the VarData objects for this variable

dim()

Return the dimension of the index

display([ostream, verbose, prefix])

extract_values([include_fixed_values])

Return a dictionary of index-value pairs.

flag_as_stale()

Set the 'stale' attribute of every variable data object to True.

get_continuousset_list()

Return the a list of ContinuousSet components the derivative is being taken with respect to.

get_derivative_expression()

Returns the current discretization expression for this derivative or creates an access function to its Var the first time this method is called.

get_state_var()

Return the Var that is being differentiated.

get_suffix_value(suffix_or_name[, default])

Get the suffix value for this component data

get_units()

Return the units expression for this Var.

get_values([include_fixed_values])

Return a dictionary of index-value pairs.

getname([fully_qualified, name_buffer, ...])

Returns the component name associated with this object.

id_index_map()

Return an dictionary id->index for all ComponentData instances.

index_set()

Return the index set

is_component_type()

Return True if this class is a Pyomo component

is_constructed()

Return True if this class has been constructed

is_expression_type([expression_system])

Return True if this numeric value is an expression

is_fully_discretized()

Check to see if all the ContinuousSets this derivative is taken with respect to have been discretized.

is_indexed()

Return true if this component is indexed

is_logical_type()

Return True if this class is a Pyomo Boolean object.

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 component is a reference, where "reference" is interpreted as any component that does not own its own data.

is_variable_type()

Return False unless this class is a variable object

items([sort, ordered])

Return an iterator of (index,data) component data tuples

iteritems()

DEPRECATED.

iterkeys()

DEPRECATED.

itervalues()

DEPRECATED.

keys([sort, ordered])

Return an iterator over the component data keys

model()

Returns the model associated with this object.

parent_block()

Returns the parent of this object.

parent_component()

Returns the component associated with this object.

pprint([ostream, verbose, prefix])

Print component information

reconstruct([data])

REMOVED: reconstruct() was removed in Pyomo 6.0.

root_block()

Return self.model()

set_derivative_expression(expr)

Sets``_expr``, an expression representing the discretization equations linking the DerivativeVar to its state Var

set_suffix_value(suffix_or_name, value[, expand])

Set the suffix value for this component data

set_value(value)

Set the value of a scalar component.

set_values(new_values[, skip_validation])

Set the values of a dictionary.

to_dense_data()

TODO

type()

DEPRECATED.

valid_model_component()

Return True if this can be used as a model component.

values([sort, ordered])

Return an iterator of the component data objects

Attributes

active

Return the active attribute

ctype

Return the class type for this component

local_name

Get the component name only within the context of the immediate parent container.

name

Get the fully qualified component name.

Member Documentation

add(index)

Add a variable with a particular index.

clear()

Clear the data in this component

clear_suffix_value(suffix_or_name, expand=True)

Clear 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)

Construct the VarData objects for this variable

dim()

Return the dimension of the index

extract_values(include_fixed_values=True)

Return a dictionary of index-value pairs.

flag_as_stale()

Set the ‘stale’ attribute of every variable data object to True.

get_continuousset_list()[source]

Return the a list of ContinuousSet components the derivative is being taken with respect to.

Return type:

list

get_derivative_expression()[source]

Returns the current discretization expression for this derivative or creates an access function to its Var the first time this method is called. The expression gets built up as the discretization transformations are sequentially applied to each ContinuousSet in the model.

get_state_var()[source]

Return the Var that is being differentiated.

Return type:

Var

get_suffix_value(suffix_or_name, default=None)

Get the suffix value for this component data

get_units()

Return the units expression for this Var.

get_values(include_fixed_values=True)

Return a dictionary of index-value pairs.

getname(fully_qualified=False, name_buffer=None, relative_to=None)

Returns the component name associated with this object.

Parameters:
  • fully_qualified (bool) – Generate full name from nested block names

  • relative_to (Block) – Generate fully_qualified names relative to the specified block.

id_index_map()

Return an dictionary id->index for all ComponentData instances.

index_set()

Return the index set

is_component_type()

Return True if this class is a Pyomo component

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_fully_discretized()[source]

Check to see if all the ContinuousSets this derivative is taken with respect to have been discretized.

Return type:

boolean

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 component is a reference, where “reference” is interpreted as any component that does not own its own data.

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(), and items() 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()

Returns the model associated with this object.

parent_block()

Returns the parent of this object.

parent_component()

Returns the component associated with this object.

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_derivative_expression(expr)[source]

Sets``_expr``, an expression representing the discretization equations linking the DerivativeVar to its state Var

set_suffix_value(suffix_or_name, value, expand=True)

Set the suffix value for this component data

set_value(value)

Set the value of a scalar component.

set_values(new_values, skip_validation=False)

Set the values of a dictionary.

The default behavior is to validate the values in the dictionary.

to_dense_data()

TODO

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.