Adding an Old Seral Stage Target using the Patchworks Console

Let's look at an example of how a task carried out in the Patchworks interface can be automated using a Beanshell script run from the Patchworks console.

We may want to add another target to our objective function of maintaining at least 30,000 ha of the old seral stage across the planning horizon. We can go to the targets panel and open the feature > Seral > old target chart. In the target chart, click on the "Use target in objective function" button (the white checkmark). Notice how the feature > Seral > old bullet has changed from red to green. Click in the red box at the bottom of the target chart and type in 30000. Then click on the "Apply minimum target levels" box (the red checkmark) and watch the red bars materialize in the targetchart. You have set a minimum target for the old seral stage. Now uncheck both the white and red boxes to reverse the process. Now we will see how all these steps can be carried out with two lines in the Patchworks console.

Figure 70. Setting up a Target for the Old Seral Stage in the Target Chart

The feature.Seral.old target is active (green) and the target chart shows that the minumum target is active.


In the directory C:/Program Files/Spatial Planning Systems/Patchworks/scripts, there is a script library containing several BeanShell script files containing one or more functions that can help automate a modeling task (for more information see the section called “The Scripts Directory”. Taking syntax from the beanshell files setActive.bsh and setMinimum.bsh, type

setActive("feature.Seral.old",true,true,false);
setMinimum("feature.Seral.old",30000/5.0); 

into the Patchworks console (Access the console from the tools menu). Then view the feature.Seral.old target chart again. The target chart will be exactly the same as in Figure 70, “Setting up a Target for the Old Seral Stage in the Target Chart”.

Figure 71. Setting up a Target for the Old Seral Stage in the Console

Beanshell scrips inputted in the console are reflected in the target charts. Note that all targets inputted with scripts are annual, not periodic, so the periodic target was divided by 5.


So now you have an idea of how steps carried out in the interface can also be accomplished through scripts. When the steps are carried out in scripts, there is also a record of them. A file containing scripts for all your targets can comprise a scenario (see the section called “Automating a Series of Scenarios”).