Documentation

This page hosts the documentation of the SmartCGMS software architecture and all of its components.

The documentation is being updated to acommodate the recent improvements. Please, be patient, we are working on it...


Calculated signal filter

The calculated signal filter maintains the lifetime of the calculated signal entity of a given signal model. It can run the solver during the simulation and perform additional operations on the signal object.

Please note, that the use of signal models is discouraged in favor of discrete models. This filter, as well, as the signal model subsystem is kept for legacy reasons.

Configuration

  • Model (GUID) - a GUID of a signal model to select signals from
  • Signal (GUID) - a GUID of the signal from the selected signal model
  • Prediction_Window (time) - a time delta for signal's Get_Continuous_Levels call
  • Model_Bounds (double array) - model parameters with lower and upper bounds (order: lower bounds, default parameters, upper bounds)
  • Solve_Parameters (boolean) - should we start the solver to obtain model parameters?
  • Solver (GUID) - a GUID of the selected solver
  • Solve_On_Level_Count (integer) - when to run solver - when this many new levels are obtained
  • Solve_On_Calibration (boolean) - when to run solver - when a calibration signal is obtained (scgms::signal_Calibration)
  • Solve_On_Time_Segment_End (boolean) - when to run solver - when the Time_Segment_End device event is obtained
  • Solve_Using_All_Segments (boolean) - use all segments to run solver?
  • Metric (GUID) - a GUID of a metric to use when running the solver
  • Levels_Required (integer) - metric parameter - how many levels are required to calculate the metric value
  • Measured_Levels (boolean) - use discrete levels instead of continuous levels as a reference for fitness calculation
  • Relative_Error (boolean) - metric parameter - use relative error instead of absolute
  • Squared_Diff (boolean) - metric parameter - use squared differences for metric calculation
  • Prefer_More_Levels (boolean) - metric parameter - prefer more levels over less, when calculating metric value
  • Metric_Threshold (double) - metric parameter - a threshold for given metric; this is a specific parameter for every metric, may be ignored

Supported interfaces

  • scgms::ICalculate_Filter_Inspection

General function

The calculated signal filter internally maintains time segments and all of the levels, that were obtained through the filter chain. It does not put any memory constraints on accumulated values - for larger segments, this filter may potentially allocate large portions of memory. It gathers all values, sorts them into time segments and repeatedly calls the Get_Continuous_Levels method of selected signal to obtain calculated values of this signal.

When calling the Get_Continuous_Levels method, there are a handful of implications that needs to be taken into account. First, when the signal returns NaN for a requested time, the calculate filter tries to retrieve this time again in the future. Second, the calculated signal levels are retained as measured levels in any further filter - there is no way, that any other filter, than the calculated value source, will recognize the signal as calculated. This has one effect on the calculated signal itself - if the calculated signal needs another signal, that was calculated by the previous filter, the only way to consider its values is to either use discrete levels only (through the Get_Discrete_Levels call), or to instantiate an approximator to obtain continuous levels. However, the latter has a potential performance drawback. Better solution is to configure calculated signals to emit levels at the same time (or time delta), so we can be sure, that there is a matching discrete level at the requested time.

Running the solver

If the Solve_Parameters is set to true, every solver and metric-related parameter applies. When the solver is started, it pauses all the events in the chain (Execute call blocks) until it finishes.

There are a few possible occasions, when the solver is started:

  • Solve_On_Level_Count is set to a valid value greater, than zero, and exactly this many device events containing a signal level passes through the filter
  • Solve_On_Calibration is set to true, and a scgms::signal_Calibration signal level passes through the filter
  • Solve_On_Time_Segment_End is set to true, and a Time_Segment_End device event passes through the filter

The metric of the selected GUID (Metric parameter) is instantiated to calculate the metric values during solving. All the parameters are further described in the metric subpage.

Once finished, the filter evaluates the metric value of the newly obtained parameter set, and if the value improved, it applies the parameter set to the signal for further Get_Continuous_Levels method calls and sends the new parameters through the filter chain as a Parameters device event.

The solver obtains every paramaters of such signal, that comes thorugh the chain as a Parameters device event in a form of solution hint.