-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into new-updates
- Loading branch information
Showing
31 changed files
with
928 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Empty solution index sets indicates that the solution is non-unique. In these cases there is no test. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Some help functions to generate interesting test cases | ||
circle_segment(N) = sin.(acos.(linspace(-1, 1, N))) | ||
linear_trend(N) = (0:N-1) | ||
|
||
# Finds the solution to the cardinality constrained problem for | ||
# m=1:M segments using brute force | ||
function brute_force_multi(g, t, M; tol=1e-3) | ||
|
||
if length(g) <= M | ||
warn("Specified M too large. Setting M=length(g)-1.") | ||
M = length(g)-1 | ||
end | ||
|
||
ℓ = [] | ||
V_N = [] | ||
|
||
if typeof(g) <: AbstractArray | ||
ℓ = compute_discrete_transition_costs(g) | ||
V_N = QuadraticPolynomial(1.0, -2*g[end], g[end]^2) | ||
else | ||
ℓ = TransitionCostContinuous{Float64}(g, t, tol=tol) | ||
V_N = zero(QuadraticPolynomial{Float64}) | ||
end | ||
|
||
I_vec = Vector{Vector{Int64}}(M) | ||
Y_vec = Vector{Vector{Float64}}(M) | ||
f_vec = Vector{Float64}(M) | ||
|
||
for m=1:M | ||
(I_bf, Y_bf, f_bf) = brute_force_search(ℓ, V_N, m) | ||
I_vec[m] = I_bf | ||
Y_vec[m] = Y_bf | ||
f_vec[m] = f_bf | ||
end | ||
|
||
return I_vec, Y_vec, f_vec | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Base.Test | ||
using DynamicApproximations | ||
|
||
include("auxilliary_test_fcns.jl") | ||
|
||
# Consider a subset of tests that are relatively small | ||
for problem_fcn in ["discontinuous1", | ||
"discontinuous2", | ||
"super_exponential1", | ||
"super_exponential3", | ||
"white_noise", | ||
"exponential"] | ||
|
||
include(joinpath(Pkg.dir("DynamicApproximations"),"test","problems", problem_fcn * ".jl")) | ||
|
||
g, ζ_vec, I_sols, f_sols = @eval $(Symbol(problem_fcn))() | ||
|
||
M = length(I_sols) | ||
I_vec, _, f_vec = brute_force_multi(g, -1, M) | ||
|
||
@testset "Data set: $problem_fcn, brute_force_search m=$m" for m in 1:length(f_sols) | ||
@test f_vec[m] ≈ f_sols[m] atol=1e-10 | ||
if !isempty(I_sols[m]) | ||
@test I_vec[m] == I_sols[m] | ||
end | ||
end | ||
end |
Oops, something went wrong.