pyepo.model.grb =============== .. py:module:: pyepo.model.grb .. autoapi-nested-parse:: Optimization Model based on GurobiPy Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyepo/model/grb/grbmodel/index /autoapi/pyepo/model/grb/knapsack/index /autoapi/pyepo/model/grb/portfolio/index /autoapi/pyepo/model/grb/shortestpath/index /autoapi/pyepo/model/grb/tsp/index Classes ------- .. autoapisummary:: pyepo.model.grb.optGrbModel pyepo.model.grb.shortestPathModel pyepo.model.grb.knapsackModel pyepo.model.grb.tspGGModel pyepo.model.grb.tspDFJModel pyepo.model.grb.tspMTZModel pyepo.model.grb.portfolioModel Package Contents ---------------- .. py:class:: optGrbModel Bases: :py:obj:`pyepo.model.opt.optModel` This is an abstract class for Gurobi-based optimization model .. attribute:: _model Gurobi model :type: GurobiPy model .. 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 (float) :rtype: tuple .. 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: float :returns: new model with the added constraint :rtype: optModel .. py:class:: shortestPathModel(grid) Bases: :py:obj:`pyepo.model.grb.grbmodel.optGrbModel` This class is optimization model for shortest path problem .. attribute:: _model Gurobi model :type: GurobiPy model .. 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:: _getModel() A method to build Gurobi model :returns: optimization model and variables :rtype: tuple .. py:class:: knapsackModel(weights, capacity) Bases: :py:obj:`pyepo.model.grb.grbmodel.optGrbModel` This class is optimization model for 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:: _getModel() A method to build Gurobi model :returns: optimization model and variables :rtype: tuple .. py:method:: relax() A method to get linear relaxation model .. py:class:: tspGGModel(num_nodes) Bases: :py:obj:`tspABModel` This class is optimization model for traveling salesman problem based on Gavish–Graves (GG) formulation. .. attribute:: _model Gurobi model :type: GurobiPy model .. attribute:: num_nodes Number of nodes :type: int .. attribute:: edges List of edge index :type: list .. py:method:: _getModel() A method to build Gurobi model :returns: optimization model and variables :rtype: tuple .. py:method:: setObj(c) A method to set objective function :param c: cost vector :type c: list .. py:method:: solve() A method to solve model .. py:method:: addConstr(coefs, rhs) A method to add new constraint :param coefs: coeffcients of new constraint :type coefs: ndarray :param rhs: right-hand side of new constraint :type rhs: float :returns: new model with the added constraint :rtype: optModel .. py:method:: relax() A method to get linear relaxation model .. py:class:: tspDFJModel(num_nodes) Bases: :py:obj:`tspABModel` This class is optimization model for traveling salesman problem based on Danzig–Fulkerson–Johnson (DFJ) formulation and constraint generation. .. attribute:: _model Gurobi model :type: GurobiPy model .. attribute:: num_nodes Number of nodes :type: int .. attribute:: edges List of edge index :type: list .. py:method:: _getModel() A method to build Gurobi model :returns: optimization model and variables :rtype: tuple .. py:method:: _subtourelim(model, where) :staticmethod: A static method to add lazy constraints for subtour elimination .. py:method:: setObj(c) A method to set objective function :param c: cost vector :type c: list .. py:method:: solve() A method to solve model .. py:method:: addConstr(coefs, rhs) A method to add new constraint :param coefs: coeffcients of new constraint :type coefs: ndarray :param rhs: right-hand side of new constraint :type rhs: float :returns: new model with the added constraint :rtype: optModel .. py:class:: tspMTZModel(num_nodes) Bases: :py:obj:`tspABModel` This class is optimization model for traveling salesman problem based on Miller-Tucker-Zemlin (MTZ) formulation. .. attribute:: _model Gurobi model :type: GurobiPy model .. attribute:: num_nodes Number of nodes :type: int .. attribute:: edges List of edge index :type: list .. py:method:: _getModel() A method to build Gurobi model :returns: optimization model and variables :rtype: tuple .. py:method:: setObj(c) A method to set objective function :param c: cost vector :type c: list .. py:method:: solve() A method to solve model .. py:method:: addConstr(coefs, rhs) A method to add new constraint :param coefs: coeffcients of new constraint :type coefs: ndarray :param rhs: right-hand side of new constraint :type rhs: float :returns: new model with the added constraint :rtype: optModel .. py:method:: relax() A method to get linear relaxation model .. py:class:: portfolioModel(num_assets, covariance, gamma=2.25) Bases: :py:obj:`pyepo.model.grb.grbmodel.optGrbModel` This class is an optimization model for portfolio problem .. attribute:: _model Gurobi model :type: GurobiPy model .. attribute:: num_assets number of assets :type: int .. attribute:: covariance covariance matrix of the returns :type: numpy.ndarray .. attribute:: risk_level risk level :type: float .. py:attribute:: num_assets .. py:attribute:: covariance .. py:attribute:: risk_level .. py:method:: _getRiskLevel(gamma) A method to calculate the risk level :returns: risk level :rtype: float .. py:method:: _getModel() A method to build Gurobi model :returns: optimization model and variables :rtype: tuple