Circuitscape / Circuitscape.jl

Algorithms from circuit theory to predict connectivity in heterogeneous landscapes
https://circuitscape.org
MIT License
128 stars 35 forks source link

Feature request: Onetoall/AlltoOne mode with polygons in the point file. #311

Open luroy opened 3 years ago

luroy commented 3 years ago

Dear all,

I tried using Circuitscape on Julia with to connect only some focal node pairs (for which the Euclidean distance is less than a given threshold theshold).

From a given input, I ran Circuiscape in all-to-one mode with a file indicating focal node pairs to include following the example file "listofpairstoinclude.txt" in the examples directory. I got the following error when running ini file in R using “JuliaCall” package:

> Error happens in Julia.
> BoundsError: attempt to access 7025949-element Vector{Float64} at index [7039487]
> Stacktrace:
>   [1] (::Base.var"#837#839")(x::Task)
>     @ Base .\asyncmap.jl:177
>   [2] foreach(f::Base.var"#837#839", itr::Vector{Any})
>     @ Base .\abstractarray.jl:2141
>   [3] maptwice(wrapped_f::Function, chnl::Channel{Any}, worker_tasks::Vector{Any}, c::UnitRange{Int64})
>     @ Base .\asyncmap.jl:177
>   [4] wrap_n_exec_twice
>     @ .\asyncmap.jl:153 [inlined]
>   [5] #async_usemap#822
>     @ .\asyncmap.jl:103 [inlined]
>   [6] #asyncmap#821
>     @ .\asyncmap.jl:81 [inlined]
>   [7] pmap(f::Function, p::Distributed.WorkerPool, c::UnitRange{Int64}; distributed::Bool, batch_size::Int64, on_error::Nothing, retry_delays::Vector{Any}, retry_check::Nothing)
>     @ Distributed C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Distributed\src\pmap.jl:126
>   [8] pmap(f::Function, p::Distributed.WorkerPool, c::UnitRange{Int64})
>     @ Distributed C:\buildbot\worker\package_win64

Please find all input files and the .ini file associated at the following link: https://drive.google.com/drive/folders/1wdBCJvFvKUArEZjF4MaRfYS9NPawzo-q?usp=sharing

Thank you for your attention to this matter,

Léa

vlandau commented 3 years ago

Hi @luroy, I think part of the issue might be that you are trying to include pairs in all-to-one mode. If you want to look at pairwise connections, the appropriate Circuitscape mode would be "pairwise". In all to one or one to all, it's similar to pairwise, but each node is connected to all other nodes for each solve. There is a great explanation of this in the docs.

Let me know if pairwise mode might be what you're looking for. If so, try changing the mode to pairwise and see if things work for you.

luroy commented 3 years ago

Dear @vlandau, Thanks for responding so quickly ! I use the all-to-one mode can be as an alternative to the pairwise mode to use less memory. With this approach, I want Circuitscape to connect one focal node to ground and all other nearby focal nodes (for which the Euclidean distance to the ground-connected focal node is less than a given threshold) to 1 amp current sources. Hoping that it is possible :-) All the best, Léa

vlandau commented 3 years ago

Ah you're right -- I've just used all-to-one typically for only one node so I was confused. @ranjanan do all-to-one and one-to-all support the include pairs file input?

vlandau commented 3 years ago

Hi @luroy, apologies for the delay in following up on this. I have looked into the Circuitscape source code and all-to-one mode should handle specifying included pairs just fine, so I'm now going to reproduce the problem to see if I can figure out what is going on. Thanks for your patience!

vlandau commented 3 years ago

I was able to reproduce this error. I'm still not sure what is causing it but I'll continue to dig in.

vlandau commented 3 years ago

@ranjanan it looks like the issue is that the number of elements in nodemap is larger than the size of G. I'm wondering if this is happening because the input nodes are polygons as opposed to points. Nothing in the docs suggests that this shouldn't work, but maybe it hasn't been implemented? I'm going to cross reference with the pariwise mode code to see if the same correction for the polygons case is being done in all-to-one mode.

vlandau commented 3 years ago

I think there may not be support for "polygon" nodes in all-to-one mode. @ranjanan please confirm.

ranjanan commented 3 years ago

I believe polygons are supported in one to all mode. It could be that if point files contain polygons, that isn't supported in one to all mode. That may need to be implemented.

The more I work with Circuitscape, the more I realise there are just so many corner cases and features. These will all need to be documented and listed.

ranjanan commented 1 year ago

I am going to rename this issue to: "Feature request: one-to-all and all-to-one mode with polygons in the point file".

FaustiniG commented 6 months ago

Hi, I also ran Circuiscape in all-to-one mode with a file indicating focal node pairs (which are actually regions). I encountered the same problem reported here (BoundsError).

Do you know if the possibility to run all-to-one mode with pairs of polygons was implemented?

Thank you!