SimpleObjective
(class from pyomo.core.base.objective
)
- class pyomo.core.base.objective.SimpleObjective(*args, **kwargs)[source]
Bases:
ScalarObjective
- __init__(*args, **kwd)
Methods
__init__
(*args, **kwd)activate
()Set the active attribute to True
add
(index, expr)Add an expression with a given index.
arg
(index)clear
()Clear the data in this component
clear_suffix_value
(suffix_or_name[, expand])Set the suffix value for this component data
clone
()Return a clone of this expression (no-op).
cname
(*args, **kwds)DEPRECATED.
construct
([data])Construct the expression(s) for this objective.
create_node_with_local_data
(values[, classtype])Construct a simple expression after constructing the contained expression.
Set the active attribute to False
dim
()Return the dimension of the index
display
([prefix, ostream])Provide a verbose display of this object
get_suffix_value
(suffix_or_name[, default])Get the suffix value for this component data
getname
(*args, **kwargs)If this is a component, return the component's name on the owning block; otherwise return the value converted to a string
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
A boolean indicating whether this expression is constant.
Return True if this class has been constructed
is_expression_type
([expression_system])A boolean indicating whether this in an expression.
is_fixed
()A boolean indicating whether this expression is fixed.
Return True if this numeric value is an indexed object
Return True if this class is a Pyomo Boolean object.
Return True if this is a minimization objective.
A boolean indicating whether this in 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 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.
nargs
()Return the parent of the component that owns this data.
Returns the component associated with this object.
A tuple of subexpressions involved in this expressions operation.
pprint
([ostream, verbose, prefix])Print component information
reconstruct
([data])REMOVED: reconstruct() was removed in Pyomo 6.0.
Return self.model()
set_sense
(sense)Set the sense (direction) of this objective.
set_suffix_value
(suffix_or_name, value[, expand])Set the suffix value for this component data
set_value
(expr)Set the expression of this objective.
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
PRECEDENCE
Return the active attribute
args
Return the class type for this component
Access the expression of this objective.
Get the component name only within the context of the immediate parent container.
Get the fully qualified component name.
Access sense (direction) of this objective.
Member Documentation
- activate()
Set the active attribute to True
- add(index, expr)
Add an expression with a given index.
- clear()
Clear the data in this component
- clear_suffix_value(suffix_or_name, expand=True)
Set the suffix value for this component data
- clone()
Return a clone of this expression (no-op).
- 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 expression(s) for this objective.
- create_node_with_local_data(values, classtype=None)
Construct a simple expression after constructing the contained expression.
This class provides a consistent interface for constructing a node, which is used in tree visitor scripts.
- deactivate()
Set the active attribute to False
- dim()
Return the dimension of the index
- display(prefix='', ostream=None)
Provide a verbose display of this object
- get_suffix_value(suffix_or_name, default=None)
Get the suffix value for this component data
- getname(*args, **kwargs)
If this is a component, return the component’s name on the owning block; otherwise return the value converted to a string
- 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()
A boolean indicating whether this expression is constant.
- is_constructed()
Return True if this class has been constructed
- is_expression_type(expression_system=None)
A boolean indicating whether this in an expression.
- is_fixed()
A boolean indicating whether this expression is fixed.
- is_indexed()
Return True if this numeric value is an indexed object
- is_logical_type()
Return True if this class is a Pyomo Boolean object.
Boolean objects include constants, variables, or logical expressions.
- is_minimizing()
Return True if this is a minimization objective.
- is_named_expression_type()
A boolean indicating whether this in 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 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()
A tuple of subexpressions involved in this expressions operation.
- 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_sense(sense)
Set the sense (direction) of this objective.
- set_suffix_value(suffix_or_name, value, expand=True)
Set the suffix value for this component data
- set_value(expr)
Set the expression of this objective.
- 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 expr
Access the expression of this objective.
- 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 sense
Access sense (direction) of this objective.