## Model Basics

The following classes are used all over the Amalthea model to define specific attributes of the model classes.

### Custom Properties

The CustomProperty element is used to define own properties that are not (yet) available in AMALTHEA. If there is the need to extend an element or to store tool information related to processing steps, CustomProperties can be used to store this type of information. It also provides the possibility to work with prototypical approaches that later (if established and more stable) can be integrated in the standard model.

The elements are stored in a HashMap. The values can be of different types as shown in the structure picture, like String, Integer, Boolean...
In addition a ReferenceObject is available to store own references to other EObject elements.
The ListObject can be used to store multi-valued custom properties.

### Time (and Time Unit)

The AMALTHEA data model includes a common element to describe time ranges in an easy way, the Time element. The Time class in general allows to define negative time values. If only positive values are expected the AMALTHEA validation will show a warning.
The Time element can be contained by any other element for specifying attributes to store time information.
Time units are needed to describe different timing behavior and requirements, like deadlines or offsets of components.
To support different time ranges, especially different time units, AMALTHEA predefines these types like seconds, milli-seconds, micro-seconds, nano-seconds or pico-seconds.

### Frequency (and Frequency Unit)

### Data Size (and Data Size Unit)

The DataSize (and DataRate) definition contains units and prefixes

- according to the SI Standard
- for binary multiples

International System of Units (SI) | Prefixes for binary multiples
--- | ---

Name | Prefix | Factor
kilo | k | 103
mega | M | 106
giga | G | 109
tera | T | 1012
peta | P | 1015

Name | Prefix | Factor
kibi | Ki | 210
mebi | Mi | 220
gibi | Gi | 230
tebi | Ti | 240
pebi | Pi | 250
exbi | Ei | 260

The DataSize provides convenience methods to get the size also in bit and byte.
It is internally converted and can be retrieved in both ways.

### Data Rate (and Data Rate Unit)

### Deviation

Deviations used to model constant values, histograms and statistical distributions within AMALTHEA. There is a wide variety of possible use cases, where such a distribution is needed. For example, the variation in runtime of functions can be imitated. Therefore, AMALTHEA currently supports the following statistical distributions:

The earlier implementation used Generics to support the different use cases. To simplify the usage (via Java API and in the editor) the new implementation provides three different top level interfaces for Time Deviation, Discrete Value Deviation (integer values) and Continuous Value Deviation (float values). They provide specialized methods to handle their values and a common interface to access lower bound, upper bound and average.
The following image shows the detailed hierarchy of time deviations, the other implementations are built accordingly.

#### Boundaries

With the Boundaries class it is possible to specify commonly used deviations (scenarios). On the one hand, the scenario specified by the minimum and maximum value between which the sampled values vary. On the other hand, the Sampling Type denotes the specific scenario that is covered. These scenarios are actually defined by a Beta Distribution with preconfigured Alpha and Beta parameters. The following sampling types are available (visualized in the figures below):

BestCase
  Defines the scenario in which most instances should have runtimes close to the specified minimum runtime, but still should consider some more time-consuming outliers up to the set maximum. Alpha = 0.2; Beta = 1.
WorstCase
  Defines the scenario in which most instances should have runtimes close to the specified maximum runtime, but still should consider some less time-consuming outliers down to the set minimum. Alpha = 1; Beta = 0.2.
AverageCase
  Defines the scenario in which most instances should have runtimes close to the middle between the specified minimum and maximum, but still should consider some more or less time-consuming outliers down to the set minimum or up to the set maximum respectively. Alpha = 2; Beta = 2.
CornerCase
  Defines the scenario in which most instances should have runtimes close to the specified minimum and maximum runtime, but still should consider some other time-consuming outliers between those two. Alpha = 0.2; Beta = 0.2.
Uniform
  Defines the scenario in which all instances should have runtimes that are uniformly distributed between the specified minimum and maximum. Alpha = 1; Beta = 1.

#### Uniform Distribution

The uniform distribution is a statistical distribution where the values between the stated lower and upper bound are equally likely to be observed.

#### Gaussian/Normal Distribution

The Gaussian/normal distribution is a statistical distribution where the values decrease symmetrically. The maximum value and thus its location is thereby stated by the mean and the rate of decrease is defined by its standard deviation. Since the curves approach zero on either side, an additional upper and lower bound can be added to constraint the values.

#### Beta Distribution

The Beta distribution is a statistical distribution whose shape is defined by alpha > 0 and beta > 0. That way, the Beta distribution can also be used to model other distributions like for example uniform, normal, or Bernoulli distribution. Since the curves can approach zero or infinity on either side, an additional upper and lower bound can be added to constraint the values.

#### Weibull Distribution

The Weibull distribution is a statistical distribution whose shape is mathematically defined by kappa > 0 and the scale of the distribution by lambda > 0. In the model, it is parameterized using the mean value, the lower and upper bound, and the probability that a real-valued random variable of that distribution will not take a value less than or equal to a specific value. To calculate the scale and shape parameter for the Weibull distribution from the model parameters, the equation of the mean (see Weibull distribution – Wikipedia is solved for the scale parameter, first. Then, the resulting equation for lambda is plugged into the equation of the cumulative distribution function (CDF) for the Weibull distribution. Finally, the lower and upper bound allow to shift this function and the remaining unknown shape parameter in the equation is numerically approximated until the value of the parameter that constraints the distribution regarding the per mill of remaining values is reached.

#### Histogram

A histogram represents a distribution containing a limited number of entries (e.g. extracted from a trace). Each entry thereby is an Interval with the extra attribute occurrences which holds the number instances within the interval. The intervals do not have to cover a continuous range nor do they need to have the same interval size. Histograms are useful if there is a limited number of possibilities of valuations, which covers most practical systems. See the following figure for an example of two runnables having a time histogram deviation of their execution times.

### Statistic Elements

The contained elements are representing statistical values.
The values can be set either with a min, avg and max representation using the MinAvgMaxStatistic element.
The other possibility is to set a single value using the SingleValueStatistic element.
The minimum and maximum values are set as a normal int value, the average the single value as float.

### Ticks

Ticks are used to express execution times in a basic way. The number of ticks characterizes the amount of computation that is necessary to execute e.g. a Runnable. The corresponding execution time can be easily calculated if the frequency of the executing ProcessingUnit (PU) is known.The corresponding execution time can be easily calculated if the frequency of the executing ProcessingUnit (PU) is knownexecution time can be easily calculated if the frequency of the executing ProcessingUnit (PU) is known. Depending on the capabilities of a PU the time to execute such an element will differ. If necessary the fundamentally different numbers for specific types of PUs can be stored as extended values in a map.

In the next picture Ticks are shown in more detail.

Name | Description
--- | ---
default | The default number of ticks. This value is used if (1) the executing PU is unknown or (2) no extended entry is available for the PU.
extended | Possibility to store a PU-specific number of ticks.

### Counters

The Counter element describes an activation of a target element that happens only every nth time.

Name | Description
--- | ---
prescaler | Gives the number n for the activation, e.g. if set to 2, the target element is executed every second time.
offset | Initial shift for the first execution of the target.

If for example prescaler is 5 and offset is 2 it is executed on the 2nd, 7th, 12th, … time.

Counters are available at the following elements:

- Activity graph items:
  - ClearEvent
  - EnforcedMigration
  - InterProcessActivation
  - SchedulePoint
  - SetEvent
  - TerminateProcess
  - RunnableCall
  - WaitEvent
- Stimuli:
  - InterProcess
  - EventStimulus