Result models

From Heureka Wiki
Revision as of 12:18, 19 May 2010 by Fkl (talk | contribs)
Jump to navigation Jump to search

Implementing a Result Model

A result model is implemented as a class that is depending on:

  1. Treatment Unit
  2. Period (optional)
  3. Before or after treatment in the period (optional)
  4. Other results (optional)

The class is given the attribute Slu.Heureka.DomainLayer.Forest.TreatmentUnitResult. In the attribute it is specified which of the above parameters that are required by the model (the attribute also specifices more information about the result model, see code for more details).

The class must also have a constructor with the required parameters, in the same order as above. When a new instance of the class is created, the results of the model should be calculated.

All properties of the class will be exposed as result variables, unless the attribute Browsable is set to false.

Each property must be a simple type (nullable simple types are allowed), or a SpeciesCollection. Note that all simple types not have been used, so simple types other than int, double, bool, and int-based enums should be tested carefully.

On each property the DisplayName attribute and the Slu.Heureka.DomainLayer.Forest.Unit attribute may be given. The former is the name that will be presented to the user for the property, and the latter gives the user extra information about the unit of the attribute.

Once the model is implemented as above, the result variables will be available in maps, diagrams, tables, optimization models, and forest domains.

Different types of result models

There are several different types of result models:

Before/After result
Results that are affected by treatments, e.g.

== Advanced result model implementation considerations

Getting results in code

The results of each result model is managed by the Result class, which acts as a container of result model objects, and can be accessed via a TreatmentUnit:

GetResult(int period)
Gets the results in a given period changes)
GetResults()
Gets all results up to current period
CopyResults(IList<Type> resultTypes)
Gets a deep copy of all results up to current period, with all result models of the given types calculated.

Note that results retrieved via the first two methods might later be changed if the state of the TreatmentUnit changes. The values from a given result model can be retrieved on demand when the result(s) has been retrieved. Results retrieved via the last method are a copy and thus will not be changed, and the result models must be specified beforehand, values from result models not given in the call cannot be retrieved at a later time.

Once a Result object has been retrieved, it is possible to get result model objects from it:

ContainsBefore(Type t), ContainsAfter(Type t), ContainsTreatment(Type t)
Checks if the given result model type exists in the result
Before(Type t), After(Type t), Treatment(Type t)
Gets the result model objects of the given type (note that several objects may be retrieved)
BeforeAndAfterSame
Returns a value indicating that values before treatment are identical to values after treatment (e.g. no treatment has been performed in the period the result belongs to)

The inner workings of the result class