PuLP 3.3.2__tar.gz → 4.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. pulp-4.0.0/PKG-INFO +314 -0
  2. pulp-4.0.0/README.rst +254 -0
  3. {pulp-3.3.2 → pulp-4.0.0}/pulp/__init__.py +4 -7
  4. pulp-4.0.0/pulp/_rustcore.pyi +221 -0
  5. {pulp-3.3.2 → pulp-4.0.0}/pulp/apis/__init__.py +79 -27
  6. pulp-3.3.2/pulp/apis/choco_api.py → pulp-4.0.0/pulp/apis/choco.py +34 -30
  7. pulp-4.0.0/pulp/apis/coin.py +992 -0
  8. pulp-3.3.2/pulp/apis/copt_api.py → pulp-4.0.0/pulp/apis/copt.py +234 -250
  9. pulp-4.0.0/pulp/apis/core.py +680 -0
  10. pulp-4.0.0/pulp/apis/cplex.py +657 -0
  11. pulp-4.0.0/pulp/apis/cuopt.py +245 -0
  12. pulp-4.0.0/pulp/apis/glpk.py +447 -0
  13. pulp-4.0.0/pulp/apis/gurobi.py +610 -0
  14. pulp-4.0.0/pulp/apis/highs.py +497 -0
  15. pulp-3.3.2/pulp/apis/mipcl_api.py → pulp-4.0.0/pulp/apis/mipcl.py +46 -34
  16. pulp-4.0.0/pulp/apis/mosek.py +350 -0
  17. pulp-4.0.0/pulp/apis/ortools.py +282 -0
  18. pulp-4.0.0/pulp/apis/sas.py +738 -0
  19. pulp-3.3.2/pulp/apis/scip_api.py → pulp-4.0.0/pulp/apis/scip.py +267 -301
  20. pulp-3.3.2/pulp/apis/xpress_api.py → pulp-4.0.0/pulp/apis/xpress.py +283 -287
  21. {pulp-3.3.2 → pulp-4.0.0}/pulp/constants.py +31 -35
  22. pulp-4.0.0/pulp/core/__init__.py +24 -0
  23. pulp-4.0.0/pulp/core/_internal.py +74 -0
  24. pulp-4.0.0/pulp/core/linear.py +98 -0
  25. pulp-4.0.0/pulp/core/lp_affine_expression.py +470 -0
  26. pulp-4.0.0/pulp/core/lp_constraint.py +205 -0
  27. pulp-4.0.0/pulp/core/lp_problem.py +927 -0
  28. pulp-4.0.0/pulp/core/lp_stats.py +321 -0
  29. pulp-4.0.0/pulp/core/lp_variable.py +345 -0
  30. pulp-4.0.0/pulp/mps_lp.py +241 -0
  31. pulp-4.0.0/pulp/pulp.py +138 -0
  32. pulp-4.0.0/pulp/rust/Cargo.lock +155 -0
  33. pulp-4.0.0/pulp/rust/Cargo.toml +16 -0
  34. pulp-4.0.0/pulp/rust/src/affine_expr.rs +492 -0
  35. pulp-4.0.0/pulp/rust/src/constraint.rs +203 -0
  36. pulp-4.0.0/pulp/rust/src/format.rs +441 -0
  37. pulp-4.0.0/pulp/rust/src/io.rs +1516 -0
  38. pulp-4.0.0/pulp/rust/src/lib.rs +42 -0
  39. pulp-4.0.0/pulp/rust/src/model.rs +443 -0
  40. pulp-4.0.0/pulp/rust/src/types.rs +387 -0
  41. pulp-4.0.0/pulp/rust/src/variable.rs +275 -0
  42. {pulp-3.3.2 → pulp-4.0.0}/pulp/sparse.py +15 -13
  43. {pulp-3.3.2 → pulp-4.0.0}/pulp/tests/__init__.py +2 -0
  44. {pulp-3.3.2 → pulp-4.0.0}/pulp/tests/bin_packing_problem.py +17 -10
  45. {pulp-3.3.2 → pulp-4.0.0}/pulp/tests/run_tests.py +1 -10
  46. pulp-4.0.0/pulp/tests/solver_common.py +954 -0
  47. pulp-4.0.0/pulp/tests/test_add_solver.py +60 -0
  48. pulp-4.0.0/pulp/tests/test_choco_cmd.py +25 -0
  49. pulp-4.0.0/pulp/tests/test_coin_cmd.py +323 -0
  50. pulp-4.0.0/pulp/tests/test_coinmp_dll.py +20 -0
  51. pulp-4.0.0/pulp/tests/test_copt.py +22 -0
  52. pulp-4.0.0/pulp/tests/test_cplex_cmd.py +70 -0
  53. pulp-4.0.0/pulp/tests/test_cplex_py.py +97 -0
  54. pulp-4.0.0/pulp/tests/test_cpsat.py +128 -0
  55. pulp-4.0.0/pulp/tests/test_cuopt.py +22 -0
  56. {pulp-3.3.2 → pulp-4.0.0}/pulp/tests/test_examples.py +2 -1
  57. pulp-4.0.0/pulp/tests/test_fscip_cmd.py +45 -0
  58. pulp-4.0.0/pulp/tests/test_glpk_cmd.py +73 -0
  59. pulp-4.0.0/pulp/tests/test_gurobi.py +17 -0
  60. pulp-4.0.0/pulp/tests/test_gurobi_cmd.py +43 -0
  61. {pulp-3.3.2 → pulp-4.0.0}/pulp/tests/test_gurobipy_env.py +18 -17
  62. pulp-4.0.0/pulp/tests/test_highs.py +54 -0
  63. pulp-4.0.0/pulp/tests/test_highs_cmd.py +32 -0
  64. pulp-4.0.0/pulp/tests/test_lpdot.py +26 -0
  65. pulp-4.0.0/pulp/tests/test_mipcl_cmd.py +23 -0
  66. pulp-4.0.0/pulp/tests/test_mosek.py +22 -0
  67. pulp-4.0.0/pulp/tests/test_pulp.py +1483 -0
  68. pulp-4.0.0/pulp/tests/test_pyglpk.py +18 -0
  69. pulp-4.0.0/pulp/tests/test_rust_core.py +26 -0
  70. pulp-4.0.0/pulp/tests/test_sas94.py +19 -0
  71. pulp-4.0.0/pulp/tests/test_sascas.py +19 -0
  72. pulp-4.0.0/pulp/tests/test_scip_cmd.py +39 -0
  73. pulp-4.0.0/pulp/tests/test_scip_py.py +36 -0
  74. pulp-4.0.0/pulp/tests/test_solve_stats.py +538 -0
  75. pulp-4.0.0/pulp/tests/test_solver_logs.py +156 -0
  76. pulp-4.0.0/pulp/tests/test_source_checkout.py +79 -0
  77. pulp-4.0.0/pulp/tests/test_write_lp.py +265 -0
  78. pulp-4.0.0/pulp/tests/test_write_mps.py +26 -0
  79. pulp-4.0.0/pulp/tests/test_xpress_cmd.py +16 -0
  80. pulp-4.0.0/pulp/tests/test_xpress_py.py +10 -0
  81. pulp-4.0.0/pulp/tests/test_yaposib.py +22 -0
  82. {pulp-3.3.2 → pulp-4.0.0}/pulp/utilities.py +24 -12
  83. pulp-4.0.0/pyproject.toml +149 -0
  84. pulp-3.3.2/PKG-INFO +0 -228
  85. pulp-3.3.2/PuLP.egg-info/PKG-INFO +0 -228
  86. pulp-3.3.2/PuLP.egg-info/SOURCES.txt +0 -58
  87. pulp-3.3.2/PuLP.egg-info/dependency_links.txt +0 -1
  88. pulp-3.3.2/PuLP.egg-info/entry_points.txt +0 -2
  89. pulp-3.3.2/PuLP.egg-info/requires.txt +0 -38
  90. pulp-3.3.2/PuLP.egg-info/top_level.txt +0 -1
  91. pulp-3.3.2/README.rst +0 -182
  92. pulp-3.3.2/pulp/apis/coin_api.py +0 -1044
  93. pulp-3.3.2/pulp/apis/core.py +0 -400
  94. pulp-3.3.2/pulp/apis/cplex_api.py +0 -639
  95. pulp-3.3.2/pulp/apis/cuopt_api.py +0 -279
  96. pulp-3.3.2/pulp/apis/glpk_api.py +0 -455
  97. pulp-3.3.2/pulp/apis/gurobi_api.py +0 -550
  98. pulp-3.3.2/pulp/apis/highs_api.py +0 -540
  99. pulp-3.3.2/pulp/apis/mosek_api.py +0 -345
  100. pulp-3.3.2/pulp/apis/sas_api.py +0 -746
  101. pulp-3.3.2/pulp/mps_lp.py +0 -527
  102. pulp-3.3.2/pulp/pulp.py +0 -2814
  103. pulp-3.3.2/pulp/solverdir/cbc/linux/arm64/__init__.py +0 -0
  104. pulp-3.3.2/pulp/solverdir/cbc/linux/arm64/cbc +0 -0
  105. pulp-3.3.2/pulp/solverdir/cbc/linux/arm64/coin-license.txt +0 -239
  106. pulp-3.3.2/pulp/solverdir/cbc/linux/i32/__init__.py +0 -0
  107. pulp-3.3.2/pulp/solverdir/cbc/linux/i32/cbc +0 -0
  108. pulp-3.3.2/pulp/solverdir/cbc/linux/i32/coin-license.txt +0 -239
  109. pulp-3.3.2/pulp/solverdir/cbc/linux/i64/__init__.py +0 -0
  110. pulp-3.3.2/pulp/solverdir/cbc/linux/i64/cbc +0 -0
  111. pulp-3.3.2/pulp/solverdir/cbc/linux/i64/coin-license.txt +0 -239
  112. pulp-3.3.2/pulp/solverdir/cbc/osx/i64/__init__.py +0 -0
  113. pulp-3.3.2/pulp/solverdir/cbc/osx/i64/cbc +0 -0
  114. pulp-3.3.2/pulp/solverdir/cbc/osx/i64/coin-license.txt +0 -239
  115. pulp-3.3.2/pulp/solverdir/cbc/win/i32/__init__.py +0 -0
  116. pulp-3.3.2/pulp/solverdir/cbc/win/i32/cbc.exe +0 -0
  117. pulp-3.3.2/pulp/solverdir/cbc/win/i32/coin-license.txt +0 -239
  118. pulp-3.3.2/pulp/solverdir/cbc/win/i64/__init__.py +0 -0
  119. pulp-3.3.2/pulp/solverdir/cbc/win/i64/cbc.exe +0 -0
  120. pulp-3.3.2/pulp/solverdir/cbc/win/i64/coin-license.txt +0 -239
  121. pulp-3.3.2/pulp/tests/test_lpdot.py +0 -24
  122. pulp-3.3.2/pulp/tests/test_pulp.py +0 -2594
  123. pulp-3.3.2/pulp/v4_migration.py +0 -19
  124. pulp-3.3.2/pyproject.toml +0 -103
  125. pulp-3.3.2/setup.cfg +0 -4
  126. {pulp-3.3.2 → pulp-4.0.0}/LICENSE +0 -0
  127. /pulp-3.3.2/pulp/solverdir/__init__.py → /pulp-4.0.0/pulp/py.typed +0 -0
  128. {pulp-3.3.2 → pulp-4.0.0}/pulp/tests/test_sparse.py +0 -0
pulp-4.0.0/PKG-INFO ADDED
@@ -0,0 +1,314 @@
1
+ Metadata-Version: 2.4
2
+ Name: PuLP
3
+ Version: 4.0.0
4
+ Classifier: Development Status :: 5 - Production/Stable
5
+ Classifier: Environment :: Console
6
+ Classifier: Intended Audience :: Science/Research
7
+ Classifier: Natural Language :: English
8
+ Classifier: Programming Language :: Python
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
14
+ Requires-Dist: orloge>=1.0.0
15
+ Requires-Dist: cbcbox ; extra == 'cbc'
16
+ Requires-Dist: coptpy ; python_full_version < '3.14' and extra == 'copt'
17
+ Requires-Dist: cplex ; (sys_platform != 'darwin' and extra == 'cplex') or (platform_machine == 'arm64' and extra == 'cplex')
18
+ Requires-Dist: swiglpk ; extra == 'glpk'
19
+ Requires-Dist: gurobipy ; extra == 'gurobi'
20
+ Requires-Dist: highspy<1.14 ; extra == 'highs'
21
+ Requires-Dist: highsbox ; extra == 'highs-cmd'
22
+ Requires-Dist: mosek ; extra == 'mosek'
23
+ Requires-Dist: highspy<1.14 ; extra == 'open-py'
24
+ Requires-Dist: pyscipopt ; extra == 'open-py'
25
+ Requires-Dist: cbcbox ; extra == 'open-py'
26
+ Requires-Dist: swiglpk ; extra == 'open-py'
27
+ Requires-Dist: ortools ; extra == 'ortools'
28
+ Requires-Dist: gurobipy ; extra == 'public-py'
29
+ Requires-Dist: coptpy ; python_full_version < '3.14' and extra == 'public-py'
30
+ Requires-Dist: xpress ; extra == 'public-py'
31
+ Requires-Dist: cplex ; (sys_platform != 'darwin' and extra == 'public-py') or (platform_machine == 'arm64' and extra == 'public-py')
32
+ Requires-Dist: pyscipopt ; extra == 'scip'
33
+ Requires-Dist: xpress ; extra == 'xpress'
34
+ Provides-Extra: cbc
35
+ Provides-Extra: copt
36
+ Provides-Extra: cplex
37
+ Provides-Extra: glpk
38
+ Provides-Extra: gurobi
39
+ Provides-Extra: highs
40
+ Provides-Extra: highs_cmd
41
+ Provides-Extra: mosek
42
+ Provides-Extra: open_py
43
+ Provides-Extra: ortools
44
+ Provides-Extra: public_py
45
+ Provides-Extra: scip
46
+ Provides-Extra: xpress
47
+ License-File: LICENSE
48
+ Summary: PuLP is an LP modeler written in python. PuLP can generate MPS or LP files and call GLPK, COIN CLP/CBC, CPLEX, and GUROBI to solve linear problems.
49
+ Keywords: Optimization,Linear Programming,Operations Research
50
+ Author: J.S. Roy
51
+ Author-email: "S.A. Mitchell" <pulp@stuartmitchell.com>, Franco Peschiera <pchtsp@gmail.com>
52
+ Maintainer-email: Franco Peschiera <pchtsp@gmail.com>
53
+ License-Expression: MIT
54
+ Requires-Python: >=3.12
55
+ Description-Content-Type: text/x-rst; charset=UTF-8
56
+ Project-URL: download, https://github.com/coin-or/pulp/archive/master.zip
57
+ Project-URL: forum, https://groups.google.com/g/pulp-or-discuss
58
+ Project-URL: source, https://github.com/coin-or/pulp
59
+
60
+ pulp
61
+ **************************
62
+
63
+ .. image:: https://travis-ci.org/coin-or/pulp.svg?branch=master
64
+ :target: https://travis-ci.org/coin-or/pulp
65
+ .. image:: https://img.shields.io/pypi/v/pulp
66
+ :target: https://pypi.org/project/PuLP/
67
+ :alt: PyPI
68
+ .. image:: https://img.shields.io/pypi/dm/pulp
69
+ :target: https://pypi.org/project/PuLP/
70
+ :alt: PyPI - Downloads
71
+
72
+ PuLP is an linear and mixed integer programming modeler written in Python. With PuLP, it is simple to create MILP optimisation problems and solve them with the latest open-source (or proprietary) solvers. PuLP can generate MPS or LP files and call solvers such as GLPK_, COIN-OR CLP/`CBC`_, CPLEX_, GUROBI_, MOSEK_, XPRESS_, CHOCO_, MIPCL_, HiGHS_, SCIP_/FSCIP_, and OR-Tools `CP-SAT`_ (via the ``CPSAT`` API).
73
+
74
+ The documentation for PuLP can be `found here <https://coin-or.github.io/pulp/>`_.
75
+
76
+ PuLP is part of the `COIN-OR project <https://www.coin-or.org/>`_.
77
+
78
+ .. note::
79
+
80
+ **Upgrading from PuLP 3.x?** PuLP 4.0 has breaking changes: variables are
81
+ created with ``prob.add_variable(...)``, ``prob.constraints()`` returns a list,
82
+ and ``prob.solve()`` returns an ``LpSolveStats`` object instead of a status
83
+ code. See the `guide to migrate from PuLP 3.x to 4.0
84
+ <https://coin-or.github.io/pulp/guides/how_to_migrate_to_v4.html>`_
85
+ (source: `doc/source/guides/how_to_migrate_to_v4.rst
86
+ <https://github.com/coin-or/pulp/blob/master/doc/source/guides/how_to_migrate_to_v4.rst>`_).
87
+
88
+ .. important::
89
+
90
+ **CBC is not shipped inside the PuLP package.** Older releases bundled a CBC
91
+ binary and exposed it as ``PULP_CBC_CMD``; that API and the bundled solver are
92
+ **removed**. To solve models with CBC through PuLP you should:
93
+
94
+ * install PuLP with the optional CBC extra: ``python -m pip install pulp[cbc]``
95
+ (this installs the `cbcbox <https://pypi.org/project/cbcbox/>`_ wheel, which
96
+ provides a CBC executable PuLP can find automatically), **or**
97
+ * install a CBC build yourself and ensure the ``cbc`` (or ``cbc.exe`` on
98
+ Windows) executable is on your ``PATH``,
99
+
100
+ then use the ``COIN_CMD`` solver (or call ``prob.solve()`` with no arguments
101
+ when CBC is available; otherwise install another solver such as GLPK or pass
102
+ an explicit solver). Without CBC or another available solver, the default
103
+ solve path will raise ``PulpError: No solver available``.
104
+
105
+ Installation
106
+ ================
107
+
108
+ PuLP requires Python 3.12 or newer.
109
+
110
+ **Recommended:** install with CBC support::
111
+
112
+ python -m pip install pulp[cbc]
113
+
114
+ Plain ``python -m pip install pulp`` installs only the modeler; you must then
115
+ supply your own CBC on ``PATH`` or another solver.
116
+
117
+ Otherwise follow the download instructions on the `PyPi page <https://pypi.python.org/pypi/PuLP>`_.
118
+
119
+ Installing solvers
120
+ ----------------------
121
+
122
+ PuLP can use a variety of solvers. When CBC is available (via ``pulp[cbc]`` or
123
+ ``cbc`` on ``PATH``), ``COIN_CMD`` is the usual open-source MIP/LP choice and is
124
+ selected as the default ahead of GLPK. PuLP can also install other solvers via
125
+ optional PyPI extras (some require a commercial license for running or for large models)::
126
+
127
+ python -m pip install pulp[gurobi]
128
+ python -m pip install pulp[cplex]
129
+ python -m pip install pulp[xpress]
130
+ python -m pip install pulp[scip]
131
+ python -m pip install pulp[highs]
132
+ python -m pip install pulp[copt]
133
+ python -m pip install pulp[mosek]
134
+ python -m pip install pulp[ortools]
135
+ python -m pip install pulp[cylp]
136
+ python -m pip install pulp[cbc]
137
+ python -m pip install pulp[glpk]
138
+
139
+ If you want to install all open source solvers (scip, highs, cbc, glpk), you can use the shortcut::
140
+ python -m pip install pulp[open_py]
141
+
142
+ For more information on how to install solvers, see the `guide on configuring solvers <https://coin-or.github.io/pulp/guides/how_to_configure_solvers.html>`_.
143
+
144
+ Quickstart
145
+ ===============
146
+
147
+ Use ``LpProblem`` to create a problem, then add variables with ``add_variable``. Create a problem called "myProblem" and a variable x with 0 ≤ x ≤ 3::
148
+
149
+ from pulp import *
150
+ prob = LpProblem("myProblem", LpMinimize)
151
+ x = prob.add_variable("x", 0, 3)
152
+
153
+ To create a binary variable y (values 0 or 1)::
154
+
155
+ y = prob.add_variable("y", cat="Binary")
156
+
157
+ Combine variables to create expressions and constraints and add them to the problem::
158
+
159
+ prob += x + y <= 2
160
+
161
+ An expression is a constraint without a right-hand side (RHS) sense (one of ``=``, ``<=`` or ``>=``). If you add an expression to a problem, it will become the objective::
162
+
163
+ prob += -4*x + y
164
+
165
+ To solve the problem with the default solver (CBC when installed via ``pulp[cbc]``
166
+ or ``cbc`` on ``PATH``, otherwise another available backend)::
167
+
168
+ stats = prob.solve()
169
+
170
+ If you want to try another solver to solve the problem::
171
+
172
+ stats = prob.solve(GLPK(msg = 0))
173
+
174
+ ``GLPK`` uses GLPK's command-line tool (``glpsol``) and requires it to be on
175
+ your ``PATH``. To use GLPK's python API instead, install
176
+ ``python -m pip install pulp[glpk]`` and use ``PYGLPK``::
177
+
178
+ status = prob.solve(PYGLPK(msg = 0))
179
+
180
+ To use the OR-Tools CP-SAT solver (install with ``python -m pip install pulp[ortools]``).
181
+ Every variable must have finite lower and upper bounds; continuous variables are
182
+ solved on their integer-rounded domain::
183
+
184
+ from pulp import CPSAT
185
+ stats = prob.solve(CPSAT(msg=False))
186
+
187
+ Display the status of the solution::
188
+
189
+ stats.status_str
190
+ > 'Optimal'
191
+
192
+ You can get the value of the variables using ``value``. ex::
193
+
194
+ value(x)
195
+ > 2.0
196
+
197
+
198
+ Essential Classes
199
+ ------------------
200
+
201
+ These types form the usual modelling workflow: create an ``LpProblem``, attach
202
+ ``LpVariable`` instances with ``add_variable``, build linear expressions (often
203
+ with ``lpSum`` / ``lpDot`` / ``lpSum_vars`` / ``lpSum_vars_coefs``), combine them
204
+ into ``LpConstraint`` rows, and call ``solve``.
205
+
206
+ * ``LpProblem`` -- Container for an LP or MIP: variables, objective, constraints, and solve API
207
+ * ``LpVariable`` -- A decision variable belonging to one problem; used inside expressions and constraints
208
+ * ``LpAffineExpression`` -- A linear combination of variables and a constant (objectives, constraint bodies, intermediate terms)
209
+ * ``LpConstraint`` -- A single row relating an affine expression to a bound with ``<=``, ``=``, or ``>=``:
210
+
211
+ a1x1 + a2x2 + ... + anxn (<=, =, >=) b
212
+
213
+ Useful Functions
214
+ ------------------
215
+
216
+ * ``value()`` -- Finds the value of a variable or expression
217
+ * ``lpSum()`` -- Given a list of the form [a1*x1, a2*x2, ..., an*xn] will construct a linear expression to be used as a constraint or variable
218
+ * ``lpDot()`` -- Given two lists of the form [a1, a2, ..., an] and [x1, x2, ..., xn] will construct a linear expression to be used as a constraint or variable
219
+ * ``lpSum_vars()`` -- Sum of variables with coefficient 1 each (batch construction)
220
+ * ``lpSum_vars_coefs()`` -- Sum of ``coeff * var`` pairs from an iterable of ``(variable, coefficient)`` (batch construction)
221
+
222
+ More Examples
223
+ ================
224
+
225
+ Several tutorial are given in `documentation <https://coin-or.github.io/pulp/CaseStudies/index.html>`_ and pure code examples are available in `examples/ directory <https://github.com/coin-or/pulp/tree/master/examples>`_ .
226
+
227
+ The examples assume CBC is available (for example after ``pip install pulp[cbc]``).
228
+ To use other solvers they must be available (installed and accessible). For more
229
+ information, see the `guide on configuring solvers <https://coin-or.github.io/pulp/guides/how_to_configure_solvers.html>`_.
230
+
231
+
232
+ For Developers
233
+ ================
234
+
235
+ If you want to install the latest version from GitHub you can run::
236
+
237
+ python -m pip install -U "pulp[cbc] @ git+https://github.com/coin-or/pulp.git"
238
+
239
+ Building from source
240
+ --------------------------
241
+
242
+ This version of PuLP includes a Rust extension (``pulp._rustcore``) that provides the core model, variables, constraints, and expressions. The build uses `maturin <https://github.com/PyO3/maturin>`_ and requires a Rust toolchain in addition to Python.
243
+
244
+ **Requirements**
245
+
246
+ * **Python** 3.12 or newer
247
+ * **Rust** (latest stable). Install from https://rustup.rs/
248
+ * **uv** (recommended for install and dev). See the `uv documentation <https://docs.astral.sh/uv/>`_ for installation.
249
+ * **OS**: Windows, macOS (x86_64, arm64), or Linux (x86_64, arm64). The Rust extension is built for the host platform.
250
+
251
+ **Build steps**
252
+
253
+ From the PuLP root directory, create a virtual environment and install the package in editable mode with dev dependencies::
254
+
255
+ uv venv
256
+ uv pip install --group dev -e .[cbc]
257
+
258
+ Or with plain pip (maturin will be used automatically by the build backend)::
259
+
260
+ python -m venv .venv
261
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
262
+ python -m pip install --upgrade pip
263
+ python -m pip install -e ".[cbc]"
264
+
265
+ **Running tests**
266
+
267
+ ::
268
+
269
+ uv run python -m unittest discover -s pulp/tests -v
270
+
271
+ Building the documentation
272
+ --------------------------
273
+
274
+ The PuLP documentation is built with `Sphinx <https://www.sphinx-doc.org>`_. Use a virtual environment and the dev install above, then::
275
+
276
+ cd doc
277
+ make html
278
+
279
+ A folder named ``html`` will be created inside ``doc/build/``. Open ``doc/build/html/index.html`` in a browser.
280
+
281
+ Contributing to PuLP
282
+ -----------------------
283
+ Instructions for making your first contribution to PuLP are given `here <https://coin-or.github.io/pulp/develop/contribute.html>`_.
284
+
285
+ **Comments, bug reports, patches and suggestions are very welcome!**
286
+
287
+ * Comments and suggestions: https://github.com/coin-or/pulp/discussions
288
+ * `PuLP Google Group <https://groups.google.com/g/pulp-or-discuss>`_ — community discussion and Q&A
289
+ * Bug reports: https://github.com/coin-or/pulp/issues
290
+ * Patches: https://github.com/coin-or/pulp/pulls
291
+
292
+ Copyright and License
293
+ =======================
294
+ PuLP is distributed under an MIT license.
295
+
296
+ Copyright J.S. Roy, 2003-2005
297
+ Copyright Stuart A. Mitchell
298
+ See the LICENSE file for copyright information.
299
+
300
+ .. _Python: http://www.python.org/
301
+
302
+ .. _GLPK: http://www.gnu.org/software/glpk/glpk.html
303
+ .. _CBC: https://github.com/coin-or/Cbc
304
+ .. _CPLEX: http://www.cplex.com/
305
+ .. _GUROBI: http://www.gurobi.com/
306
+ .. _MOSEK: https://www.mosek.com/
307
+ .. _XPRESS: https://www.fico.com/es/products/fico-xpress-solver
308
+ .. _CHOCO: https://choco-solver.org/
309
+ .. _MIPCL: http://mipcl-cpp.appspot.com/
310
+ .. _SCIP: https://www.scipopt.org/
311
+ .. _HiGHS: https://highs.dev
312
+ .. _FSCIP: https://ug.zib.de
313
+ .. _CP-SAT: https://developers.google.com/optimization/cp/cp_solver
314
+
pulp-4.0.0/README.rst ADDED
@@ -0,0 +1,254 @@
1
+ pulp
2
+ **************************
3
+
4
+ .. image:: https://travis-ci.org/coin-or/pulp.svg?branch=master
5
+ :target: https://travis-ci.org/coin-or/pulp
6
+ .. image:: https://img.shields.io/pypi/v/pulp
7
+ :target: https://pypi.org/project/PuLP/
8
+ :alt: PyPI
9
+ .. image:: https://img.shields.io/pypi/dm/pulp
10
+ :target: https://pypi.org/project/PuLP/
11
+ :alt: PyPI - Downloads
12
+
13
+ PuLP is an linear and mixed integer programming modeler written in Python. With PuLP, it is simple to create MILP optimisation problems and solve them with the latest open-source (or proprietary) solvers. PuLP can generate MPS or LP files and call solvers such as GLPK_, COIN-OR CLP/`CBC`_, CPLEX_, GUROBI_, MOSEK_, XPRESS_, CHOCO_, MIPCL_, HiGHS_, SCIP_/FSCIP_, and OR-Tools `CP-SAT`_ (via the ``CPSAT`` API).
14
+
15
+ The documentation for PuLP can be `found here <https://coin-or.github.io/pulp/>`_.
16
+
17
+ PuLP is part of the `COIN-OR project <https://www.coin-or.org/>`_.
18
+
19
+ .. note::
20
+
21
+ **Upgrading from PuLP 3.x?** PuLP 4.0 has breaking changes: variables are
22
+ created with ``prob.add_variable(...)``, ``prob.constraints()`` returns a list,
23
+ and ``prob.solve()`` returns an ``LpSolveStats`` object instead of a status
24
+ code. See the `guide to migrate from PuLP 3.x to 4.0
25
+ <https://coin-or.github.io/pulp/guides/how_to_migrate_to_v4.html>`_
26
+ (source: `doc/source/guides/how_to_migrate_to_v4.rst
27
+ <https://github.com/coin-or/pulp/blob/master/doc/source/guides/how_to_migrate_to_v4.rst>`_).
28
+
29
+ .. important::
30
+
31
+ **CBC is not shipped inside the PuLP package.** Older releases bundled a CBC
32
+ binary and exposed it as ``PULP_CBC_CMD``; that API and the bundled solver are
33
+ **removed**. To solve models with CBC through PuLP you should:
34
+
35
+ * install PuLP with the optional CBC extra: ``python -m pip install pulp[cbc]``
36
+ (this installs the `cbcbox <https://pypi.org/project/cbcbox/>`_ wheel, which
37
+ provides a CBC executable PuLP can find automatically), **or**
38
+ * install a CBC build yourself and ensure the ``cbc`` (or ``cbc.exe`` on
39
+ Windows) executable is on your ``PATH``,
40
+
41
+ then use the ``COIN_CMD`` solver (or call ``prob.solve()`` with no arguments
42
+ when CBC is available; otherwise install another solver such as GLPK or pass
43
+ an explicit solver). Without CBC or another available solver, the default
44
+ solve path will raise ``PulpError: No solver available``.
45
+
46
+ Installation
47
+ ================
48
+
49
+ PuLP requires Python 3.12 or newer.
50
+
51
+ **Recommended:** install with CBC support::
52
+
53
+ python -m pip install pulp[cbc]
54
+
55
+ Plain ``python -m pip install pulp`` installs only the modeler; you must then
56
+ supply your own CBC on ``PATH`` or another solver.
57
+
58
+ Otherwise follow the download instructions on the `PyPi page <https://pypi.python.org/pypi/PuLP>`_.
59
+
60
+ Installing solvers
61
+ ----------------------
62
+
63
+ PuLP can use a variety of solvers. When CBC is available (via ``pulp[cbc]`` or
64
+ ``cbc`` on ``PATH``), ``COIN_CMD`` is the usual open-source MIP/LP choice and is
65
+ selected as the default ahead of GLPK. PuLP can also install other solvers via
66
+ optional PyPI extras (some require a commercial license for running or for large models)::
67
+
68
+ python -m pip install pulp[gurobi]
69
+ python -m pip install pulp[cplex]
70
+ python -m pip install pulp[xpress]
71
+ python -m pip install pulp[scip]
72
+ python -m pip install pulp[highs]
73
+ python -m pip install pulp[copt]
74
+ python -m pip install pulp[mosek]
75
+ python -m pip install pulp[ortools]
76
+ python -m pip install pulp[cylp]
77
+ python -m pip install pulp[cbc]
78
+ python -m pip install pulp[glpk]
79
+
80
+ If you want to install all open source solvers (scip, highs, cbc, glpk), you can use the shortcut::
81
+ python -m pip install pulp[open_py]
82
+
83
+ For more information on how to install solvers, see the `guide on configuring solvers <https://coin-or.github.io/pulp/guides/how_to_configure_solvers.html>`_.
84
+
85
+ Quickstart
86
+ ===============
87
+
88
+ Use ``LpProblem`` to create a problem, then add variables with ``add_variable``. Create a problem called "myProblem" and a variable x with 0 ≤ x ≤ 3::
89
+
90
+ from pulp import *
91
+ prob = LpProblem("myProblem", LpMinimize)
92
+ x = prob.add_variable("x", 0, 3)
93
+
94
+ To create a binary variable y (values 0 or 1)::
95
+
96
+ y = prob.add_variable("y", cat="Binary")
97
+
98
+ Combine variables to create expressions and constraints and add them to the problem::
99
+
100
+ prob += x + y <= 2
101
+
102
+ An expression is a constraint without a right-hand side (RHS) sense (one of ``=``, ``<=`` or ``>=``). If you add an expression to a problem, it will become the objective::
103
+
104
+ prob += -4*x + y
105
+
106
+ To solve the problem with the default solver (CBC when installed via ``pulp[cbc]``
107
+ or ``cbc`` on ``PATH``, otherwise another available backend)::
108
+
109
+ stats = prob.solve()
110
+
111
+ If you want to try another solver to solve the problem::
112
+
113
+ stats = prob.solve(GLPK(msg = 0))
114
+
115
+ ``GLPK`` uses GLPK's command-line tool (``glpsol``) and requires it to be on
116
+ your ``PATH``. To use GLPK's python API instead, install
117
+ ``python -m pip install pulp[glpk]`` and use ``PYGLPK``::
118
+
119
+ status = prob.solve(PYGLPK(msg = 0))
120
+
121
+ To use the OR-Tools CP-SAT solver (install with ``python -m pip install pulp[ortools]``).
122
+ Every variable must have finite lower and upper bounds; continuous variables are
123
+ solved on their integer-rounded domain::
124
+
125
+ from pulp import CPSAT
126
+ stats = prob.solve(CPSAT(msg=False))
127
+
128
+ Display the status of the solution::
129
+
130
+ stats.status_str
131
+ > 'Optimal'
132
+
133
+ You can get the value of the variables using ``value``. ex::
134
+
135
+ value(x)
136
+ > 2.0
137
+
138
+
139
+ Essential Classes
140
+ ------------------
141
+
142
+ These types form the usual modelling workflow: create an ``LpProblem``, attach
143
+ ``LpVariable`` instances with ``add_variable``, build linear expressions (often
144
+ with ``lpSum`` / ``lpDot`` / ``lpSum_vars`` / ``lpSum_vars_coefs``), combine them
145
+ into ``LpConstraint`` rows, and call ``solve``.
146
+
147
+ * ``LpProblem`` -- Container for an LP or MIP: variables, objective, constraints, and solve API
148
+ * ``LpVariable`` -- A decision variable belonging to one problem; used inside expressions and constraints
149
+ * ``LpAffineExpression`` -- A linear combination of variables and a constant (objectives, constraint bodies, intermediate terms)
150
+ * ``LpConstraint`` -- A single row relating an affine expression to a bound with ``<=``, ``=``, or ``>=``:
151
+
152
+ a1x1 + a2x2 + ... + anxn (<=, =, >=) b
153
+
154
+ Useful Functions
155
+ ------------------
156
+
157
+ * ``value()`` -- Finds the value of a variable or expression
158
+ * ``lpSum()`` -- Given a list of the form [a1*x1, a2*x2, ..., an*xn] will construct a linear expression to be used as a constraint or variable
159
+ * ``lpDot()`` -- Given two lists of the form [a1, a2, ..., an] and [x1, x2, ..., xn] will construct a linear expression to be used as a constraint or variable
160
+ * ``lpSum_vars()`` -- Sum of variables with coefficient 1 each (batch construction)
161
+ * ``lpSum_vars_coefs()`` -- Sum of ``coeff * var`` pairs from an iterable of ``(variable, coefficient)`` (batch construction)
162
+
163
+ More Examples
164
+ ================
165
+
166
+ Several tutorial are given in `documentation <https://coin-or.github.io/pulp/CaseStudies/index.html>`_ and pure code examples are available in `examples/ directory <https://github.com/coin-or/pulp/tree/master/examples>`_ .
167
+
168
+ The examples assume CBC is available (for example after ``pip install pulp[cbc]``).
169
+ To use other solvers they must be available (installed and accessible). For more
170
+ information, see the `guide on configuring solvers <https://coin-or.github.io/pulp/guides/how_to_configure_solvers.html>`_.
171
+
172
+
173
+ For Developers
174
+ ================
175
+
176
+ If you want to install the latest version from GitHub you can run::
177
+
178
+ python -m pip install -U "pulp[cbc] @ git+https://github.com/coin-or/pulp.git"
179
+
180
+ Building from source
181
+ --------------------------
182
+
183
+ This version of PuLP includes a Rust extension (``pulp._rustcore``) that provides the core model, variables, constraints, and expressions. The build uses `maturin <https://github.com/PyO3/maturin>`_ and requires a Rust toolchain in addition to Python.
184
+
185
+ **Requirements**
186
+
187
+ * **Python** 3.12 or newer
188
+ * **Rust** (latest stable). Install from https://rustup.rs/
189
+ * **uv** (recommended for install and dev). See the `uv documentation <https://docs.astral.sh/uv/>`_ for installation.
190
+ * **OS**: Windows, macOS (x86_64, arm64), or Linux (x86_64, arm64). The Rust extension is built for the host platform.
191
+
192
+ **Build steps**
193
+
194
+ From the PuLP root directory, create a virtual environment and install the package in editable mode with dev dependencies::
195
+
196
+ uv venv
197
+ uv pip install --group dev -e .[cbc]
198
+
199
+ Or with plain pip (maturin will be used automatically by the build backend)::
200
+
201
+ python -m venv .venv
202
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
203
+ python -m pip install --upgrade pip
204
+ python -m pip install -e ".[cbc]"
205
+
206
+ **Running tests**
207
+
208
+ ::
209
+
210
+ uv run python -m unittest discover -s pulp/tests -v
211
+
212
+ Building the documentation
213
+ --------------------------
214
+
215
+ The PuLP documentation is built with `Sphinx <https://www.sphinx-doc.org>`_. Use a virtual environment and the dev install above, then::
216
+
217
+ cd doc
218
+ make html
219
+
220
+ A folder named ``html`` will be created inside ``doc/build/``. Open ``doc/build/html/index.html`` in a browser.
221
+
222
+ Contributing to PuLP
223
+ -----------------------
224
+ Instructions for making your first contribution to PuLP are given `here <https://coin-or.github.io/pulp/develop/contribute.html>`_.
225
+
226
+ **Comments, bug reports, patches and suggestions are very welcome!**
227
+
228
+ * Comments and suggestions: https://github.com/coin-or/pulp/discussions
229
+ * `PuLP Google Group <https://groups.google.com/g/pulp-or-discuss>`_ — community discussion and Q&A
230
+ * Bug reports: https://github.com/coin-or/pulp/issues
231
+ * Patches: https://github.com/coin-or/pulp/pulls
232
+
233
+ Copyright and License
234
+ =======================
235
+ PuLP is distributed under an MIT license.
236
+
237
+ Copyright J.S. Roy, 2003-2005
238
+ Copyright Stuart A. Mitchell
239
+ See the LICENSE file for copyright information.
240
+
241
+ .. _Python: http://www.python.org/
242
+
243
+ .. _GLPK: http://www.gnu.org/software/glpk/glpk.html
244
+ .. _CBC: https://github.com/coin-or/Cbc
245
+ .. _CPLEX: http://www.cplex.com/
246
+ .. _GUROBI: http://www.gurobi.com/
247
+ .. _MOSEK: https://www.mosek.com/
248
+ .. _XPRESS: https://www.fico.com/es/products/fico-xpress-solver
249
+ .. _CHOCO: https://choco-solver.org/
250
+ .. _MIPCL: http://mipcl-cpp.appspot.com/
251
+ .. _SCIP: https://www.scipopt.org/
252
+ .. _HiGHS: https://highs.dev
253
+ .. _FSCIP: https://ug.zib.de
254
+ .. _CP-SAT: https://developers.google.com/optimization/cp/cp_solver
@@ -53,14 +53,11 @@ try:
53
53
  except Exception:
54
54
  pass
55
55
 
56
+ from importlib.metadata import version
56
57
 
57
- from .constants import VERSION
58
+ __version__ = version("PuLP")
58
59
 
59
- from .v4_migration import set_v4_migration_warnings
60
- from .pulp import *
61
60
  from .apis import *
62
- from .utilities import *
63
61
  from .constants import *
64
-
65
- __doc__ = pulp.__doc__ # type: ignore[name-defined]
66
- __version__ = VERSION
62
+ from .pulp import *
63
+ from .utilities import *