Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/juliaci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
with:
include-windows-x86: false # not worth it, windows 32bit is too uncommon
include-macos-x64: false # most mac are aarch64 nowadays
include-macos-aarch64: false # would like to include it, but too unreliable for now
include-linux-x86: false # would like to include it, but too unreliable for now
permissions: write-all
secrets:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ModelPredictiveControl"
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
version = "2.16.1"
version = "2.16.2"
authors = ["Francis Gagnon"]

[deps]
Expand Down
16 changes: 13 additions & 3 deletions src/controller/nonlinmpc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -943,10 +943,20 @@ function get_nonlinobj_op(mpc::NonLinMPC, optim::JuMP.GenericModel{JNT}) where J
return fill_diffstructure!(∇²J_arg, ∇²J, ∇²J_structure)
end
end
if !isnothing(hess)
@operator(optim, J_op, nZ̃, J_func, ∇J_func!, ∇²J_func!)
J_op = if !isnothing(hess)
JuMP.add_nonlinear_operator(
optim, nZ̃,
NoTypeFunction(J_func),
NoTypeFunction(∇J_func!),
NoTypeFunction(∇²J_func!);
name = :J_op)
else
@operator(optim, J_op, nZ̃, J_func, ∇J_func!)
JuMP.add_nonlinear_operator(
optim,
nZ̃,
NoTypeFunction(J_func),
NoTypeFunction(∇J_func!);
name = :J_op)
end
return J_op
end
Expand Down
16 changes: 13 additions & 3 deletions src/estimator/mhe/construct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1551,10 +1551,20 @@ function get_nonlinobj_op(
update_objective!(J, ∇J, ∇²J, Z̃_J, Z̃_arg)
return fill_diffstructure!(∇²J_arg, ∇²J, ∇²J_structure)
end
if !isnothing(hess)
@operator(optim, J_op, nZ̃, J_func, ∇J_func!, ∇²J_func!)
J_op = if !isnothing(hess)
JuMP.add_nonlinear_operator(
optim, nZ̃,
NoTypeFunction(J_func),
NoTypeFunction(∇J_func!),
NoTypeFunction(∇²J_func!);
name = :J_op)
else
@operator(optim, J_op, nZ̃, J_func, ∇J_func!)
JuMP.add_nonlinear_operator(
optim,
nZ̃,
NoTypeFunction(J_func),
NoTypeFunction(∇J_func!);
name = :J_op)
end
return J_op
end
Expand Down
15 changes: 15 additions & 0 deletions src/general.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ const ERROR_STATUSES = (
JuMP.INVALID_OPTION, JuMP.INTERRUPTED, JuMP.OTHER_ERROR
)

"""
A callable wrapper that erases the concrete type of its function.

The `f` field is deliberately an abstract type (`Function`) to hide its concrete type. It
means that calling this wrapper produces a dynamic dispatch, which is acceptable since MOI
already does a dynamic dispatch when calling registered nonlinear operators. The goal is
to hide the concrete type of `J_func`, `∇J_func` and `∇²J_func` closures at construction,
since they are huge because of all the captured variables. Methods are slow to compile when
their signature contains giant types. The constructor TTFX is thus reduced with this trick.
"""
struct NoTypeFunction <: Function
f::Function
end
(obj::NoTypeFunction)(args...) = obj.f(args...)

"Verify that `optim` termination status is `OPTIMAL` or `LOCALLY_SOLVED`."
function issolved(optim::JuMP.GenericModel)
status = JuMP.termination_status(optim)
Expand Down
Loading