Interface description of the COSTA default model component. For user implementation see cta_usr_model.h. More...
#include "cta_handles.h"
#include "cta_datatypes.h"
#include "cta_functions.h"
#include "cta_treevector.h"
#include "cta_time.h"
#include "cta_obsdescr.h"
Go to the source code of this file.
Defines | |
#define | I_CTA_MODEL_CREATE_SIZE ( 0) |
#define | I_CTA_MODEL_CREATE_INIT ( 1) |
#define | I_CTA_MODEL_FREE ( 2) |
#define | I_CTA_MODEL_COMPUTE ( 3) |
#define | I_CTA_MODEL_SET_STATE ( 4) |
#define | I_CTA_MODEL_GET_STATE ( 5) |
#define | CTA_MODEL_AXPY_STATE ( 6) |
#define | CTA_MODEL_AXPY_MODEL ( 7) |
#define | CTA_MODEL_SET_FORC ( 8) |
#define | CTA_MODEL_GET_FORC ( 9) |
#define | CTA_MODEL_AXPY_FORC (10) |
#define | CTA_MODEL_SET_PARAM (11) |
#define | CTA_MODEL_GET_PARAM (12) |
#define | CTA_MODEL_AXPY_PARAM (13) |
#define | CTA_MODEL_GET_STATESCALING (14) |
#define | CTA_MODEL_GET_TIMEHORIZON (15) |
#define | CTA_MODEL_GET_CURRENTTIME (16) |
#define | CTA_MODEL_GET_NOISE_COUNT (17) |
#define | CTA_MODEL_GET_NOISE_COVAR (18) |
#define | CTA_MODEL_GET_OBSVALUES (19) |
#define | CTA_MODEL_GET_OBSSELECT (20) |
#define | CTA_MODEL_ANNOUNCE_OBSVALUES (21) |
#define | CTA_MODEL_ADD_NOISE (22) |
#define | I_CTA_MODEL_EXPORT (23) |
#define | I_CTA_MODEL_IMPORT (24) |
#define | CTA_MODEL_ADJ_SET_FORC (25) |
#define | CTA_MODEL_ADJ_COMPUTE (26) |
#define | CTA_MODEL_ADJ_PREPARE (27) |
#define | I_CTA_MODEL_GETOBSLOCALIZATION (28) |
#define | CTA_MODEL_SAVE_INTERNALSTATE (30) |
#define | CTA_MODEL_RESTORE_INTERNALSTATE (31) |
#define | CTA_MODEL_RELEASE_INTERNALSTATE (32) |
#define | CTA_MODEL_SAVE_PERSISTENTSTATE (33) |
#define | CTA_MODEL_LOAD_PERSISTENTSTATE (29) |
#define | CTA_MODEL_NUMFUNC (34) |
Typedefs | |
typedef CTA_Handle | CTA_Model |
typedef CTA_Handle | CTA_ModelClass |
Functions | |
CTAEXPORT int | CTA_Model_Create (CTA_ModelClass hmodcl, CTA_Handle userdata, CTA_Model *hmodel) |
Create a model instance. | |
CTAEXPORT int | CTA_Model_Compute (CTA_Model hmodel, CTA_Time htime) |
Compute model for given timespan. | |
CTAEXPORT int | CTA_Model_AddNoise (CTA_Model hmodel, CTA_Time htime) |
Add noise during during the given timespan at the Compute. | |
CTAEXPORT int | CTA_Model_SetState (CTA_Model hmodel, CTA_TreeVector hstate) |
Set the internal state of the model. | |
CTAEXPORT int | CTA_Model_GetState (CTA_Model hmodel, CTA_TreeVector *hstate) |
Get a copy of the internal state. | |
CTAEXPORT int | CTA_Model_AxpyState (CTA_Model hmodel, double alpha, CTA_Handle hx) |
Perform axpy operation on the internal state. | |
CTAEXPORT int | CTA_Model_GetStateScaling (CTA_Model hmodel, CTA_TreeVector *hscale) |
Get element-wise scaling for model state. | |
CTAEXPORT int | CTA_Model_SetForc (CTA_Model hmodel, CTA_Time tspan, CTA_TreeVector hforc) |
Set the models forcings. | |
CTAEXPORT int | CTA_Model_GetForc (CTA_Model hmodel, CTA_Time tspan, CTA_TreeVector *hforc) |
Get a copy of the values of the models forcings. | |
CTAEXPORT int | CTA_Model_AxpyForc (CTA_Model hmodel, CTA_Time tspan, double alpha, CTA_TreeVector hx) |
Perform axpy operation on the models forcings. | |
CTAEXPORT int | CTA_Model_SetParam (CTA_Model hmodel, CTA_TreeVector hparam) |
Set parameters of the model. | |
CTAEXPORT int | CTA_Model_GetParam (CTA_Model hmodel, CTA_TreeVector *hparam) |
Get a copy of the parameters of the model. | |
CTAEXPORT int | CTA_Model_AxpyParam (CTA_Model hmodel, double alpha, CTA_TreeVector hx) |
Perform axpy operation on the models parameters. | |
CTAEXPORT int | CTA_Model_GetTimeHorizon (CTA_Model hmodel, CTA_Time tHorizon) |
Return the timehorizon on the model. The time horizon is the initial overal simulation span for which the mode is configured. | |
CTAEXPORT int | CTA_Model_GetCurrentTime (CTA_Model hmodel, CTA_Time tCurrent) |
Return the current time of the model. | |
CTAEXPORT int | CTA_Model_GetNoiseCovar (CTA_Model hmodel, CTA_TreeVector *hstmat) |
Get covariance matrix of noise parameters. | |
CTAEXPORT int | CTA_Model_GetNoiseCount (CTA_Model hmodel, int *nnoise) |
Get number of noise parameters: the number of columns of the noise covariance matrix. | |
CTAEXPORT int | CTA_Model_Free (CTA_Model *hmodel) |
Free model instance. | |
CTAEXPORT int | CTA_Model_AnnounceObsValues (CTA_Model hmodel, CTA_ObsDescr hdescr) |
Announce to the model what observations will be requested. | |
CTAEXPORT int | CTA_Model_GetObsValues (CTA_Model hmodel, CTA_Time htime, CTA_ObsDescr hdescr, CTA_Vector values) |
Get (interpolate) the models internal state to the observations described as specified in the observation description component. | |
CTAEXPORT int | CTA_Model_GetObsLocalization (CTA_Model hmodel, CTA_ObsDescr hdescr, double distance, CTA_Vector locVecs) |
Get for each observation a localization scaling vector. | |
CTAEXPORT int | CTA_Model_GetObsSelect (CTA_Model hmodel, CTA_Time htime, CTA_ObsDescr hdescr, CTA_String sselect) |
Get a query for the stochastic observer in order to filter out the observations that can actually be provided by the model. | |
CTAEXPORT int | CTA_Model_SaveInternalState (CTA_Model hmodel, CTA_String *instanceID) |
CTAEXPORT int | CTA_Model_RestoreInternalState (CTA_Model hmodel, CTA_String instanceID) |
CTAEXPORT int | CTA_Model_ReleaseInternalState (CTA_Model hmodel, CTA_String instanceID) |
CTAEXPORT int | CTA_Model_SavePersistentState (CTA_Model hmodel, CTA_String filename, CTA_String instanceID) |
CTAEXPORT int | CTA_Model_LoadPersistentState (CTA_Model hmodel, CTA_String filename, CTA_String *instanceID) |
int | CTA_Model_Export (CTA_Model hmodel, CTA_Handle hexport) |
Export the whole internal state of a model This export function will export the whole state of the model such that a so called "restart" start from this point yielding the same results. There are no ruled on the format that is used to store the data. Various extra otions are valid but a model will in most cases support an export to a file and to a COSTA pack object. | |
int | CTA_Model_Import (CTA_Model hmodel, CTA_Handle himport) |
Import the whole internal state of a model After the inport the models internal state is exactly the same as the point that the export was created using CTA_Model_Export. | |
int | CTA_Model_AdjSetointForc (CTA_Model hmodel, CTA_ObsDescr hdescr, CTA_Vector vforc) |
bla HOMEWORK FOR JULIUS! | |
int | CTA_Model_AdjPrepare (CTA_Model hmodel, CTA_Time time) |
bla HOMEWORK FOR JULIUS! | |
int | CTA_Model_AdjCompute (CTA_Model hmodel, CTA_Time time) |
bla HOMEWORK FOR JULIUS! | |
int | CTAI_Model_PerformTimesteps (CTA_Model hmodel, CTA_Function *function, CTA_Time htime, int mindBarrier) |
Interface description of the COSTA default model component. For user implementation see cta_usr_model.h.
Functions for creating and working with models. CTA_Model is the default class implementation for models.
Definition in file cta_model.h.
#define CTA_MODEL_ADD_NOISE (22) |
Definition at line 68 of file cta_model.h.
#define CTA_MODEL_ADJ_COMPUTE (26) |
Definition at line 74 of file cta_model.h.
#define CTA_MODEL_ADJ_PREPARE (27) |
Definition at line 75 of file cta_model.h.
#define CTA_MODEL_ADJ_SET_FORC (25) |
Definition at line 73 of file cta_model.h.
#define CTA_MODEL_ANNOUNCE_OBSVALUES (21) |
Definition at line 66 of file cta_model.h.
#define CTA_MODEL_AXPY_FORC (10) |
Definition at line 51 of file cta_model.h.
#define CTA_MODEL_AXPY_MODEL ( 7) |
Definition at line 48 of file cta_model.h.
#define CTA_MODEL_AXPY_PARAM (13) |
Definition at line 54 of file cta_model.h.
#define CTA_MODEL_AXPY_STATE ( 6) |
Definition at line 47 of file cta_model.h.
#define CTA_MODEL_GET_CURRENTTIME (16) |
Definition at line 57 of file cta_model.h.
#define CTA_MODEL_GET_FORC ( 9) |
Definition at line 50 of file cta_model.h.
#define CTA_MODEL_GET_NOISE_COUNT (17) |
Definition at line 60 of file cta_model.h.
#define CTA_MODEL_GET_NOISE_COVAR (18) |
Definition at line 61 of file cta_model.h.
#define CTA_MODEL_GET_OBSSELECT (20) |
Definition at line 65 of file cta_model.h.
#define CTA_MODEL_GET_OBSVALUES (19) |
Definition at line 64 of file cta_model.h.
#define CTA_MODEL_GET_PARAM (12) |
Definition at line 53 of file cta_model.h.
#define CTA_MODEL_GET_STATESCALING (14) |
Definition at line 55 of file cta_model.h.
#define CTA_MODEL_GET_TIMEHORIZON (15) |
Definition at line 56 of file cta_model.h.
#define CTA_MODEL_LOAD_PERSISTENTSTATE (29) |
Definition at line 85 of file cta_model.h.
#define CTA_MODEL_NUMFUNC (34) |
Definition at line 87 of file cta_model.h.
#define CTA_MODEL_RELEASE_INTERNALSTATE (32) |
Definition at line 83 of file cta_model.h.
#define CTA_MODEL_RESTORE_INTERNALSTATE (31) |
Definition at line 82 of file cta_model.h.
#define CTA_MODEL_SAVE_INTERNALSTATE (30) |
Definition at line 81 of file cta_model.h.
#define CTA_MODEL_SAVE_PERSISTENTSTATE (33) |
Definition at line 84 of file cta_model.h.
#define CTA_MODEL_SET_FORC ( 8) |
Definition at line 49 of file cta_model.h.
#define CTA_MODEL_SET_PARAM (11) |
Definition at line 52 of file cta_model.h.
#define I_CTA_MODEL_COMPUTE ( 3) |
Definition at line 44 of file cta_model.h.
#define I_CTA_MODEL_CREATE_INIT ( 1) |
Definition at line 42 of file cta_model.h.
#define I_CTA_MODEL_CREATE_SIZE ( 0) |
Definition at line 41 of file cta_model.h.
#define I_CTA_MODEL_EXPORT (23) |
Definition at line 69 of file cta_model.h.
#define I_CTA_MODEL_FREE ( 2) |
Definition at line 43 of file cta_model.h.
#define I_CTA_MODEL_GET_STATE ( 5) |
Definition at line 46 of file cta_model.h.
#define I_CTA_MODEL_GETOBSLOCALIZATION (28) |
Definition at line 78 of file cta_model.h.
#define I_CTA_MODEL_IMPORT (24) |
Definition at line 70 of file cta_model.h.
#define I_CTA_MODEL_SET_STATE ( 4) |
Definition at line 45 of file cta_model.h.
typedef CTA_Handle CTA_Model |
Definition at line 37 of file cta_model.h.
typedef CTA_Handle CTA_ModelClass |
Definition at line 38 of file cta_model.h.
Add noise during during the given timespan at the Compute.
hmodel | IO handle of model instance | |
htime | I timespan for which to compute adding noise |
bla HOMEWORK FOR JULIUS!
hmodel | I handle of model instance |
bla HOMEWORK FOR JULIUS!
hmodel | I handle of model instance |
int CTA_Model_AdjSetointForc | ( | CTA_Model | hmodel, | |
CTA_ObsDescr | hdescr, | |||
CTA_Vector | vforc | |||
) |
bla HOMEWORK FOR JULIUS!
hmodel | I handle of model instance |
CTAEXPORT int CTA_Model_AnnounceObsValues | ( | CTA_Model | hmodel, | |
CTA_ObsDescr | hdescr | |||
) |
Announce to the model what observations will be requested.
Before the compute method this method is used to announce what obeservation will be requested after the CTA_Model_Compute using the CTA_Model_GetObsvalues method.
For some simulation models it is more efficient to do a single simulation (a single CTA_Model_Compute call) for a particular simulation span then simulating the same simulation span in a number of steps (multiple CTA_Model_Compute calls).
This method can be used to announce for what observations the model must provide a prediction in advance. This method must be called prior to the CTA_Compute method and makes it possible to perform simulations over a longer time interval without the need to interupt the computations in order to get the predictions at intermediate time instances.
Notes on the behavior of the method:
hmodel | I handle of model instance | |
hdescr | I observation description component |
CTAEXPORT int CTA_Model_AxpyForc | ( | CTA_Model | hmodel, | |
CTA_Time | tspan, | |||
double | alpha, | |||
CTA_TreeVector | hx | |||
) |
Perform axpy operation on the models forcings.
hmodel | IO handle of model instance (y) | |
tspan | I time span for wich the given forcings are valid | |
alpha | I scalar | |
hx | I handle of forcings tree-vector x |
CTAEXPORT int CTA_Model_AxpyParam | ( | CTA_Model | hmodel, | |
double | alpha, | |||
CTA_TreeVector | hx | |||
) |
Perform axpy operation on the models parameters.
hmodel | IO handle of model instance (y) | |
alpha | I alpha | |
hx | I handle of treevector of parameters (x) |
CTAEXPORT int CTA_Model_AxpyState | ( | CTA_Model | hmodel, | |
double | alpha, | |||
CTA_Handle | hx | |||
) |
Perform axpy operation on the internal state.
hmodel | IO handle of model instance (y) | |
alpha | I alpha | |
hx | I handle of x (state or model) |
Compute model for given timespan.
hmodel | IO handle of model instance | |
htime | I timespan for which to compute |
CTAEXPORT int CTA_Model_Create | ( | CTA_ModelClass | hmodcl, | |
CTA_Handle | userdata, | |||
CTA_Model * | hmodel | |||
) |
Create a model instance.
hmodcl | I model class of new instance | |
userdata | IO user data needed for creation (depends on modelclass) | |
hmodel | O receives handle of new model instance |
int CTA_Model_Export | ( | CTA_Model | hmodel, | |
CTA_Handle | hexport | |||
) |
Export the whole internal state of a model This export function will export the whole state of the model such that a so called "restart" start from this point yielding the same results. There are no ruled on the format that is used to store the data. Various extra otions are valid but a model will in most cases support an export to a file and to a COSTA pack object.
hmodel | I handle of model instance | |
hexport | I target for export e.g. CTA_File or CTA_Pack |
CTAEXPORT int CTA_Model_Free | ( | CTA_Model * | hmodel | ) |
Free model instance.
hmodel | IO handle of model instance, replaced by CTA_NULL on return |
Return the current time of the model.
hmodel | I handle of model instance | |
tCurrent | I time corresponding the the model state |
CTAEXPORT int CTA_Model_GetForc | ( | CTA_Model | hmodel, | |
CTA_Time | tspan, | |||
CTA_TreeVector * | hforc | |||
) |
Get a copy of the values of the models forcings.
hmodel | I handle of model instance | |
tspan | I timespan for wich the given forcings are valid | |
hforc | IO receives models forcings, *hforc can be CTA_NULL on calling (see note) |
CTAEXPORT int CTA_Model_GetNoiseCount | ( | CTA_Model | hmodel, | |
int * | nnoise | |||
) |
Get number of noise parameters: the number of columns of the noise covariance matrix.
hmodel | I handle of model instance | |
nnoise | O receives number of noise parameters |
CTAEXPORT int CTA_Model_GetNoiseCovar | ( | CTA_Model | hmodel, | |
CTA_TreeVector * | hstmat | |||
) |
Get covariance matrix of noise parameters.
hmodel | I handle of model instance | |
hstmat | O receives array of tree-vectors, *hstmat can equal CTA_NULL on calling (see note) |
CTAEXPORT int CTA_Model_GetObsLocalization | ( | CTA_Model | hmodel, | |
CTA_ObsDescr | hdescr, | |||
double | distance, | |||
CTA_Vector | locVecs | |||
) |
Get for each observation a localization scaling vector.
hmodel | I handle of model instance | |
hdescr | I observation description for which we want localization scaling vectors | |
distance | I characteristic distance | |
locVecs | O costa vector of handles to treevectors (scaling vectors). The treevectors are created when the indices are CTA_NULL on entry |
CTAEXPORT int CTA_Model_GetObsSelect | ( | CTA_Model | hmodel, | |
CTA_Time | htime, | |||
CTA_ObsDescr | hdescr, | |||
CTA_String | sselect | |||
) |
Get a query for the stochastic observer in order to filter out the observations that can actually be provided by the model.
hmodel | I handle of model instance | |
htime | I time instance | |
hdescr | I observation description component | |
sselect | O receives a query to filter out the observations, must exist before calling |
CTAEXPORT int CTA_Model_GetObsValues | ( | CTA_Model | hmodel, | |
CTA_Time | htime, | |||
CTA_ObsDescr | hdescr, | |||
CTA_Vector | values | |||
) |
Get (interpolate) the models internal state to the observations described as specified in the observation description component.
hmodel | I handle of model instance | |
htime | I time instance (for checking and time-interpolation if supported by model) | |
hdescr | I observation description component | |
values | O receives values of the models internal state corresponding to observations as described in hdescr |
CTAEXPORT int CTA_Model_GetParam | ( | CTA_Model | hmodel, | |
CTA_TreeVector * | hparam | |||
) |
Get a copy of the parameters of the model.
hmodel | I handle of model instance | |
hparam | IO receives model forcings, *hforc can equal CTA_NULL on calling (see note) |
CTAEXPORT int CTA_Model_GetState | ( | CTA_Model | hmodel, | |
CTA_TreeVector * | hstate | |||
) |
Get a copy of the internal state.
hmodel | I handle of model instance | |
hstate | IO receives state of the model, *hstate can be CTA_NULL on calling (see note) |
CTAEXPORT int CTA_Model_GetStateScaling | ( | CTA_Model | hmodel, | |
CTA_TreeVector * | hscale | |||
) |
Get element-wise scaling for model state.
The values in the state-vector are compared on "importance" in various algorithms like RRSQRT and COFFEE. The model state holds in general various quantities like concentration, velicity, location etc in arbitrary units. The scaling vector (that can be model state dependend) makes it possible to meaningfull compare elements in the state-vector for importance. Various methods are available like a transformation to enery.
The scaling vector represents a diagonal scaling matrix but is respresented by a tree-vector.
hmodel | I handle of model instance | |
hscale | IO receives state scaling vector for the model state, hstate can be CTA_NULL on calling (see note) |
Return the timehorizon on the model. The time horizon is the initial overal simulation span for which the mode is configured.
hmodel | I handle of model instance | |
tHorizon | I time horizon of model |
int CTA_Model_Import | ( | CTA_Model | hmodel, | |
CTA_Handle | himport | |||
) |
Import the whole internal state of a model After the inport the models internal state is exactly the same as the point that the export was created using CTA_Model_Export.
hmodel | I handle of model instance | |
himport | I handle with data created by CTA_MODEL_Export e.g. CTA_File or CTA_Pack |
CTAEXPORT int CTA_Model_LoadPersistentState | ( | CTA_Model | hmodel, | |
CTA_String | filename, | |||
CTA_String * | instanceID | |||
) |
CTAEXPORT int CTA_Model_ReleaseInternalState | ( | CTA_Model | hmodel, | |
CTA_String | instanceID | |||
) |
CTAEXPORT int CTA_Model_RestoreInternalState | ( | CTA_Model | hmodel, | |
CTA_String | instanceID | |||
) |
CTAEXPORT int CTA_Model_SaveInternalState | ( | CTA_Model | hmodel, | |
CTA_String * | instanceID | |||
) |
CTAEXPORT int CTA_Model_SavePersistentState | ( | CTA_Model | hmodel, | |
CTA_String | filename, | |||
CTA_String | instanceID | |||
) |
CTAEXPORT int CTA_Model_SetForc | ( | CTA_Model | hmodel, | |
CTA_Time | tspan, | |||
CTA_TreeVector | hforc | |||
) |
Set the models forcings.
hmodel | IO handle of model instance | |
tspan | I time span on which to set the forcing values | |
hforc | I handle of vector with new forcings |
CTAEXPORT int CTA_Model_SetParam | ( | CTA_Model | hmodel, | |
CTA_TreeVector | hparam | |||
) |
Set parameters of the model.
hmodel | IO handle of model instance | |
hparam | I handle of parameters vector |
CTAEXPORT int CTA_Model_SetState | ( | CTA_Model | hmodel, | |
CTA_TreeVector | hstate | |||
) |
Set the internal state of the model.
hmodel | IO handle of model instance | |
hstate | I handle of new state |
int CTAI_Model_PerformTimesteps | ( | CTA_Model | hmodel, | |
CTA_Function * | function, | |||
CTA_Time | htime, | |||
int | mindBarrier | |||
) |