NegatedStepFunction

(class from pyomo.contrib.cp.scheduling_expr.step_function_expressions)

class pyomo.contrib.cp.scheduling_expr.step_function_expressions.NegatedStepFunction(args)[source]

Bases: StepFunction

The negated form of an elementary step function: That is, it represents subtracting the elementary function’s (nonnegative) height rather than adding it.

Parameters:

arg (Step or Pulse) – Child elementary step function of this node

__init__(args)[source]

Methods

__init__(args)

arg(i)

Return the i-th child node.

clone([substitute])

Return a clone of the expression tree.

create_node_with_local_data(args[, classtype])

Construct a node using given arguments.

getname(*args, **kwds)

Return the text name of a function associated with this expression object.

is_component_type()

Return True if this class is a Pyomo component

is_constant()

Return True if this expression is an atomic constant

is_expression_type([expression_system])

Return True if this object is an expression.

is_fixed()

Return True if this expression contains no free variables.

is_logical_type()

Return True if this class is a Pyomo Boolean object.

is_named_expression_type()

Return True if this object 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_potentially_variable()

Return True if this expression might represent a variable expression.

is_reference()

Return True if this object is a reference.

is_variable_type()

Return False unless this class is a variable object

nargs()

Returns the number of child nodes.

size()

Return the number of nodes in the expression tree.

to_string([verbose, labeler, smap, ...])

Return a string representation of the expression tree.

within(bounds, times)

Attributes

PRECEDENCE

Return the associativity of this operator.

args

Return the child nodes

Member Documentation

arg(i)

Return the i-th child node.

Parameters:
  • i (int) – Index of the child argument to return

  • Returns (The i-th child node.)

clone(substitute=None)

Return a clone of the expression tree.

Note

This method does not clone the leaves of the tree, which are numeric constants and variables. It only clones the interior nodes, and expression leaf nodes like _MutableLinearExpression. However, named expressions are treated like leaves, and they are not cloned.

Parameters:

substitute (dict) – a dictionary that maps object ids to clone objects generated earlier during the cloning process.

Returns:

A new expression tree.

create_node_with_local_data(args, classtype=None)

Construct a node using given arguments.

This method provides a consistent interface for constructing a node, which is used in tree visitor scripts. In the simplest case, this returns:

self.__class__(args)

But in general this creates an expression object using local data as well as arguments that represent the child nodes.

Parameters:

args (list) – A list of child nodes for the new expression object

Returns:

A new expression object with the same type as the current class.

getname(*args, **kwds)

Return the text name of a function associated with this expression object.

In general, no arguments are passed to this function.

Parameters:
  • *arg – a variable length list of arguments

  • **kwds – keyword arguments

Returns:

A string name for the function.

is_component_type()

Return True if this class is a Pyomo component

is_constant()

Return True if this expression is an atomic constant

This method contrasts with the is_fixed() method. This method returns True if the expression is an atomic constant, that is it is composed exclusively of constants and immutable parameters. NumericValue objects returning is_constant() == True may be simplified to their numeric value at any point without warning.

Note: This defaults to False, but gets redefined in sub-classes.

is_expression_type(expression_system=None)

Return True if this object is an expression.

This method obviously returns True for this class, but it is included in other classes within Pyomo that are not expressions, which allows for a check for expressions without evaluating the class type.

Returns:

A boolean.

is_fixed()

Return True if this expression contains no free variables.

Returns:

A boolean.

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 object is a named expression.

This method returns False for this class, and it is included in other classes within Pyomo that are not named expressions, which allows for a check for named expressions without evaluating the class type.

Returns:

A boolean.

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_potentially_variable()

Return True if this expression might represent a variable expression.

This method returns True when (a) the expression tree contains one or more variables, or (b) the expression tree contains a named expression. In both cases, the expression cannot be treated as constant since (a) the variables may not be fixed, or (b) the named expressions may be changed at a later time to include non-fixed variables.

Returns:

A boolean. Defaults to True for expressions.

is_reference()

Return True if this object is a reference.

is_variable_type()

Return False unless this class is a variable object

nargs()[source]

Returns the number of child nodes.

Note

Individual expression nodes may use different internal storage schemes, so it is imperative that developers use this method and not assume the existence of a particular attribute!

Returns:

int

Return type:

A nonnegative integer that is the number of child nodes.

size()

Return the number of nodes in the expression tree.

Returns:

A nonnegative integer that is the number of interior and leaf nodes in the expression tree.

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 algebraic (infix notation) equation. Defaults to False.

  • labeler – An object that generates string labels for variables in the expression tree. Defaults to None.

  • smap – If specified, this SymbolMap is used to cache labels for variables.

  • (bool) (compute_values) – If True, then parameters and fixed variables are evaluated before the expression string is generated. Default is False.

  • Returns – A string representation for the expression tree.

PRECEDENCE = 0

Return the associativity of this operator.

Returns 1 if this operator is left-to-right associative or -1 if it is right-to-left associative. Any other return value will be interpreted as “not associative” (implying any arguments that are at this operator’s PRECEDENCE will be enclosed in parens).

property args

Return the child nodes

Returns:

Sequence containing only the child nodes of this node. The return type depends on the node storage model. Users are not permitted to change the returned data (even for the case of data returned as a list), as that breaks the promise of tree immutability.

Return type:

list or tuple