pyepo.model.grb
Optimization Model based on GurobiPy
Submodules
Classes
This is an abstract class for Gurobi-based optimization model |
|
This class is optimization model for shortest path problem |
|
This class is optimization model for knapsack problem |
|
This class is optimization model for traveling salesman problem based on Gavish–Graves (GG) formulation. |
|
This class is optimization model for traveling salesman problem based on Danzig–Fulkerson–Johnson (DFJ) formulation and |
|
This class is optimization model for traveling salesman problem based on Miller-Tucker-Zemlin (MTZ) formulation. |
|
This class is an optimization model for portfolio problem |
Package Contents
- class pyepo.model.grb.optGrbModel
Bases:
pyepo.model.opt.optModel
This is an abstract class for Gurobi-based optimization model
- _model
Gurobi model
- Type:
GurobiPy model
- __repr__()
- property num_cost
number of cost to be predicted
- setObj(c)
A method to set objective function
- Parameters:
c (np.ndarray / list) – cost of objective function
- solve()
A method to solve model
- Returns:
optimal solution (list) and objective value (float)
- Return type:
tuple
- class pyepo.model.grb.shortestPathModel(grid)
Bases:
pyepo.model.grb.grbmodel.optGrbModel
This class is optimization model for shortest path problem
- _model
Gurobi model
- Type:
GurobiPy model
- grid
Size of grid network
- Type:
tuple of int
- arcs
List of arcs
- Type:
list
- grid
- arcs = []
- _getArcs()
A method to get list of arcs for grid network
- Returns:
arcs
- Return type:
list
- _getModel()
A method to build Gurobi model
- Returns:
optimization model and variables
- Return type:
tuple
- class pyepo.model.grb.knapsackModel(weights, capacity)
Bases:
pyepo.model.grb.grbmodel.optGrbModel
This class is optimization model for knapsack problem
- _model
Gurobi model
- Type:
GurobiPy model
- weights
Weights of items
- Type:
np.ndarray / list
- capacity
Total capacity
- Type:
np.ndarray / listy
- items
List of item index
- Type:
list
- weights
- capacity
- items
- _getModel()
A method to build Gurobi model
- Returns:
optimization model and variables
- Return type:
tuple
- relax()
A method to get linear relaxation model
- class pyepo.model.grb.tspGGModel(num_nodes)
Bases:
tspABModel
This class is optimization model for traveling salesman problem based on Gavish–Graves (GG) formulation.
- _model
Gurobi model
- Type:
GurobiPy model
- num_nodes
Number of nodes
- Type:
int
- edges
List of edge index
- Type:
list
- _getModel()
A method to build Gurobi model
- Returns:
optimization model and variables
- Return type:
tuple
- setObj(c)
A method to set objective function
- Parameters:
c (list) – cost vector
- solve()
A method to solve model
- addConstr(coefs, rhs)
A method to add new constraint
- Parameters:
coefs (ndarray) – coeffcients of new constraint
rhs (float) – right-hand side of new constraint
- Returns:
new model with the added constraint
- Return type:
- relax()
A method to get linear relaxation model
- class pyepo.model.grb.tspDFJModel(num_nodes)
Bases:
tspABModel
This class is optimization model for traveling salesman problem based on Danzig–Fulkerson–Johnson (DFJ) formulation and constraint generation.
- _model
Gurobi model
- Type:
GurobiPy model
- num_nodes
Number of nodes
- Type:
int
- edges
List of edge index
- Type:
list
- _getModel()
A method to build Gurobi model
- Returns:
optimization model and variables
- Return type:
tuple
- static _subtourelim(model, where)
A static method to add lazy constraints for subtour elimination
- setObj(c)
A method to set objective function
- Parameters:
c (list) – cost vector
- solve()
A method to solve model
- class pyepo.model.grb.tspMTZModel(num_nodes)
Bases:
tspABModel
This class is optimization model for traveling salesman problem based on Miller-Tucker-Zemlin (MTZ) formulation.
- _model
Gurobi model
- Type:
GurobiPy model
- num_nodes
Number of nodes
- Type:
int
- edges
List of edge index
- Type:
list
- _getModel()
A method to build Gurobi model
- Returns:
optimization model and variables
- Return type:
tuple
- setObj(c)
A method to set objective function
- Parameters:
c (list) – cost vector
- solve()
A method to solve model
- addConstr(coefs, rhs)
A method to add new constraint
- Parameters:
coefs (ndarray) – coeffcients of new constraint
rhs (float) – right-hand side of new constraint
- Returns:
new model with the added constraint
- Return type:
- relax()
A method to get linear relaxation model
- class pyepo.model.grb.portfolioModel(num_assets, covariance, gamma=2.25)
Bases:
pyepo.model.grb.grbmodel.optGrbModel
This class is an optimization model for portfolio problem
- _model
Gurobi model
- Type:
GurobiPy model
- num_assets
number of assets
- Type:
int
- covariance
covariance matrix of the returns
- Type:
numpy.ndarray
- risk_level
risk level
- Type:
float
- num_assets
- covariance
- risk_level
- _getRiskLevel(gamma)
A method to calculate the risk level
- Returns:
risk level
- Return type:
float
- _getModel()
A method to build Gurobi model
- Returns:
optimization model and variables
- Return type:
tuple