pyepo.model.omo =============== .. py:module:: pyepo.model.omo .. autoapi-nested-parse:: Optimization Model based on Pyomo Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyepo/model/omo/knapsack/index /autoapi/pyepo/model/omo/omomodel/index /autoapi/pyepo/model/omo/portfolio/index /autoapi/pyepo/model/omo/shortestpath/index /autoapi/pyepo/model/omo/tsp/index Classes ------- .. autoapisummary:: pyepo.model.omo.optOmoModel pyepo.model.omo.shortestPathModel pyepo.model.omo.knapsackModel pyepo.model.omo.knapsackModelRel pyepo.model.omo.tspGGModel pyepo.model.omo.tspGGModelRel pyepo.model.omo.tspMTZModel pyepo.model.omo.tspMTZModelRel pyepo.model.omo.portfolioModel Package Contents ---------------- .. py:class:: optOmoModel(solver='glpk') Bases: :py:obj:`pyepo.model.opt.optModel` This is an abstract class for a Pyomo-based optimization model .. attribute:: _model Pyomo model :type: Pyomo model .. attribute:: solver optimization solver in the background :type: str .. py:attribute:: solver :value: 'glpk' .. py:method:: __repr__() .. py:method:: setObj(c) A method to set the objective function :param c: cost of objective function :type c: np.ndarray / list .. py:method:: solve() A method to solve the model :returns: optimal solution (list) and objective value (float) :rtype: tuple .. py:method:: copy() A method to copy the model :returns: new copied model :rtype: optModel .. py:method:: addConstr(coefs, rhs) A method to add a new constraint :param coefs: coefficients 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, solver='glpk') Bases: :py:obj:`pyepo.model.omo.omomodel.optOmoModel` This class is an optimization model for the shortest path problem .. attribute:: _model Pyomo model :type: Pyomo model .. attribute:: solver optimization solver in the background :type: str .. 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:: _getModel() A method to build Pyomo model .. py:class:: knapsackModel(weights, capacity, solver='glpk') Bases: :py:obj:`pyepo.model.omo.omomodel.optOmoModel` This class is an optimization model for the knapsack problem .. attribute:: _model Pyomo model :type: Pyomo model .. attribute:: solver optimization solver in the background :type: str .. attribute:: weights weights of items :type: np.ndarray .. attribute:: capacity total capacity :type: np.ndarray .. attribute:: items list of item index :type: list .. py:attribute:: weights .. py:attribute:: capacity .. py:attribute:: items .. py:method:: _getModel() A method to build Pyomo model .. py:method:: relax() A method to get linear relaxation model .. py:class:: knapsackModelRel(weights, capacity, solver='glpk') Bases: :py:obj:`knapsackModel` This class is relaxed optimization model for knapsack problem. .. py:method:: _getModel() A method to build Pyomo model .. py:method:: relax() A forbidden method to relax MIP model .. py:class:: tspGGModel(num_nodes, solver='glpk') Bases: :py:obj:`tspABModel` This class is an optimization model for the traveling salesman problem based on Gavish-Graves (GG) formulation. .. attribute:: _model Pyomo model :type: Pyomo model .. attribute:: solver optimization solver in the background :type: str .. attribute:: num_nodes Number of nodes :type: int .. attribute:: edges List of edge index :type: list .. py:method:: _getModel() A method to build Pyomo model :returns: optimization model and variables :rtype: tuple .. py:method:: setObj(c) A method to set the 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: coefficients 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:: tspGGModelRel(num_nodes, solver='glpk') Bases: :py:obj:`tspGGModel` This class is relaxation of tspGGModel. .. attribute:: _model Pyomo model :type: Pyomo model .. attribute:: solver optimization solver in the background :type: str .. attribute:: num_nodes Number of nodes :type: int .. attribute:: edges List of edge index :type: list .. py:method:: _getModel() A method to build Pyomo model :returns: optimization model and variables :rtype: tuple .. py:method:: solve() A method to solve model :returns: optimal solution (list) and objective value (float) :rtype: tuple .. py:method:: relax() A forbidden method to relax MIP model .. py:method:: getTour(sol) A forbidden method to get a tour from solution .. py:class:: tspMTZModel(num_nodes, solver='glpk') Bases: :py:obj:`tspABModel` This class is an optimization model for the traveling salesman problem based on Miller-Tucker-Zemlin (MTZ) formulation. .. attribute:: _model Pyomo model :type: Pyomo model .. attribute:: solver optimization solver in the background :type: str .. attribute:: num_nodes Number of nodes :type: int .. attribute:: edges List of edge index :type: list .. py:method:: _getModel() A method to build Pyomo model :returns: optimization model and variables :rtype: tuple .. py:method:: setObj(c) A method to set the 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: coefficients 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:: tspMTZModelRel(num_nodes, solver='glpk') Bases: :py:obj:`tspMTZModel` This class is relaxation of tspMTZModel. .. attribute:: _model Pyomo model :type: Pyomo model .. attribute:: solver optimization solver in the background :type: str .. attribute:: num_nodes Number of nodes :type: int .. attribute:: edges List of edge index :type: list .. py:method:: _getModel() A method to build Pyomo model :returns: optimization model and variables :rtype: tuple .. py:method:: solve() A method to solve model :returns: optimal solution (list) and objective value (float) :rtype: tuple .. py:method:: relax() A forbidden method to relax MIP model .. py:method:: getTour(sol) A forbidden method to get a tour from solution .. py:class:: portfolioModel(num_assets, covariance, gamma=2.25, solver='glpk') Bases: :py:obj:`pyepo.model.omo.omomodel.optOmoModel` This class is an optimization model for the portfolio problem .. attribute:: _model Pyomo model :type: Pyomo model .. attribute:: solver optimization solver in the background :type: str .. 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 :param gamma: risk level parameter :type gamma: float :returns: risk level :rtype: float .. py:method:: _getModel() A method to build Pyomo model :returns: optimization model and variables :rtype: tuple