pulp
pulp copied to clipboard
SCIP interface does not read solution when problem not solved
Details for the issue
What did you do?
Solving a problem with SCIP solver with time limit.
What did you expect to see?
After a time-out, a solution in accordance with SCIP logs
What did you see instead?
a zero solution for all variables that is the one computed by SCIP (I also checked the temporary file created by SCIP.
Useful extra information
Looking at the code, it seems to me the issue is at https://github.com/coin-or/pulp/blob/master/pulp/apis/scip_api.py#L184-L185 these lines completely skip the solution read when the problem was not solved. I would be tempeted to just remove constants.LpStatusNotSolved from the noSolutionStatus in https://github.com/coin-or/pulp/blob/master/pulp/apis/scip_api.py#L94, but I am not sure if this works in all cases.
The info below often helps, please fill it out if you're able to. :)
What operating system are you using?
- [x] Windows: ( _version:_10 )
- [ ] Linux: ( distro: ___ )
- [ ] Mac OS: ( version: ___ )
- [ ] Other: ___
I'm using python version:
- [ ] 2.7
- [ ] 3.4
- [ ] 3.5
- [x] 3.6
- [ ] Other: ___
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
- [x] Searched for an existing similar issue: https://github.com/coin-or/pulp/issues?utf8=%E2%9C%93&q=is%3Aissue%20
Sorry but I'm at a miss. From what I understand, the NO_SOLUTION_STATUSES
mean that a solution was not produced by this solver. As you can see the three options (infeasible, unbounded, not solve) really do imply that a solution was not found when the time limit was reached. So I don't see how do you expect to have a solution in these cases. Can you elaborate please?
Hello, thank for the reply. So what is happening in my case is that SCIP times out, meaning that he could not certify that the current solution he has is optimal within the gap I want. But he does have a solution. The solution is written out to a temporary file, but is not read by pulp back. Basically, SCIP exits with status "time limit reached", which typically means he has a solution but he has not reached the optimality gap requested. CBC has exactly the same behaviour, it will exit with time out, but in this case, PULP reads the solution and returns it. NOt with SCIP. I am not sure what it different in CBC and SCIP interfaces. I am pretty sure the desired behaviour is to read the solution even when we are not sure it is optimal because it is really common practice in MIPs to take the best solution found so far.
Hello, I recently run into a similar issue when SCIP stopped because it reached a user-specified gap limit. In my version of PuLP, PuLP returns that the problem is not solved. There has recently been a commit that modifies the way PuLP reads the solution file and solves my issue with the gap limit (see line 78): https://github.com/coin-or/pulp/commit/df9d41dd07d7fd65851db7e4cf13a75f540c982c#diff-7ac5ab8fb332d7604a000300539cf7d69f68b3dc7d397f8eb1f4df6f83cd208d
I would expect that your issue can be fixed in a similar way by modifying the SCIP_STATUSES at line 83: https://github.com/coin-or/pulp/blob/master/pulp/apis/scip_api.py#L83, so that
"time limit reached": constants.LpStatusNotSolved
becomes
"time limit reached": constants.LpStatusOptimal
Yes, this should do the trick to read the solution. However, the status information will be misleading since it will suggest it was solved to optimality while it was not... I wonder if this is not an issue in other interface even the CBC one. I will try that anyway.
Yes, I think this makes sense. Also we need to change the "memory limit reached" in this way.
On top of that, we should potentially give some more detail in the self.assignStatus() in Line https://github.com/coin-or/pulp/blob/d273841cd70fdacfa00eb8d68213334e997973ce/pulp/apis/scip_api.py#L148 to say that the solution status is IntegerFeasible by passing a solution_status=constants.IntegerFeasible
if there is a solution when the solver stops, like we do in CPLEX here: https://github.com/coin-or/pulp/blob/d273841cd70fdacfa00eb8d68213334e997973ce/pulp/apis/cplex_api.py#L1060-L1069
Someone cares to do a PR with all this?
I can have a look at some point. I tested the shortcut solution, which worked.
I did some changes to produce a status and solution status when reading the file (like for CBC). Tested for feasible and infeasible problem. Could not produce a case where the solver does not find a solution at all. Would be worth testing. Had an issue reported her #474 while looking into this. Seems unrelated
Is this still planned to be fixed? I'm having the same issue with the most recent version of pulp / scip
This issue is still occurring when using the latest versions of both pulp and scip, as noted by @dfreddi . We just switched to another solver instead of scip to avoid this issue.