pyepo.func.utils

Utility function

Attributes

_worker_model

_worker_model_key

Classes

sumGammaDistribution

creates a generator of samples for the Sum-of-Gamma distribution

Functions

_solve_or_cache(cp, module)

A function to get optimization solution in the forward/backward pass

_solve_in_pass(cp, optmodel, processes, pool[, ...])

A function to solve optimization and update solution pool

_solve_batch(cp, optmodel, processes, pool)

A function to solve optimization in the forward/backward pass

_update_solution_pool(sol, solpool, solset)

Add new solutions to solution pool

_cache_in_pass(cp, optmodel, solpool)

A function to use solution pool in the forward/backward pass

_solveWithObj4Par(cost, args, model_type)

A function to solve function in parallel processors

_check_sol(c, w, z)

A function to check solution is correct

Module Contents

pyepo.func.utils._solve_or_cache(cp, module)

A function to get optimization solution in the forward/backward pass

pyepo.func.utils._solve_in_pass(cp, optmodel, processes, pool, solpool=None, solset=None)

A function to solve optimization and update solution pool

pyepo.func.utils._solve_batch(cp, optmodel, processes, pool)

A function to solve optimization in the forward/backward pass

pyepo.func.utils._update_solution_pool(sol, solpool, solset)

Add new solutions to solution pool

Parameters:
  • sol (torch.tensor) – new solutions

  • solpool (torch.tensor) – existing solution pool

  • solset (set) – hash set for deduplication

Returns:

updated solution pool

Return type:

torch.tensor

pyepo.func.utils._cache_in_pass(cp, optmodel, solpool)

A function to use solution pool in the forward/backward pass

pyepo.func.utils._worker_model = None
pyepo.func.utils._worker_model_key = None
pyepo.func.utils._solveWithObj4Par(cost, args, model_type)

A function to solve function in parallel processors

Parameters:
  • cost (np.ndarray) – cost of objective function

  • args (dict) – optModel args

  • model_type (ABCMeta) – optModel class type

Returns:

optimal solution (list) and objective value (float)

Return type:

tuple

pyepo.func.utils._check_sol(c, w, z)

A function to check solution is correct

class pyepo.func.utils.sumGammaDistribution(kappa, n_iterations=10, seed=135)

creates a generator of samples for the Sum-of-Gamma distribution

κ
n_iterations = 10
rnd
sample(size)