or-tools-discuss cross post here.
As a disclaimer -- I am very aware that OR-Tools' Python code are just wrappers around their C++ source code. I'm just getting an odd discrepancy between a model setup in Python and one setup in C++ and am wracking my brain to figure out what I've messed up (because its most likely me not implementing something correctly or missing a "hidden-to-me" difference between the two).
Setup Context
OS
- Pop!OS 22.04 (basically Ubuntu)
- x86_64
Python Environment
- Python 3.10.5
- ortools 9.6.2534
C++ Environment
- CMake 3.26.4
- gcc 11.3.0
- or-tools
FetchContent
'd fromstable
Git branch
Problem Context
I've got two scripts, one in Python and the other in C++, that are setup to do (what I believe) is the same thing: read in an MPS file and solve the contained MIP using the SCIP solver.
The MPS file being fed into both scripts is the same, so I would have expected them to produce similar results. I might have even expected the C++ program to run faster than its Python counterpart. But what I'm seeing is that the Python script finished in ~20 seconds or so, while the C++ script errors out during the solve process after 5+ minutes.
The C++ error produced was (effectively): ERROR: (node 1) unresolved numerical troubles in LP 2 cannot be dealt with
, which is mentioned in this question.
Upon inspecting the logs from both solvers, I see they are both coming to the same primal / dual bounds. But whereas the Python script reaches those bounds and exits with an Optimal
solution, the C++ script continues to iterate until error-ing out with the above issue.
I'm wondering if it could be related to the way I've read in the MPS file and loaded it into a model? The process for each is laid out below:
Python
- use
ortools.linear_solver.python.model_builder.ModelBuilder
andModelSolver
- instantiate objects
model = ModelBuilder()
andsolver = ModelSolver("SCIP")
model.import_from_mps_file
to read MPSsolver.solve(model)
to optimize MIP
C++
#include <ortools/lp_data/mps_reader.h>
and#include <ortools/linear_solver/linear_solver.h>
- instantiate solver `solver = MPSolver::CreateSolver("SCIP")
- read MPS file to proto
model_proto = glop::MpsFileToMPModelProto(mps_file)
- load model from proto
solver->LoadModelFromProto(*model_proto, ...)
solver->Solve()
So, in Python, I'm using the ModelHelpers and in C++ I'm interfacing directly with the MPSolver
class. Perhaps this is where the difference lies?
Any thoughts / suggestions as to why I'm seeing this difference would be much appreciated!