pybnb.pyomo.misc

Miscellaneous utilities used for development.

Copyright by Gabriel A. Hackebeil (gabe.hackebeil@gmail.com).

pybnb.pyomo.misc.hash_joblist(jobs)[source]

Create a hash of a Python list by casting each entry to a string.

pybnb.pyomo.misc.add_tmp_component(model, name, obj)[source]

Add a temporary component to a model, adjusting the name as needed to make sure it is unique.

for ... in pybnb.pyomo.misc.mpi_partition(comm, items, root=0)[source]

A generator that partitions the list of items across processes in the communicator. If the communicator size is greater than 1, the root process iterates over no items, but rather serves them dynamically after receiving requests from workers. This function assumes each process has an identical copy of the items list. Therefore, items in the list are not transferred (only indices).

pybnb.pyomo.misc.correct_integer_lb(lb, integer_tolerance)[source]

Converts a lower bound for an integer optimization variable to an integer equal to ceil(ub), taking care not to move a non-integer bound away from an integer point already within a given tolerance.

pybnb.pyomo.misc.correct_integer_ub(ub, integer_tolerance)[source]

Converts an upper bound for an integer optimization variable to an integer equal to floor(ub), taking care not to move a non-integer bound away from an integer point already within a given tolerance.

pybnb.pyomo.misc.create_optimality_bound(problem, pyomo_objective, best_objective_value)[source]

Returns a constraint that bounds an objective function with a known best value. That is, the constraint will require the objective function to be better than the given value.

pybnb.pyomo.misc.generate_cids(model, prefix=(), **kwds)[source]

Generate forward and reverse mappings between model components and deterministic, unique identifiers that are safe to serialize or use as dictionary keys.