This module interface COIN-OR’s CoinMpsIO. When you call CyLP.cy.CyClpSimplex.readMps() then CoinMpsIO‘s readMps is called. The main reason why CyLP interfaces this class is to be able to read an mps file without creating a Simplex object. This way it is possible to read a QP using CoinMpsIO and work on the elements of the problem, e.g. the Hessian,...
Read an mps file. Check if the file is a QP symmetrisize its Hessian and store it.
>>> import numpy as np
>>> from CyLP.cy import CyCoinMpsIO
>>> from CyLP.cy.CyCoinMpsIO import getQpsExample
>>> problem = CyCoinMpsIO()
>>> problem.readMps(getQpsExample())
0
>>> problem.nVariables
5
>>> problem.nConstraints
5
>>> signs = problem.constraintSigns
>>> [chr(i) for i in signs] == problem.nConstraints * ['G']
True
>>> c = problem.matrixByRow
>>> (abs(c.elements -
... np.array([-1., -1., -1., -1., -1., 10., 10., -3.,
... 5., 4., -8., 1., -2., -5., 3., 8., -1., 2.,
... 5., -3., -4., -2., 3., -5., 1.])) <
... 10 ** -8).all()
True
>>> (c.indices ==
... np.array([0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1,
... 2, 3, 4, 0, 1, 2, 3, 4], dtype=np.int32)).all()
True
>>> (c.vectorStarts ==
... np.array([0, 5, 10, 15, 20, 25], dtype=np.int32)).all()
True
>>> (problem.rightHandSide ==
... np.array([-5., 20., -40., 11., -30.])).all()
True
>>> H = problem.Hessian.todense()
>>> (abs(H -
... np.matrix([[20394., -24908., -2026., 3896., 658.],
... [-24908., 41818., -3466., -9828., -372.],
... [-2026., -3466., 3510., 2178., -348.],
... [3896., -9828., 2178., 3030., -44.],
... [658., -372., -348., -44., 54.]])) <
... 10 ** -8).all()
True