Skip to content

Sources

Jens Engel edited this page Jan 30, 2021 · 1 revision

Sources

In PARODIS, parameters and disturbances can have data sources. Hereby, the sources for both are handled in very much the same way. To manage and access data sources, PARODIS uses the SourceManager, which exposes the public method getDataFromSource

function [data] = getDataFromSource(T, source, callingAgent, agents, numScenarios)

Three types of sources are available: function handles, filenames to CSV sources, static values.

  • Function handles: If a function handle is given as a source, it is called with the same arguments as getDataFromSource, minus the source argument
data = source(T, callingAgent, agents, numScenarios);
  • CSV sources: if a CSV shall be used as a data source, source must be the path to the CSV file (any file extension is allowed, the file must be in CSV format). The CSV must contain column-wise time series representation of the data, and PARODIS will linearly interpolate the actual data at timesteps T from these timeseries.
  • Static: If the parameter or disturbance shall always take the same value, it can simply be put as the source. The source manager will return the static value wrapped into a cell-array with numScenarios entries

How these sources are treated differs from the use case, though:

Disturbance Sources

There are two disturbances sources, one for the predicted disturbances and one for the real disturbances:

  • controller.predDisturbanceSource
  • controller.realDisturbanceSource

Function handles and Static Values

For the predicted disturbance, it is expected that the function handle returns a cell array with numScenarios entries, which are all $n_d \times N_\mathrm{pred}$ matrices of predicted values. Similarly, if a static source is set, it must be a $n_d \times N_\mathrm{pred}$ matrix, which will automatically be repeated and wrapped in a cell array.

For the real disturbance source, it is expected that one cell with a $n_d \times 1$ vector is returned. Similary, for a static source, it must be a $n_d \times 1$ vector, the wrapping is handled by the source manager.

CSV Files

For CSV sources, two possibly file formats are allowed for predicted disturbance sources:

  • A) A file with $N$ rows and $1+n_d \cdot N_\mathrm{pred}$ columns
  • B) A file with $N$ rows and $1+n_d$ columns

where first row is always some time in simulation time scale (i.e. in the same unit as the sample times T_s).

In case A), at each time step within the simulation, PARODIS will read an entirely new prediction matrix from the file, i.e. one row in the CSV file is one entire prediction matrix.

In case B), PARODIS will interpolate $N_\mathrm{pred}$ entries from all available rows, with the first entry being interpolated from the row closest to the current time T(1), so the predictions are "rolled" through.

In both cases, PARODIS will repeat the data numScenarios times.

For real disturbances sources, case B) applies for the file format. PARODIS will then interpolate only the first entry, instead of an entire horizon, and return that value.

Parameter Sources

Parameter sources behave very much like disturbance sources, yet are a little less complicated

Function handles and Static Values

Since parameters have predefined dimensions, recalling

controller.addParam(name, dimensions, source, scenarioDependent)

The source must return values of the defined dimensions. If a function handle is used, it must return a cell array with numScenarios cells, each filled with a matrix of size dimensions. For a static value, the matrix dimensions must simply match.

CSV Files

At this moment, CSV files are only supported like case B) for the CSV files of disturbance sources. This means, the CSV file must contain $N$ rows and $1+n_p$ columns, where n_p is the number of rows the parameter has. From these files, PARODIS will interpolate $N_\mathrm{pred}$ entries from all available rows, with the first entry being interpolated from the row closest to the current time T(1), so the predictions are "rolled" through.

From this, PARODIS will wrap the interpolated $n_p \times N_\mathrm{pred}$ matrix into a cell array with numScenarios entries.