pyepo.model.mpax
Optimization Model based on MPAX
Submodules
Classes
This is an abstract class for MPAX-based optimization model |
|
This class is optimization model for shortest path problem |
|
This class is optimization model for relexed knapsack problem |
Package Contents
- class pyepo.model.mpax.optMpaxModel(A=None, b=None, G=None, h=None, l=None, u=None, use_sparse_matrix=True, minimize=True)
Bases:
pyepo.model.opt.optModel
This is an abstract class for MPAX-based optimization model
- A
The matrix of equality constraints.
- Type:
jnp.ndarray, BCOO or BCSR
- b
The right hand side of equality constraints.
- Type:
jnp.ndarray
- G
The matrix for inequality constraints.
- Type:
jnp.ndarray, BCOO or BCSR
- h
The right hand side of inequality constraints.
- Type:
jnp.ndarray
- l
The lower bound of the variables.
- Type:
jnp.ndarray
- u
The upper bound of the variables.
- Type:
jnp.ndarray
- use_sparse_matrix
Whether to use sparse matrix format, by default True.
- Type:
bool
- minimize
Whether to minimize objective, by default True.
- Type:
bool
- l
- u
- use_sparse_matrix = True
- modelSense = 1
- device = None
- jitted_solve = None
- batch_optimize
- __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 (jnp.float32)
- Return type:
tuple
- static _jitted_solve(c, A, b, G, h, l, u, use_sparse_matrix)
A static method for JIT complile
- addConstr(coefs, rhs)
A method to add new constraint
- Parameters:
coefs (np.ndarray / list) – coeffcients of new constraint
rhs (jnp.float32) – right-hand side of new constraint
- Returns:
new model with the added constraint
- Return type:
- _getModel()
Placeholder method for MPAX. MPAX does not require an explicit model creation.
- class pyepo.model.mpax.shortestPathModel(grid)
Bases:
pyepo.model.mpax.mpaxmodel.optMpaxModel
This class is optimization model for shortest path problem
- 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
- _constructMatrix()
Constructs the incidence matrix A, supply/demand vector b, and upper bound u for the shortest path problem.
- Returns:
Incidence matrix for flow conservation b (jnp.ndarray): Supply/demand vector u (jnp.ndarray): Upper bound for flow variables
- Return type:
A (jnp.ndarray)
- class pyepo.model.mpax.knapsackModel(weights, capacity)
Bases:
pyepo.model.mpax.mpaxmodel.optMpaxModel
This class is optimization model for relexed 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
- _constructMatrix()
Constructs the inequality constraint matrix G, right-hand side h, and upper bound u for the knapsack problem.
- Returns:
Weights of items h (jnp.ndarray): Total capacity u (jnp.ndarray): Upper bound for item selection
- Return type:
G (jnp.ndarray)