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

Define the neighborhood of SetNeighbors based on read data value #268

Open
remylegoff opened this issue Oct 24, 2024 · 5 comments
Open

Define the neighborhood of SetNeighbors based on read data value #268

remylegoff opened this issue Oct 24, 2024 · 5 comments

Comments

@remylegoff
Copy link

Is it possible to create a SetNeighbors where the neighborhood is defined on the cell value of read data. Similar to :

dispersion_rule =
    SetNeighbors{Tuple{:abundance,:dispersion_ability},Tuple{:abundance}}(neighborhood=VonNeuman{:dispersion_ability}) do data, hood, state, I 
        for pos in indices(hood, I)
                    migrate = state[:abundance]*state[:dispersion_rate]
                    add!(data[:abundance],migrate, pos...)
                    sub!(data[:abundance],migrate, I...)
                end
            end
    end
@rafaqz
Copy link
Member

rafaqz commented Oct 24, 2024

Does that code not work already?

If the dispersion rate is constant but spatial you can also put it in aux

@remylegoff
Copy link
Author

I get the error :
ERROR: MethodError: no method matching radius(::Type{Moore{:dispersion_rate}})

@rafaqz
Copy link
Member

rafaqz commented Oct 24, 2024

Oh I missed that bit with the type

You want the neighbourhood length to change depending on the cell value?

(If so no, it would be horribly slow too. But you can hack if with an if block that just uses a different nighborhood based on the value. That will be fast)

@remylegoff
Copy link
Author

Yes exactly. The cell value define the dispersal ability so the maximum distance that can be reach

@rafaqz
Copy link
Member

rafaqz commented Oct 24, 2024

Ok just use an if block to choose from the list of neighbourhoods.

Use the largest one as the rule neighbourhood so the bounds padding works.

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