mechmotum / cyipopt

Cython interface for the interior point optimzer IPOPT
Eclipse Public License 2.0
235 stars 54 forks source link

pyomo.common.errors.ApplicationError: No executable found for solver 'ipopt' #196

Closed yasirroni closed 1 year ago

yasirroni commented 1 year ago

Using mamba, I got this error:

    opt_results = optimizer.solve(self.instance, tee=tee)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    self.available(exception_flag=True)
  File "...\.micromamba\envs\default\Lib\site-packages\pyomo\opt\solver\shellcmd.py", line 139, in available
    raise ApplicationError(msg % self.name)
pyomo.common.errors.ApplicationError: No executable found for solver 'ipopt'
Name                     Version             Build               Channel
--------------------------------------------------------------------------------
  brotlipy                 0.7.0               py311ha68e1ae_1005  conda-forge
  bzip2                    1.0.8               h8ffe710_4          conda-forge
  ca-certificates          2022.12.7           h5b45459_0          conda-forge
  certifi                  2022.12.7           pyhd8ed1ab_0        conda-forge
  cffi                     1.15.1              py311h7d9ee11_3     conda-forge
  charset-normalizer       3.1.0               pyhd8ed1ab_0        conda-forge
  cryptography             40.0.1              py311h28e9c30_0     conda-forge
  cyipopt                  1.2.0               py311h5ff84fc_1     conda-forge
  idna                     3.4                 pyhd8ed1ab_0        conda-forge
  intel-openmp             2023.0.0            h57928b3_25922      conda-forge
  ipopt                    3.14.11             ha9547d1_0          conda-forge
  libblas                  3.9.0               16_win64_mkl        conda-forge
  libcblas                 3.9.0               16_win64_mkl        conda-forge
  libexpat                 2.5.0               h63175ca_1          conda-forge
  libffi                   3.4.2               h8ffe710_5          conda-forge
  libflang                 5.0.0               h6538335_20180525   conda-forge
  libhwloc                 2.9.0               h51c2c0f_0          conda-forge
  libiconv                 1.17                h8ffe710_0          conda-forge
  liblapack                3.9.0               16_win64_mkl        conda-forge
  libsqlite                3.40.0              hcfcfb64_0          conda-forge
  libxml2                  2.10.3              hc3477c8_6          conda-forge
  libzlib                  1.2.13              hcfcfb64_4          conda-forge
  llvm-meta                5.0.0               0                   conda-forge
  m2w64-gcc-libgfortran    5.3.0               6                   conda-forge
  m2w64-gcc-libs           5.3.0               7                   conda-forge
  m2w64-gcc-libs-core      5.3.0               7                   conda-forge
  m2w64-gmp                6.1.0               2                   conda-forge
  m2w64-libwinpthread-git  5.0.0.4634.697f757  2                   conda-forge
  metis                    5.1.0               h0e60522_1006       conda-forge
  mkl                      2022.1.0            h6a75c08_874        conda-forge
  msys2-conda-epoch        20160418            1                   conda-forge
  mumps-seq                5.2.1               hb3f9cae_11         conda-forge
  numpy                    1.24.2              py311h0b4df5a_0     conda-forge
  openmp                   5.0.0               vc14_1              conda-forge
  openssl                  3.1.0               hcfcfb64_0          conda-forge
  packaging                23.0                pyhd8ed1ab_0        conda-forge
  pip                      23.0.1              pyhd8ed1ab_0        conda-forge
  platformdirs             3.2.0               pyhd8ed1ab_0        conda-forge
  ply                      3.11                py_1                conda-forge
  pooch                    1.7.0               pyha770c72_3        conda-forge
  pthreads-win32           2.9.1               hfa6e2cd_3          conda-forge
  pycparser                2.21                pyhd8ed1ab_0        conda-forge
  pyomo                    6.5.0               py311h12c1d0e_0     conda-forge
  pyopenssl                23.1.1              pyhd8ed1ab_0        conda-forge
  pysocks                  1.7.1               pyh0701188_6        conda-forge
  python                   3.11.2              h2628c8c_0_cpython  conda-forge
  python_abi               3.11                3_cp311             conda-forge
  requests                 2.28.2              pyhd8ed1ab_1        conda-forge
  scipy                    1.10.1              py311h37ff6ca_0     conda-forge
  setuptools               67.6.1              pyhd8ed1ab_0        conda-forge
  tbb                      2021.8.0            h91493d7_0          conda-forge
  tk                       8.6.12              h8ffe710_0          conda-forge
  typing-extensions        4.5.0               hd8ed1ab_0          conda-forge
  typing_extensions        4.5.0               pyha770c72_0        conda-forge
  tzdata                   2023c               h71feb2d_0          conda-forge
  ucrt                     10.0.22621.0        h57928b3_0          conda-forge
  urllib3                  1.26.15             pyhd8ed1ab_0        conda-forge
  vc                       14.3                hb6edc58_10         conda-forge
  vs2015_runtime           14.34.31931         h4c5c07a_10         conda-forge
  wheel                    0.40.0              pyhd8ed1ab_0        conda-forge
  win_inet_pton            1.1.0               pyhd8ed1ab_6        conda-forge
  xz                       5.2.6               h8d14728_0          conda-forge

I use this yml file to create env

name: default

channels:
  - conda-forge

dependencies:
  - python
  - pip
  - cyipopt
moorepants commented 1 year ago

Firstly, this seems to be a pyomo error, so I think you should report it there first.

mamba seems to work fine for cyipopt for me on linux (we test the conda binaries on all operating systems):

examples(master)$ mamba create -n cyipopt-test python pip cyipopt

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (1.4.0) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████

Looking for: ['python', 'pip', 'cyipopt']

conda-forge/noarch                                  11.8MB @   4.3MB/s  3.1s
conda-forge/linux-64                                30.6MB @   4.6MB/s  7.7s
Transaction

  Prefix: /home/moorepants/miniconda/envs/cyipopt-test

  Updating specs:

   - python
   - pip
   - cyipopt

  Package                  Version  Build                Channel                    Size
──────────────────────────────────────────────────────────────────────────────────────────
  Install:
──────────────────────────────────────────────────────────────────────────────────────────

  + _libgcc_mutex              0.1  conda_forge          conda-forge/linux-64     Cached
  + _openmp_mutex              4.5  2_gnu                conda-forge/linux-64     Cached
  + ampl-mp                  3.1.0  h2cc385e_1006        conda-forge/linux-64     Cached
  + bzip2                    1.0.8  h7f98852_4           conda-forge/linux-64     Cached
  + ca-certificates      2022.12.7  ha878542_0           conda-forge/linux-64     Cached
  + cyipopt                  1.2.0  py311hd28d000_1      conda-forge/linux-64      138kB
  + ipopt                  3.14.11  hf9e1ecf_0           conda-forge/linux-64     Cached
  + ld_impl_linux-64          2.40  h41732ed_0           conda-forge/linux-64     Cached
  + libblas                  3.9.0  16_linux64_openblas  conda-forge/linux-64     Cached
  + libcblas                 3.9.0  16_linux64_openblas  conda-forge/linux-64     Cached
  + libedit           3.1.20191231  he28a2e2_2           conda-forge/linux-64     Cached
  + libexpat                 2.5.0  hcb278e6_1           conda-forge/linux-64     Cached
  + libffi                   3.4.2  h7f98852_5           conda-forge/linux-64     Cached
  + libgcc-ng               12.2.0  h65d4601_19          conda-forge/linux-64     Cached
  + libgfortran-ng          12.2.0  h69a702a_19          conda-forge/linux-64     Cached
  + libgfortran5            12.2.0  h337968e_19          conda-forge/linux-64     Cached
  + libgomp                 12.2.0  h65d4601_19          conda-forge/linux-64     Cached
  + libiconv                  1.17  h166bdaf_0           conda-forge/linux-64     Cached
  + liblapack                3.9.0  16_linux64_openblas  conda-forge/linux-64     Cached
  + libnsl                   2.0.0  h7f98852_0           conda-forge/linux-64     Cached
  + libopenblas             0.3.21  pthreads_h78a6416_3  conda-forge/linux-64     Cached
  + libsqlite               3.40.0  h753d276_0           conda-forge/linux-64     Cached
  + libstdcxx-ng            12.2.0  h46fd767_19          conda-forge/linux-64     Cached
  + libuuid                 2.38.1  h0b41bf4_0           conda-forge/linux-64     Cached
  + libzlib                 1.2.13  h166bdaf_4           conda-forge/linux-64     Cached
  + metis                    5.1.0  h58526e2_1006        conda-forge/linux-64     Cached
  + mumps-include            5.2.1  ha770c72_11          conda-forge/linux-64     Cached
  + mumps-seq                5.2.1  h2104b81_11          conda-forge/linux-64     Cached
  + ncurses                    6.3  h27087fc_1           conda-forge/linux-64     Cached
  + numpy                   1.24.2  py311h8e6699e_0      conda-forge/linux-64     Cached
  + openssl                  3.1.0  h0b41bf4_0           conda-forge/linux-64     Cached
  + pip                     23.0.1  pyhd8ed1ab_0         conda-forge/noarch       Cached
  + python                  3.11.2  h2755cc3_0_cpython   conda-forge/linux-64     Cached
  + python_abi                3.11  3_cp311              conda-forge/linux-64     Cached
  + readline                   8.2  h8228510_1           conda-forge/linux-64     Cached
  + scotch                   6.0.9  hb2e6521_2           conda-forge/linux-64     Cached
  + setuptools              67.6.1  pyhd8ed1ab_0         conda-forge/noarch       Cached
  + tk                      8.6.12  h27826a3_0           conda-forge/linux-64     Cached
  + tzdata                   2023c  h71feb2d_0           conda-forge/noarch       Cached
  + unixodbc                2.3.10  h583eb01_0           conda-forge/linux-64     Cached
  + wheel                   0.40.0  pyhd8ed1ab_0         conda-forge/noarch       Cached
  + xz                       5.2.6  h166bdaf_0           conda-forge/linux-64     Cached
  + zlib                    1.2.13  h166bdaf_4           conda-forge/linux-64     Cached

  Summary:

  Install: 43 packages

  Total download: 138kB

──────────────────────────────────────────────────────────────────────────────────────────

cyipopt                                            138.5kB @ 412.9kB/s  0.3s

Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

To activate this environment, use

     $ mamba activate cyipopt-test

To deactivate an active environment, use

     $ mamba deactivate

examples(master)$ act cyipopt-test 
(cyipopt-test) examples(master)$ ls
exception_handling.py  hs071.py  hs071_scipy_jax.py  lasso.py  rosen.py
(cyipopt-test) examples(master)$ python hs071.py 

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit https://github.com/coin-or/Ipopt
******************************************************************************

This is Ipopt version 3.14.11, running with linear solver MUMPS 5.2.1.

Number of nonzeros in equality constraint Jacobian...:        4
Number of nonzeros in inequality constraint Jacobian.:        4
Number of nonzeros in Lagrangian Hessian.............:       10

Total number of variables............................:        4
                     variables with only lower bounds:        0
                variables with lower and upper bounds:        4
                     variables with only upper bounds:        0
Total number of equality constraints.................:        1
Total number of inequality constraints...............:        1
        inequality constraints with only lower bounds:        1
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

Objective value at iteration #0 is - 16.1097
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.6109693e+01 1.12e+01 1.02e+00   0.0 0.00e+00    -  0.00e+00 0.00e+00   0
Objective value at iteration #1 is - 17.3461
   1  1.7346108e+01 7.50e-01 2.37e+01  -0.3 7.22e-01    -  3.51e-01 1.00e+00f  1
Objective value at iteration #2 is - 17.9222
   2  1.7922201e+01 7.70e-03 5.29e+00  -0.2 6.00e-02   2.0 9.96e-01 1.00e+00h  1
Objective value at iteration #3 is - 17.1673
   3  1.7167308e+01 6.72e-02 1.66e+00  -0.8 1.37e+00    -  9.95e-01 6.98e-01f  1
Objective value at iteration #4 is - 16.9893
   4  1.6989299e+01 1.02e-01 1.47e-01  -1.2 2.30e-01    -  9.92e-01 1.00e+00f  1
Objective value at iteration #5 is - 16.9944
   5  1.6994402e+01 3.39e-02 1.19e-02  -2.3 8.69e-02    -  9.84e-01 1.00e+00h  1
Objective value at iteration #6 is - 17.014
   6  1.7013957e+01 2.20e-04 3.14e-04  -3.8 1.15e-02    -  9.99e-01 1.00e+00h  1
Objective value at iteration #7 is - 17.014
   7  1.7014017e+01 6.30e-07 1.31e-06  -9.7 3.43e-04    -  9.99e-01 9.99e-01h  1
Objective value at iteration #8 is - 17.014
   8  1.7014017e+01 5.61e-13 8.50e-13 -11.0 5.69e-07    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 8

                                   (scaled)                 (unscaled)
Objective...............:   3.4028034280427242e+01    1.7014017140213621e+01
Dual infeasibility......:   8.5010828358650403e-13    4.2505414179325202e-13
Constraint violation....:   5.6132876125047915e-13    5.6132876125047915e-13
Variable bound violation:   9.9952566223748818e-09    9.9952566223748818e-09
Complementarity.........:   1.1688338037511438e-11    5.8441690187557189e-12
Overall NLP error.......:   1.1688338037511438e-11    5.8441690187557189e-12

Number of objective function evaluations             = 9
Number of objective gradient evaluations             = 9
Number of equality constraint evaluations            = 9
Number of inequality constraint evaluations          = 9
Number of equality constraint Jacobian evaluations   = 9
Number of inequality constraint Jacobian evaluations = 9
Number of Lagrangian Hessian evaluations             = 8
Total seconds in IPOPT                               = 0.016

EXIT: Optimal Solution Found.
Solution of the primal variables: x=array([0.99999999, 4.74299964, 3.82114998, 1.37940829])

Solution of the dual variables: lambda=array([-0.55229366,  0.16146856])

Objective=17.01401714021362
yasirroni commented 1 year ago

Weird,

(pyopf) ...>python examples\check_ipopt.py                                                                                                                                                                                        ******************************************************************************                                          This program contains Ipopt, a library for large-scale nonlinear optimization.                                           Ipopt is released as open source code under the Eclipse Public License (EPL).                                                   For more information visit https://github.com/coin-or/Ipopt                                                    ******************************************************************************                                                                                                                                                                  This is Ipopt version 3.14.11, running with linear solver MUMPS 5.2.1.                                                                                                                                                                          Number of nonzeros in equality constraint Jacobian...:        4                                                         Number of nonzeros in inequality constraint Jacobian.:        4                                                         Number of nonzeros in Lagrangian Hessian.............:       10                                                                                                                                                                                 Total number of variables............................:        4                                                                              variables with only lower bounds:        0                                                                         variables with lower and upper bounds:        4                                                                              variables with only upper bounds:        0                                                         Total number of equality constraints.................:        1                                                         Total number of inequality constraints...............:        1                                                                 inequality constraints with only lower bounds:        1                                                            inequality constraints with lower and upper bounds:        0                                                                 inequality constraints with only upper bounds:        0                                                                                                                                                                                 Objective value at iteration #0 is - 16.1097                                                                            iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls                                           0  1.6109693e+01 1.12e+01 1.02e+00   0.0 0.00e+00    -  0.00e+00 0.00e+00   0                                        Objective value at iteration #1 is - 17.3461                                                                               1  1.7346108e+01 7.50e-01 2.37e+01  -0.3 7.22e-01    -  3.51e-01 1.00e+00f  1                                        Objective value at iteration #2 is - 17.9222                                                                               2  1.7922201e+01 7.70e-03 5.29e+00  -0.2 6.00e-02   2.0 9.96e-01 1.00e+00h  1                                        Objective value at iteration #3 is - 17.1673                                                                               3  1.7167308e+01 6.72e-02 1.66e+00  -0.8 1.37e+00    -  9.95e-01 6.98e-01f  1                                        Objective value at iteration #4 is - 16.9893                                                                               4  1.6989299e+01 1.02e-01 1.47e-01  -1.2 2.30e-01    -  9.92e-01 1.00e+00f  1                                        Objective value at iteration #5 is - 16.9944                                                                               5  1.6994402e+01 3.39e-02 1.19e-02  -2.3 8.69e-02    -  9.84e-01 1.00e+00h  1                                        Objective value at iteration #6 is - 17.014                                                                                6  1.7013957e+01 2.20e-04 3.14e-04  -3.8 1.15e-02    -  9.99e-01 1.00e+00h  1                                        Objective value at iteration #7 is - 17.014                                                                                7  1.7014017e+01 6.30e-07 1.31e-06  -9.7 3.43e-04    -  9.99e-01 9.99e-01h  1                                        Objective value at iteration #8 is - 17.014                                                                                8  1.7014017e+01 5.61e-13 8.47e-13 -11.0 5.69e-07    -  1.00e+00 1.00e+00h  1                                                                                                                                                                Number of Iterations....: 8                                                                                                                                                                                                                                                        (scaled)                 (unscaled)                                                  Objective...............:   3.4028034280427242e+01    1.7014017140213621e+01                                            Dual infeasibility......:   8.4655556991432098e-13    4.2327778495716049e-13                                            Constraint violation....:   5.6132876125047915e-13    5.6132876125047915e-13                                            Variable bound violation:   9.9952566223748818e-09    9.9952566223748818e-09                                            Complementarity.........:   1.1688338037076061e-11    5.8441690185380307e-12                                            Overall NLP error.......:   1.1688338037076061e-11    5.8441690185380307e-12                                                                                                                                                                                                                                                                                            Number of objective function evaluations             = 9                                                                Number of objective gradient evaluations             = 9                                                                Number of equality constraint evaluations            = 9                                                                Number of inequality constraint evaluations          = 9                                                                Number of equality constraint Jacobian evaluations   = 9                                                                Number of inequality constraint Jacobian evaluations = 9                                                                Number of Lagrangian Hessian evaluations             = 8                                                                Total seconds in IPOPT                               = 0.157                                                                                                                                                                                    EXIT: Optimal Solution Found.                                                                                           Solution of the primal variables: x=array([0.99999999, 4.74299964, 3.82114998, 1.37940829])                                                                                                                                                     Solution of the dual variables: lambda=array([-0.55229366,  0.16146856])                                                                                                                                                                        Objective=17.01401714021362
(pyopf) C:\Data\Git\PyOPF>python examples\acopf_pglib.py
build model... end
instantiate model... end
WARNING: Could not locate the 'ipopt' executable, which is required for solver
    ipopt
Traceback (most recent call last):
  File ""...\examples\acopf_pglib.py", line 7, in <module>
    result = model.solve(solver='ipopt',
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ""...\opf\core\base.py", line 49, in solve
    return self._solve(optimizer, solve_method, tee, extract_dual)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ""...\opf\core\base.py", line 85, in _solve
    opt_results = optimizer.solve(self.instance, tee=tee)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\mambaforge\envs\pyopf\Lib\site-packages\pyomo\opt\base\solvers.py", line 513, in solve
    self.available(exception_flag=True)
  File "...\mambaforge\envs\pyopf\Lib\site-packages\pyomo\opt\solver\shellcmd.py", line 139, in available
    raise ApplicationError(msg % self.name)
pyomo.common.errors.ApplicationError: No executable found for solver 'ipopt'
yasirroni commented 1 year ago

Solved by manually add the path to environment variable ...\Ipopt-3.13.3-win64-msvs2019-md\bin and restart PC.