EstimationVariable

@author: Marco Bonvini

class estimationpy.fmu_utils.estimation_variable.EstimationVariable(fmi_var, fmu)

This class represents a variable that is part of an estimation problem, and it can be either a state variable or a parameter.

An in stance of class EstimationVariable has multiple attributes and properties that are used during the estimation process. The most relevant attributes are

  • minValue is the minimum value a variable can assume and is specified in the model description file of the FMU. For example for a temperature measured in Kelvin, the minValue is 0.0.
  • maxValue is the minimum value a variable can assume and is specified in the model description file of the FMU. For example for a real number that represents a percentage the maxValue can be either 1.0 or 100.0.
  • cov is the covariance \(\sigma^2\) associated to the variable or parameter estimated.
  • initValue is the initial value used at the beginning of the estimation algorithm.
  • constraintLow is the lower limit the variable can assume during the estimation algorithm. This value is usualy set to impose ad-hoc boundaries to the estimation algorithm that may be physically not possible or reasonable.
  • constraintHigh is the upper limit the variable can assume during the estimation algorithm. This value is usualy set to impose ad-hoc boundaries to the estimation algorithm that may be physically not possible or reasonable.
__init__(fmi_var, fmu)

Constructor of the class. This method takes as arguments an FmiVariable object and an FmuModel object and instantiates an EstimationVariable object.

Parameters:
  • fmi_var (FmiVariable) – an object representing a variable of an FMU model in PyFMI.
  • fmu (FmuModel) – an object representing an FMU model in PyFMI.
Raises TypeError:
 

the method raises a TypeError if the start value of the variable is either missing or equal to None.

@todo: verify if value[0] can be different from the start value in a FmiVariable.

__weakref__

list of weak references to the object (if defined)

get_constraint_high()

This method returns the upper bound constraint value of the EstimationVariable object.

Returns:the upper bound constraint of the variable.
Return type:float
get_constraint_low()

This method returns the lower bound constraint value of the EstimationVariable object.

Returns:the lower bound constraint of the variable.
Return type:float
get_covariance()

This method returns the covariance of the EstimationVariable object.

Returns:the covariance of the variable.
Return type:float
get_fmi_var()

This method returns the underlying FMI variable object that is managed by the instance of this class.

Returns:a reference to the underlying FMI variable object
Return type:pyfmi.fmi.ScalarVariable
get_initial_value()

This method returns a numpy.array containing the initial value of the EstimationVariable object.

Returns:a 1-dimensional numpy array of length equal to 1 containing the initial value of the EstimationVariable.
Return type:numpy.Array
get_max_value()

This method returns the maximum value of the EstimationVariable object.

Returns:the maximum value of the variable.
Return type:float
get_min_value()

This method returns the minimum value of the EstimationVariable object.

Returns:the minimum value of the variable.
Return type:float
info()

This method return a string that contains a formatted representation of the EstimationVariable object.

Returns:String rerpesentation of the variable being estimated and its attributes.
Return type:string
modify_initial_value_in_fmu(fmu)

This method takes as argument an instance of type FmuModel and sets the initial value of the variable represented by this class to its initial value. The method returns True if the value has been set corectly, False otherwise.

Parameters:fmu (FmuModel) – an object representing an FMU model in PyFMI.
Returns:The outcome of the set operation, either True or False.
Return type:bool
read_value_in_fmu(fmu)

This method reads the value of a variable/parameter assumes in a specific FMU object.

Parameters:fmu (FMuModel) – an object representing an FMU model in PyFMI.
Returns:The value of the variable represented by an instance of this class. The method returns None is the type of the variable is not recognized as one of the available ones (Real, Integer, Boolean, Enumeration, String).
Return type:float, None
set_constraint_high(value)

This method sets the upper bound constraint for the EstimationVariable object.

Parameters:value (float) – The upper bound constraint value for the variable.
set_constraint_low(value)

This method sets the upper bound constraint for the EstimationVariable object.

Parameters:value (float) – The upper bound constraint value for the variable.
set_covariance(cov)

This method sets the covariance associated to an instance of the class EstimationVariable that is used by the state and parameter estimation algorithm.

Parameters:cov (float) – The value to be used as initial value in the estimation algorithm. The value must be positive.
Returns:True if the value has been set corectly, False otherwise.
Return type:bool
set_initial_value(value)

This method sets the initial value associated to an instance of the class EstimationVariable that is used by the state and parameter estimation algorithm.

Parameters:value (float) – The value to be used as initial value in the estimation algorithm.
set_max_value(value)

This method sets the maximum value for the EstimationVariable object.

Parameters:value (float) – The maximum value for the variable.
set_min_value(value)

This method sets the minimum value for the EstimationVariable object.

Parameters:value (float) – The minimum value for the variable.