diff --git a/test/common/modeling_tests.jl b/test/common/modeling_tests.jl index 192d68d54..349a0aa65 100644 --- a/test/common/modeling_tests.jl +++ b/test/common/modeling_tests.jl @@ -116,7 +116,8 @@ end """ Every problem solved on its default grid in each configuration, and reported, not tested -(#360); an exception still fails. The second solve is timed, once compiled. +(#360); an exception still fails. The solve is timed once compiled: by a first solve on the +default grid, or by the `warmup` of the adapter when it has one (a cheaper solve, #435). """ function test_convergence(backend, adapter) name = modeling(backend) @@ -129,7 +130,12 @@ function test_convergence(backend, adapter) pb = getfield(OCP, problem)(backend) N = OCP.grid_size_data(problem) scheme = adapter.scheme(config) - sol = adapter.solve(pb, config; grid_size=N) + warmup = get(adapter, :warmup, nothing) + if isnothing(warmup) + adapter.solve(pb, config; grid_size=N) + else + warmup(pb, config) + end time = @elapsed sol = adapter.solve(pb, config; grid_size=N) # compiled # convergence is reported, not tested (#360); an exception still fails Main.TestStatus.result!( diff --git a/test/common/modelingtoolkit_tests.jl b/test/common/modelingtoolkit_tests.jl index 31a6aaa37..4bb0a4804 100644 --- a/test/common/modelingtoolkit_tests.jl +++ b/test/common/modelingtoolkit_tests.jl @@ -22,11 +22,21 @@ function analytic_objective(problem, grid_size, scheme) return isnothing(ref) ? nothing : ref.objective end -"""What the shared tests need of the ModelingToolkit solves (see `common/modeling_tests.jl`).""" +""" +What the shared tests need of the ModelingToolkit solves (see `common/modeling_tests.jl`). +The warmup compiles on the smoke grid, a few iterations: a second solve on the default grid +costs as much as the first one (#435). +""" function adapter() S = Main.SolveModelingToolkit return ( solve=(pb, config; kwargs...) -> S.solve(pb, config; kwargs...), + warmup=(pb, config) -> S.solve( + pb, + config; + grid_size=Main.TestConfigs.SMOKE_GRID, + max_iter=Main.TestConfigs.SMOKE_MAX_ITER, + ), objective=S.objective, settings=S.settings, scheme=S.scheme, diff --git a/test/common/solve_modelingtoolkit.jl b/test/common/solve_modelingtoolkit.jl index 435022907..bc5ac97d3 100644 --- a/test/common/solve_modelingtoolkit.jl +++ b/test/common/solve_modelingtoolkit.jl @@ -124,6 +124,9 @@ function solver_options( tol=o.TOL, max_iter=max_iter, mu_strategy=o.MU_STRATEGY, + # a quasi-Newton Hessian, as in the examples of Corleone: the exact one, by ForwardDiff + # through the integration of every control interval, is dense and costly (#435) + hessian_approximation="limited-memory", linear_solver="mumps", max_wall_time=o.MAX_WALL_TIME, sb=o.SB,