Pyomo / pyomo

An object-oriented algebraic modeling language in Python for structured optimization problems.
https://www.pyomo.org
Other
2k stars 514 forks source link

Feasibility pump still fails when using appsi_highs in MindtPy #2951

Closed ZedongPeng closed 5 months ago

ZedongPeng commented 1 year ago

Summary

MindtPy will support appsi_highs solver after #2887 gets merged. However, feasibility pump tests still fail after #2903 . It's a little bit weird since MindtPy works well with appsi_cplex and appsi_gurobi. Therefore, I am wondering if there is anything special or different with appsi_highs?

Steps to reproduce the issue

Use MindtPy on the mindtpy-rewrite branch.

# example.py
from pyomo.environ import *
from pyomo.contrib.mindtpy.tests.online_doc_example import OnlineDocExample

results = SolverFactory('mindtpy').solve(
                OnlineDocExample(),
                strategy='FP',
                mip_solver='appsi_cplex',
                nlp_solver='ipopt',
                absolute_bound_tolerance=1e-5,
                tee=True
            )
print(results)

results = SolverFactory('mindtpy').solve(
                OnlineDocExample(),
                strategy='FP',
                mip_solver='appsi_highs',
                nlp_solver='ipopt',
                absolute_bound_tolerance=1e-5,
                tee=True
            )
print(results)

Error Message

Output when using MindtPy with appsi_cplex

-----------------------------------------------------------------------------------------------
               Mixed-Integer Nonlinear Decomposition Toolbox in Pyomo (MindtPy)                
-----------------------------------------------------------------------------------------------
For more information, please visit 
https://pyomo.readthedocs.io/en/stable/contributed_packages/mindtpy.html
If you use this software, please cite the following:
Bernal, David E., et al. Mixed-integer nonlinear decomposition toolbox for Pyomo (MindtPy).
Computer Aided Chemical Engineering. Vol. 44. Elsevier, 2018. 895-900.

Original model has 2 constraints (2 nonlinear) and 0 disjunctions, with 2 variables, of which 1 are binary, 0 are integer, and 1 are continuous.
FP is the initial strategy being used.

 ===============================================================================================
 Iteration | Subproblem Type | Objective Value | Primal Bound |   Dual Bound |   Gap   | Time(s)

Moving objective to constraint set.
         -       Relaxed NLP                 1            inf              1      nan%      0.08
         1            FP-MIP          0.281353            inf              1      nan%      0.12
         1            FP-NLP              0.01            inf              1      nan%      0.15
         2            FP-MIP               0.9            inf              1      nan%      0.16
         2            FP-NLP       1.49165e-09            inf              1      nan%      0.20
*        1         Fixed NLP           2.43845        2.43845              1    58.99%      0.23
FP-MIP infeasible
 Primal integral          :    0.0000 
 Dual integral            :    0.0000 
 Primal-dual gap integral :    0.0000 
.
----------------------------------------------------------------------

Output of MindtPy with appsi_highs

-----------------------------------------------------------------------------------------------
               Mixed-Integer Nonlinear Decomposition Toolbox in Pyomo (MindtPy)                
-----------------------------------------------------------------------------------------------
For more information, please visit 
https://pyomo.readthedocs.io/en/stable/contributed_packages/mindtpy.html
If you use this software, please cite the following:
Bernal, David E., et al. Mixed-integer nonlinear decomposition toolbox for Pyomo (MindtPy).
Computer Aided Chemical Engineering. Vol. 44. Elsevier, 2018. 895-900.

Original model has 2 constraints (2 nonlinear) and 0 disjunctions, with 2 variables, of which 1 are binary, 0 are integer, and 1 are continuous.
FP is the initial strategy being used.

 ===============================================================================================
 Iteration | Subproblem Type | Objective Value | Primal Bound |   Dual Bound |   Gap   | Time(s)

Moving objective to constraint set.
         -       Relaxed NLP                 1            inf              1      nan%      0.07
Running HiGHS 1.5.3 [date: 2023-08-11, git hash: c3ca042f7]
Copyright (c) 2023 HiGHS under MIT licence terms
         1            FP-MIP          0.281353            inf              1      nan%      0.08
         1            FP-NLP              0.01            inf              1      nan%      0.12
         2            FP-MIP                 0            inf              1      nan%      0.12
         2            FP-NLP       1.33798e-16            inf              1      nan%      0.17
E
======================================================================
ERROR: test_FP (__main__.TestMindtPy)
Test the feasibility pump algorithm.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/zedongpeng/Github/pyomo/pyomo/contrib/mindtpy/tests/test_mindtpy_feas_pump.py", line 62, in test_FP
    results = opt.solve(
  File "/Users/zedongpeng/Github/pyomo/pyomo/contrib/mindtpy/MindtPy.py", line 113, in solve
    return SolverFactory(_supported_algorithms[config.strategy][0]).solve(
  File "/Users/zedongpeng/Github/pyomo/pyomo/contrib/mindtpy/algorithm_base_class.py", line 2713, in solve
    self.MindtPy_initialization()
  File "/Users/zedongpeng/Github/pyomo/pyomo/contrib/mindtpy/algorithm_base_class.py", line 788, in MindtPy_initialization
    self.fp_loop()
  File "/Users/zedongpeng/Github/pyomo/pyomo/contrib/mindtpy/algorithm_base_class.py", line 2462, in fp_loop
    self.handle_fp_subproblem_optimal(fp_nlp)
  File "/Users/zedongpeng/Github/pyomo/pyomo/contrib/mindtpy/algorithm_base_class.py", line 2343, in handle_fp_subproblem_optimal
    self.handle_subproblem_optimal(fixed_nlp)
  File "/Users/zedongpeng/Github/pyomo/pyomo/contrib/mindtpy/algorithm_base_class.py", line 1160, in handle_subproblem_optimal
    add_no_good_cuts(
  File "/Users/zedongpeng/Github/pyomo/pyomo/contrib/mindtpy/cut_generation.py", line 327, in add_no_good_cuts
    raise ValueError(
ValueError: Binary y = 0.10000000869092351 is not 0 or 1

The difference is the second iteration of the feasibility pump. Output of appsi_cplex

         2            FP-MIP               0.9            inf              1      nan%      0.16
Result of solving FP-MIP
Problem: 
- Lower bound: 0.8999999913090765
  Upper bound: 0.8999999913090765
  Number of objectives: 1
  Number of constraints: 0
  Number of variables: 0
  Sense: 1
Solver: 
- Status: ok
  Termination condition: optimal
  Termination message: TerminationCondition.optimal
Solution: 
- number of solutions: 1
  number of solutions displayed: 1
- Gap: 0.0
  Status: optimal
  Objective: No values
  Variable:
    x1:
      Value: 1
    x2:
      Value: 1
    x5:
      Value: 1
    x6:
      Value: 0.8999999913090765
  Constraint: No values

Output of appsi_highs

         2            FP-MIP                 0            inf              1      nan%      0.12
Result of solving FP-MIP
Problem: 
- Lower bound: 0.0
  Upper bound: 0.0
  Number of objectives: 1
  Number of constraints: 0
  Number of variables: 0
  Sense: 1
Solver: 
- Status: ok
  Termination condition: optimal
  Termination message: TerminationCondition.optimal
Solution: 
- number of solutions: 1
  number of solutions displayed: 1
- Gap: 0.0
  Status: optimal
  Objective: No values
  Variable:
    MindtPy_utils.objective_value[1]:
      Value: 1
    x:
      Value: 1
    y:
      Value: 0.10000000869092351
  Constraint: No values

I set the update_config all to True.

Information on your system

Pyomo version: 6.6.2.dev0 Python version: 3.10.12 Operating system: macOS How Pyomo was installed (PyPI, conda, source): source Solver (if applicable): appsi_cplex, appsi_highs, ipopt

Additional information

michaelbynum commented 1 year ago

I've created an issue in the HiGHS repo for this (https://github.com/ERGO-Code/HiGHS/issues/1386).