pyepo.model.mpax
Optimization Model based on MPAX
Submodules
Classes
This is an abstract class for an MPAX-based optimization model |
|
This class is an optimization model for the shortest path problem |
|
This class is an optimization model for the relaxed 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.optModelThis is an abstract class for an 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
- _has_jax_gpu
- __repr__()
- _rebuild_jit()
Rebuild JIT-compiled solve functions with current constraints.
- property num_cost
number of costs to be predicted
- setObj(c)
A method to set the objective function
- Parameters:
c (np.ndarray / list) – cost of objective function
- solve()
A method to solve the 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 compile
- addConstr(coefs, rhs)
A method to add a new constraint
- Parameters:
coefs (np.ndarray / list) – coefficients 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.optMpaxModelThis class is an optimization model for the shortest path problem
- grid
Size of grid network
- Type:
tuple of int
- arcs
List of arcs
- Type:
list
- grid
- arcs = []
- _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.optMpaxModelThis class is an optimization model for the relaxed knapsack problem
- _model
MPAX model
- weights
Weights of items
- Type:
np.ndarray / list
- capacity
Total capacity
- Type:
np.ndarray / list
- 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)