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

Omniscape fails on specific row / column: AssertionError #155

Closed
geomenke opened this issue Feb 9, 2024 · 7 comments
Closed

Omniscape fails on specific row / column: AssertionError #155

geomenke opened this issue Feb 9, 2024 · 7 comments

Comments

@geomenke
Copy link

geomenke commented Feb 9, 2024

I originally mistakenly posted this to Issue: #122 but seems it should be a separate issue.

I receive this error: ERROR: AssertionError: norm(matrix * lhs[:, i] .- rhs[:, i]) / norm(rhs[:, i]) < 1.0e-6. It was suggested that I update my version of Omniscape. I have now tried Circuitscape v5.13.2 and Omniscape v0.6.1, but it failed again with a similar stacktrace as before (below).
I am using source_from_resistance=true.
The row and column are not always the same. This may be due to the order in which the windows are solved being random. However, they are always pixels I have set to high resistance values. I have buffered primary highways as barriers. These barriers regions are quite narrow (10 pixels wide) while I am using a radius of 300 pixels. I have tried setting these barrier pixels as high resistance values, or no data values, or missing via reclassify_resistance.
I have tried clipping the raster to a smaller neighborhood around the row and column but larger than the radius and it runs fine.

Progress:  81%|█████████████████████████████████████████         |  ETA: 17:26:09Omniscape failed on the moving window centered on row 11263 column 10839
Progress:  97%|█████████████████████████████████████████████████ |  ETA: 2:58:35ERROR: TaskFailedException

    nested task error: AssertionError: norm(matrix * lhs[:, i] .- rhs[:, i]) / norm(rhs[:, i]) < 1.0e-6
    Stacktrace:
     [1] macro expansion
       @ C:\Users\Kurt Menke\.julia\packages\Omniscape\9gHf2\src\main.jl:278 [inlined]
     [2] (::Omniscape.var"#161#threadsfor_fun#12"{Omniscape.var"#161#threadsfor_fun#11#13"{Int64, ProgressMeter.Progress, Int64, Dict{String, String}, Omniscape.ConditionLayers{Float64, 2}, Omniscape.Conditions, Omniscape.OmniscapeFlags, DataType, Dict{String, Int64}, UnitRange{Int64}}})(tid::Int64; onethread::Bool)
       @ Omniscape .\threadingconstructs.jl:194
     [3] #161#threadsfor_fun
       @ .\threadingconstructs.jl:161 [inlined]
     [4] (::Base.Threads.var"#1#2"{Omniscape.var"#161#threadsfor_fun#12"{Omniscape.var"#161#threadsfor_fun#11#13"{Int64, ProgressMeter.Progress, Int64, Dict{String, String}, Omniscape.ConditionLayers{Float64, 2}, Omniscape.Conditions, Omniscape.OmniscapeFlags, DataType, Dict{String, Int64}, UnitRange{Int64}}}, Int64})()
       @ Base.Threads .\threadingconstructs.jl:139

    caused by: AssertionError: norm(matrix * lhs[:, i] .- rhs[:, i]) / norm(rhs[:, i]) < 1.0e-6
    Stacktrace:
      [1] solve_linear_system(factor::SparseArrays.CHOLMOD.Factor{Float64}, matrix::SparseArrays.SparseMatrixCSC{Float64, Int64}, rhs::Vector{Float64})
        @ Circuitscape C:\Users\Kurt Menke\.julia\packages\Circuitscape\33lUW\src\core.jl:621
      [2] macro expansion
        @ .\timing.jl:393 [inlined]
      [3] multiple_solve(s::Circuitscape.CholmodSolver, matrix::SparseArrays.SparseMatrixCSC{Float64, Int64}, sources::Vector{Float64}, suppress_info::Bool)
        @ Circuitscape C:\Users\Kurt Menke\.julia\packages\Circuitscape\33lUW\src\raster\advanced.jl:320
      [4] multiple_solver(cfg::Dict{String, String}, solver::Circuitscape.CholmodSolver, a::SparseArrays.SparseMatrixCSC{Float64, Int64}, sources::Vector{Float64}, grounds::Vector{Float64}, finitegrounds::Vector{Float64})
        @ Circuitscape C:\Users\Kurt Menke\.julia\packages\Circuitscape\33lUW\src\raster\advanced.jl:291
      [5] compute_omniscape_current(conductance::Matrix{Float64}, source::Matrix{Float64}, ground::Matrix{Float64}, cs_cfg::Dict{String, String})
        @ Circuitscape C:\Users\Kurt Menke\.julia\packages\Circuitscape\33lUW\src\utils.jl:529
      [6] solve_target!(target::Omniscape.Target, int_arguments::Dict{String, Int64}, source_strength::Matrix{Union{Missing, Float64}}, resistance::Matrix{Union{Missing, Float64}}, os_flags::Omniscape.OmniscapeFlags, cs_cfg::Dict{String, String}, condition_layers::Omniscape.ConditionLayers{Float64, 2}, conditions::Omniscape.Conditions, correction_array::Matrix{Float64}, cum_currmap::Array{Float64, 3}, fp_cum_currmap::Array{Float64, 3}, precision::DataType)
        @ Omniscape C:\Users\Kurt Menke\.julia\packages\Omniscape\9gHf2\src\utils.jl:332
      [7] macro expansion
        @ C:\Users\Kurt Menke\.julia\packages\Omniscape\9gHf2\src\main.jl:264 [inlined]
      [8] (::Omniscape.var"#161#threadsfor_fun#12"{Omniscape.var"#161#threadsfor_fun#11#13"{Int64, ProgressMeter.Progress, Int64, Dict{String, String}, Omniscape.ConditionLayers{Float64, 2}, Omniscape.Conditions, Omniscape.OmniscapeFlags, DataType, Dict{String, Int64}, UnitRange{Int64}}})(tid::Int64; onethread::Bool)
        @ Omniscape .\threadingconstructs.jl:194
      [9] #161#threadsfor_fun
        @ .\threadingconstructs.jl:161 [inlined]
     [10] (::Base.Threads.var"#1#2"{Omniscape.var"#161#threadsfor_fun#12"{Omniscape.var"#161#threadsfor_fun#11#13"{Int64, ProgressMeter.Progress, Int64, Dict{String, String}, Omniscape.ConditionLayers{Float64, 2}, Omniscape.Conditions, Omniscape.OmniscapeFlags, DataType, Dict{String, Int64}, UnitRange{Int64}}}, Int64})()
        @ Base.Threads .\threadingconstructs.jl:139
Stacktrace:
 [1] threading_run(fun::Omniscape.var"#161#threadsfor_fun#12"{Omniscape.var"#161#threadsfor_fun#11#13"{Int64, ProgressMeter.Progress, Int64, Dict{String, String}, Omniscape.ConditionLayers{Float64, 2}, Omniscape.Conditions, Omniscape.OmniscapeFlags, DataType, Dict{String, Int64}, UnitRange{Int64}}}, static::Bool)
   @ Base.Threads .\threadingconstructs.jl:151
 [2] macro expansion
   @ .\threadingconstructs.jl:199 [inlined]
 [3] run_omniscape(cfg::Dict{String, String}, resistance::Matrix{Union{Missing, Float64}}; reclass_table::Matrix{Union{Missing, Float64}}, source_strength::Matrix{Union{Missing, Float64}}, condition1::Matrix{Union{Missing, Float64}}, condition2::Matrix{Union{Missing, Float64}}, condition1_future::Matrix{Union{Missing, Float64}}, condition2_future::Matrix{Union{Missing, Float64}}, wkt::String, geotransform::Vector{Float64}, write_outputs::Bool)
   @ Omniscape C:\Users\Kurt Menke\.julia\packages\Omniscape\9gHf2\src\main.jl:257
 [4] run_omniscape(path::String)
   @ Omniscape C:\Users\Kurt Menke\.julia\packages\Omniscape\9gHf2\src\main.jl:536
 [5] top-level scope
   @ REPL[14]:1
@vlandau
Copy link
Member

vlandau commented Feb 9, 2024

Thanks for opening a new issue. Okay, it looks like I missed some places where I needed to increase the error tolerance. I'll do that this evening, and we'll release a patch to Circuitscape shortly thereafter.

@vlandau
Copy link
Member

vlandau commented Feb 10, 2024

I've got a PR in for Circuitscape. It might take a few days for it to be reviewed, merged, and released. You can follow along here: Circuitscape/Circuitscape.jl#410

@geomenke
Copy link
Author

Fantastic, thank you! Looking forward to testing the next release.

@vlandau
Copy link
Member

vlandau commented Feb 17, 2024

@geomenke the new version of Circuitscape has been released, thanks for your patience! You'll want Circuitscape v5.13.3. hopefully that resolves this problem. I'll leave this issue open until I get confirmation from you.

@geomenke
Copy link
Author

Thanks @vlandau - I am running my model again now. I'll let you know either way.

@geomenke
Copy link
Author

geomenke commented Mar 4, 2024

@vlandau this has solved the problem. I have run several iterations of the model with different settings and each one has finished successfully.

@vlandau
Copy link
Member

vlandau commented Mar 4, 2024

Great! I'm going to close this issue as solved. So glad it's working!

@vlandau vlandau closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants