Difference between revisions of "Handling of tree states"

From Heureka Wiki
Jump to navigation Jump to search
Line 24: Line 24:
 
{| border="1"
 
{| border="1"
 
|-
 
|-
|Period||width="150pt"|0||width="150pt"|1||width="150pt"|2||width="150pt"|3||width="150pt"|4
+
|Period||width="120pt"|0||width="120pt"|1||width="120pt"|2||width="120pt"|3||width="120pt"|4
 
|-
 
|-
|State||Invalid||Invalid||Invalid||Waiting Sapling||Waiting Sapling
+
|State||Invalid||Invalid||Invalid||Waiting Sapling||Sapling
 
|-
 
|-
|Residual State||Invalid||Invalid||Waiting Sapling||Waiting Sapling||Sapling
+
|Residual State||Invalid||Invalid||Waiting Sapling||Sapling||Sapling
 
|}
 
|}
  
.
+
This means that:
Klasserna Tree, TreeCollection och PredictionUnit är de klasser som främst hanterar trädtillståndet.
+
 
+
* If current period of the <tt>TreatmentUnit</tt> is changed back to period 0, 1, or 2 the <tt>Tree</tt> object will be removed, since its state is invalid.
Figur 6 5: Hantering av trädens tillstånd
+
* If current period is 3, growth of the <tt>Tree</tt> shall not be calculated, since the state WaitingSapling indicates that the <tt>Tree</tt> already has a calculated future state.
Klass Tillståndshantering
+
* If current period is 4, growth of the <tt>Tree</tt> shall be calculated, using height growth model for saplings. The <tt>Tree</tt> may also be cleaned since it represents a sapling.
Tree Innehåller tillstånd för alla perioder för ett träd i variabeln TreeCategory.
 
Innehåller tillstånd för nästa period i variabeln TreeCategoryResidual.
 
Hanterar framskrivning, i metoden Grow(), där sätts:
 
1 ]
 
BeforeComparer,
 
AfterComparer Hanterar jämförelser mellan träd i metoden Compare(Tree, Tree), där:
 
Tree < Plant < Waiting < Dead < Invalid
 
Jämförelser sker alltid i aktuell period, som finns lagrad i TreatmentUnit. BeforeComparer jämför Category, AfterComparer jämför CategoryResidual.
 
TreeCollection Kan sortera träden i metoden Sort() med hjälp av jämförelser mellan träd.
 
(sortering sker alltid i aktuell period, som finns lagrad i TreatmentUnit)
 
Kan ta bort alla träd som är Invalid i den aktuella perioden, i metoden RemoveInvalidTrees()
 
Har färdiga listor (Trees, Plants, WaitingTrees och DeadTrees) med alla träd i ett visst tillstånd (utom invalid) i den aktuella perioden, samt en speciallista, Valid, med alla giltiga träd (Plant, Tree, Waiting) i den aktuella perioden. Dessa hanteras med klassen InnerTreeCollection, vilken tillåter att man enkelt itererar över alla träd i ett visst tillstånd.
 
PredictionUnit Kan interpolera träd som ska aktiveras i en senare period, i metoden InterpolateWaitingTrees()
 
Ansvarar för att ta bort ogiltiga träd om man går tillbaka till en tidigare period, i metoden Back(), genom att sortera trädlistan och sedan ta bort alla ogiltiga träd.
 

Revision as of 15:47, 19 May 2010

Tree States

Each tree may have one of the following states:

Tree
Establised tree
IngrownTree
A tree that just has been ingrown.
Sapling
Sapling
WatingTree
Tree waiting to be activated. This means that the future state of the tree has been calculated, and growth for the tree should not be calculated in growth prognosis. Waiting trees might be felled.
WaitingSapling
Sapling waiting to be activated. This is similar to waiting trees. However, waiting saplings cannot be cleaned.
RemovedTree
Tree that is dead
InvalidTree
Tree that is invalid. A tree can be removed if it is invalid in the current period.

Each Tree has a state before treatment, TreeCategory, and after treatment, TreeCategoryResidual.

Sorting Trees

The TreeCollection class keeps trees sorted in the current period. This makes it easy and fast to iterate over trees with a certain state, since all those trees are kept together.

Adding new Trees

Both the ingrowth model and the regeneration models creates and adds new Trees to a PredictionUnit.

Say that the regeneration model runs in period 2, and the saplings are to be activated in period 4. A Tree object would then have the following states for each period (before and after treatment):

Period 0 1 2 3 4
State Invalid Invalid Invalid Waiting Sapling Sapling
Residual State Invalid Invalid Waiting Sapling Sapling Sapling

This means that:

  • If current period of the TreatmentUnit is changed back to period 0, 1, or 2 the Tree object will be removed, since its state is invalid.
  • If current period is 3, growth of the Tree shall not be calculated, since the state WaitingSapling indicates that the Tree already has a calculated future state.
  • If current period is 4, growth of the Tree shall be calculated, using height growth model for saplings. The Tree may also be cleaned since it represents a sapling.