Hello, it seems to be possible to make calls to an external R script from ST-Sim (from the “external program” pane in the advanced tab in the scenario properties). Would it be possible to maybe get a working example of a script to get an idea of how it would be written and implemented with rsynchrosim? For instance in order to perform some operation on state attribute values between time steps.
This example works with a minimum of SyncroSim 2.0.42, ST-Sim 3.1.42, and rsyncrosim 1.0.6. It should be forward compatible to future versions.
Note that to run this on the scenario properties under “Advanced | External Program” you need to point to the correct locations for the “externalProgramScript.R” file that is included in the zip as well as the correct location for your Rscript.exe, usually found in “…/Program Files/R/R-VERSION/bin/”.
There are two scenarios in the library, the first does not use the external program and the second does. In this example, the external program makes timber harvest conditional on the amount of a state attribute (ungulate winter habitat). The first scenario targets 10,000 acres of harvest per year. The second scenario makes this target conditional on habitat being above 12,000 acres, otherwise it sets the harvest target to 0.
Note that you can also access the External Program feature directly from R (using the rsyncrosim package) or the SyncroSim Console (i.e. using SyncroSim.Console.Exe) through the datasheet named STime_External