QuantEcon.jl
QuantEcon.jl copied to clipboard
DiscreteDP: Should not modify s_indices and a_indices when sorting
julia> using QuantEcon
julia> s_indices = [2, 1, 1]; # Not sorted;
julia> a_indices = [1, 1, 2];
julia> R = [-1., 5, 10];
julia> Q = [0 1; 0.5 0.5; 0 1];
julia> beta = 0.95;
julia> ddp = DiscreteDP(R, Q, beta, s_indices, a_indices);
julia> s_indices
3-element Array{Int64,1}:
1
1
2
julia> a_indices
3-element Array{Int64,1}:
1
1
2
One cannot reuse s_indices
and a_indices
:
julia> ddp = DiscreteDP(R, Q, beta, s_indices, a_indices);
ERROR: ArgumentError: Duplicate s-a pair found
in anonymous at /Users/oyama/.julia/v0.4/QuantEcon/src/markov/ddp.jl:131
in sparse at sparse/csparse.jl:93
in call at /Users/oyama/.julia/v0.4/QuantEcon/src/markov/ddp.jl:130
in call at /Users/oyama/.julia/v0.4/QuantEcon/src/markov/ddp.jl:205
cc @albep
@oyamad thanks for pointing that out. PR #122 fixes that, I tried it with your example