Debian Codegraph @

doc/source/guides/how_to_elastic_constraints.rst

raw
1 Elastic Constraints
2 ^^^^^^^^^^^^^^^^^^^
3 .. currentmodule:: pulp
4
5 A constraint :math:`C(x) = c` (equality may be replaced by :math:`\le`
6 or :math:`\ge`)
7 can be elasticized to the form
8
9 .. math:: C(x) \in D
10
11 where :math:`D` denotes some interval containing the value
12 :math:`c`.
13
14 Define the constraint in two steps:
15
16 #. instantiate constraint (subclass of :class:`LpConstraint`) with target :math:`c`.
17 #. call its :meth:`~LpConstraint.makeElasticSubProblem` method which returns
18 an object of type :class:`FixedElasticSubProblem`
19 (subclass of :class:`LpProblem`) - its objective is the minimization
20 of the distance of :math:`C(x)` from :math:`D`.
21
22 .. code-block:: python
23
24 constraint = LpConstraint(..., rhs = c)
25 elasticProblem = constraint.makeElasticSubProblem(
26 penalty = <penalty_value>,
27 proportionFreeBound = <freebound_value>,
28 proportionFreeBoundList = <freebound_list_value>,
29 )
30
31 where:
32 * ``<penalty_value>`` is a real number
33 * ``<freebound_value>`` :math:`a \in [0,1]` specifies a symmetric
34 target interval :math:`D = (c(1-a),c(1+a))` about :math:`c`
35 * ``<freebound_list_value> = [a,b]``, a list of
36 proportions :math:`a, b \in [0,1]` specifying an asymmetric target
37 interval :math:`D = (c(1-a),c(1+b))` about :math:`c`
38
39 The penalty applies to the constraint at points :math:`x` where
40 :math:`C(x) \not \in D`.
41 The magnitude of ``<penalty_value>`` can be assessed by examining
42 the final objective function in the ``.lp`` file written by
43 :meth:`LpProblem.writeLP`.
44
45 Example:
46
47 >>> constraint_1 = LpConstraint('ex_1',sense=1,rhs=200)
48 >>> elasticProblem_1 = constraint_1.makeElasticSubproblem(penalty=1, proportionFreeBound = 0.01)
49 >>> constraint_2 = LpConstraint('ex_2',sense=0,rhs=500)
50 >>> elasticProblem_2 = constraint_2.makeElasticSubproblem(penalty=1,
51 proportionFreeBoundList = [0.02, 0.05])
52
53 #. constraint_1 has a penalty-free target interval of 1% either side of the rhs value, 200
54 #. constraint_2 has a penalty-free target interval of
55 - 2% on left and 5% on the right side of the rhs value, 500
56
57 .. image:: ../_static/freebound.*
58 :height: 5in
59 :alt: Freebound interval
60
61 Following are the methods of the return-value:
62