GLOP LinearProgram's GetTransposeSparseMatrix fails if not cleaned up
Author: discoptCreated Jul 31, 2026Updated Sep 15, 2026
LabelsSolver: Linear Solver
What version of OR-Tools and what language are you using? Version: main Language: C++
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi) GLOP
What operating system (Linux, Windows, ...) and version? Linux
What did you do? Steps to reproduce the behavior:
- Create a glop::LinearProgram instance.
- Call
SetCoefficienton an existing nonzero, which makes the LP dirty, i.e., IsCleanedUp returns false. - Now a call to
GetTransposeSparseMatrixfails.
What did you expect to see
Success of the GetTransposeSparseMatrix.
What did you see instead? Failed debug checks
There are three solutions I see:
- Add DCHECK() calls within
GetTransposeSparseMatrixand document that it must be called on a cleaned-up version. - Clean up the matrix before.
- Adapt the transposition method to explicitly take care of duplicates / zeros. This may lead to unnecessary memory allocation, but not much additional effort I think.
Source: google/or-tools