Repository: coin-or/pulp

Issue:
Incorrect MPS import
Details for the issue
--------------------

Consider the MPS file (taken from [here](http://lpsolve.sourceforge.net/5.5/mps-format.htm))
```
NAME          TESTPROB
ROWS
 N  COST
 L  LIM1
 G  LIM2
 E  MYEQN
COLUMNS
    XONE      COST                 1   LIM1                 1
    XONE      LIM2                 1
    YTWO      COST                 4   LIM1                 1
    YTWO      MYEQN               -1
    ZTHREE    COST                 9   LIM2                 1
    ZTHREE    MYEQN                1
RHS
    RHS1      LIM1                 5   LIM2                10
    RHS1      MYEQN                7
BOUNDS
 UP BND1      XONE                 4
 LO BND1      YTWO                -1
 UP BND1      YTWO                 1
ENDATA
```

#### What did you do?

Executed `_, problem = pulp.LpProblem.fromMPS('test.mps')`

#### What did you expect to see?

I expected for the `LIM2` constraint to be `LIM2: XONE + ZTHREE >= 10`

#### What did you see instead?

```
TESTPROB:
MINIMIZE
1.0*XONE + 4.0*YTWO + 9.0*ZTHREE + 0
SUBJECT TO
LIM1: XONE + YTWO <= 5

LIM2: XONE + ZTHREE >= 0

MYEQN: - YTWO + ZTHREE = 7

VARIABLES
XONE <= 4 Continuous
-1 <= YTWO <= 1 Continuous
ZTHREE Continuous
```
In my test, all MPS files whose `RHS` section contains definitions in Fields 5 & 6 are not imported correctly. The following modification of the MPS file is imported correctly (I simply manually moved the `LIM2` RHS specification):

```
NAME          TESTPROB
ROWS
 N  COST
 L  LIM1
 G  LIM2
 E  MYEQN
COLUMNS
    XONE      COST                 1   LIM1                 1
    XONE      LIM2                 1
    YTWO      COST                 4   LIM1                 1
    YTWO      MYEQN               -1
    ZTHREE    COST                 9   LIM2                 1
    ZTHREE    MYEQN                1
RHS
    RHS1      LIM1                 5
    RHS1      LIM2                10
    RHS1      MYEQN                7
BOUNDS
 UP BND1      XONE                 4
 LO BND1      YTWO                -1
 UP BND1      YTWO                 1
ENDATA
```
I tested with [pysmps](https://github.com/jmaerte/pysmps) and it imports both versions of the MPS file correctly. 

Useful extra information
-------------------------

#### What operating system are you using?

Linux: (Fedora)

#### I'm using python version:

`3.10.2`

#### I installed PuLP via:

- [X] pypi (python -m pip install pulp)
- [X] github (python -m pip install -U git+https://github.com/coin-or/pulp)

#### Did you also

- [X] Tried out the latest github version: https://github.com/coin-or/pulp
- [X] Searched for an existing similar issue: https://github.com/coin-or/pulp/issues?utf8=%E2%9C%93&q=is%3Aissue%20

It seems related to #459

Discussion:
CLAassistant: [![CLA assistant check](https://cla-assistant.io/pull/badge/not_signed)](https://cla-assistant.io/coin-or/pulp?pullRequest=530) <br/>Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our [Contributor License Agreement](https://cla-assistant.io/coin-or/pulp?pullRequest=530) before we can accept your contribution.<br/><hr/>**dimitrod** seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please [add the email address used for this commit to your account](https://help.github.com/articles/why-are-my-commits-linked-to-the-wrong-user/#commits-are-not-linked-to-any-user).<br/><sub>You have signed the CLA already but the status is still pending? Let us [recheck](https://cla-assistant.io/check/coin-or/pulp?pullRequest=530) it.</sub>
pchtsp: thanks!

Patch:
diff --git a/pulp/mps_lp.py b/pulp/mps_lp.py
index d9ddb11..9cd3932 100644
--- a/pulp/mps_lp.py
+++ b/pulp/mps_lp.py
@@ -183,6 +183,8 @@ def readMPSSetBounds(line, variable_dict):
 
 def readMPSSetRhs(line, constraintsDict):
     constraintsDict[line[1]]["constant"] = -float(line[2])
+    if len(line) == 5:  # read fields 5, 6
+        constraintsDict[line[3]]["constant"] = -float(line[4])
     return
 
 


Test patch:
diff --git a/pulp/tests/test_pulp.py b/pulp/tests/test_pulp.py
index 059de67..b7d476c 100644
--- a/pulp/tests/test_pulp.py
+++ b/pulp/tests/test_pulp.py
@@ -1,6 +1,9 @@
 """
 Tests for pulp
 """
+import os
+import tempfile
+
 from pulp.constants import PulpError
 from pulp.apis import *
 from pulp import LpVariable, LpProblem, lpSum, LpConstraintVar, LpFractionConstraint
@@ -9,6 +12,29 @@ from pulp.tests.bin_packing_problem import create_bin_packing_problem
 from pulp.utilities import makeDict
 import unittest
 
+# from: http://lpsolve.sourceforge.net/5.5/mps-format.htm
+EXAMPLE_MPS_RHS56 = """NAME          TESTPROB
+ROWS
+ N  COST
+ L  LIM1
+ G  LIM2
+ E  MYEQN
+COLUMNS
+    XONE      COST                 1   LIM1                 1
+    XONE      LIM2                 1
+    YTWO      COST                 4   LIM1                 1
+    YTWO      MYEQN               -1
+    ZTHREE    COST                 9   LIM2                 1
+    ZTHREE    MYEQN                1
+RHS
+    RHS1      LIM1                 5   LIM2                10
+    RHS1      MYEQN                7
+BOUNDS
+ UP BND1      XONE                 4
+ LO BND1      YTWO                -1
+ UP BND1      YTWO                 1
+ENDATA
+"""
 
 def dumpTestProblem(prob):
     try:
@@ -1079,6 +1105,14 @@ class BaseSolverTest:
             print("\t Testing reading MPS files - binary variable, no constraint names")
             self.assertDictEqual(_dict1, _dict2)
 
+        def test_importMPS_RHS_fields56(self):
+            """Import MPS file with RHS definitions in fields 5 & 6."""
+            with tempfile.NamedTemporaryFile(delete=False) as h:
+                h.write(str.encode(EXAMPLE_MPS_RHS56))
+            _, problem = LpProblem.fromMPS(h.name)
+            os.unlink(h.name)
+            self.assertEqual(problem.constraints['LIM2'].constant, -10)
+
         # def test_importMPS_2(self):
         #     name = self._testMethodName
         #     # filename = name + ".mps"