HiGHS_CMD - .sol file only has values of the decision variables ; not their names
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 432
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
Research direction
Start at the HiGHS_CMD readsol function shown in the issue and reproduce the failure with a HiGHS .sol file whose Columns section contains only values. Compare the expected and actual solution-file format, then make readsol handle that format and verify that the returned values still correspond to the supplied decision variables.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100