Translate LP format to Numpy matrices

We have a large-scale optimization problem (~10K vars and ~10K constraints) in the form of LP format file (generated using Cplex library).

We wanted to solve that problem file using Cvxpy (with Gurobi solver - Note: Cvxpy is unavoidable), which doesn't accepts LP format file directly (rather constraint matrices/list).

So, is it possible to somehow read (/transform/parse) that LP format file into regular Numpy matrices?

• Careful. 1) cvxpy is a modelling tool (with tons of overhead due to it's powerful concepts) and if you already have a LP modelled, it's questionable what cvxpy would offer here. It's basically a slow wrapper then (potentially destroying your problem in some more complex QP/PSD cases -> internal eigenvalue-checks). 2) Numpy only knows dense arrays. Most real-world LP-instances would not fit into your memory when stored densely. scipy.sparse is what you are interested in (cvxpy supports both). 3) The task itself is 99% LP-format parsing, so focus on finding an accessible parser (in python). Commented Feb 28, 2022 at 20:15
• Please Note: Cvxpy is unavoidable because Cvxpy does clever transformations which stabilizes and significantly reduces runtime for our large-scale problem
– pqrz
Commented Mar 1, 2022 at 3:38
• That Cvxpy should do transformations a presolve in good a commercial optimizer does not do sound right. Commented Mar 1, 2022 at 9:19
• I agree with @ErlingMOSEK. To answer the question though, I would write a parser using the original CPLEX model rather than the LP format, because that will be a lot of work. Commented Mar 1, 2022 at 9:53
• There is this thing called performance variability in MIP (google it). For instance if CVXPY permutes the variables and or constraints you may see a big change in solution time. It is a random effect though. Commented Mar 1, 2022 at 10:58

import gurobipy as gp