Skip to content

Conversation

@alyst
Copy link
Contributor

@alyst alyst commented Jan 27, 2026

Extracted from #245 -- moving all engine-specific code (types) into extensions for modularity and leaner API, updating docstrings to make all optimizer help available for the user.

Requires #245 to be merged first.

@alyst alyst mentioned this pull request Jan 27, 2026
@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 56.25000% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.15%. Comparing base (8b0f880) to head (2b42351).
⚠️ Report is 58 commits behind head on devel.

Files with missing lines Patch % Lines
src/optimizer/abstract.jl 15.38% 11 Missing ⚠️
ext/SEMNLOptExt/NLopt.jl 86.66% 2 Missing ⚠️
src/optimizer/Empty.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel     #299      +/-   ##
==========================================
- Coverage   72.94%   72.15%   -0.80%     
==========================================
  Files          50       51       +1     
  Lines        2218     2216       -2     
==========================================
- Hits         1618     1599      -19     
- Misses        600      617      +17     

☔ View full report in Codecov by Sentry.
📢 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.

alyst and others added 13 commits January 27, 2026 12:45
It is a simple and intuitive syntax and avoids declaring new types.
Also allow specifying default constraint tolerance as `constraint_tol`.
use SemOptimizer(engine = :NLopt) instead of SemOptimizerNLopt()
as this is a more universal scheme
It works around docstring errors during SemOptimizer{:E} parsing.
Instead of engine-specific subtype as it might be not available
in the user session.
@alyst alyst force-pushed the refactor_semopt_api branch from fe23e46 to 8dacd43 Compare January 27, 2026 20:52
@alyst alyst marked this pull request as ready for review January 27, 2026 20:55
@alyst
Copy link
Contributor Author

alyst commented Jan 27, 2026

Rebased to the current devel

Alexey Stukalov added 3 commits January 27, 2026 13:50

"""
Uses *NLopt.jl* as the optimization engine.
Only available if *NLopt.jl* is loaded in the current Julia session!

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
Only available if *NLopt.jl* is loaded in the current Julia session!
!isa(inequality_constraints, NamedTuple) ||

Comment on lines +3 to +7
When [`NLopt.jl`](https://github.com/jump-dev/NLopt.jl) is loaded in the running Julia session,
it could be used by the [`SemOptimizer`](@ref) by specifying `engine = :NLopt`
(see [NLopt-specific options](@ref `SemOptimizer(Val(:NLopt))`)).
Among other things, `NLopt` enables constrained optimization of the SEM models, which is
explained in the [Constrained optimization](@ref) section.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
When [`NLopt.jl`](https://github.com/jump-dev/NLopt.jl) is loaded in the running Julia session,
it could be used by the [`SemOptimizer`](@ref) by specifying `engine = :NLopt`
(see [NLopt-specific options](@ref `SemOptimizer(Val(:NLopt))`)).
Among other things, `NLopt` enables constrained optimization of the SEM models, which is
explained in the [Constrained optimization](@ref) section.
When [`NLopt.jl`](https://github.com/jump-dev/NLopt.jl) is loaded in the running Julia session,
it can be used by the [`SemOptimizer`](@ref) by specifying `engine = :NLopt`
(see [NLopt-specific options](@ref `SemOptimizer(Val(:NLopt))`)).
Among other things, `NLopt` enables constrained optimization of SEMs, which is
explained in the [Constrained optimization](@ref) section.

To choose an algorithm, just pass its name without the 'NLOPT\_' prefix (for example, 'NLOPT\_LD\_SLSQP' can be used by passing `algorithm = :LD_SLSQP`).

The README of the [julia package](https://github.com/JuliaOpt/NLopt.jl) may also be helpful, and provides a list of options:
The README of the [*NLopt.jl*](https://github.com/JuliaOpt/NLopt.jl) may also be helpful, and provides a list of options:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The README of the [*NLopt.jl*](https://github.com/JuliaOpt/NLopt.jl) may also be helpful, and provides a list of options:
The README of [*NLopt.jl*](https://github.com/JuliaOpt/NLopt.jl) may also be helpful, and provides a list of options:

Comment on lines +8 to +10
You can define lasso, elastic net and other forms of regularization using [`ProximalOperators.jl`](https://github.com/JuliaFirstOrder/ProximalOperators.jl)
and optimize the SEM model with [`ProximalAlgorithms.jl`](https://github.com/JuliaFirstOrder/ProximalAlgorithms.jl)
that provides so-called *proximal optimization* algorithms.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
You can define lasso, elastic net and other forms of regularization using [`ProximalOperators.jl`](https://github.com/JuliaFirstOrder/ProximalOperators.jl)
and optimize the SEM model with [`ProximalAlgorithms.jl`](https://github.com/JuliaFirstOrder/ProximalAlgorithms.jl)
that provides so-called *proximal optimization* algorithms.
You can define lasso, elastic net and other forms of regularization using [`ProximalOperators.jl`](https://github.com/JuliaFirstOrder/ProximalOperators.jl)
and optimize the SEM with so-called *proximal optimization* algorithms from [`ProximalAlgorithms.jl`](https://github.com/JuliaFirstOrder/ProximalAlgorithms.jl).

Comment on lines +26 to +27
With *ProximalAlgorithms* package loaded, it is now possible to use `:Proximal` optimization engine
in `SemOptimizer` for estimating regularized models.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
With *ProximalAlgorithms* package loaded, it is now possible to use `:Proximal` optimization engine
in `SemOptimizer` for estimating regularized models.
With the *ProximalAlgorithms* package loaded, it is now possible to use the `:Proximal` optimization engine
in `SemOptimizer` for estimating regularized models.

To define a sup of separable proximal operators (i.e. no parameter is penalized twice),
we can use [`SlicedSeparableSum`](https://juliafirstorder.github.io/ProximalOperators.jl/stable/calculus/#ProximalOperators.SlicedSeparableSum) from the `ProximalOperators` package:
Since we apply *l1* and *l0* to the disjoint sets of parameters, this regularization could be represented as
as sum of *separable proximal operators* (i.e. no parameter is penalized twice)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
as sum of *separable proximal operators* (i.e. no parameter is penalized twice)
a sum of *separable proximal operators* (i.e. no parameter is penalized twice)

@Maximilian-Stefan-Ernst
Copy link
Collaborator

I opened alyst#4 to try to streamline the access of the docs a bit further - let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants