@@ -11,6 +11,29 @@ facts("Population") do
1111 @fact isnafitness (fitness (p1, 1 ), fs) --> true
1212 @fact isnafitness (fitness (p1, 4 ), fs) --> true
1313
14+ context (" accessing individuals" ) do
15+ @fact typeof (p1[1 ]) --> Vector{Float64}
16+ @fact length (p1[1 ]) --> numdims (p1)
17+ @fact isa (BlackBoxOptim. viewer (p1, 1 ), AbstractVector{Float64}) --> true
18+ @fact length (BlackBoxOptim. viewer (p1, 1 )) --> numdims (p1)
19+ @fact typeof (p1[popsize (p1)]) --> Vector{Float64} # last solution vector
20+ @fact_throws BoundsError p1[0 ]
21+ @fact_throws BoundsError p1[popsize (p1)+ 1 ]
22+ @fact_throws BoundsError BlackBoxOptim. viewer (p1, 0 )
23+ @fact_throws BoundsError BlackBoxOptim. viewer (p1, popsize (p1)+ 1 )
24+ rand_solution_idx = rand (2 : (popsize (p1)- 1 ))
25+ @fact isa (p1[rand_solution_idx], Array{Float64, 1 }) --> true # random solution vector
26+ end
27+
28+ context (" accessing individuals fitness" ) do
29+ # and to access their fitness values:
30+ @fact typeof (fitness (p1, 1 )) --> Float64
31+ @fact typeof (fitness (p1, popsize (p1))) --> Float64
32+ rand_solution_idx = rand (2 : (popsize (p1)- 1 ))
33+ @fact_throws BoundsError fitness (p1, 0 )
34+ @fact_throws BoundsError fitness (p1, popsize (p1)+ 1 )
35+ end
36+
1437 context (" candidates pool" ) do
1538 @fact BlackBoxOptim. candi_pool_size (p1) --> 0
1639 candi1 = BlackBoxOptim. acquire_candi (p1, 1 )
0 commit comments