|
55 | 55 | stopping_criterion_state = AI.initialize_state( |
56 | 56 | problem, algorithm, algorithm.stopping_criterion |
57 | 57 | ) |
58 | | - state = AIE.DefaultState(; iterate = [0.0, 0.0], stopping_criterion_state) |
59 | | - |
60 | | - initial_iterate = [1.0, 2.0] |
61 | | - AI.initialize_state!(problem, algorithm, state; iterate = initial_iterate) |
62 | | - @test state.iterate == initial_iterate |
| 58 | + state = AIE.DefaultState(; |
| 59 | + iteration = 2, iterate = [0.0, 0.0], stopping_criterion_state |
| 60 | + ) |
| 61 | + AI.initialize_state!(problem, algorithm, state) |
| 62 | + @test state.iterate == [0.0, 0.0] |
63 | 63 | @test state.iteration == 0 |
| 64 | + @test state.stopping_criterion_state == stopping_criterion_state |
64 | 65 | end |
65 | 66 |
|
66 | 67 | @testset "initialize_state" begin |
|
99 | 100 | state = AI.initialize_state(problem, algorithm; iterate = copy(initial_iterate)) |
100 | 101 |
|
101 | 102 | # Solve with custom initial iterate |
| 103 | + initial_iterate = [5.0, 10.0] |
102 | 104 | final_state = AI.solve!( |
103 | 105 | problem, algorithm, state; iterate = copy(initial_iterate) |
104 | 106 | ) |
105 | 107 |
|
106 | 108 | @test final_state.iteration == 3 |
107 | | - # Each step increments by 1, so after 3 steps: [10, 20] + 3 = [13, 23] |
108 | | - @test final_state.iterate ≈ [13.0, 23.0] |
| 109 | + # Each step increments by 1, so after 3 steps: [5, 10] + 3 = [8, 13] |
| 110 | + @test final_state.iterate ≈ [8.0, 13.0] |
109 | 111 |
|
110 | 112 | # Test solve without exclamation |
111 | 113 | problem2 = TestProblem([1.0, 2.0]) |
|
0 commit comments