User Tools

Site Tools


tutorials:sensitivity-analysis-using-grolink-and-gror

This is an old revision of the document!


Sensitivity analysis on GroIMP models using GroR

This wiki explains how to do a sensitivity analysis on GroIMP models using the GroR interface using a Morris screening over input parameters of the "Example08" FSPM model from the gallery as an example.

Prerequisites

Make sure to set up GroR. Play a bit around with it and get a feel for how it works and what the different functions do and what they return. The approach presented in the wiki here is just one way you could approach a sensitivity analysis. You will likely find your own approach for your specific model, but GroR will be the space you work in.

Prepare your model

In any sensitivity analysis, you will need three things:

  • Some way of pushing parameter settings to the model
  • Some way of knowing that your model has finished or reached a point of interest
  • Some way of grabbing the model output at that point of interest

The approach presented here is built on the idea of being able to do all of these things from within R. Therefore, your model will likely have to be adapted so you can feed all of this information easily through GroR.

Parameter File

Parameters will be pushed to the model by modifying a special RGG file which contains only the Parameter definitions, as this is easy to do in GroR. In the Example08 FSPM, I decided to change five hardcoded parameters to variables in the run() and la methods:

protected void run ()
[ 	Bud(r,p,o),(r<10 && p>0) ==> Bud(r,p-1,o);
	Bud(r,p,o),(r<10 && p==0 && o<4) ==> 
				RV(-0.1) Internode(parameters.NormalInternodeLength,1) NiceNode [ RL(50) Bud(r+1,phyllo+irandom(-5,5),o+1) ] 
				[RL(70) Leaf(parameters.LeafLength, 0.07,0,1,0)] RH(137) RV(-parameters.PlantWideness) NiceInternode Bud(r+1,phyllo+irandom(-5,5), o);
	Bud(r,p,o), (r==10) ==> RV(-0.1) Internode(parameters.FlowerInternodeLength,1) Internode(parameters.FlowerInternodeLength,1) NiceFlower(1);
 
	nf:NiceFlower ::> nf[age]++;
	nf:NiceFlower, (nf[age]>irandom(10,15)) ==> ;
]
 
protected void la ()
[
	lf:Leaf ::> {
		lf[al] = lm.getAbsorbedPower3d(lf).integrate()*2.25;
		lf.(setShader(new AlgorithmSwitchShader(new RGBAShader((float) lf[al]/5.0f, (float) lf[al]*2, (float) lf[al]/100.0f), GREEN)));
		//println(lf[al]);
		lf[as] = (lf[al]*86400*2)/1000000.0f;
		lf[age]++;
		float lfas = sum((* Leaf *)[as]);
		if (lfas>0) {lf[length] += logistic(2,lf[age],10,0.5);
		lf[width] = lf[length]*parameters.LeafAspectRatio;}
				}
	...
]

Model execution and output gathering in R

source("path/to/GroR.R")
...

Example: Morris Screening using the sensitivity package

tutorials/sensitivity-analysis-using-grolink-and-gror.1719319661.txt.gz · Last modified: 2024/06/25 14:47 by thomas