diff --git a/test/suite/initial_guess.jl b/test/suite/initial_guess.jl index 3c39975..946fee3 100644 --- a/test/suite/initial_guess.jl +++ b/test/suite/initial_guess.jl @@ -1,4 +1,4 @@ -println("Test: initial guess options\n") +println("Test: initial guess options") # use 0 iterations to check initial guess, >0 to check cv maxiter = 0 @@ -48,10 +48,18 @@ u_vec = [0, 0.3, .1] # 1 Pass initial guess to all-in-one solve call # 1.a default initial guess -@testset verbose = true showtiming = true ":default_init" begin +@testset verbose = true showtiming = true ":default_init_no_arg" begin sol = solve(ocp, print_level=0, max_iter=maxiter) @test(check_xf(sol, [0.1, 0.1]) && check_uf(sol, 0.1) && check_v(sol, 0.1)) end +@testset verbose = true showtiming = true ":default_init_()" begin + sol = solve(ocp, print_level=0, init=(), max_iter=maxiter) + @test(check_xf(sol, [0.1, 0.1]) && check_uf(sol, 0.1) && check_v(sol, 0.1)) +end +@testset verbose = true showtiming = true ":default_init_nothing" begin + sol = solve(ocp, print_level=0, init=nothing,max_iter=maxiter) + @test(check_xf(sol, [0.1, 0.1]) && check_uf(sol, 0.1) && check_v(sol, 0.1)) +end # 1.b constant initial guess @testset verbose = true showtiming = true ":constant_x" begin diff --git a/test/test_initial_guess.jl b/test/test_initial_guess.jl index 544434a..04781eb 100644 --- a/test/test_initial_guess.jl +++ b/test/test_initial_guess.jl @@ -59,6 +59,18 @@ if maxiter > 0 else println(check_xf(sol, [0.1, 0.1]) && check_uf(sol, 0.1) && check_v(sol, 0.1)) end +sol = solve(ocp, print_level=0, init=(), max_iter=maxiter) +if maxiter > 0 + @printf("%-56s %.3f at %d iterations\n", "Default initial guess", sol.objective, sol.iterations) +else + println(check_xf(sol, [0.1, 0.1]) && check_uf(sol, 0.1) && check_v(sol, 0.1)) +end +sol = solve(ocp, print_level=0, init=nothing, max_iter=maxiter) +if maxiter > 0 + @printf("%-56s %.3f at %d iterations\n", "Default initial guess", sol.objective, sol.iterations) +else + println(check_xf(sol, [0.1, 0.1]) && check_uf(sol, 0.1) && check_v(sol, 0.1)) +end # 1.b constant initial guess sol = solve(ocp, print_level=0, init=(state=x_const,), max_iter=maxiter) @@ -110,7 +122,7 @@ else println(check_xf(sol, x_const) && check_uf(sol, u_const) && check_v(sol, v_const)) end -# 1. functional initial guess +# 1.c functional initial guess sol = solve(ocp, print_level=0, init=(state=x_func,), max_iter=maxiter) if maxiter > 0 @printf("%-56s %.3f at %d iterations\n", "Functional x; default u,v", sol.objective, sol.iterations)