Skip to content

Add support for custom model - #273

Draft
blegat wants to merge 7 commits into
masterfrom
bl/diff_backend
Draft

blegat wants to merge 7 commits into
masterfrom
bl/diff_backend

Conversation

@blegat

@blegat blegat commented Apr 8, 2026 •

Copy link
Copy Markdown
Member

@blegat
blegat marked this pull request as draft April 8, 2026 20:11
@codecov

codecov Bot commented Apr 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.65%. Comparing base (331de28) to head (e32848e).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
ext/NLoptMathOptInterfaceExt.jl 40.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #273      +/-   ##
==========================================
- Coverage   99.86%   98.65%   -1.21%     
==========================================
  Files           2        2              
  Lines         756      820      +64     
==========================================
+ Hits          755      809      +54     
- Misses          1       11      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread .github/workflows/ci.yml
using Pkg
Pkg.add([
PackageSpec(name="MathOptInterface", rev="bl/nonlinear_model"),
])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add [sources] section to Project.toml instead

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Well at minimum, it'll work for the newer versions. Just exclude 1.10 during testing.

blegat and others added 3 commits May 5, 2026 10:06
The nonlinear model is now built with MOI.Nonlinear.model(ad_backend),
which ArrayDiff overrides for ArrayDiff.Mode, so the ArrayDiff
dependency is removed. The default backend receives MOI's layered
model; the ObjectiveFunctionType query goes through a _has_nlp_objective
helper that understands the layers, plain models, and custom AD models.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`MOI.Nonlinear.model`, `ModelWithQuad` and `ModelWithOracles` only exist on
MathOptInterface#bl/linearity, so the extension failed to load against a
released MathOptInterface, which is what ArrayDiff's CI resolves.

The two layered-model methods of `_has_nlp_objective` are now only defined
when `ModelWithQuad` exists, and `_init_nlp_model` goes through
`_nonlinear_model`, which uses `MOI.Nonlinear.model` when available and
otherwise asks the backend's own package for `model`, as ArrayDiff defines
`ArrayDiff.model(::ArrayDiff.Mode)`. MOI's own backends keep using
`MOI.Nonlinear.Model`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants