Package com.anylogic.engine.analysis
          
          
- java.lang.Object
- com.anylogic.engine.analysis.ChartItem
- com.anylogic.engine.analysis.BasicDataSet
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- DataSet
public class BasicDataSet extends ChartItem
A data set capable of storing 2D (X,Y) data of type double and maintaining the
 up-to-date minimum and maximum of the stored data for each dimension. The data 
 set keeps a given limited number of the latest data items.
Please note that adding a new item when the dataset is full will cause loss of the oldest sample and, if the lost item contained minimum or maximum, will initiate a new search for min/max, which may be quite time consuming for large datasets. Therefore for large datasets it is recommended to have the size not less than the number of items yoiu plan to add.
Please note that adding a new item when the dataset is full will cause loss of the oldest sample and, if the lost item contained minimum or maximum, will initiate a new search for min/max, which may be quite time consuming for large datasets. Therefore for large datasets it is recommended to have the size not less than the number of items yoiu plan to add.
- Author:
- AnyLogic North America, LLC https://anylogic.com
- See Also:
- Serialized Form
| Constructor | Description | 
|---|---|
| BasicDataSet | Constructs a 2D data set with data of type double with a given capacity. | 
| BasicDataSet | Constructs a 2D data set with data of type double with a given capacity. Registers the given updater so that dataset uses it while being updated. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| void | add | Adds a new data item to the data set. | 
| void | add | Adds a new data item to the data set. | 
| void | allowDuplicateX | Sets the way of handling two subsequent calls of add() with identical X values. | 
| void | allowDuplicateY | Sets the way of handling two subsequent calls of add() with identical Y values. | 
| void | destroyUpdater_xjal() | This method is used to 'disconnect' this data class from the
 agent/experiment this object was defined in. It is usually called on agent destroy so that experiment could use this data object e.g. | 
| boolean | duplicateXAllowed() | Tests if subsequent data items with same X values are allowed in this dataset. | 
| boolean | duplicateYAllowed() | Tests if subsequent data items with same Y values are allowed in this dataset. | 
| void | fillFrom | Makes this dataset an exact copy of the given original dataset. | 
| void | fillFrom | Discards all existing data, sets the capacity to equal to the 
 number of entries in the given table function and fills the
 dataset from the given table function. | 
| int | getCapacity() | Returns the capacity of the data set. | 
| List<List<Object>> | getPlainDataTable() | |
| double | getX | Returns the x of the data items with a given index (which must be
 in the range 0..size()-1). | 
| double | getXMax() | Returns the maximum of all x values of all stored items,
 or  -infinityin case there are no items. | 
| double | getXMean() | Returns the average of all x values of all stored items,
 or  0in case there are no items. | 
| double | getXMedian() | Returns the median of all x values of all stored items, 
 or  0in case there are no items.Note that this median calculation is time consuming | 
| double | getXMin() | Returns the minimum of all x values of all stored data items,
 or  +infinityin case there are no items. | 
| double | getY | Returns the y of the data items with a given index (which must be
 in the range 0..size()-1). | 
| double | getYMax() | Returns the maximum of all y values of all stored items, 
 or  -infinityin case there are no items. | 
| double | getYMean() | Returns the average of all y values of all stored items,
 or  0in case there are no items. | 
| double | getYMedian() | Returns the median of all y values of all stored items, 
 or  0in case there are no items.Note that this median calculation is time consuming | 
| double | getYMin() | Returns the minimum of all y values of all stored items,
 or  +infinityin case there are no items. | 
| void | reset() | Discards all stored data and their minimum/maximum. | 
| void | setCapacity | Resizes the data set according to the new capacity. | 
| int | size() | Returns the number of items stored in the data set. | 
| String | toString() | Returns a tab-separated multi-line textual representation of the data set
 containing not more than 1000 data items. | 
| void | update() | Should be overridden and call add( x, y ) if the user has 
 specified the values for horizontal and/or vertical axes. | 
public BasicDataSet(int capacity) 
Constructs a 2D data set with data of type double with a given capacity.
- Parameters:
- capacity- the maximum number of (x,y) items the data set can store
public BasicDataSet(int capacity, DataUpdater_xjal updater) 
Constructs a 2D data set with data of type double with a given capacity.
Registers the given updater so that dataset uses it while being updated. Updater may be dropped off when no more needed, in order to improve memory performance.
Registers the given updater so that dataset uses it while being updated. Updater may be dropped off when no more needed, in order to improve memory performance.
- Parameters:
- capacity- the maximum number of (x,y) items the data set can store
- updater- updater which may be used instead of overriding- update()method
@AnyLogicInternalCodegenAPI public void destroyUpdater_xjal()
This method is used to 'disconnect' this data class from the
 agent/experiment this object was defined in.
It is usually called on agent destroy so that experiment could use this data object e.g. in its charts.
It is usually called on agent destroy so that experiment could use this data object e.g. in its charts.
public void fillFrom(TableFunction tf) 
Discards all existing data, sets the capacity to equal to the 
 number of entries in the given table function and fills the
 dataset from the given table function.
- Parameters:
- tf- the table function to copy data from
public void reset()
Discards all stored data and their minimum/maximum.
public void setCapacity(int newcapacity) 
Resizes the data set according to the new capacity. As many as possible
 of old data items will be kept. The minimum/maximum are recalculated.
- Parameters:
- newcapacity- the new size of the data set
public int getCapacity()
Returns the capacity of the data set. The actual number of stored
 items may be smaller and can be retrieved by size().
- Returns:
- the capacity of the data set
public void allowDuplicateY(boolean yes) 
Sets the way of handling two subsequent calls of add() with identical Y values.
- Parameters:
- yes- if- true, two entries in the dataset will be created, otherwise second item will override the last one.
public boolean duplicateYAllowed()
Tests if subsequent data items with same Y values are allowed in this dataset.
 By default they are allowed.
- Returns:
- trueif yes, otherwise- false
public void allowDuplicateX(boolean yes) 
Sets the way of handling two subsequent calls of add() with identical X values.
- Parameters:
- yes- if- true, two entries in the dataset will be created, otherwise second item will override the last one.
public boolean duplicateXAllowed()
Tests if subsequent data items with same X values are allowed in this dataset.
 By default they are allowed.
- Returns:
- trueif yes, otherwise- false
public void add(double x, double y) 
Adds a new data item to the data set. If the data set is full, the oldest
 item will be pushed out and lost. The minimum/maximum may change as a result of
 both adding new and discarding old values and are recalculated.
- Parameters:
- x- the x value of the data item
- y- the y value of the data item
public void add(double y) 
Adds a new data item to the data set. This method is
 supported only by datasets with enabled
 "Use time (run number) as horizontal axis value" option
 (see General Properties page of DataSet in the AnyLogic IDE).
If the data set is full, the oldest item will be pushed out and lost. The minimum/maximum may change as a result of both adding new and discarding old values and are recalculated.
If the data set is full, the oldest item will be pushed out and lost. The minimum/maximum may change as a result of both adding new and discarding old values and are recalculated.
- Parameters:
- y- the y value of the data item
public void fillFrom(BasicDataSet ds) 
Makes this dataset an exact copy of the given original dataset.
- Parameters:
- ds- the original dataset
public void update()
Should be overridden and call add( x, y ) if the user has 
 specified the values for horizontal and/or vertical axes.
 By default does nothing or uses updater if was created
 with appropriate constructor.
public double getXMin()
Returns the minimum of all x values of all stored data items,
 or 
+infinity in case there are no items.- Returns:
- the minimum of the x values or +infinity
public double getXMax()
Returns the maximum of all x values of all stored items,
 or 
-infinity in case there are no items.- Returns:
- the maximum of the x values or -infinity
public double getXMean()
Returns the average of all x values of all stored items,
 or 
0 in case there are no items.- Returns:
- the average of all x values or 0
- Since:
- 7.2
public double getXMedian()
Returns the median of all x values of all stored items, 
 or 
Note that this median calculation is time consuming
0 in case there are no items.Note that this median calculation is time consuming
- Returns:
- the median of the x values or 0
- Since:
- 7.0
public double getYMin()
Returns the minimum of all y values of all stored items,
 or 
+infinity in case there are no items.- Returns:
- the minimum of the y values or +infinity
public double getYMax()
Returns the maximum of all y values of all stored items, 
 or 
-infinity in case there are no items.- Returns:
- the maximum of the y values or -infinity
public double getYMean()
Returns the average of all y values of all stored items,
 or 
0 in case there are no items.- Returns:
- the average of all y values or 0
- Since:
- 7.2
public double getYMedian()
Returns the median of all y values of all stored items, 
 or 
Note that this median calculation is time consuming
0 in case there are no items.Note that this median calculation is time consuming
- Returns:
- the median of the y values or 0
- Since:
- 7.0
public int size()
Returns the number of items stored in the data set.
- Returns:
- the number of items stored
public double getX(int i) 
Returns the x of the data items with a given index (which must be
 in the range 0..size()-1).
- Parameters:
- i- the index of the data items
- Returns:
- the x of the data items
public double getY(int i) 
Returns the y of the data items with a given index (which must be
 in the range 0..size()-1).
- Parameters:
- i- the index of the data items
- Returns:
- the y of the data items
public String toString()
Returns a tab-separated multi-line textual representation of the data set
 containing not more than 1000 data items. If there are more items, the
 very last line says "... xxx more items".
@AnyLogicInternalAPI public List<List<Object>> getPlainDataTable()