Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse noSolution status from CPLEXShell and CPLEXDirect solvers correctly #1313

Closed
wants to merge 15 commits into from

Conversation

ruaridhw
Copy link
Contributor

Fixes

Summary/Motivation:

Currently when CPLEX returns "No Solution", this isn't captured in any of the Pyomo solution or solver data objects. We can identify "No Solution" because when both of (1) max time limit is reached and (2) the model is infeasible occur.

Changes proposed in this PR:

CPLEXDirect

  • Clean up the status codes in _postsolve() to use the actual CPLEX library constants
  • Add new logic to handle MIP_time_limit_infeasible and MIP_dettime_limit_infeasible as indicating a solver termination_condition of noSolution
  • Get the solver return code if possible from any CplexSolverErrors (but don't add this to the returned Bunch due to downstream code raising ApplicationErrors)
  • Set results.solver.return_code and results.solver.termination_message using the available information

CPLEXSHELL

  • Fix process_logfile() for CPLEX 12.10 as it looks like IBM have updated the log file schema and is no longer being parsed correctly
  • Add new logic to handle 'no integer solution.' in the log file as indicating a solver termination_condition of noSolution
  • Get the solver return code if possible from any CPLEX Error lines in the log file

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@codecov
Copy link

codecov bot commented Feb 25, 2020

Codecov Report

Merging #1313 into master will increase coverage by 1.17%.
The diff coverage is 84.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1313      +/-   ##
==========================================
+ Coverage   71.57%   72.75%   +1.17%     
==========================================
  Files         547      491      -56     
  Lines       83583    79087    -4496     
==========================================
- Hits        59821    57536    -2285     
+ Misses      23762    21551    -2211     
Impacted Files Coverage Δ
pyomo/solvers/plugins/solvers/CPLEX.py 46.78% <80.00%> (-41.93%) ⬇️
pyomo/solvers/plugins/solvers/cplex_direct.py 74.72% <88.88%> (+1.62%) ⬆️
pyomo/pysp/lagrangeMorePR.py 5.54% <0.00%> (-68.98%) ⬇️
pyomo/solvers/plugins/solvers/gurobi_direct.py 12.67% <0.00%> (-58.28%) ⬇️
pyomo/solvers/plugins/solvers/GUROBI.py 31.61% <0.00%> (-57.42%) ⬇️
pyomo/pysp/drive_lagrangian_cc.py 9.38% <0.00%> (-48.36%) ⬇️
pyomo/solvers/plugins/solvers/gurobi_persistent.py 20.20% <0.00%> (-48.19%) ⬇️
pyomo/opt/parallel/async_solver.py 56.00% <0.00%> (-44.00%) ⬇️
pyomo/solvers/plugins/solvers/SCIPAMPL.py 24.39% <0.00%> (-39.64%) ⬇️
... and 99 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3f888c...33b0b2d. Read the comment docs.

@ruaridhw ruaridhw force-pushed the fix/cplex_shell_logfile_1210 branch from 8b61118 to 7e8d86c Compare February 27, 2020 11:10
@michaelbynum
Copy link
Contributor

@ruaridhw It looks like the changes in #1300 are also included in this PR. However, the changes to the direct interface do not depend on the changes in #1300. If you do not want this PR to be held up by #1300, then I would recommend creating a PR with just the changes to the direct interface.

@ruaridhw ruaridhw force-pushed the fix/cplex_shell_logfile_1210 branch from 7e8d86c to 12cdacb Compare March 4, 2020 18:04
@ruaridhw
Copy link
Contributor Author

ruaridhw commented Mar 4, 2020

@michaelbynum, sorry about that. Branch is fixed now.

ruaridhw added 15 commits May 7, 2020 08:21
- It looks as though IBM have updated the schema that the shell logfile uses and therefore the parsing is not quite done correctly
- Notably, 'CPLEX Error; no integer solution' is being flagged and returned as ('ok', 'unknown') for the status and termination condition
- The Direct solver should return the same solver and solution status as the Shell solver when no solution is found
- These error codes are currently unhandled and just return `TerminationCondition.error`
- It seems reasonable to assume that if a solve reaches max time limit and is infeasible that we cannot yet determine whether it is actually infeasible and therefore makes sense to return `noSolution`.
- I've elected not to add this to the return Bunch from `_apply_solver()` because that would change the behaviour of the downstream code (which raises an ApplicationError)
- Do not adjust `SolverInformation` since this is called `return_code` here
- Reaching these limits could also be reasons for having not found a solution
…ation

- If we have already determined a reasonable termination condition that would have otherwise returned an `ok` SolverStatus, return `warning` instead of `error`
- In the case of `noSolution`, CPLEXSHELL now considers this a `warning` solver status
- Similarly, `GAMSDirect` returns a `SolutionStatus.unknown` so we should be consistent with that
- Constraint `C` is being overwritten
- This is a much harder model that is more likely to not be solved within the allowed time
@ruaridhw ruaridhw force-pushed the fix/cplex_shell_logfile_1210 branch from 12cdacb to 33b0b2d Compare May 7, 2020 07:26
@ruaridhw
Copy link
Contributor Author

ruaridhw commented May 7, 2020

@michaelbynum, this should be ready to review whenever you get a chance

@michaelbynum
Copy link
Contributor

@ruaridhw Thanks. I will review these PRs early next week.

Base automatically changed from master to main February 26, 2021 15:07
@blnicho blnicho requested a review from emma58 March 29, 2022 19:00
@mrmundt
Copy link
Contributor

mrmundt commented Jan 9, 2024

This PR is going to be superseded by work to complete #1030 - which builds in base support for "no solution" to all solver interfaces. As such, I am going to close this PR.

@mrmundt mrmundt closed this Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants