AutoUpdateConfig

(class from pyomo.contrib.observer.model_observer)

class pyomo.contrib.observer.model_observer.AutoUpdateConfig(description=None, doc=None, implicit=False, implicit_domain=None, visibility=0)[source]

Bases: ConfigDict

Control which parts of the model are automatically checked and/or updated upon re-solve

Options:
  • check_for_new_or_removed_constraints (bool, default=True) – If False, new/old constraints will not be automatically detected on subsequent solves. Use False only when manually updating the change detector with cd.add_constraints() and cd.remove_constraints() or when you are certain constraints are not being added to/removed from the model.

  • check_for_new_or_removed_objectives (bool, default=True) – If False, new/old objectives will not be automatically detected on subsequent solves. Use False only when manually updating the solver with opt.add_objectives() and opt.remove_objectives() or when you are certain objectives are not being added to/removed from the model.

  • update_constraints (bool, default=True) – If False, changes to existing constraints will not be automatically detected on subsequent solves. This includes changes to the lower, body, and upper attributes of constraints. Use False only when manually updating the solver with opt.remove_constraints() and opt.add_constraints() or when you are certain constraints are not being modified.

  • update_vars (bool, default=True) – If False, changes to existing variables will not be automatically detected on subsequent solves. This includes changes to the lb, ub, domain, and fixed attributes of variables. Use False only when manually updating the observer with opt.update_variables() or when you are certain variables are not being modified.

  • update_parameters (bool, default=True) – If False, changes to parameter values and fixed variable values will not be automatically detected on subsequent solves. Use False only when manually updating the observer with opt.update_parameters_and_fixed_variables() or when you are certain parameters are not being modified.

  • update_named_expressions (bool, default=True) – If False, changes to Expressions will not be automatically detected on subsequent solves. Use False only when manually updating the solver with opt.remove_constraints() and opt.add_constraints() or when you are certain Expressions are not being modified.

  • update_objectives (bool, default=True) – If False, changes to objectives will not be automatically detected on subsequent solves. This includes the expr and sense attributes of objectives. Use False only when manually updating the solver with opt.set_objective() or when you are certain objectives are not being modified.

__init__(description=None, doc=None, implicit=False, implicit_domain=None, visibility=0)[source]

Methods

__init__([description, doc, implicit, ...])

add(name, config, **kwargs)

clear()

declare(name, config)

Declare a new configuration item in the ConfigDict

declare_as_argument(*args, **kwds)

Map this Config item to an argparse argument.

declare_from(other[, skip])

display([content_filter, indent_spacing, ...])

Print the current Config value, in YAML format.

domain_name()

generate_documentation([block_start, ...])

Document the this Config object.

generate_yaml_template([indent_spacing, ...])

Document Config object, in YAML format.

get(k[,d])

import_argparse(parsed_args)

Import parsed arguments back into this Config object

initialize_argparse(parser)

Initialize an ArgumentParser with arguments from this Config object.

items()

iteritems()

DEPRECATED.

iterkeys()

DEPRECATED.

itervalues()

DEPRECATED.

keys()

name([fully_qualified])

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

reset()

set_default_value(default)

set_domain(domain)

set_value(value[, skip_implicit])

setdefault(k[,d])

unused_user_values()

update([E, ]**F)

If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

user_values()

value([accessValue])

values()

Attributes

content_filters

check_for_new_or_removed_constraints

automatically detect new/removed constraints on subsequent solves

check_for_new_or_removed_objectives

automatically detect new/removed objectives on subsequent solves

update_constraints

automatically detect changes to constraints on subsequent solves

update_vars

automatically detect changes to variables on subsequent solves

update_parameters

automatically detect changes to parameters on subsequent solves

update_named_expressions

automatically detect changes to named expressions on subsequent solves

update_objectives

automatically detect changes to objectives on subsequent solves

Member Documentation

clear() None.  Remove all items from D.
declare(name, config)

Declare a new configuration item in the ConfigDict

declare_as_argument(*args, **kwds)

Map this Config item to an argparse argument.

Valid arguments include all valid arguments to argparse.ArgumentParser.add_argument() with the exception of default.

In addition, you may provide a group keyword argument that can be:

  • an argument group returned from ~argparse.ArgumentParser.add_argument_group

  • a subparser returned from ~argparse.ArgumentParser.add_subparsers

  • a string specifying the name of a subparser or argument group

  • a tuple of strings specifying a (subparser, group)

display(content_filter=None, indent_spacing=2, ostream=None, visibility=None)

Print the current Config value, in YAML format.

The current values stored in this Config object are output to ostream (or sys.stdout if ostream is None). If visibility is not None, then only items with visibility less than or equal to visibility will be output. Output can be further filtered by providing a content_filter.

generate_documentation(block_start=None, block_end=None, item_start=None, item_body=None, item_end=None, indent_spacing: int = 2, width: int = 78, visibility: int | None = None, format: ConfigFormatter | str = 'latex')

Document the this Config object.

Generate documentation for this config object in the specified format. While it can be called on any class derived from ConfigBase, it is typically used for documenting ConfigDict instances.

Note that unlike display() and generate_yaml_template(), generate_documentation() does not document the current value of any ConfigList containers. Instead, it generates the documentation for the ConfigList domain.

If the format argument is a string, this method is equivalent to:

ConfigFormatter.formats[format]().generate(
    self, indent_spacing, width, visibility
)

Otherwise, if format is a ConfigFormatter instance, then this is simply:

format.generate(self, indent_spacing, width, visibility)
generate_yaml_template(indent_spacing=2, width=78, visibility=0)

Document Config object, in YAML format.

Output a description of this Config object. While similar to display(), this routine has two key differences:

  • The description for each item is output as a comment.

  • The result is returned as a string instead of being sent directly to an output stream

If visibility is not None, then only items with visibility less than or equal to visibility will be output.

get(k[, d]) D[k] if k in D, else d.  d defaults to None.
import_argparse(parsed_args)

Import parsed arguments back into this Config object

initialize_argparse(parser)

Initialize an ArgumentParser with arguments from this Config object.

Translate items from this Config object that have been marked with declare_as_argument() into argparse arguments.

items() a set-like object providing a view on D's items
iteritems()

DEPRECATED.

Deprecated since version 6.0: The iteritems method is deprecated. Use dict.keys().

iterkeys()

DEPRECATED.

Deprecated since version 6.0: The iterkeys method is deprecated. Use dict.keys().

itervalues()

DEPRECATED.

Deprecated since version 6.0: The itervalues method is deprecated. Use dict.keys().

keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() an object providing a view on D's values
check_for_new_or_removed_constraints: bool

automatically detect new/removed constraints on subsequent solves

check_for_new_or_removed_objectives: bool

automatically detect new/removed objectives on subsequent solves

update_constraints: bool

automatically detect changes to constraints on subsequent solves

update_named_expressions: bool

automatically detect changes to named expressions on subsequent solves

update_objectives: bool

automatically detect changes to objectives on subsequent solves

update_parameters: bool

automatically detect changes to parameters on subsequent solves

update_vars: bool

automatically detect changes to variables on subsequent solves