Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The FMUFunction should not exist #118

Open
mbaudin47 opened this issue Nov 5, 2024 · 0 comments
Open

The FMUFunction should not exist #118

mbaudin47 opened this issue Nov 5, 2024 · 0 comments

Comments

@mbaudin47
Copy link
Contributor

mbaudin47 commented Nov 5, 2024

The FMUFunction class should not exist. Only the FMUPointToFieldFunction class needs to exist. This is because, provided we can access to the whole trajectory of the output depending on the time, then we can always access the last value of the time series. To do this, the user can implement a new FinalValueFMUFunction an OpenTURNSPythonFunction which takes the FMUPointToFieldFunction model as input:

model = otfmi.FMUPointToFieldFunction()
fmuFunction = FinalValueFMUFunction(model)

In the exec() method, we evaluate the underlying function, then extracts the last value of the time series and returns it.

We could, however, make this much easier if a new ot.VertexFunction class is created in OpenTURNS. This function would have the constructor:

function = ot.VertexFunction(pointToFieldFunction, indices)

where pointToFieldFunction is a PointToFieldFunction and indices is:

  • either a single int if the output dimension of the Field is greater or equal to 1,
  • or a list of several integers if the output dimension of the Field is equal to 1.

These indices must be in the integer interval $[0, n - 1]$ where $n$ is the number of vertices. This new VertexFunction would return the value of the output Field corresponding to the indices at the vertices corresponding to the given indices.

To make things clearer, I consider the SIR epidemiological model as an example. This is a PointToField function with input dimension 2 corresponding to $\beta$ and $\gamma$ and output the Field corresponding to the time series.

  • Example 1. Suppose the model only returns the output $S$, i.e. the output Field has dimension equal to 1. Then indices can be a list of arbitrary indices in the integer $[0, n-1]$ where $n$ is the number of time steps. Then the function returns the value of $S$ at the given time points.
  • Example 2. Suppose the model returns the 3 outputs $S$, $I$ and $R$, i.e. the output Field has dimension equal to 3. Then indices can be a single integer. Then the function returns the value of the vector $(S, I, R)$ at that particular time point. If indices = -1, this corresponds to the last time value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant