User Tools

The Numberable interface change from int to double

F. de Coligny - 24.8.2006

The original Numberable interface

This capsis.util.Numberable interface contains two accessors:

public int getNumber ();
public void setNumber (int n);

It is mainly used in the Capsis kernel trees description for distance-independent tree models :

public class GMaidTree implements Numberable

The subclasses of GMaidTree (ex: Pp3Tree in Maritime pine model) use this property to handle the number of trees in the dbh class they represent.

public class Pp3Tree extends GMaidTree

Till now, this number was an integer (int type).

The new Numberable interface

Some models need to manage a decimal number in their tree description. When the need first arised, modellers coped with the existing int number by using an Oversampling method. The numbers were multiplied by some value to have more accurate calculations despite of the int restriction. This method leads to more complexity and needed to be changed. The change has been done on 22th august 2006 to ease the integration of the NZ1 Radiata pine model.

The new Numberable interface:

public double getNumber ();
public void setNumber (double n);	// fc - 22.8.2006

Corrections have been done in all the impacted source files:

  • The modules using an integer number pass the integer in the double type without change, their functioning do not change.
  • The extensions using this number have been adapted to consider the double precision, including on graphics, curves, etc. (e.g.: capsis.extension.dataextractor.DETimeN).
  • The genetics library has been technicaly adapted to handle a double (24.8.2006).
  • On the adapted histogram extractors, a configuration property has been added: “N rounded to the nearest integer” to allow the same results than previously, particularly when using the “Per hectare” option which can produce decimal values.
  • Some extensions which compatibility is restricted to a particular module not using the number property may have not been adapted.
  • The NProvider interface has been adapted to handle a double, the method providers of the modules have also been upgraded.
  • The “NumberOfDead” property has not been changed, it is still an integer. This property may be replaced by the use of the statusMap in the GTCStand superclass to memorize the dead trees under the “dead” status (available for individual based models and also for diameter class models). The related method in GTCStand has been updated to manage a double:
public void storeStatus (Numberable tree, String status, 
        double numberUnderThisStatus) {

Here is the list of impacted files and source files:

The following images shows the evolution of the decimal number of trees over time in the NZ1 model (under development) and the N over slenderness classes histogram.

documentation/numberable_change.txt · Last modified: 2013/05/23 10:25 (external edit)