Personal tools
You are here: Home Community Help Center How-tos Write a Model

Write a Model

A model is a flexible net of components and describes the relations between business objects. Models are kept separate from the parametrization, structure, result templates and results.

Purpose

Build a simple model producing single losses. A frequency generator produces the number of claims and a claims size generator produces the claims size.

Prerequisities

Source code of PillarOne modelling.

All models are available in the folder src/java/models. Each model has its own folder.

Step by step

  1. Create a new folder in src/java/models. There aren't any naming conventions to observe.
  2. In this folder create a class ending with the word Model. A model class has to extend from the class org.pillarone.modelling.simulation.Model. (see line 1 below)
  3. In our model class we have to list all components as member variables (lines 2,3)
  4. Components can be found in src/groovy/org/pillarone/modelling/domain. As we need a frequency and a claims size generator, the sub packages of the generators package contains what we are looking for.
  5. Finally, we have to implement the abstract methods of the Model class:
    1. In initComponents() we have to instantiate our components (lines 5,6) and define the starting point(s) (line 7) of our net. The start components will be executed first. Other components will be executed once they have received all required information from their preceding components.
    2. In wireComponents() we define the connections of our net, the dataflow between our components. The left side describes the receiving component, the right side the sending component. The in and out properties have to be of the same type. In our case the generated frequency will be sent to the claims generator (line 10).
1: class SparrowModel extends Model {
2:    FrequencyGenerator frequencyGenerator
3:    SingleClaimsGenerator claimsGenerator

4:    void initComponents() {
5:        frequencyGenerator = new FrequencyGenerator()
6:        claimsGenerator = new SingleClaimsGenerator()
7:        startComponents << frequencyGenerator
8:    }

9:    void wireComponents() {
10:       claimsGenerator.inClaimCount = frequencyGenerator.outFrequency
11:   }
12:}

(package and import statements are not displayed)

 

Remarks:

  • It is possible to instantiate the components with default values.

 

Next Steps

Writing the model class is not the end of the story, in order to run a model we need three additional scripts defining the parametrization and the structure of a model. In the third script file we have to define the results that should be collected in every iteration.

Document Actions