pulp icon indicating copy to clipboard operation
pulp copied to clipboard

HiGHS_CMD - .sol file only has values of the decision variables ; not their names

Open s-u-m-a-n-t-h opened this issue 2 years ago • 0 comments

Details for the issue

What did you do?

I ran the pulp.HiGHS_CMD on a .lp file.

What did you expect to see?

The call to readsol function that follows the solving was expected to work fine.

` @staticmethod def readsol(variables, filename): """Read a HiGHS solution file""" with open(filename) as file: lines = file.readlines()

    begin, end = None, None
    for index, line in enumerate(lines):
        if begin is None and line.startswith("# Columns"):
            begin = index + 1
        if end is None and line.startswith("# Rows"):
            end = index
    if begin is None or end is None:
        raise PulpSolverError("Cannot read HiGHS solver output")

    values = {}
    for line in lines[begin:end]:
        name, value = line.split()
        values[name] = float(value)
    return values `

What did you see instead?

name, value = line.split()

The above line causes an error from the code above as the .sol file only contains the value of the decision variables under the heading columns. The line.split() expects the .sol file to have the name of the variable followed by the value of the variable.

Useful extra information

The info below often helps, please fill it out if you're able to. :)

What operating system are you using?

  • [ ] Windows: ( version: ___ )
  • [x ] Linux: ( distro: ___ )
  • [ ] Mac OS: ( version: ___ )
  • [ ] Other: ___

I'm using python version:

  • [ ] 2.7
  • [ ] 3.4
  • [ ] 3.5
  • [ ] 3.6
  • [ x] Other: 3.8.16

I installed PuLP via:

  • [ x] pypi (python -m pip install pulp)
  • [ ] github (python -m pip install -U git+https://github.com/coin-or/pulp)
  • [ ] Other: ___ (conda?)

Did you also

  • [ ] Tried out the latest github version: https://github.com/coin-or/pulp
  • [ ] Searched for an existing similar issue: https://github.com/coin-or/pulp/issues?utf8=%E2%9C%93&q=is%3Aissue%20

s-u-m-a-n-t-h avatar Jul 05 '23 13:07 s-u-m-a-n-t-h