Skip to content

Latest commit

 

History

History
47 lines (43 loc) · 1.62 KB

2.3 Signal.md

File metadata and controls

47 lines (43 loc) · 1.62 KB

Introduction

Signals encapsulate the payload to be returned. The Signal object maintains a list of valid values (EnumeratedSignal) or the range it can vary (BoundedSignal). Refer to section 2.3 for more information on signals. The value is randomly selected in the initialization phase and can only be changed via mutation.

BoundedSignal

BoundedSignal objects can yield values between an interval.

Consturctor

The constructor of BoundedSignal.

Arguments

Argument Description
lowerBound The lower bound of the interval.
upperBound The upper bound of the interval.
returnType Can be either int, float, or double.

Special rule

  1. If the lowerBound equals the upperBound, the framework will supress the forming of a Value object in the right-hand side.

Example

% An integer between -5 and 5
bs = BoundedSignal(-5, 5, 'int');
bs.init();
disp(bs.signal);

% A decimal value between -5 and 5
BoundedSignal(-5, 5, 'double');
bs.init();
disp(bs.signal);

EnumeratedSignals

EnumeratedSignals are objects that can yield enumerated values.

Consturctor

The constructor of EnumeratedSignals.

Arguments

Argument Description
allowedValues A cell of values.

Example

% Yield either 'Buy', 'Hold', or 'Sell'.
% In a real world application, it is recommended to replace the three strings with integers for better performance.
es = EnumeratedSignal({'Buy', 'Hold', 'Sell'});
es.init();
disp(es.signal);

License

This project, including the documentation, is licensed under the MIT license. Copyright (c) 2022 Bohui WU.