#5276·or-tools

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:

  1. Create a glop::LinearProgram instance.
  2. Call SetCoefficient on an existing nonzero, which makes the LP dirty, i.e., IsCleanedUp returns false.
  3. Now a call to GetTransposeSparseMatrix fails.

What did you expect to see Success of the GetTransposeSparseMatrix.

What did you see instead? Failed debug checks

There are three solutions I see:

  1. Add DCHECK() calls within GetTransposeSparseMatrix and document that it must be called on a cleaned-up version.
  2. Clean up the matrix before.
  3. 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.