Code Monkey home page Code Monkey logo

Comments (2)

rafaqz avatar rafaqz commented on September 10, 2024 1

First we need to get your code updated to get rid of all those macros! Can you push your latest code? then I can convert it and put in a PR. It will be so much easier to discuss after that.

For having multiple sub-populations in the grid, for intrinsicrate use a Tuple. (but you might not even need to lock it like this)

struct DiscreteGrowthRate{R,W,GR<:Tuple,I}
    intrinsicrate::GR
    numberSupPop::I
end

With a Tuple you can just map over the populations and growth rates, and it will handle any number of sub populations making this generic to all similar problems:

@inline function applyrule(data, rule::DiscreteGrowthRate, pops, index)
    map(pops, rule.intrinsicrate) do pop, ir
         ir * pop * (1 - sum(pops) / rule.carrycap)
    end
end

(map with a Vector is allocating and much slower, and can't be optimised the same way a Tuple can be. We also need to return a Tuple to be written back to the N separate grids, which just works using a Tuple for intrinsicrate)

Edit: you could get rid of the <:Tuple limitation, then a single instrinsicrate would also work

from dispersal.jl.

virgile-baudrot avatar virgile-baudrot commented on September 10, 2024

Great.
I just send a PR #64

from dispersal.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.