Skip to content

Commit b3ec8a3

Browse files
authored
Update Optim to v2 (#191)
* Update Project.toml and source files for version 2.11.9 and autodiff improvements * up DataInt version
1 parent ebfb4e7 commit b3ec8a3

5 files changed

Lines changed: 14 additions & 11 deletions

File tree

‎Project.toml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name = "ControlSystemIdentification"
22
uuid = "3abffc1c-5106-53b7-b354-a47bfc086282"
33
authors = ["baggepinnen <baggepinnen@gmail.com>"]
4-
version = "2.11.8"
4+
version = "2.11.9"
55

66
[deps]
7+
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
78
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
89
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
910
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
@@ -35,6 +36,7 @@ LeastSquaresOptim = "0fc2ff8b-aaa3-5acd-a817-1944a5e08891"
3536
ControlSystemIdentificationLSOptExt = "LeastSquaresOptim"
3637

3738
[compat]
39+
ADTypes = "1"
3840
ChainRules = "1.58"
3941
ComponentArrays = "0.14, 0.15"
4042
ControlSystemsBase = "1.8"
@@ -50,7 +52,7 @@ LinearAlgebra = "1.6"
5052
LowLevelParticleFilters = "2.0, 3.0"
5153
MatrixEquations = "1.1, 2.0"
5254
MonteCarloMeasurements = "1.0"
53-
Optim = "<0.20, 0.20, 0.21, 0.22, 1.0"
55+
Optim = "2"
5456
Parameters = "<0.13"
5557
QuadGK = "2.4"
5658
Random = "1.6"

‎docs/Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SeeToDee = "1c904df7-48cd-41e7-921b-d889ed9a470c"
1616
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1717

1818
[compat]
19-
DataInterpolations = "7"
19+
DataInterpolations = "8"
2020
Documenter = "1"
2121
LowLevelParticleFilters = "3.3.5"
2222
PrettyTables = "2"

‎src/ControlSystemIdentification.jl‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module ControlSystemIdentification
22

3-
using ComponentArrays,
3+
using ADTypes,
4+
ComponentArrays,
45
ControlSystemsBase,
56
DelimitedFiles,
67
FFTW,

‎src/arx.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,9 @@ function tfest(
739739
end + 0.001abs2(a[1]-1) # Promote a monic polynomial for regularization (could enforce it without loss of generality.
740740
end
741741

742-
res = Optim.optimize(loss, ComponentVector(p0), opt, opts, autodiff = :forward)
742+
res = Optim.optimize(loss, ComponentVector(p0), opt, opts; autodiff = AutoForwardDiff())
743743
if refine
744-
res = Optim.optimize(loss2, res.minimizer, opt, opts, autodiff = :forward)
744+
res = Optim.optimize(loss2, res.minimizer, opt, opts; autodiff = AutoForwardDiff())
745745
end
746746
a0 = res.minimizer.a[1]
747747
tf(res.minimizer.b ./ a0, res.minimizer.a ./ a0)

‎src/pem.jl‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ using Optim, Optim.LineSearches
5353
optimizer = BFGS(
5454
linesearch = LineSearches.BackTracking(),
5555
),
56-
autodiff = :forward,
56+
autodiff = AutoForwardDiff(),
5757
store_trace = true,
5858
show_trace = true,
5959
show_every = 50,
@@ -90,7 +90,7 @@ If a manually provided initial guess `sys0`, this must also be scaled appropriat
9090
- `focus`: `prediction` or `:simulation`. If `:simulation`, the `K` matrix will be zero.
9191
- `h`: Prediction horizon for the prediction error filter. Large values of `h` makes the problem computationally expensive. As `h` approaches infinity, the problem approaches the `focus = :simulation` case.
9292
- `optimizer`: One of Optim's optimizers
93-
- `autodiff`: Whether or not to use forward-mode AD to compute gradients. `:forward` (default) for forward-mode AD, or `:finite` for finite differences.
93+
- `autodiff`: Whether or not to use forward-mode AD to compute gradients. `AutoForwardDiff()` (default) for forward-mode AD, or `AutoFiniteDiff()` for finite differences.
9494
- `metric`: The metric used to measure residuals. Try, e.g., `abs` for better resistance to outliers.
9595
The rest of the arguments are related to `Optim.Options`.
9696
- `regularizer`: A function of the parameter vector and the corresponding `PredictionStateSpace/StateSpace` system that can be used to regularize the estimate.
@@ -175,7 +175,7 @@ function newpem(
175175
# alphaguess = LineSearches.InitialStatic(alpha = 0.95),
176176
linesearch = LineSearches.BackTracking(),
177177
),
178-
autodiff = :forward,
178+
autodiff = AutoForwardDiff(),
179179
store_trace = true,
180180
show_trace = true,
181181
show_every = 50,
@@ -764,8 +764,8 @@ function structured_pem(
764764
optimizer,
765765
Optim.Options(;
766766
store_trace, show_trace, show_every, iterations, allow_f_increases,
767-
time_limit, x_abstol, f_abstol, g_tol, f_calls_limit, g_calls_limit),
768-
autodiff = :forward,
767+
time_limit, x_abstol, f_abstol, g_tol, f_calls_limit, g_calls_limit);
768+
autodiff = AutoForwardDiff(),
769769
)
770770
sys_opt, K_opt, x0_opt = inner_constructor(res.minimizer, constructor, d.Ts)
771771
sysp_opt = PredictionStateSpace(

0 commit comments

Comments
 (0)