Skip to content

Commit 4cf60ac

Browse files
authored
Merge pull request #665 from control-toolbox/663-bug-max-objective-for-exa
[Bug] Max objective for exa
2 parents 137d836 + 0b43155 commit 4cf60ac

3 files changed

Lines changed: 15 additions & 34 deletions

File tree

test/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ CTModels = "34c4fa32-2049-4079-8329-de33c2a22e2d"
33
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
44
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
55
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
6-
MINPACK = "4854310b-de5a-5eb6-a2a5-c1dee2bd17f9"
76
MadNLP = "2621e9c9-9eb4-46b1-8089-e8c72242dfb6"
87
MadNLPMumps = "3b83494e-c0a4-4895-918b-9157a7a085a1"
98
NLPModelsIpopt = "f4238b75-b362-5c4c-b852-0801c9a21d71"
9+
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
1010
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
1111
SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66"
1212
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
@@ -16,10 +16,10 @@ CTModels = "0.6"
1616
DifferentiationInterface = "0.7"
1717
ForwardDiff = "0.10, 1.0"
1818
LinearAlgebra = "1"
19-
MINPACK = "1"
2019
MadNLP = "0.8"
2120
MadNLPMumps = "0.5"
2221
NLPModelsIpopt = "0.10"
22+
NonlinearSolve = "4"
2323
OrdinaryDiffEq = "6"
2424
SplitApplyCombine = "1"
2525
Test = "1"

test/indirect/test_goddard_indirect.jl

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,39 +42,20 @@ function test_goddard_indirect()
4242
end
4343

4444
# tests
45-
t1 = 0.025246759388000528
46-
t2 = 0.061602092906721286
47-
t3 = 0.10401664867856217
48-
tf = 0.20298394547952422
49-
p0 = [3.9428857983400074, 0.14628855388160236, 0.05412448008321635]
45+
p0 = [3.9457646586891744, 0.15039559623165552, 0.05371271293970545]
46+
t1 = 0.023509684041879215
47+
t2 = 0.059737380899876
48+
t3 = 0.10157134842432228
49+
tf = 0.20204744057100849
5050

51-
# test shooting function
51+
# test shooting function with solve from NonlinearSolve
5252
s = zeros(eltype(p0), 7)
53-
shoot!(s, p0, t1, t2, t3, tf)
54-
s_guess_sol = [
55-
-0.02456074767656735,
56-
-0.05699760226157302,
57-
0.0018629693253921868,
58-
-0.027013078908634858,
59-
-0.21558816838342798,
60-
-0.0121146739026253,
61-
0.015713236406057297,
62-
]
63-
@test s s_guess_sol atol = 1e-6
64-
65-
# solve and compare
6653
ξ0 = [p0; t1; t2; t3; tf]
67-
backend = AutoForwardDiff()
68-
nle! = (s, ξ) -> shoot!(s, ξ[1:3], ξ[4], ξ[5], ξ[6], ξ[7])
69-
jnle! = (js, ξ) -> jacobian!(nle!, similar(ξ), js, backend, ξ)
70-
indirect_sol = fsolve(nle!, jnle!, ξ0; show_trace=true)
71-
72-
p0 = indirect_sol.x[1:3]
73-
t1 = indirect_sol.x[4]
74-
t2 = indirect_sol.x[5]
75-
t3 = indirect_sol.x[6]
76-
tf = indirect_sol.x[7]
77-
78-
shoot!(s, p0, t1, t2, t3, tf)
54+
shoot!(s, ξ, λ) = shoot!(s, ξ[1:3], ξ[4], ξ[5], ξ[6], ξ[7])
55+
prob = NonlinearProblem(shoot!, ξ0)
56+
sol = solve(prob)
57+
ξ = sol.u
58+
p0, t1, t2, t3, tf = ξ[1:3], ξ[4], ξ[5], ξ[6], ξ[7]
7959
@test norm(s) < 1e-6
60+
8061
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ using MadNLP
55
using MadNLPMumps
66
using LinearAlgebra
77
using OrdinaryDiffEq
8-
using MINPACK
98
using DifferentiationInterface
109
using ForwardDiff: ForwardDiff
1110
using SplitApplyCombine # for flatten in some tests
11+
using NonlinearSolve
1212

1313
# NB some direct tests use functional definition and are `using CTModels`
1414

0 commit comments

Comments
 (0)