mathoptmodel 0.1.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.
- mathoptmodel-0.1.0/CMakeLists.txt +55 -0
- mathoptmodel-0.1.0/LICENSE +21 -0
- mathoptmodel-0.1.0/PKG-INFO +63 -0
- mathoptmodel-0.1.0/README.md +188 -0
- mathoptmodel-0.1.0/cmake/FindIPOPT.cmake +22 -0
- mathoptmodel-0.1.0/extern/CMakeLists.txt +839 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/dual.hpp +50 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt.hpp +461 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_cbc.hpp +84 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_conicbundle.hpp +24 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_cplex.hpp +86 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_dlib.hpp +20 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_gurobi.hpp +96 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_highs.hpp +51 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_ipopt.hpp +81 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_json.hpp +57 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_knitro.hpp +70 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_lp.hpp +72 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_mps.hpp +74 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_nl.hpp +79 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_nonlinear.hpp +89 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_scip.hpp +93 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_smspp.hpp +39 -0
- mathoptmodel-0.1.0/include/mathoptsolverscmake/mathopt_xpress.hpp +44 -0
- mathoptmodel-0.1.0/pyproject.toml +68 -0
- mathoptmodel-0.1.0/python/CMakeLists.txt +25 -0
- mathoptmodel-0.1.0/python/README.md +43 -0
- mathoptmodel-0.1.0/python/mathoptmodel/__init__.py +90 -0
- mathoptmodel-0.1.0/python/mathoptmodel/_version.py +1 -0
- mathoptmodel-0.1.0/python/src/mathoptmodel_ext.cpp +308 -0
- mathoptmodel-0.1.0/python/tests/test_bindings.py +207 -0
- mathoptmodel-0.1.0/src/CMakeLists.txt +123 -0
- mathoptmodel-0.1.0/src/dual.cpp +166 -0
- mathoptmodel-0.1.0/src/mathopt.cpp +1635 -0
- mathoptmodel-0.1.0/src/mathopt_cbc.cpp +214 -0
- mathoptmodel-0.1.0/src/mathopt_conicbundle.cpp +98 -0
- mathoptmodel-0.1.0/src/mathopt_cplex.cpp +495 -0
- mathoptmodel-0.1.0/src/mathopt_dlib.cpp +108 -0
- mathoptmodel-0.1.0/src/mathopt_gurobi.cpp +561 -0
- mathoptmodel-0.1.0/src/mathopt_highs.cpp +227 -0
- mathoptmodel-0.1.0/src/mathopt_ipopt.cpp +1164 -0
- mathoptmodel-0.1.0/src/mathopt_json.cpp +700 -0
- mathoptmodel-0.1.0/src/mathopt_knitro.cpp +609 -0
- mathoptmodel-0.1.0/src/mathopt_lp.cpp +885 -0
- mathoptmodel-0.1.0/src/mathopt_mps.cpp +926 -0
- mathoptmodel-0.1.0/src/mathopt_nl.cpp +1251 -0
- mathoptmodel-0.1.0/src/mathopt_nonlinear.cpp +204 -0
- mathoptmodel-0.1.0/src/mathopt_scip.cpp +716 -0
- mathoptmodel-0.1.0/src/mathopt_smspp.cpp +466 -0
- mathoptmodel-0.1.0/src/mathopt_xpress.cpp +189 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.15.0)
|
|
2
|
+
|
|
3
|
+
project(MathOptSolversCMake LANGUAGES CXX)
|
|
4
|
+
|
|
5
|
+
# Solver options.
|
|
6
|
+
option(MATHOPTSOLVERSCMAKE_USE_CLP "Use Clp" OFF)
|
|
7
|
+
option(MATHOPTSOLVERSCMAKE_USE_CBC "Use Cbc" OFF)
|
|
8
|
+
option(MATHOPTSOLVERSCMAKE_USE_HIGHS "Use HiGHS" OFF)
|
|
9
|
+
option(MATHOPTSOLVERSCMAKE_USE_XPRESS "Use XPRESS" OFF)
|
|
10
|
+
option(MATHOPTSOLVERSCMAKE_USE_CPLEX "Use CPLEX" OFF)
|
|
11
|
+
option(MATHOPTSOLVERSCMAKE_USE_GUROBI "Use GUROBI" OFF)
|
|
12
|
+
option(MATHOPTSOLVERSCMAKE_USE_KNITRO "Use Knitro" OFF)
|
|
13
|
+
option(MATHOPTSOLVERSCMAKE_USE_IPOPT "Use Ipopt" OFF)
|
|
14
|
+
option(MATHOPTSOLVERSCMAKE_USE_SCIP "Use SCIP" OFF)
|
|
15
|
+
option(MATHOPTSOLVERSCMAKE_SCIP_USE_IPOPT "Build SCIP with Ipopt as NLP solver" ON)
|
|
16
|
+
option(MATHOPTSOLVERSCMAKE_USE_DLIB "Use dlib" OFF)
|
|
17
|
+
option(MATHOPTSOLVERSCMAKE_USE_CONICBUNDLE "Use ConicBundle" OFF)
|
|
18
|
+
option(MATHOPTSOLVERSCMAKE_USE_SMSPP "Use SMS++ (BundleSolver)" OFF)
|
|
19
|
+
|
|
20
|
+
# Test option.
|
|
21
|
+
option(MATHOPTSOLVERSCMAKE_BUILD_TESTS "Build tests" ON)
|
|
22
|
+
|
|
23
|
+
# App option.
|
|
24
|
+
option(MATHOPTSOLVERSCMAKE_BUILD_APP "Build the mathoptsolverscmake_solve CLI app" ON)
|
|
25
|
+
|
|
26
|
+
# Python bindings option (set by pyproject.toml when building the Python package).
|
|
27
|
+
option(MATHOPTSOLVERSCMAKE_BUILD_PYTHON "Build the Python bindings" OFF)
|
|
28
|
+
|
|
29
|
+
# Avoid FetchContent warning.
|
|
30
|
+
cmake_policy(SET CMP0135 NEW)
|
|
31
|
+
|
|
32
|
+
# Require C++11.
|
|
33
|
+
set(CMAKE_CXX_STANDARD 11)
|
|
34
|
+
|
|
35
|
+
# Enable output of compile commands during generation.
|
|
36
|
+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
37
|
+
|
|
38
|
+
# The static library is linked into the Python extension module.
|
|
39
|
+
if(MATHOPTSOLVERSCMAKE_BUILD_PYTHON)
|
|
40
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
41
|
+
endif()
|
|
42
|
+
|
|
43
|
+
# Add sub-directories.
|
|
44
|
+
add_subdirectory(extern)
|
|
45
|
+
add_subdirectory(src)
|
|
46
|
+
if(MATHOPTSOLVERSCMAKE_BUILD_TESTS)
|
|
47
|
+
enable_testing()
|
|
48
|
+
add_subdirectory(test)
|
|
49
|
+
endif()
|
|
50
|
+
if(MATHOPTSOLVERSCMAKE_BUILD_APP)
|
|
51
|
+
add_subdirectory(app)
|
|
52
|
+
endif()
|
|
53
|
+
if(MATHOPTSOLVERSCMAKE_BUILD_PYTHON)
|
|
54
|
+
add_subdirectory(python)
|
|
55
|
+
endif()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Florian Fontan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mathoptmodel
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MathOptSolversCMake's optimization model and its MPS, LP, JSON and AMPL .nl readers/writers
|
|
5
|
+
Author-Email: Florian Fontan <dev@florian-fontan.fr>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Programming Language :: C++
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Operating System :: MacOS
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
14
|
+
Project-URL: Homepage, https://github.com/fontanf/mathoptsolverscmake
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Requires-Dist: numpy
|
|
17
|
+
Provides-Extra: test
|
|
18
|
+
Requires-Dist: pytest; extra == "test"
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# mathoptmodel
|
|
22
|
+
|
|
23
|
+
`mathoptmodel` is the Python package of
|
|
24
|
+
[MathOptSolversCMake](https://github.com/fontanf/mathoptsolverscmake): Python
|
|
25
|
+
bindings for the solver-independent part of the library, its
|
|
26
|
+
`MathOptModel` optimization-model structure and its MPS, LP, JSON and AMPL
|
|
27
|
+
`.nl` readers and writers. No solver is bundled. Requires Python 3.12 or
|
|
28
|
+
newer (a single stable-ABI wheel per platform).
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
pip install mathoptmodel
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import mathoptmodel as mom
|
|
36
|
+
|
|
37
|
+
model = mom.read("p0033.mps.gz") # format from the extension; .gz/.bz2 handled
|
|
38
|
+
print(model.number_of_variables, model.number_of_constraints)
|
|
39
|
+
|
|
40
|
+
# Arrays are read-only NumPy views onto the C++ model (no copy).
|
|
41
|
+
starts = model.constraints_starts
|
|
42
|
+
for i in range(model.number_of_constraints):
|
|
43
|
+
begin, end = starts[i], model.constraint_end(i)
|
|
44
|
+
variables = model.elements_variables[begin:end]
|
|
45
|
+
coefficients = model.elements_coefficients[begin:end]
|
|
46
|
+
print(model.constraint_name(i), model.constraint_class(i), dict(zip(variables, coefficients)))
|
|
47
|
+
|
|
48
|
+
mom.write(model, "p0033.lp")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The fields mirror `MathOptModel` in
|
|
52
|
+
[`mathopt.hpp`](https://github.com/fontanf/mathoptsolverscmake/blob/main/include/mathoptsolverscmake/mathopt.hpp),
|
|
53
|
+
which documents each of them, including the expression-tree layout of
|
|
54
|
+
nonlinear objectives and constraints. `variables_types` and
|
|
55
|
+
`constraints_classes` are int8 arrays of `VariableType` / `ConstraintClass`
|
|
56
|
+
values.
|
|
57
|
+
|
|
58
|
+
## Building from source
|
|
59
|
+
|
|
60
|
+
```shell
|
|
61
|
+
pip install .
|
|
62
|
+
pytest python/tests
|
|
63
|
+
```
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# MathOptSolversCMake
|
|
2
|
+
|
|
3
|
+
This library includes:
|
|
4
|
+
* CMake wrappers for mathematical optimization solvers
|
|
5
|
+
* A mathematical programming modeler that supports:
|
|
6
|
+
* Coninous and integer variables
|
|
7
|
+
* Linear structures
|
|
8
|
+
* Quadratic structures
|
|
9
|
+
* Nonlinear structures
|
|
10
|
+
* Black-box functions
|
|
11
|
+
|
|
12
|
+
The goal of the modeler are:
|
|
13
|
+
* Minimize the modeler's overhead
|
|
14
|
+
* Run multiple solvers while writing the model's code once and ensuring that the model passed to each solver is the same
|
|
15
|
+
* Keep access to all the direct API features of the solvers
|
|
16
|
+
* Minimize the quantity of code to integrate a new solver
|
|
17
|
+
* Provide some features to help model debugging
|
|
18
|
+
|
|
19
|
+
They are not designed to be as user-friendly as possible.
|
|
20
|
+
And switching solver requires a bit more lines of code than changing a string.
|
|
21
|
+
|
|
22
|
+
Supported solvers:
|
|
23
|
+
* HiGHS (MILP) https://highs.dev/
|
|
24
|
+
* Cbc (MILP) https://github.com/coin-or/Cbc
|
|
25
|
+
* FICO Xpress (MILP) https://www.fico.com/en/products/fico-xpress-optimization
|
|
26
|
+
* IBM ILOG CPLEX (MIQP; non-convex quadratic objectives solved to global optimality) https://www.ibm.com/products/ilog-cplex-optimization-studio
|
|
27
|
+
* Gurobi (MINLP, solved to global optimality; no black-box functions) https://www.gurobi.com/
|
|
28
|
+
* Artelys Knitro (all) https://www.artelys.com/solvers/knitro/
|
|
29
|
+
* SCIP (MINLP, solved to global optimality; no black-box functions) https://www.scipopt.org/
|
|
30
|
+
* Ipopt (continuous NLP, local optimality) https://github.com/coin-or/Ipopt
|
|
31
|
+
* Dlib (box-constrained) https://dlib.net/
|
|
32
|
+
* ConicBundle (box-constrained) https://www-user.tu-chemnitz.de/~helmberg/ConicBundle/
|
|
33
|
+
|
|
34
|
+
Examples:
|
|
35
|
+
* MILP:
|
|
36
|
+
* [Multiple-choice knapsack](https://github.com/fontanf/multiplechoiceknapsacksolver/blob/main/src/algorithms/milp.cpp)
|
|
37
|
+
* [Set covering](https://github.com/fontanf/setcoveringsolver/blob/master/src/algorithms/milp.cpp)
|
|
38
|
+
* [Generalized assignment](https://github.com/fontanf/generalizedassignmentsolver/blob/master/src/algorithms/milp.cpp)
|
|
39
|
+
* [Clique](https://github.com/fontanf/stablesolver/blob/master/src/clique/algorithms/milp.cpp), [stable](https://github.com/fontanf/stablesolver/blob/master/src/stable/algorithms/milp.cpp)
|
|
40
|
+
* [Knapsack with conflicts](https://github.com/fontanf/knapsackwithconflictssolver/blob/main/src/algorithms/milp.cpp)
|
|
41
|
+
* [Graph coloring](https://github.com/fontanf/coloringsolver/blob/master/src/algorithms/milp.cpp)
|
|
42
|
+
* Shop scheduling, [positional model](https://github.com/fontanf/shopschedulingsolver/blob/main/src/algorithms/milp_positional.cpp), [disjunctive model](https://github.com/fontanf/shopschedulingsolver/blob/main/src/algorithms/milp_disjunctive.cpp)
|
|
43
|
+
* Box-constrained (Lagrangian relaxations):
|
|
44
|
+
* [Generalized assignment](https://github.com/fontanf/generalizedassignmentsolver/blob/master/src/algorithms/lagrangian_relaxation.cpp)
|
|
45
|
+
* [Knapsack with conflicts](https://github.com/fontanf/knapsackwithconflictssolver/blob/main/src/algorithms/lagrangian_relaxation.cpp)
|
|
46
|
+
|
|
47
|
+
CMake integration example:
|
|
48
|
+
```cmake
|
|
49
|
+
# Fetch fontanf/mathoptsolverscmake.
|
|
50
|
+
set(MATHOPTSOLVERSCMAKE_USE_CLP ON)
|
|
51
|
+
FetchContent_Declare(
|
|
52
|
+
mathoptsolverscmake
|
|
53
|
+
GIT_REPOSITORY https://github.com/fontanf/mathoptsolverscmake.git
|
|
54
|
+
GIT_TAG ...)
|
|
55
|
+
#SOURCE_DIR "${PROJECT_SOURCE_DIR}/../mathoptsolverscmake/")
|
|
56
|
+
FetchContent_MakeAvailable(mathoptsolverscmake)
|
|
57
|
+
|
|
58
|
+
...
|
|
59
|
+
|
|
60
|
+
target_link_libraries(MyProject_my_target PUBLIC
|
|
61
|
+
MathOptSolversCMake::clp)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## CLI app
|
|
65
|
+
|
|
66
|
+
An optional CLI app reads a model file and solves it directly, no code required.
|
|
67
|
+
It supports the MPS, LP, JSON and .nl formats (guessed from the file extension, or given with `--format`),
|
|
68
|
+
and the Cbc, HiGHS, XPRESS, CPLEX, Gurobi, Knitro, Ipopt and SCIP solvers (`--solver`), whichever were enabled at configure time.
|
|
69
|
+
Enable it with `MATHOPTSOLVERSCMAKE_BUILD_APP`, together with the solver(s) it should be able to use:
|
|
70
|
+
```shell
|
|
71
|
+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DMATHOPTSOLVERSCMAKE_USE_HIGHS=ON
|
|
72
|
+
cmake --build build --config Release --parallel
|
|
73
|
+
cmake --install build --config Release --prefix install
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For example, solving the small MIPLIB3 instance [`data/miplib3/p0033.mps`](data/miplib3/p0033.mps)
|
|
77
|
+
(33 binary variables, optimal objective value 3089) with HiGHS:
|
|
78
|
+
```shell
|
|
79
|
+
./install/bin/mathoptsolverscmake_solve --input data/miplib3/p0033.mps --solver highs
|
|
80
|
+
```
|
|
81
|
+
```
|
|
82
|
+
===========================
|
|
83
|
+
MathOpt
|
|
84
|
+
===========================
|
|
85
|
+
|
|
86
|
+
Model
|
|
87
|
+
-----
|
|
88
|
+
Number of variables: 33
|
|
89
|
+
Number of constraints: 16
|
|
90
|
+
Number of elements: 98
|
|
91
|
+
Objective: Minimize
|
|
92
|
+
Has non-continuous: 1
|
|
93
|
+
Has quadratic: 0
|
|
94
|
+
Has nonlinear: 0
|
|
95
|
+
Has black-box: 0
|
|
96
|
+
Is LP: 0
|
|
97
|
+
Is MILP: 1
|
|
98
|
+
Is box-constrained: 0
|
|
99
|
+
|
|
100
|
+
Running HiGHS 1.16.0 (git hash: n/a): Copyright (c) 2026 under MIT licence terms
|
|
101
|
+
Includes third-party software components, see THIRD_PARTY_NOTICES.md for full details
|
|
102
|
+
MIP has 16 rows; 33 cols; 98 nonzeros; 33 integer variables (33 binary)
|
|
103
|
+
Coefficient ranges:
|
|
104
|
+
Matrix [1e+00, 4e+02]
|
|
105
|
+
Cost [5e+01, 5e+02]
|
|
106
|
+
Bound [1e+00, 1e+00]
|
|
107
|
+
RHS [1e+00, 3e+03]
|
|
108
|
+
Presolving model
|
|
109
|
+
16 rows, 33 cols, 98 nonzeros 0s
|
|
110
|
+
13 rows, 26 cols, 67 nonzeros 0s
|
|
111
|
+
12 rows, 24 cols, 64 nonzeros 0s
|
|
112
|
+
Presolve reductions: rows 12(-4); columns 24(-9); nonzeros 64(-34)
|
|
113
|
+
Objective function is integral with scale 1
|
|
114
|
+
|
|
115
|
+
Solving MIP model with:
|
|
116
|
+
12 rows
|
|
117
|
+
24 cols (20 binary, 4 integer, 0 implied int., 0 continuous, 0 domain fixed)
|
|
118
|
+
64 nonzeros
|
|
119
|
+
Thread count: 6 available cores, 6 logical processors, using up to 6 workers across 6 threads.
|
|
120
|
+
|
|
121
|
+
Src: B => Branching; C => Central rounding; F => Feasibility pump; H => Heuristic;
|
|
122
|
+
I => Shifting; J => Feasibility jump; L => Sub-MIP; P => Empty MIP; R => Randomized rounding;
|
|
123
|
+
S => Solve LP; T => Evaluate node; U => Unbounded; X => User solution; Y => HiGHS solution;
|
|
124
|
+
Z => ZI Round; l => Trivial lower; p => Trivial point; u => Trivial upper; z => Trivial zero
|
|
125
|
+
|
|
126
|
+
Nodes | B&B Tree | Objective Bounds | Dynamic Constraints | Work
|
|
127
|
+
Src Proc. InQueue | Leaves Expl. | BestBound BestSol Gap | Cuts InLp Confl. | LpIters Time
|
|
128
|
+
|
|
129
|
+
J 0 0 0 0.00% -inf 3705 Large 0 0 0 0 0.0s
|
|
130
|
+
R 0 0 0 0.00% 2838.546739 3347 15.19% 0 0 0 10 0.0s
|
|
131
|
+
|
|
132
|
+
4.2% inactive integer columns, restarting
|
|
133
|
+
Model after restart has 12 rows, 23 cols (19 bin., 4 int., 0 impl., 0 cont., 0 dom.fix.), and 61 nonzeros
|
|
134
|
+
|
|
135
|
+
0 0 0 0.00% 3073.628205 3347 8.17% 9 0 0 55 0.0s
|
|
136
|
+
0 0 0 0.00% 3073.628205 3347 8.17% 9 8 7 69 0.0s
|
|
137
|
+
L 0 0 0 0.00% 3089 3089 0.00% 165 16 7 85 0.0s
|
|
138
|
+
1 0 1 100.00% 3089 3089 0.00% 165 16 7 85 0.0s
|
|
139
|
+
|
|
140
|
+
Solving report
|
|
141
|
+
Status Optimal
|
|
142
|
+
Primal bound 3089
|
|
143
|
+
Dual bound 3089
|
|
144
|
+
Gap 0% (tolerance: 0.01%)
|
|
145
|
+
P-D integral 0.01
|
|
146
|
+
Solution status feasible
|
|
147
|
+
3089 (objective)
|
|
148
|
+
Timing 0.03
|
|
149
|
+
0.00 (Presolve)
|
|
150
|
+
MIP time [calls] = 0.00 [1]
|
|
151
|
+
subMIP time [calls] = 0.00 [3]
|
|
152
|
+
0.03 (Solve)
|
|
153
|
+
MIP time [calls] = 0.02 [1]
|
|
154
|
+
subMIP time [calls] = 0.01 [1]
|
|
155
|
+
0.00 (Postsolve)
|
|
156
|
+
MIP time [calls] = 0.00 [1]
|
|
157
|
+
subMIP time [calls] = 0.00 [3]
|
|
158
|
+
Max sub-MIP depth 2
|
|
159
|
+
Nodes 1
|
|
160
|
+
Repair LPs 0
|
|
161
|
+
LP iterations 85
|
|
162
|
+
0 (strong br.)
|
|
163
|
+
54 (separation)
|
|
164
|
+
7 (heuristics)
|
|
165
|
+
|
|
166
|
+
Final statistics
|
|
167
|
+
----------------
|
|
168
|
+
Objective value: 3089
|
|
169
|
+
Bound: 3089
|
|
170
|
+
Feasible: 1
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
For a linear program, `--dual` solves its dual (built with `mathoptsolverscmake::dual()`) instead of the model itself.
|
|
174
|
+
The reported objective value is the dual's, equal to the primal's at optimality, and `--output` writes the dual solution.
|
|
175
|
+
|
|
176
|
+
## Python package
|
|
177
|
+
|
|
178
|
+
The solver-independent part of the library — `MathOptModel` and the MPS, LP, JSON and `.nl` readers/writers — is also available as a Python package, `mathoptmodel`, with the model's arrays exposed as read-only NumPy views:
|
|
179
|
+
```shell
|
|
180
|
+
pip install mathoptmodel
|
|
181
|
+
```
|
|
182
|
+
```python
|
|
183
|
+
import mathoptmodel as mom
|
|
184
|
+
|
|
185
|
+
model = mom.read("data/miplib3/p0033.mps") # also .gz / .bz2
|
|
186
|
+
print(model.number_of_variables, model.constraint_class(0))
|
|
187
|
+
```
|
|
188
|
+
See [`python/README.md`](python/README.md) for details. The wheels are built by `.github/workflows/python.yml` and published to PyPI when a `v*` tag is pushed.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Find module used by SCIP's find_package(IPOPT) (see
|
|
2
|
+
# mathoptsolverscmake_fetch_scip in extern/CMakeLists.txt) so that SCIP links
|
|
3
|
+
# the Ipopt fetched by MathOptSolversCMake instead of searching the system.
|
|
4
|
+
#
|
|
5
|
+
# Defines the variables SCIP's CMakeLists.txt uses: IPOPT_FOUND,
|
|
6
|
+
# IPOPT_INCLUDE_DIRS, IPOPT_LIBRARIES and IPOPT_VERSION.
|
|
7
|
+
|
|
8
|
+
if(TARGET MathOptSolversCMake_ipopt)
|
|
9
|
+
get_target_property(IPOPT_INCLUDE_DIRS MathOptSolversCMake_ipopt INTERFACE_INCLUDE_DIRECTORIES)
|
|
10
|
+
set(IPOPT_LIBRARIES MathOptSolversCMake_ipopt)
|
|
11
|
+
if(EXISTS "${IPOPT_INCLUDE_DIRS}/IpoptConfig.h")
|
|
12
|
+
file(STRINGS "${IPOPT_INCLUDE_DIRS}/IpoptConfig.h" _ipopt_version_line
|
|
13
|
+
REGEX "^#define IPOPT_VERSION ")
|
|
14
|
+
string(REGEX REPLACE "^#define IPOPT_VERSION \"([^\"]*)\".*" "\\1"
|
|
15
|
+
IPOPT_VERSION "${_ipopt_version_line}")
|
|
16
|
+
endif()
|
|
17
|
+
endif()
|
|
18
|
+
|
|
19
|
+
include(FindPackageHandleStandardArgs)
|
|
20
|
+
find_package_handle_standard_args(IPOPT
|
|
21
|
+
REQUIRED_VARS IPOPT_LIBRARIES IPOPT_INCLUDE_DIRS
|
|
22
|
+
VERSION_VAR IPOPT_VERSION)
|