How to create a context strategy

Parent Previous Next

The creation of a new context strategy is realized via the Strategy Class Coder software. This topic provides a step-by-step guide for this creation.

The context strategy will compose two simple strategies.


1. Download the Strategy Class Coder application (http://components.biomamodelling.org/components/scc/publish.htm)



2. Open the SCC software and click on "Data-interfaces DLL". A file browser will appear.


3. Select  the .dll file CRA.Diseases.Airborne.DiseaseProgress.Interfaces containing the definition of the domain classes of the DiseaseProgress component.



4. Once done, the SCC software will automatically configure according to the domain classes included in the .dll file loaded:


5. Then, click on the "Strategies DLL" button. A file browser will appear.



6. Select the .dll file CRA.Diseases.Airborne.DiseaseProgress, containing the definition of the strategies of the DiseaseProgress component.


7. Once done, click on the "Composite or Context strategy" button. The panel "Associated strategies" will appear.


8. Then, the General panel has to be filled with the definition of the Domain, the Model Type, the Strategy name, the Strategy description (these fields must be filled according to the user need). The right part of the graphical user interface let the opportunity to add some information about the author of the strategy. This part is common to the creation of a simple strategy.


9. The definition of the input and output variables ("Inputs - Outputs" panel) and of the parameters ("Parameters" panel) of a context strategy is the same as of a simple strategy, therefore please see the topic "How to create a simple strategy"


10. Once done, select the "AssociatedStrategies" panel. Click on the "SelectStrategy" button to select the simple, composite or context strategies to be composed.


11. In this example, the two strategies DispersalRain and DispersalWind are composed into a Context strategy, which will contain the logic to switch between rain and wind as the driving variable for the dispersion of the spores.


12. Once done, go to the "Switches" panel, in order to set the logic to switch between the two strategies. Click on "Add new switch" button and insert the name of the switch, then click on "OK".



13. Then, a description of the Switch variable and the possible values of the Switch must be defined (in this example true/false). Once done, click on "Generate Code" button.



14. Most of the generated code of a context strategy is the same as for simple strategy (topic "What is a strategy"). The only differences are that SCC automatically retrieves the input and output variables and the parameters from the associated strategies for the test of pre- and post- conditions.

As for simple strategies, the only method which should be implemented by the developer is the "Estimate" method.

The peculiarity of context strategies is the presence of the Switch variable to select at runtime one of the associated strategies.

Once a context strategy is created, the SCC software compiles a code region ("Composite class: associations"), in which the method "EstimateOfAssociatedClasses" calls the "Update" method of the simple strategies associated. This is the only logic implemented by default.


In this example, the name of the Switch variable is "UseWindAsDrivingVariable".

The following code shows how to implement the logic to switch between two associated strategies.


Created with the Personal Edition of HelpNDoc: Full-featured EBook editor