Use Enzyme in ipopt rather than FiniteDiff#20
Merged
Conversation
# Conflicts: # Project.toml # examples/budgerigar.jl # src/endotherm/thermoregulation/ipopt.jl # src/endotherm/thermoregulation/rulebased.jl
Caller-side updates for upstream renames: generated_heat_flow → metabolic_heat_flow, per-side insulation_depth/conductivity moved under .dorsal/.ventral, shape_b → axis_ratio_b, respiration_mass → respiration_mass_flow. Adds `smoothing` field on IPOPTControl (default SmoothBound(1e-5)) threaded into nlp_pack so AD sees differentiable kinks.
mrke
approved these changes
May 11, 2026
| generated_heat_flow_ipopt, skin_temperature_ipopt, insulation_temperature_ipopt) | ||
|
|
||
| generated_heat_flow_ipopt = out.energy_flows.generated_heat_flow | ||
| generated_heat_flow_ipopt = out.energy_flows.metabolic_heat_flow |
Member
Author
There was a problem hiding this comment.
how come? why would it change?
| called at runtime when L-BFGS is active. | ||
| **Differentiation strategy.** Gradients and constraint Jacobians are computed via | ||
| [`Enzyme.jl`](https://github.com/EnzymeAD/Enzyme.jl): reverse-mode for the scalar objective | ||
| gradient and forward-mode for the constraint Jacobian. The `hess` and `cons_h` callbacks |
Contributor
There was a problem hiding this comment.
can delete this last caveat - it's repeated below in the limitations
| # of `p` doesn't compose with Unitful values. | ||
| # hess! and cons_h! are registered (required by IpoptOptimizer) but not | ||
| # called at runtime when hessian_approximation="limited-memory" is set. | ||
| function grad_fn!(g, x, _) |
Contributor
There was a problem hiding this comment.
we should go for expressive names in this IPOPT code too
Member
Author
There was a problem hiding this comment.
Yeah, all of these functions likely need to be deleted later on
Contributor
|
Would be good to keep finite diff as an option, at least initially to compare performance |
|
@rafaqz anything I can do for better unit support in DI? |
rafaqz
commented
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Still has a few hacky approaches skipping around DifferentiationInterface because of units.
We need to extract the unit stripping code from debtool into a shared package to clean this up.