Soletta machine learning
Machine learning for IoT devices
 All Data Structures Files Functions Typedefs Enumerations Enumerator Groups Pages
Data Structures | Macros | Functions
Variables

SML Variable operations. More...

Data Structures

struct  sml_variable
 
struct  sml_variables_list
 

Macros

#define SML_VARIABLES_LIST_FOREACH(sml, list, len, var, i)
 

Functions

struct sml_variablesml_get_input (struct sml_object *sml, const char *name)
 Get input variable by name. More...
 
struct sml_variables_listsml_get_input_list (struct sml_object *sml)
 Return the input variables list. More...
 
struct sml_variablesml_get_output (struct sml_object *sml, const char *name)
 Get input variable by name. More...
 
struct sml_variables_listsml_get_output_list (struct sml_object *sml)
 Return the output variables list. More...
 
struct sml_variablesml_new_input (struct sml_object *sml, const char *name)
 Create a new input variable. More...
 
struct sml_variablesml_new_output (struct sml_object *sml, const char *name)
 Create a new output variable. More...
 
bool sml_remove_variable (struct sml_object *sml, struct sml_variable *variable)
 Remove a variable from the engine. More...
 
int sml_variable_get_name (struct sml_object *sml, struct sml_variable *sml_variable, char *var_name, size_t var_name_size)
 Get sml_variable name. More...
 
bool sml_variable_get_range (struct sml_object *sml, struct sml_variable *sml_variable, float *min, float *max)
 Get variable range. More...
 
float sml_variable_get_value (struct sml_object *sml, struct sml_variable *sml_variable)
 Get the variable current value. More...
 
bool sml_variable_is_enabled (struct sml_object *sml, struct sml_variable *variable)
 Check if a sml_variable is enabled. More...
 
int sml_variable_set_enabled (struct sml_object *sml, struct sml_variable *variable, bool enabled)
 Enable or disable a variable. More...
 
bool sml_variable_set_range (struct sml_object *sml, struct sml_variable *sml_variable, float min, float max)
 Set variable range. More...
 
bool sml_variable_set_value (struct sml_object *sml, struct sml_variable *sml_variable, float value)
 Set the variable value. More...
 
bool sml_variables_list_contains (struct sml_object *sml, struct sml_variables_list *list, struct sml_variable *var)
 Check if sml_variable is present in a sml_variables_list. More...
 
uint16_t sml_variables_list_get_length (struct sml_object *sml, struct sml_variables_list *list)
 Get the sml_variables_list size. More...
 
struct sml_variablesml_variables_list_index (struct sml_object *sml, struct sml_variables_list *list, uint16_t index)
 Get sml_variable by index. More...
 

Detailed Description

SML Variable operations.

Macro Definition Documentation

#define SML_VARIABLES_LIST_FOREACH (   sml,
  list,
  len,
  var,
 
)
Value:
for (i = 0, len = sml_variables_list_get_length(sml, list); \
i < len && ((var = sml_variables_list_index(sml, list, i))); \
i++)
uint16_t sml_variables_list_get_length(struct sml_object *sml, struct sml_variables_list *list)
Get the sml_variables_list size.
struct sml_variable * sml_variables_list_index(struct sml_object *sml, struct sml_variables_list *list, uint16_t index)
Get sml_variable by index.

Function Documentation

struct sml_variable* sml_get_input ( struct sml_object sml,
const char *  name 
)

Get input variable by name.

Parameters
smlThe sml_object object.
nameThe variable name.
Returns
sml_variable on success.
NULL on failure.
struct sml_variables_list* sml_get_input_list ( struct sml_object sml)

Return the input variables list.

Parameters
smlThe sml_object object.
Returns
sml_variables_list on success.
NULL on failure.
struct sml_variable* sml_get_output ( struct sml_object sml,
const char *  name 
)

Get input variable by name.

Parameters
smlThe sml_object object.
nameThe variable name.
Returns
sml_variable on success.
NULL on failure.
struct sml_variables_list* sml_get_output_list ( struct sml_object sml)

Return the output variables list.

Parameters
smlThe sml_object object.
Returns
sml_variables_list on success.
NULL on failure.
struct sml_variable* sml_new_input ( struct sml_object sml,
const char *  name 
)

Create a new input variable.

New input variables start with NAN set as value.

Parameters
smlThe sml_object object.
nameThe variable name. If length is greater than SML_VARIABLE_NAME_MAX_LEN variable creation will fail.
Returns
sml_variable on success.
NULL on failure.
struct sml_variable* sml_new_output ( struct sml_object sml,
const char *  name 
)

Create a new output variable.

If its value can't be calculated in a sml_process execution, the value set on NAN will be used.

Parameters
smlThe sml_object object.
nameThe variable name. If length is greater than SML_VARIABLE_NAME_MAX_LEN variable creation will fail.
Returns
sml_variable on success.
NULL on failure.
bool sml_remove_variable ( struct sml_object sml,
struct sml_variable variable 
)

Remove a variable from the engine.

Remarks
Removing a variable from a running SML engine may make it loose all previous knowledge. For temporary removals, use sml_variable_set_enabled
Parameters
smlThe sml_object object.
variableThe sml_variable to be removed
Returns
true on success.
false on failure.
int sml_variable_get_name ( struct sml_object sml,
struct sml_variable sml_variable,
char *  var_name,
size_t  var_name_size 
)

Get sml_variable name.

Parameters
smlThe sml_object object.
sml_variableThe sml_variable.
var_namePointer to memory where name should be copied.
var_name_sizeSize of memory pointed by var_name.
Returns
0 on success or error value.
bool sml_variable_get_range ( struct sml_object sml,
struct sml_variable sml_variable,
float *  min,
float *  max 
)

Get variable range.

Parameters
smlThe sml_object object.
sml_variableThe sml_variable.
minVariable where min value will be set. If NULL it is ignored.
maxVariable where max value will be set. If NULL it is ignored.
Returns
true on success.
false on failure.
float sml_variable_get_value ( struct sml_object sml,
struct sml_variable sml_variable 
)

Get the variable current value.

Parameters
smlThe sml_object object.
sml_variableThe sml_variable
Returns
true on success.
false on failure.
bool sml_variable_is_enabled ( struct sml_object sml,
struct sml_variable variable 
)

Check if a sml_variable is enabled.

Parameters
smlThe sml_object object.
variableThe sml_variable
Returns
true on success.
false on failure.
int sml_variable_set_enabled ( struct sml_object sml,
struct sml_variable variable,
bool  enabled 
)

Enable or disable a variable.

If a variable is disabled and is an input variable, its value will be ignored when trying to predict the values or training the engine. If it is an output variable, no prediction for this variable will be processed

Remarks
All variables are enabled by default.
Parameters
smlThe sml_object object.
variableThe sml_variable.
enabledtrue to enable, false to disable.
Returns
true on success.
false on failure.
bool sml_variable_set_range ( struct sml_object sml,
struct sml_variable sml_variable,
float  min,
float  max 
)

Set variable range.

If max is NAN, max value is not changed. If min is NAN, min value is not changed.

Remarks
default value is -FLT_MAX for min and FLT_MAX for max.
Parameters
smlThe sml_object object.
sml_variableThe sml_variable.
minVariable's min value.
maxVariable's max value
Returns
true on success.
false on failure.
bool sml_variable_set_value ( struct sml_object sml,
struct sml_variable sml_variable,
float  value 
)

Set the variable value.

Parameters
smlThe sml_object object.
sml_variableThe sml_variable
valueThe desired value.
Returns
true on success.
false on failure.
bool sml_variables_list_contains ( struct sml_object sml,
struct sml_variables_list list,
struct sml_variable var 
)

Check if sml_variable is present in a sml_variables_list.

Parameters
smlThe sml_object object.
listThe sml_variables_list.
varThe sml_variable.
Returns
true it is present.
false is is not present.
uint16_t sml_variables_list_get_length ( struct sml_object sml,
struct sml_variables_list list 
)

Get the sml_variables_list size.

Parameters
smlThe sml_object Object.
listThe sml_variables_list.
Returns
The list size
struct sml_variable* sml_variables_list_index ( struct sml_object sml,
struct sml_variables_list list,
uint16_t  index 
)

Get sml_variable by index.

Parameters
smlThe sml_object object.
listThe sml_variables_list.
indexThe list index.
Returns
sml_variable on success.
NULL on failure..