Closed sbugosen closed 7 months ago
How long does this take to fail for you? When I run implicit_fs_mixer_included.py
I get a reported 260 s spend in Ipopt. I get the following traceback:
******************************************************************************
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 ma27.
Number of nonzeros in equality constraint Jacobian...: 2852
Number of nonzeros in inequality constraint Jacobian.: 4
Number of nonzeros in Lagrangian Hessian.............: 4359
Total number of variables............................: 760
variables with only lower bounds: 25
variables with lower and upper bounds: 711
variables with only upper bounds: 0
Total number of equality constraints.................: 757
Total number of inequality constraints...............: 4
inequality constraints with only lower bounds: 1
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 3
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 -9.0909091e-02 1.32e+06 1.00e+00 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Evaluation error during soft restoration phase step.
Warning: Evaluation error during soft restoration phase step.
Warning: Evaluation error during soft restoration phase step.
Restoration phase failed due to evaluation errors.
Number of Iterations....: 0
(scaled) (unscaled)
Exception of type: Eval_Error in file "Algorithm/IpOrigIpoptNLP.cpp" at line 499:
Exception message: success && IsFiniteNumber(ret) evaluated false: Error evaluating the objective function
Number of objective function evaluations = 14
Number of objective gradient evaluations = 2
Number of equality constraint evaluations = 23
Number of inequality constraint evaluations = 11
Number of equality constraint Jacobian evaluations = 1
Number of inequality constraint Jacobian evaluations = 1
Number of Lagrangian Hessian evaluations = 1
Total seconds in IPOPT = 259.271
EXIT: Invalid number in NLP function or derivative detected.
ERROR: Exception encountered during cyipopt solve:
Traceback (most recent call last):
...
...
...
pyomo.common.errors.IterationLimitError: Linesearch iteration limit reached solving for variable 'fs.combined_reformer.reformer_mix.mixed_state[0.0].temperature' using constraint 'fs.combined_reformer.reformer_mix.enthalpy_mixing_equations[0.0]'
; remaining residual = -2.384185791015625e-07.
Does this match what you see?
When I hard-code a new tolerance of 1e-6
for calculate_variable_from_constraint
, I get the following:
******************************************************************************
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 ma27.
Number of nonzeros in equality constraint Jacobian...: 2852
Number of nonzeros in inequality constraint Jacobian.: 4
Number of nonzeros in Lagrangian Hessian.............: 4359
Total number of variables............................: 760
variables with only lower bounds: 25
variables with lower and upper bounds: 711
variables with only upper bounds: 0
Total number of equality constraints.................: 757
Total number of inequality constraints...............: 4
inequality constraints with only lower bounds: 1
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 3
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 -9.0909091e-02 1.32e+06 1.00e+00 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0
Warning: SOC step rejected due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Evaluation error during soft restoration phase step.
Warning: Evaluation error during soft restoration phase step.
Warning: Evaluation error during soft restoration phase step.
Restoration phase failed due to evaluation errors.
Number of Iterations....: 0
(scaled) (unscaled)
Exception of type: Eval_Error in file "Algorithm/IpOrigIpoptNLP.cpp" at line 499:
Exception message: success && IsFiniteNumber(ret) evaluated false: Error evaluating the objective function
Number of objective function evaluations = 7
Number of objective gradient evaluations = 1
Number of equality constraint evaluations = 22
Number of inequality constraint evaluations = 3
Number of equality constraint Jacobian evaluations = 1
Number of inequality constraint Jacobian evaluations = 1
Number of Lagrangian Hessian evaluations = 1
Total seconds in IPOPT = 78.237
EXIT: Invalid number in NLP function or derivative detected.
Traceback (most recent call last):
...
...
...
pyomo.contrib.pynumero.exceptions.PyNumeroEvaluationError: Error in AMPL evaluation
How long does this take to fail for you? When I run
implicit_fs_mixer_included.py
I get a reported 260 s spend in Ipopt. I get the following traceback:****************************************************************************** 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 ma27. Number of nonzeros in equality constraint Jacobian...: 2852 Number of nonzeros in inequality constraint Jacobian.: 4 Number of nonzeros in Lagrangian Hessian.............: 4359 Total number of variables............................: 760 variables with only lower bounds: 25 variables with lower and upper bounds: 711 variables with only upper bounds: 0 Total number of equality constraints.................: 757 Total number of inequality constraints...............: 4 inequality constraints with only lower bounds: 1 inequality constraints with lower and upper bounds: 0 inequality constraints with only upper bounds: 3 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls 0 -9.0909091e-02 1.32e+06 1.00e+00 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0 Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Cutting back alpha due to evaluation error Warning: Evaluation error during soft restoration phase step. Warning: Evaluation error during soft restoration phase step. Warning: Evaluation error during soft restoration phase step. Restoration phase failed due to evaluation errors. Number of Iterations....: 0 (scaled) (unscaled) Exception of type: Eval_Error in file "Algorithm/IpOrigIpoptNLP.cpp" at line 499: Exception message: success && IsFiniteNumber(ret) evaluated false: Error evaluating the objective function Number of objective function evaluations = 14 Number of objective gradient evaluations = 2 Number of equality constraint evaluations = 23 Number of inequality constraint evaluations = 11 Number of equality constraint Jacobian evaluations = 1 Number of inequality constraint Jacobian evaluations = 1 Number of Lagrangian Hessian evaluations = 1 Total seconds in IPOPT = 259.271 EXIT: Invalid number in NLP function or derivative detected. ERROR: Exception encountered during cyipopt solve: Traceback (most recent call last): ... ... ... pyomo.common.errors.IterationLimitError: Linesearch iteration limit reached solving for variable 'fs.combined_reformer.reformer_mix.mixed_state[0.0].temperature' using constraint 'fs.combined_reformer.reformer_mix.enthalpy_mixing_equations[0.0]' ; remaining residual = -2.384185791015625e-07.
Does this match what you see?
I do get the same remaining residual and the same error. It takes for me 627 s. I'm still using an IDE and IPOPT 3.14.9 with MUMPS. I'll try to see what i can do with that variable and constraint.
'fs.combined_reformer.reformer_mix.mixed_state[0.0].temperature' 'fs.combined_reformer.reformer_mix.enthalpy_mixing_equations[0.0]'
I'm not 100% sure what's going on here. I'm not sure why the AMPL evaluation error isn't getting caught and handled. I also don't understand why we get the same termination status when we encounter the RuntimeError, which should be unhandled.
From what I see here, I think the problem we should try to debug is the original evaluation error. I will run with halt_on_evaluation_error=True
in CyIpopt and try to debug.
In the meantime, can you add an optional calc_var_kwds
argument to DecomposedImplicitFunctionBase
in this file: https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/pynumero/algorithms/solvers/implicit_functions.py#L558? This option should be a dict of options that get sent to calculate_variable_from_constraint
here: https://github.com/Pyomo/pyomo/blob/d04f6bbecce8261bd7dbb622a99489ecadf54e67/pyomo/contrib/pynumero/algorithms/solvers/implicit_functions.py#L558. This way we will be able to easily send arguments like {"eps": 1e-6}
to calculate_variable_from_constraint
from our ExternalPyomoModel
constructor. You can implement this on a branch of Pyomo, then open a PR on the main Pyomo repository. Let me know if you have any questions about how to do this.
The procedure is:
Is this correct?
On Wed, Jan 10, 2024 at 2:29 PM Robert Parker @.***> wrote:
In the meantime, can you add an optional calc_var_kwds argument to DecomposedImplicitFunctionBase in this file: https://github.com/Pyomo/pyomo/blob/main/pyomo/contrib/pynumero/algorithms/solvers/implicit_functions.py#L558? This option should be a dict of options that get sent to calculate_variable_from_constraint here: https://github.com/Pyomo/pyomo/blob/d04f6bbecce8261bd7dbb622a99489ecadf54e67/pyomo/contrib/pynumero/algorithms/solvers/implicit_functions.py#L558. This way we will be able to easily send arguments like {"eps": 1e-6} to calculate_variable_from_constraint from our ExternalPyomoModel constructor. You can implement this on a branch of Pyomo, then open a PR on the main Pyomo repository. Let me know if you have any questions about how to do this.
— Reply to this email directly, view it on GitHub https://github.com/Robbybp/surrogate-vs-implicit/pull/11#issuecomment-1885764113, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2YFNXXRZJOI7NH5YRWCLU3YN4B5DAVCNFSM6AAAAABBSEQLQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVG43DIMJRGM . You are receiving this because you authored the thread.Message ID: @.***>
Only these changes? I'm not entirely sure.
That is almost correct. Your line self._calc_var_kwds = calc_var_kwds or {}
should be self._calc_var_kwds = {} if calc_var_kwds is None else calc_var_kwds
. Then this functionality will need to be tested. I would just find one of the tests in pyomo/contrib/pynumero/algorithms/solvers/tests/test_implicit_functions.py
, and add a calc_var_kwds = {"eps": 1e-6}
option to the SccImplicitFunctionSolver
constructor. It is difficult to make sure that this option is actually doing something, so I think just passing the option and making sure it doesn't error is sufficient.
Can I complete this once my computer is all set up at the office? I want to do everything over the command line using Linux.
That sounds good to me
Closing this PR as we are not actively working on it. We can re-visit this PR/branch when/if we work on this.
This PR contains two files.
RuntimeError: Linesearch iteration limit reached; remaining residual = -2.384185791015625e-07.