GithubHelp home page GithubHelp logo

Comments (3)

bhaller avatar bhaller commented on June 11, 2024

Yes, this sort of thing would be useful. There are two problems. One, script blocks get parsed and set up in the scheduler before anything gets executed, so the value of N is not known at the time that the expression would be encountered. And two, "constants" are not really constant; N can be removed with rm() and re-defined with a different value, so the expressions involving N are not truly constant expressions. Those two difficulties have prevented me from doing anything with this sort of idea, until such time as I come with a solution. However, rescheduleScriptBlock() makes it pretty easy to achieve this sort of thing anyway, so it's mostly a matter of convenience; the functionality you want is fairly easily achieved, just with a less intuitive and pretty syntax than one might wish.

from slim.

grahamgower avatar grahamgower commented on June 11, 2024

Rather than using rescheduleScriptBlock(), which requires that an existing block be defined, I've been using registerLateEvent(). So the example given would become:

initialize() {

defineConstant("N", 1000);
initializeMutationRate(1e-7);

initializeMutationType("m1", 0.5, "f", 0.0);

initializeGenomicElementType("g1", m1, 1.0);

initializeGenomicElement(g1, 0, 99999);

initializeRecombinationRate(1e-8);

}


1 {
    sim.addSubpop("p1", N);
    // start outputting after burnin, for twenty generations
    sim.registerLateEvent(NULL, "{ sim.outputFull(); }", 10*N, 10*N+20);
}


For longer expressions, I create a function that is scheduled using registerLateEvent. The major disadvantage of this approach is that syntax errors in the lambda expressions don't have the appropriate source code line reported.

from slim.

bhaller avatar bhaller commented on June 11, 2024

Rather than using rescheduleScriptBlock(), which requires that an existing block be defined, I've been using registerLateEvent(). ... The major disadvantage of this approach is that syntax errors in the lambda expressions don't have the appropriate source code line reported.

Yes; with rescheduleScriptBlock() errors are correctly attributed. Error attribution within lambdas and user-defined functions is something that could use some work in Eidos...

from slim.

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.