1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
=====================================
:mod:`pulp`: Pulp classes
=====================================
.. module:: pulp
.. currentmodule:: pulp
.. autosummary::
LpProblem
LpVariable
LpAffineExpression
LpConstraint
LpConstraint.makeElasticSubProblem
FixedElasticSubProblem
.. todo:: LpFractionConstraint, FractionElasticSubProblem
The LpProblem Class
-------------------
.. autoclass:: LpProblem
:show-inheritance:
Three important attributes of the problem are:
.. attribute:: objective
The objective of the problem, an :obj:`LpAffineExpression`
.. attribute:: constraints
An :class:`ordered dictionary<odict.OrderedDict>` of
:class:`constraints<LpConstraint>` of the problem - indexed by their names.
.. attribute:: status
The return :data:`status <pulp.constants.LpStatus>`
of the problem from the solver.
Some of the more important methods:
.. automethod:: solve
.. automethod:: roundSolution
.. automethod:: setObjective
.. automethod:: writeLP
.. automethod:: writeMPS
.. automethod:: toJson
.. automethod:: fromJson
.. automethod:: variables
Variables and Expressions
-------------------------
.. autoclass:: LpElement
:members:
----
.. autoclass:: LpVariable
:members:
Example:
>>> x = LpVariable('x',lowBound = 0, cat='Continuous')
>>> y = LpVariable('y', upBound = 5, cat='Integer')
gives :math:`x \in [0,\infty)`, :math:`y \in (-\infty, 5]`, an
integer.
----
.. autoclass:: LpAffineExpression
:show-inheritance:
:members:
In brief, :math:`\textsf{LpAffineExpression([(x[i],a[i]) for i in
I])} = \sum_{i \in I} a_i x_i` where (note the order):
* ``x[i]`` is an :class:`LpVariable`
* ``a[i]`` is a numerical coefficient.
----
.. autofunction:: lpSum
Constraints
-----------
.. autoclass:: LpConstraint
:show-inheritance:
:members:
.. autoclass:: FixedElasticSubProblem
:show-inheritance:
:members:
Combinations and Permutations
------------------------------
.. autofunction:: combination
.. autofunction:: allcombinations
.. autofunction:: permutation
.. autofunction:: allpermutations
.. autofunction:: value
|