# 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). Feb 28 at 20:15
• That Cvxpy should do transformations a presolve in good a commercial optimizer does not do sound right. Mar 1 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. Mar 1 at 9:53
• The purpose of the Cvxpy transformations is to setup the data on the form that optimizer needs. Not to improve the formulation IMO. I think even the Cvxpy authors would be surprised by your statement/observation. Mar 1 at 10:22
• 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. Mar 1 at 10:58

import gurobipy as gp