pyepo.model.mpax ================ .. py:module:: pyepo.model.mpax .. autoapi-nested-parse:: Optimization Model based on MPAX Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyepo/model/mpax/knapsack/index /autoapi/pyepo/model/mpax/mpaxmodel/index /autoapi/pyepo/model/mpax/shortestpath/index Classes ------- .. autoapisummary:: pyepo.model.mpax.optMpaxModel pyepo.model.mpax.shortestPathModel pyepo.model.mpax.knapsackModel Package Contents ---------------- .. py:class:: optMpaxModel(A=None, b=None, G=None, h=None, l=None, u=None, use_sparse_matrix=True, minimize=True) Bases: :py:obj:`pyepo.model.opt.optModel` This is an abstract class for MPAX-based optimization model .. attribute:: A The matrix of equality constraints. :type: jnp.ndarray, BCOO or BCSR .. attribute:: b The right hand side of equality constraints. :type: jnp.ndarray .. attribute:: G The matrix for inequality constraints. :type: jnp.ndarray, BCOO or BCSR .. attribute:: h The right hand side of inequality constraints. :type: jnp.ndarray .. attribute:: l The lower bound of the variables. :type: jnp.ndarray .. attribute:: u The upper bound of the variables. :type: jnp.ndarray .. attribute:: use_sparse_matrix Whether to use sparse matrix format, by default True. :type: bool .. attribute:: minimize Whether to minimize objective, by default True. :type: bool .. py:attribute:: l .. py:attribute:: u .. py:attribute:: use_sparse_matrix :value: True .. py:attribute:: modelSense :value: 1 .. py:attribute:: device :value: None .. py:attribute:: jitted_solve :value: None .. py:attribute:: batch_optimize .. py:method:: __repr__() .. py:property:: num_cost number of cost to be predicted .. py:method:: setObj(c) A method to set objective function :param c: cost of objective function :type c: np.ndarray / list .. py:method:: solve() A method to solve model :returns: optimal solution (list) and objective value (jnp.float32) :rtype: tuple .. py:method:: _jitted_solve(c, A, b, G, h, l, u, use_sparse_matrix) :staticmethod: A static method for JIT complile .. py:method:: copy() A method to copy model :returns: new copied model :rtype: optModel .. py:method:: addConstr(coefs, rhs) A method to add new constraint :param coefs: coeffcients of new constraint :type coefs: np.ndarray / list :param rhs: right-hand side of new constraint :type rhs: jnp.float32 :returns: new model with the added constraint :rtype: optModel .. py:method:: _getModel() Placeholder method for MPAX. MPAX does not require an explicit model creation. .. py:class:: shortestPathModel(grid) Bases: :py:obj:`pyepo.model.mpax.mpaxmodel.optMpaxModel` This class is optimization model for shortest path problem .. attribute:: grid Size of grid network :type: tuple of int .. attribute:: arcs List of arcs :type: list .. py:attribute:: grid .. py:attribute:: arcs :value: [] .. py:method:: _getArcs() A method to get list of arcs for grid network :returns: arcs :rtype: list .. py:method:: _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 :rtype: A (jnp.ndarray) .. py:class:: knapsackModel(weights, capacity) Bases: :py:obj:`pyepo.model.mpax.mpaxmodel.optMpaxModel` This class is optimization model for relexed knapsack problem .. attribute:: _model Gurobi model :type: GurobiPy model .. attribute:: weights Weights of items :type: np.ndarray / list .. attribute:: capacity Total capacity :type: np.ndarray / listy .. attribute:: items List of item index :type: list .. py:attribute:: weights .. py:attribute:: capacity .. py:attribute:: items .. py:method:: _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 :rtype: G (jnp.ndarray)