pyepo.model.predefined

Backend-dispatching factories for the built-in problems.

Each factory builds the requested problem on the chosen solver backend, selected by the backend keyword (default Gurobi) rather than by importing a backend-specific class.

Functions

shortestPathModel(grid, *[, backend])

Shortest path on a grid network.

knapsackModel(weights, capacity, *[, backend])

Multi-dimensional knapsack.

portfolioModel(num_assets, covariance, *[, backend])

Mean-variance portfolio optimization.

tspModel(num_nodes, *[, backend, formulation])

Traveling salesperson.

vrpModel(num_nodes, demands, capacity, num_vehicle, *)

Capacitated vehicle routing.

Module Contents

pyepo.model.predefined.shortestPathModel(grid, *, backend='gurobi', **kwargs)

Shortest path on a grid network.

Parameters:
  • grid (tuple) – grid size (h, w)

  • backend (str) – solver backend; one of "gurobi", "copt", "pyomo", "ortools", "mpax"

pyepo.model.predefined.knapsackModel(weights, capacity, *, backend='gurobi', **kwargs)

Multi-dimensional knapsack.

Parameters:
  • weights (ndarray) – item weights with shape (dim, n_items)

  • capacity (ndarray) – per-dimension capacity with length dim

  • backend (str) – solver backend; one of "gurobi", "copt", "pyomo", "ortools", "mpax"

pyepo.model.predefined.portfolioModel(num_assets, covariance, *, backend='gurobi', **kwargs)

Mean-variance portfolio optimization.

Parameters:
  • num_assets (int) – number of assets

  • covariance (ndarray) – covariance matrix of the asset returns

  • backend (str) – solver backend; one of "gurobi", "copt", "pyomo"

pyepo.model.predefined.tspModel(num_nodes, *, backend='gurobi', formulation='DFJ', **kwargs)

Traveling salesperson.

Parameters:
  • num_nodes (int) – number of nodes

  • backend (str) – solver backend; one of "gurobi", "copt", "pyomo"

  • formulation (str) – ILP formulation; one of "DFJ", "GG", "MTZ" ("DFJ" on gurobi and copt only)

pyepo.model.predefined.vrpModel(num_nodes, demands, capacity, num_vehicle, *, backend='gurobi', formulation='RCI', **kwargs)

Capacitated vehicle routing.

Parameters:
  • num_nodes (int) – number of nodes, with the depot as node 0

  • demands (list) – per-customer demands with length num_nodes - 1

  • capacity (float) – vehicle capacity

  • num_vehicle (int) – number of vehicles

  • backend (str) – solver backend; one of "gurobi", "copt", "pyomo"

  • formulation (str) – ILP formulation; "RCI" or "MTZ" ("RCI" on gurobi and copt only)