You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ed078b6
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/controller/nonlinmpc.jl
+23-42Lines changed: 23 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -825,12 +825,14 @@ Return the nonlinear operator for the objective of `mpc` [`NonLinMPC`](@ref).
825
825
826
826
It is based on the splatting syntax. This method is really intricate and that's because of:
827
827
828
-
- These functions are used inside the nonlinear optimization, so they must be type-stable
829
-
and as efficient as possible. All the function outputs and derivatives are cached and
830
-
updated in-place if required to use the efficient [`value_and_gradient!`](@extref DifferentiationInterface DifferentiationInterface.value_and_jacobian!).
831
-
- The splatting syntax for objective functions implies the use of `Vararg{T,N}` (see the [performance tip](@extref Julia Be-aware-of-when-Julia-avoids-specializing))
832
-
and memoization to avoid redundant computations. This is already complex, but it's even
833
-
worse knowing that the automatic differentiation tools do not support splatting.
828
+
- These functions are used inside the nonlinear optimization, so as efficient as possible.
829
+
All the function outputs and derivatives are cached and updated in-place if required to
830
+
use the efficient [`value_and_gradient!`](@extref DifferentiationInterface DifferentiationInterface.value_and_jacobian!).
831
+
- The splatting syntax is required for [`add_nonlinear_operator`](@extref JuMP JuMP.add_nonlinear_operator)
832
+
but automatic differentiation tools do not support splatting.
833
+
- The internal of `MOI.jl` calls the 3 functions of `add_nonlinear_operator` with a runtime
834
+
dispatch. It is thus a waste of time and resources to compile (a.k.a specialize) these
835
+
functions. The `NoTypeFunction` wrapper hide their concrete type to disable compilation.
834
836
- The signature of gradient and hessian functions is not the same for univariate (`nZ̃ == 1`)
835
837
and multivariate (`nZ̃ > 1`) operators in `JuMP`. Both must be defined.
836
838
"""
@@ -897,51 +899,30 @@ function get_nonlinobj_op(mpc::NonLinMPC, optim::JuMP.GenericModel{JNT}) where J
0 commit comments