Skip to content

Commit

Permalink
FIX: Remove 0.0 from candidates in solve_discrete_riccati
Browse files Browse the repository at this point in the history
  • Loading branch information
oyamad committed Oct 25, 2017
1 parent 6310172 commit 5246a7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/matrix_eqn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function solve_discrete_riccati(A::ScalarOrArray, B::ScalarOrArray,
I = eye(k)

current_min = Inf
candidates = [0.0, 0.01, 0.1, 0.25, 0.5, 1.0, 2.0, 10.0, 100.0, 10e5]
candidates = [0.01, 0.1, 0.25, 0.5, 1.0, 2.0, 10.0, 100.0, 10e5]
BB = B' * B
BTA = B' * A

Expand Down
6 changes: 3 additions & 3 deletions test/test_matrix_eqn.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@testset "Testing matrix_eqn.jl" begin
rough_kwargs = Dict(:atol => 1e-7, :rtol => 1e-7)

@testset "simple test where X is all zero" begin
A = eye(4) .* .95
B = zeros(4, 4)
Expand Down Expand Up @@ -38,14 +38,14 @@
@testset "testing ricatti golden_num_float" begin
val = solve_discrete_riccati(1.0, 1.0, 1.0, 1.0)
gold_ratio = (1 + sqrt(5)) / 2.
@test val[1] == (gold_ratio)
@test isapprox(val[1], gold_ratio; rough_kwargs...)
end

@testset "testing ricatti golden_num_2d" begin
A, B, R, Q = eye(2), eye(2), eye(2), eye(2)
gold_diag = eye(2) .* (1 + sqrt(5)) ./ 2.
val = solve_discrete_riccati(A, B, Q, R)
@test val == (gold_diag)
@test isapprox(val, gold_diag; rough_kwargs...)
end

@testset "test tjm 1" begin
Expand Down

0 comments on commit 5246a7d

Please sign in to comment.