Skip to content

Commit 947007c

Browse files
Update runtests.jl
1 parent b4b84f1 commit 947007c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/OptimizationSophia/test/runtests.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,14 @@ res1 = solve(optprob,
6565
OptimizationSophia.Sophia(), callback = callback,
6666
maxiters = 2000)
6767
@test 10res1.objective < l1
68+
69+
# Test Sophia with ComponentArrays + Enzyme (shadow generation fix)
70+
using ComponentArrays
71+
x0_comp = ComponentVector(a = 0.0, b = 0.0)
72+
rosenbrock_comp(x, p = nothing) = (1 - x.a)^2 + 100 * (x.b - x.a^2)^2
73+
74+
optf_sophia = OptimizationFunction(rosenbrock_comp, AutoEnzyme())
75+
prob_sophia = OptimizationProblem(optf_sophia, x0_comp)
76+
res_sophia = solve(prob_sophia, Optimization.Sophia=0.01, k=5), maxiters = 50)
77+
@test res_sophia.objective < rosenbrock_comp(x0_comp) # Test optimization progress
78+
@test res_sophia.retcode == Optimization.SciMLBase.ReturnCode.Success

0 commit comments

Comments
 (0)