diff --git a/docs/build/index.html b/docs/build/index.html index 401c98b2e20f7cfc3c27c5cfe6b1da39264da25b..f78acaf812d3a7ed9c8b25be9f3ff6782a21816b 100644 --- a/docs/build/index.html +++ b/docs/build/index.html @@ -1,2 +1,42 @@ <!DOCTYPE html> -<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Introduction · Persefone</title><meta name="title" content="Introduction · Persefone"/><meta property="og:title" content="Introduction · Persefone"/><meta property="twitter:title" content="Introduction · Persefone"/><meta name="description" content="Documentation for Persefone."/><meta property="og:description" content="Documentation for Persefone."/><meta property="twitter:description" content="Documentation for Persefone."/><script data-outdated-warner src="assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="search_index.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="index.html"><img src="assets/logo.png" alt="Persefone logo"/></a><div class="docs-package-name"><span class="docs-autofit"><a href="index.html">Persefone</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li class="is-active"><a class="tocitem" href="index.html">Introduction</a></li><li><span class="tocitem">User guide</span><ul><li><a class="tocitem" href="using.html">The Persefone.jl Package</a></li><li><a class="tocitem" href="gui.html">Graphical User Interface</a></li><li><a class="tocitem" href="config.html">Configuration</a></li></ul></li><li><span class="tocitem">Developer guide</span><ul><li><a class="tocitem" href="developing.html">Developing Persefone</a></li><li><a class="tocitem" href="adapting.html">Adapting Persefone</a></li><li><a class="tocitem" href="architecture.html">Source code architecture</a></li><li><a class="tocitem" href="gis.html">Maps and weather data</a></li><li><a class="tocitem" href="species-dsl.html">Defining new species</a></li></ul></li><li><span class="tocitem">Core</span><ul><li><a class="tocitem" href="simulation.html">Simulation</a></li><li><a class="tocitem" href="io.html">Input and Output</a></li></ul></li><li><span class="tocitem">Nature</span><ul><li><a class="tocitem" href="nature.html">Nature</a></li><li><a class="tocitem" href="energy.html">Dynamic Energy Budgets</a></li><li><a class="tocitem" href="species.html">Species</a></li></ul></li><li><a class="tocitem" href="crops.html">Crop submodel</a></li><li><a class="tocitem" href="farm.html">Farm submodel</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href="index.html">Introduction</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="index.html">Introduction</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://git.idiv.de/persefone/persefone-model" title="View the repository"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">Repository</span></a><a class="docs-navbar-link" href="https://git.idiv.de/persefone/persefone-model/-/tree/master/docs/src/index.md" title="Edit source"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><p><a href="https://persefone-model.eu"><img src="assets/persefonejl_logo_v3_splash.png" alt="Persefone.jl splash screen"/></a></p><h1 id="Introduction"><a class="docs-heading-anchor" href="#Introduction">Introduction</a><a id="Introduction-1"></a><a class="docs-heading-anchor-permalink" href="#Introduction" title="Permalink"></a></h1><p><a href="https://persefone-model.eu">Persefone.jl</a> models agricultural practice and how it impacts animal species at a landscape scale. It includes a farm submodel, a crop growth submodel, and individual-based models of multiple indicator species. Its aim is to investigate how changes in farm operations (e.g. through policy changes in the CAP) influence biodiversity.</p><p>The model is open-source software available on <a href="https://git.idiv.de/persefone/persefone-model">Gitlab</a>.</p><p><em>Last updated: 2023-10-27 (commit b27fb1b)</em></p></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="using.html">The Persefone.jl Package »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="auto">Automatic (OS)</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.1.2 on <span class="colophon-date" title="Tuesday 31 October 2023 18:07">Tuesday 31 October 2023</span>. Using Julia version 1.9.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> +<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Introduction · Persefone</title><script data-outdated-warner src="assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.045/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.24/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="index.html"><img src="assets/logo.png" alt="Persefone logo"/></a><div class="docs-package-name"><span class="docs-autofit"><a href="index.html">Persefone</a></span></div><form class="docs-search" action="search.html"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li class="is-active"><a class="tocitem" href="index.html">Introduction</a><ul class="internal"><li><a class="tocitem" href="#Running-the-model"><span>Running the model</span></a></li><li><a class="tocitem" href="#Model-input"><span>Model input</span></a></li></ul></li><li><a class="tocitem" href="odd.html">Overview, Design, Details (ODD)</a></li><li><span class="tocitem">Developing</span><ul><li><a class="tocitem" href="developing.html">Developing Persefone</a></li><li><a class="tocitem" href="adapting.html">Adapting Persefone</a></li><li><a class="tocitem" href="architecture.html">Source code architecture</a></li><li><a class="tocitem" href="gis.html">Maps and weather data</a></li><li><a class="tocitem" href="species-dsl.html">Defining new species</a></li></ul></li><li><span class="tocitem">Core</span><ul><li><a class="tocitem" href="simulation.html">Simulation</a></li><li><a class="tocitem" href="io.html">Input, Output, and Settings</a></li></ul></li><li><span class="tocitem">Nature</span><ul><li><a class="tocitem" href="nature.html">Nature</a></li><li><a class="tocitem" href="energy.html">Dynamic Energy Budgets</a></li><li><a class="tocitem" href="species.html">Species</a></li></ul></li><li><a class="tocitem" href="crops.html">Crop submodel</a></li><li><a class="tocitem" href="farm.html">Farm submodel</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href="index.html">Introduction</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="index.html">Introduction</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://git.idiv.de/xo30xoqa/persephone/-/blob/master//docs/src/index.md#" title="Edit source"><span class="docs-icon fa"></span><span class="docs-label is-hidden-touch">Edit source</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Introduction"><a class="docs-heading-anchor" href="#Introduction">Introduction</a><a id="Introduction-1"></a><a class="docs-heading-anchor-permalink" href="#Introduction" title="Permalink"></a></h1><p>Persefone is an agent-based, socio-economic-ecological model of agricultural landscapes in Europe under the Common Agricultural Policy (CAP).</p><p>It's aim is to investigate how policy affects farmer decision-making, and how this in turn affects various animal species. It includes a farm submodel, a crop-growth submodel, and an ecological submodels.</p><h2 id="Running-the-model"><a class="docs-heading-anchor" href="#Running-the-model">Running the model</a><a id="Running-the-model-1"></a><a class="docs-heading-anchor-permalink" href="#Running-the-model" title="Permalink"></a></h2><p>To run a single experiment, execute <code>run.jl</code>:</p><pre><code class="nohighlight hljs">julia run.jl -c <CONFIG></code></pre><p>Other commandline arguments are:</p><pre><code class="nohighlight hljs">usage: run.jl [-c CONFIGFILE] [-s SEED] [-o OUTDIR] [-l LOGLEVEL] + [--version] [-h] + +optional arguments: + -c, --configfile CONFIGFILE + name of the configuration file + -s, --seed SEED inital random seed (type: Int64) + -o, --outdir OUTDIR location of the output directory + -l, --loglevel LOGLEVEL + verbosity: "debug", "info", or "quiet" + --version show version information and exit + -h, --help show this help message and exit</code></pre><h2 id="Model-input"><a class="docs-heading-anchor" href="#Model-input">Model input</a><a id="Model-input-1"></a><a class="docs-heading-anchor-permalink" href="#Model-input" title="Permalink"></a></h2><p>Persefone requires three input files: a configuration file and two map files. How to generate the map files is documented <a href="gis.html">elsewhere</a>. The <a href="io.html">configuration file</a> defines parameter values and looks like this (see <code>src/parameters.toml</code> for a complete list of parameters):</p><pre><code class="language-TOML hljs">### Persefone - a socio-economic-ecological model of European agricultural landscapes. +### +### This is the default configuration file for Persefone, containing all model parameters. +### The syntax is described here: https://toml.io/en/ + +[core] +configfile = "src/parameters.toml" # location of the configuration file +outdir = "results" # location and name of the output folder +overwrite = "ask" # overwrite the output directory? (true/false/"ask") +loglevel = "debug" # verbosity level: "debug", "info", "warn" +processors = 2 # number of processors to use on parallel runs +seed = 2 # seed value for the RNG (0 -> random value) +# dates to start and end the simulation +startdate = 2022-01-01 +enddate = 2022-12-31 + +[world] +landcovermap = "data/landcover_jena.tif" # location of the landcover map +farmfieldsmap = "data/fields_jena.tif" # location of the field geometry map + +[farm] +farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented) + +[nature] +targetspecies = ["Wolpertinger", "Wyvern"] # list of target species to simulate +popoutfreq = "daily" # output frequency population-level data, daily/monthly/yearly/end/never +indoutfreq = "end" # output frequency individual-level data, daily/monthly/yearly/end/never + +[crop] +cropmodel = "linear" # crop growth model to use, "linear" or "aquacrop" (not yet implemented)</code></pre><div class="admonition is-info"><header class="admonition-header">Parameter scanning</header><div class="admonition-body"><p>You can set any parameter to a list of different values, e.g. <code>seed = [1,2,3]</code>. Persefone will then set up and run multiple simulations, one for every possible combination of parameters that you entered (i.e. do a full-factorial simulation experiment).</p></div></div><p><em>Last updated: 2023-07-27 (commit 1e6e7d6)</em></p></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="odd.html">Overview, Design, Details (ODD) »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.23 on <span class="colophon-date" title="Thursday 27 July 2023 10:12">Thursday 27 July 2023</span>. Using Julia version 1.9.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> diff --git a/docs/src/architecture.md b/docs/src/architecture.md index 1889fd89ccb36d3829b2d6fd8f3c7640a9d5d51b..1712124a2e15628dfec9361eb1e5a059f5d63cf0 100644 --- a/docs/src/architecture.md +++ b/docs/src/architecture.md @@ -33,7 +33,7 @@ the `Animal`s in the model landscape. ### The `model` object A cursory reading of the source code will quickly show that most functions take an -`AgentBasedModel` object as one of their arguments. This is the key data structure +`SimulationModel` object as one of their arguments. This is the key data structure of [Agents.jl](https://juliadynamics.github.io/Agents.jl/stable/tutorial/#.-The-model-1), and holds all state that is in any way relevant to a simulation run. (Persefone has a strict "no global state" policy to avoid state-dependent bugs and allow parallelisation.) diff --git a/test/io_tests.jl b/test/io_tests.jl index 734ee7844566ddf2eb6cc01cd421204d9d253084..de75781afc8f997b64f75fec715c6d677ae26ce2 100644 --- a/test/io_tests.jl +++ b/test/io_tests.jl @@ -7,7 +7,7 @@ settings = Ps.getsettings(TESTPARAMETERS) properties = Dict{Symbol,Any}(:settings=>settings) space = GridSpace((10,10), periodic=false) - model = AgentBasedModel(Animal, space, properties=properties, warn=false) + model = SimulationModel(Animal, space, properties=properties, warn=false) @test @param(core.configfile) == basename(TESTPARAMETERS) @test @param(core.startdate) == Date(2022, 2, 1) diff --git a/test/runtests.jl b/test/runtests.jl index 4636903dfea5c7034e079cbae9f42b5eec5c95fc..c761eeb1b3f79f7424d5f4c9ca8fc9dbcd6a8f1e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,7 +6,6 @@ using Pkg Pkg.activate("..") -using Agents using Dates using DataFrames using Logging @@ -24,7 +23,7 @@ const TESTSETTINGS = Ps.getsettings(TESTPARAMETERS) """ inittestmodel(smallmap=true) -Initialise an AgentBasedModel for testing purposes. +Initialise an SimulationModel for testing purposes. `smallmap`: use a hypothetical small landscape rather than a real one? """ @@ -35,24 +34,26 @@ function inittestmodel(smallmap=true) landscape = Ps.initlandscape(TESTSETTINGS["world.landcovermap"], TESTSETTINGS["world.farmfieldsmap"]) end - space = GridSpace(size(landscape), periodic=false) weather = Ps.initweather(TESTSETTINGS["world.weatherfile"], TESTSETTINGS["core.startdate"], TESTSETTINGS["core.enddate"]) crops = Ps.readcropparameters(TESTSETTINGS["crop.cropfile"], TESTSETTINGS["crop.growthfile"]) - properties = Dict{Symbol,Any}(:date=>TESTSETTINGS["core.startdate"], - :landscape=>landscape, - :weather=>weather, - :crops=>crops, - :events=>Vector{FarmEvent}(), - :migrants=>Vector{Pair{Animal, Date}}(), - :logger=>global_logger(), - :dataoutputs=>Vector{DataOutput}(), - :datatables=>Dict{String,DataFrame}(), - :settings=>TESTSETTINGS) - return AgentBasedModel(Union{Farmer,Animal,FarmPlot}, space, properties=properties, - rng=StableRNG(TESTSETTINGS["core.seed"]), warn=false) + model = SimulationModel(TESTSETTINGS, + StableRNG(TESTSETTINGS["core.seed"]), + global_logger(), + Vector{DataOutput}(), + Dict{String, DataFrame}(), + TESTSETTINGS["core.startdate"], + landscape, + weather, + crops, + Vector{Farmer}(), + Vector{FarmPlot}(), + Vector{Union{Animals,Nothing}}(), + Vector{Pair{Animal, Date}}(), + Vector{FarmEvent}()) + model end """