Comments (3)
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.
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.
Rather than using
rescheduleScriptBlock()
, which requires that an existing block be defined, I've been usingregisterLateEvent()
. ... 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)
- Tree-seq docs in the SLiM manual need a review HOT 4
- SLiM 4.0.1 release process HOT 13
- More than ~2 billion segregating mutations doesn't give a good error HOT 1
- add `localPopulationDensityAtPoint` method HOT 4
- Windows CI failing due to SIGTRAP HOT 3
- Can't reload recapitated tree to SLiM HOT 16
- "Total fitness <= 0.0" error loading population state - memory issue or something else? HOT 5
- Windows fix for RNG seeding needed HOT 8
- open and save file dialogs should start in working directory? HOT 4
- SLiMgui prompts "This document has been modified" even though it hasn't HOT 6
- "end of simulation" tick specification HOT 3
- between-species interactions invalidated for species other than the first in reproduction() HOT 1
- Manual needs to be updated to reflect change of originTick to originGeneration HOT 2
- Output a full ARG tree sequence HOT 3
- [Feature Request] Creating gene/exon entries automatically via GFF3/GTF annotation files in nucleotide-based models HOT 5
- make resizing text easier in GUI HOT 1
- rank() function request HOT 5
- Smoothing of spatial maps HOT 17
- simulation inscrutibly dies out HOT 4
- compile failure of `core/chromosome.cpp` on gcc 13.1.1 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slim.