Skip to content

Commit aa48eb1

Browse files
committed
changed: better jacobian and hessian defaults for the sparse case
1 parent 0bc9ebf commit aa48eb1

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/controller/nonlinmpc.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const DEFAULT_NONLINMPC_JACDENSE = AutoForwardDiff()
55
const DEFAULT_NONLINMPC_JACSPARSE = AutoSparse(
66
AutoForwardDiff();
77
sparsity_detector=TracerSparsityDetector(),
8-
coloring_algorithm=GreedyColoringAlgorithm(),
8+
coloring_algorithm=GreedyColoringAlgorithm(ALL_COLORING_ORDERS),
99
)
1010
const DEFAULT_NONLINMPC_HESSIAN = DEFAULT_NONLINMPC_JACSPARSE
1111

@@ -291,10 +291,11 @@ NonLinMPC controller with a sample time Ts = 10.0 s:
291291
AutoSparse(
292292
AutoForwardDiff();
293293
sparsity_detector = TracerSparsityDetector(),
294-
coloring_algorithm = GreedyColoringAlgorithm()
294+
coloring_algorithm = GreedyColoringAlgorithm(ALL_COLORING_ORDERS)
295295
)
296296
```
297-
This is also the sparse backend selected for the Hessian of the Lagrangian function if
297+
that is, it will test all coloring orders at preparation and keep the best. This is
298+
also the sparse backend selected for the Hessian of the Lagrangian function if
298299
`oracle=true` and `hessian=true`, which is the second exception. Second order
299300
derivatives are only supported with `oracle=true` option.
300301

src/estimator/mhe/construct.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const DEFAULT_NONLINMHE_JACOBIAN = AutoForwardDiff()
55
const DEFAULT_NONLINMHE_HESSIAN = AutoSparse(
66
AutoForwardDiff();
77
sparsity_detector=TracerSparsityDetector(),
8-
coloring_algorithm=GreedyColoringAlgorithm(),
8+
coloring_algorithm=GreedyColoringAlgorithm(ALL_COLORING_ORDERS),
99
)
1010

1111
@doc raw"""
@@ -382,9 +382,11 @@ MovingHorizonEstimator estimator with a sample time Ts = 10.0 s:
382382
AutoSparse(
383383
AutoForwardDiff();
384384
sparsity_detector = TracerSparsityDetector(),
385-
coloring_algorithm = GreedyColoringAlgorithm()
385+
coloring_algorithm = GreedyColoringAlgorithm(ALL_COLORING_ORDERS)
386386
)
387387
```
388+
that is, it will test all coloring orders at preparation and keep the best.
389+
388390
The slack variable ``ε`` relaxes the constraints if enabled, see [`setconstraint!`](@ref).
389391
It is disabled by default for the MHE (from `Cwt=Inf`) but it should be activated for
390392
problems with two or more types of bounds, to ensure feasibility (e.g. on the estimated

src/general.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ const DEFAULT_LWT = 0.0
66
const DEFAULT_CWT = 1e5
77
const DEFAULT_EWT = 0.0
88

9+
"All deterministic algorithms for matrix coloring order in `SparseMatrixColoring.jl`."
10+
const ALL_COLORING_ORDERS = (
11+
NaturalOrder(),
12+
LargestFirst(),
13+
SmallestLast(),
14+
IncidenceDegree(),
15+
DynamicLargestFirst(),
16+
)
17+
918
"Termination status that means 'no solution available'."
1019
const ERROR_STATUSES = (
1120
JuMP.INFEASIBLE, JuMP.DUAL_INFEASIBLE, JuMP.LOCALLY_INFEASIBLE,

0 commit comments

Comments
 (0)