Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid index Error, but model runs fine on GUI #368

Closed
pdh21 opened this issue Nov 8, 2022 · 1 comment · Fixed by #372
Closed

Invalid index Error, but model runs fine on GUI #368

pdh21 opened this issue Nov 8, 2022 · 1 comment · Fixed by #372
Assignees

Comments

@pdh21
Copy link

pdh21 commented Nov 8, 2022

I am trying to run my model using Circuitscape.jl but run into the following error:

[ Info: 2022-11-08 13:55:36 : Logs will recorded to file: log_file
[ Info: 2022-11-08 13:55:36 : Precision used: Double
┌ Info: 2022-11-08 13:55:36 : Circuitscape.jl starts counting nodes from 1,
└ not 0. This will be reflected in the outputs.
[ Info: 2022-11-08 13:55:36 : Time taken to construct graph laplacian = 4.5e-6 
[ Info: 2022-11-08 13:55:36 : Solver used: AMG accelerated by CG 
[ Info: 2022-11-08 13:55:36 : Graph has 11 nodes, 11 focal points and 1 connected components 
[ Info: 2022-11-08 13:55:36 : Total number of pair solves = 55                                                          
[ Info: 2022-11-08 13:55:36 : Time taken to construct preconditioner = 5.74e-5 seconds                                  
[ Info: 2022-11-08 13:55:36 : Time taken to construct local nodemap = 1.7e-6 seconds                                    
[ Info: 2022-11-08 13:55:36 : Solving pair 1 of 55                                                                      
[ Info: 2022-11-08 13:55:36 : Time taken to solve linear system = 1.61e-5 seconds                                       
[ Info: 2022-11-08 13:55:36 : Time taken to write voltage maps = 0.0007811 seconds                                      
ERROR: ArgumentError: invalid index: nothing of type Nothing                                                            
Stacktrace:                                                                                                               
[1] to_index(i::Nothing)                                                                                                  
@ Base .\indices.jl:300                                                                                               
[2] to_index(A::SharedArrays.SharedVector{Float64}, i::Nothing)                                                           
@ Base .\indices.jl:277                                                                                               
[3] to_indices                                                                                                            
@ .\indices.jl:333 [inlined]                                                                                          
[4] to_indices                                                                                                            
@ .\indices.jl:325 [inlined]                                                                                          
[5] getindex                                                                                                              
@ .\abstractarray.jl:1241 [inlined]                                                                                   
[6] write_cur_maps(name::String, output::Circuitscape.Output{Float64, Int64}, component_data::Circuitscape.ComponentData{Float64, Int64}, finitegrounds::Vector{Float64}, flags::Circuitscape.NetworkFlags, cfg::Dict{String, String})            
@ Circuitscape C:\Users\hurleyp\.julia\packages\Circuitscape\XpftG\src\out.jl:73                                      
[7] macro expansion                                                                                                       
@ .\timing.jl:382 [inlined]                                                                                           
[8] postprocess(output::Circuitscape.Output{Float64, Int64}, component_data::Circuitscape.ComponentData{Float64, Int64}, flags::Circuitscape.NetworkFlags, shortcut::Circuitscape.Shortcut{Float64}, cfg::Dict{String, String})                   
@ Circuitscape C:\Users\hurleyp\.julia\packages\Circuitscape\XpftG\src\core.jl:667                                    
[9] (::Circuitscape.var"#f#100"{Float64, Int64, Circuitscape.NetworkFlags, Dict{String, String}, Bool, Circuitscape.Shortcut{Float64}, Circuitscape.Cumulative{Float64, Int64}, Vector{Int64}, Vector{Tuple{Int64, Int64}}, Vector{Int64}, Vector{Int64}, Circuitscape.ComponentData{Float64, Int64}, AlgebraicMultigrid.Preconditioner{AlgebraicMultigrid.MultiLevel{AlgebraicMultigrid.Pinv{Float64}, AlgebraicMultigrid.GaussSeidel{AlgebraicMultigrid.SymmetricSweep}, AlgebraicMultigrid.GaussSeidel{AlgebraicMultigrid.SymmetricSweep}, SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.SparseMatrixCSC{Float64, Int64}, LinearAlgebra.Adjoint{Float64, SparseArrays.SparseMatrixCSC{Float64, Int64}}, AlgebraicMultigrid.MultiLevelWorkspace{Vector{Float64}, 1}}, AlgebraicMultigrid.V}, SparseArrays.SparseMatrixCSC{Float64, Int64}, Vector{Int64}})(i::Int64)                                                                                                               
@ Circuitscape C:\Users\hurleyp\.julia\packages\Circuitscape\XpftG\src\core.jl:231                                   
[10] #98                                                                                                                   
@ C:\Users\hurleyp\.julia\packages\Circuitscape\XpftG\src\core.jl:251 [inlined]                                      
[11] iterate                                                                                                               
@ .\generator.jl:47 [inlined]                                                                                        
[12] _collect(c::UnitRange{Int64}, itr::Base.Generator{UnitRange{Int64}, Circuitscape.var"#98#104"{Circuitscape.var"#f#100"{Float64, Int64, Circuitscape.NetworkFlags, Dict{String, String}, Bool, Circuitscape.Shortcut{Float64}, Circuitscape.Cumulative{Float64, Int64}, Vector{Int64}, Vector{Tuple{Int64, Int64}}, Vector{Int64}, Vector{Int64}, Circuitscape.ComponentData{Float64, Int64}, AlgebraicMultigrid.Preconditioner{AlgebraicMultigrid.MultiLevel{AlgebraicMultigrid.Pinv{Float64}, AlgebraicMultigrid.GaussSeidel{AlgebraicMultigrid.SymmetricSweep}, AlgebraicMultigrid.GaussSeidel{AlgebraicMultigrid.SymmetricSweep}, SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.SparseMatrixCSC{Float64, Int64}, LinearAlgebra.Adjoint{Float64, SparseArrays.SparseMatrixCSC{Float64, Int64}}, AlgebraicMultigrid.MultiLevelWorkspace{Vector{Float64}, 1}}, AlgebraicMultigrid.V}, SparseArrays.SparseMatrixCSC{Float64, Int64}, Vector{Int64}}}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})                                     @ Base .\array.jl:807                                                                                                
[13] collect_similar(cont::UnitRange{Int64}, itr::Base.Generator{UnitRange{Int64}, Circuitscape.var"#98#104"{Circuitscape.var"#f#100"{Float64, Int64, Circuitscape.NetworkFlags, Dict{String, String}, Bool, Circuitscape.Shortcut{Float64}, Circuitscape.Cumulative{Float64, Int64}, Vector{Int64}, Vector{Tuple{Int64, Int64}}, Vector{Int64}, Vector{Int64}, Circuitscape.ComponentData{Float64, Int64}, AlgebraicMultigrid.Preconditioner{AlgebraicMultigrid.MultiLevel{AlgebraicMultigrid.Pinv{Float64}, AlgebraicMultigrid.GaussSeidel{AlgebraicMultigrid.SymmetricSweep}, AlgebraicMultigrid.GaussSeidel{AlgebraicMultigrid.SymmetricSweep}, SparseArrays.SparseMatrixCSC{Float64, Int64}, SparseArrays.SparseMatrixCSC{Float64, Int64}, LinearAlgebra.Adjoint{Float64, SparseArrays.SparseMatrixCSC{Float64, Int64}}, AlgebraicMultigrid.MultiLevelWorkspace{Vector{Float64}, 1}}, AlgebraicMultigrid.V}, SparseArrays.SparseMatrixCSC{Float64, Int64}, Vector{Int64}}}})                  
@ Base .\array.jl:716                                         
[14] map(f::Function, A::UnitRange{Int64})                                                                                 
@ Base .\abstractarray.jl:2933                                                                                       
[15] solve(prob::Circuitscape.GraphProblem{Float64, Int64, Circuitscape.AMGSolver}, #unused#::Circuitscape.AMGSolver, flags::Circuitscape.NetworkFlags, cfg::Dict{String, String}, log::Bool)                                                      
@ Circuitscape C:\Users\hurleyp\.julia\packages\Circuitscape\XpftG\src\core.jl:251                                   
[16] single_ground_all_pairs (repeats 2 times)                                                                             
@ C:\Users\hurleyp\.julia\packages\Circuitscape\XpftG\src\core.jl:66 [inlined]                                       
[17] network_pairwise(T::Type, V::Type, cfg::Dict{String, String})                                                         
@ Circuitscape C:\Users\hurleyp\.julia\packages\Circuitscape\XpftG\src\network\pairwise.jl:16                        
[18] _compute(T::Type, V::Type, cfg::Dict{String, String})                                                                 
@ Circuitscape C:\Users\hurleyp\.julia\packages\Circuitscape\XpftG\src\run.jl:53                                     
[19] macro expansion                                                                                                       
@ .\timing.jl:382 [inlined]                                                                                          
[20] compute(path::String)                                                                                                 
@ Circuitscape C:\Users\hurleyp\.julia\packages\Circuitscape\XpftG\src\run.jl:31                                     
[21] top-level scope                                                                                                       
@ REPL[26]:1 

INI file

[Options for advanced mode]
ground_file_is_resistances = True
remove_src_or_gnd = keepall
ground_file = (Browse for a ground point file)
use_unit_currents = False
source_file = (Browse for a current source file)
use_direct_grounds = False

[Mask file]
mask_file = (Browse for a raster mask file)
use_mask = False

[Calculation options]
low_memory_mode = False
parallelize = False
solver = cg+amg
print_timings = 1
preemptive_memory_release = False
print_rusages = False
max_parallel = 0

[Short circuit regions (aka polygons)]
polygon_file = (Browse for a short-circuit region file)
use_polygons = False

[Options for one-to-all and all-to-one modes]
use_variable_source_strengths = False
variable_source_file = (Browse for a source strength file)

[Output options]
set_null_currents_to_nodata = False
set_focal_node_currents_to_zero = False
set_null_voltages_to_nodata = False
compress_grids = False
write_cur_maps = 1
write_volt_maps = 0
output_file = test_small_10.out
write_cum_cur_map_only = True
log_transform_maps = False
write_max_cur_maps = False

[Version]
version = 4.0.5

[Options for reclassification of habitat data]
reclass_file = (Browse for file with reclassification data)
use_reclass_table = False

[Logging Options]
log_level = INFO
log_file = test_small_10.log
profiler_log_file = test_small_10__rusages.log
screenprint_log = False

[Options for pairwise and one-to-all and all-to-one modes]
included_pairs_file = (Browse for a file with pairs to include or exclude)
use_included_pairs = False
point_file = input_focal_nodes_10.txt

[Connection scheme for raster habitat data]
connect_using_avg_resistances = False
connect_four_neighbors_only = False

[Habitat raster or graph]
habitat_map_is_resistances = True
habitat_file = input_resist_test_10.txt

[Circuitscape mode]
data_type = network
scenario = pairwise

resistance file

0.000000000000000e+00 2.000000000000000e+00 1.000000000000000e+01
0.000000000000000e+00 5.000000000000000e+00 1.000000000000000e+01
0.000000000000000e+00 8.000000000000000e+00 1.000000000000000e+01
0.000000000000000e+00 7.000000000000000e+00 1.000000000000000e+01
1.000000000000000e+00 7.000000000000000e+00 5.000000000000000e+00
1.000000000000000e+00 4.000000000000000e+00 5.000000000000000e+00
2.000000000000000e+00 4.000000000000000e+00 1.000000000000000e+00
2.000000000000000e+00 6.000000000000000e+00 1.000000000000000e+00
2.000000000000000e+00 7.000000000000000e+00 1.000000000000000e+00
2.000000000000000e+00 1.000000000000000e+01 1.000000000000000e+00
3.000000000000000e+00 9.000000000000000e+00 1.000000000000000e+01
3.000000000000000e+00 1.000000000000000e+00 1.000000000000000e+01
3.000000000000000e+00 4.000000000000000e+00 1.000000000000000e+01
4.000000000000000e+00 6.000000000000000e+00 1.000000000000000e+00
4.000000000000000e+00 7.000000000000000e+00 1.000000000000000e+00
4.000000000000000e+00 9.000000000000000e+00 1.000000000000000e+00
5.000000000000000e+00 1.000000000000000e+01 1.000000000000000e+01
5.000000000000000e+00 2.000000000000000e+00 1.000000000000000e+01
6.000000000000000e+00 9.000000000000000e+00 1.000000000000000e+00
6.000000000000000e+00 1.000000000000000e+01 1.000000000000000e+00
8.000000000000000e+00 7.000000000000000e+00 1.000000000000000e+01

Focal node file

0.000000000000000e+00
1.000000000000000e+00
2.000000000000000e+00
3.000000000000000e+00
4.000000000000000e+00
5.000000000000000e+00
6.000000000000000e+00
7.000000000000000e+00
8.000000000000000e+00
9.000000000000000e+00
1.000000000000000e+01

Circuitscape and Julia version
Circuitscape v5.11.2 and Julia v1.8.1

Additional context
The same ini and input files work fine with the GUI. I have also tried two tests from Circuitscape\test\inputs, mgNetworkVerify3.ini and sgNetworkVerify1.ini . Both of these work without any issues. I am on Windows, but I have also tried running via docker and get the same issue.

Any guidance or help would be much appreciated. Thanks

@ranjanan
Copy link
Member

ranjanan commented Nov 8, 2022

Thanks, I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants