New feature as of ResSim 3.3

Accompanying config file:  HEC-ResSim.config

Custom Java State Variables

Three State Variables re-created as Java code:
Watershed: CRT_Power_13Jun2011
Simulation: test
Alternatives:

  1. VECC Ops (with regular state variables) Average compute time -130 sec
  2. JavaSVs (trial of VECC Ops which replaces scripted state variables below with java coded state variables) Average compute time- 119 sec


State Variable Name - Arrow_Power_Operating_Criteria
Reservoir used in: Arrow Lakes
Referenced By: Operating Rule - APOC Release-spec

State Variable Name - Headloss_Albeni_Falls
Reservoir used in: Albeni Falls
Referenced By: Forebay Head Loss

State Variable Name - Headloss_Corra_Linn
Reservoir used in: Corra Linn
Referenced By: Forebay Head Loss
State Variable Name - Mica_Arrow_Balance_Operation
Reservoir used in: Mica
Referenced By: Operating Rule - Mica Arrow balancing-spec

Changes to Script Editor

The State Variable Editor now contains an option to specify the state variable as a Jython script, Use Jython Script radio button, Slave, or Java class, Use Java Class radio button. See Figure 1 below.

Figure 1 - State Variable Editor
If the java class option is selected, the path to the specified class is entered in the Use Java Class text field and the Initialization, Main, and CleanUp tabs are disabled. See Figure 2 below.

Figure 2 – Specifying State Variable as a Java Class
The user created jar containing their created Java class State Variables must be located in the ResSim application directory's jar/ext folder. In the example pictured in Figure 3, the jar file is named stateVariableTest.jar. This jar was created by the user and filled with all the class files used as state variables. It is important to note that the state variables within this jar can be referenced by multiple watersheds.

Figure 3 – Location of user created State Variable jar

Creating the Java Class

The Java class representing the State Variable must extend the hec.rss.model.StateVariableIncf interface and implement the following methods:
public boolean initilization(StateVariable currentSV, RssSystem rssSys);
public void main(StateVariable currentSV, RunTimeStep currentRunTimeStep, RssSystem rssSys);
public boolean cleanUp(StateVariable currentSV, RssSystem rssSys);
The StateVariableIncf class's three methods represent the three jython scripts used in the State Variable Editor.
In the example class below, the State Variable Java class was given the same name as the State Variable, "Arrow_Power_Operating_Criteria " and implements the same logic as its jython-scripted counterpart. Therefore, the two versions of the state variable compute the same results.

Figure 4 – State Variable as a Java Class
The ResSim application's jars should be imported into the users IDE state variable project so that can classes available in ResSim can be used and imported.


Custom Scripted Rule as Java Object

Test Watershed:  CRT_System_Ops_19Jul2011

Original Alternative Run: CallUpon_o

Alternative that replaced Scripted Rule: ScriptedJavaCalssRule

Reservoir:  Grand Coulee

Rule: SynRes GCL

Java Class: SynResGCL.java (see pic above for screen shot)

Results are similar, but not exact, probably due to a calculation converted in the java code.


Java script alt runs about 2 to 3 seconds faster….out of an average 35 sec run.  This isn’t much, but given that only one script was replaced and the simulation was small this difference may be more worth it if the simulation was longer and more scripts were replaced.


User must implement the hec.rss.model.ScriptedRuleJavaInfc.java class and implement its two required methods:

public boolean initRuleScript(OpRule currentRule,RssSystem network);

public OpValue  runRuleScript(OpRule currentRule, RssSystem network, RunTimeStep currentRuntimestep);


Test Watershed:  CRT_System_Ops_19Jul2011

Original Alternative Run: CallUpon_o

Alternative that replaced Scripted Rule: ScriptedJavaCalssRule

Reservoir:  Grand Coulee

Rule: SynRes GCL

Java Class: SynResGCL.java (see pic above for screen shot)

Results are similar, but not exact, probably due to a calculation converted in the java code.


Java script alt runs about 2 to 3 seconds faster….out of an average 35 sec run.  This isn’t much, but given that only one script was replaced and the simulation was small this difference may be more worth it if the simulation was longer and more scripts were replaced.


User must implement the hec.rss.model.ScriptedRuleJavaInfc.java class and implement its two required methods:

public boolean initRuleScript(OpRule currentRule,RssSystem network);

public OpValue  runRuleScript(OpRule currentRule, RssSystem network, RunTimeStep currentRuntimestep);