Hi @Colette_Jost ,
This is quite an interesting use case.
As far as I know, there is no field similar to Parameters
of the default (i.e., standard) MODEL object in UQLink model, but I have some ideas for a workaround:
- The most straightforward thing to do is to create multiple parsers (yes, duplicate the files) each having a fixed value for the parameter. Granted, if you want to change the parameters on the fly or you have many combinations of results you want to include or not include, this is not ideal; or
- Modify the internal property of UQLink object, namely
myModel.Internal.Output.Parser
(the name myModel
is your choice), after the object is created. I’d like to recommend this approach because this is not intrusive, although there are some steps involved and a couple of MATLAB particularities you need to keep in mind.
Following up the second option, assuming your parser has the following signature:
function Y = myParser(outputfile,params)
you can modify the .Internal.Output.Parser
field of the MODEL object and assign to it a function handle as follows:
myModel.Internal.Output.Parser = @(outputfile) myParser(outputfile,{'deviation','max. moment'});
Such a handle is required because internally, UQLink always calls the parser function with a single argument (i.e., the output file).
The above solution works as is for parameter given as a literal. Now if you put the parameter into a variable such as:
params = {'deviation','max. moment'};
myModel.Internal.Output.Parser = @(outputfile) myParser(outputfile,params);
you need to define the parameter first before you create the function handle, just like the above. So for instance, if below is the first time you use params
:
myModel.Internal.Output.Parser = @(outputfile) myParser(outputfile,params);
params = {'deviation','max. moment'};
Y = uq_evalModel(myModel,X);
it will throw an error because params
at the time the handle is created is not yet defined and it remains undefined when the handle is used later on by UQLink (from calling uq_evalModel
) to parse the output file.
Also, every time you change the value of the parameter, you need to recreate the function handle and reassign it to the .Internal.Output.Parser
field before calling uq_evalModel
. Otherwise the new value will not be used.
Of course, you can wrap these steps into a single separate function that takes a parameter value and update the MODEL object so not to forget; you don’t need to explicitly return an updated MODEL object, because the object is passed by-reference.
I hope this helps (and let me know if it does, or doesn’t)!
PS: You cannot assign a function handle as a configuration option before the object is created. That is, the following won’t work:
...
ModelOpts.Output.Parser = @(outputfile) myParser(outputfile,{'deviation','max. moment'});
...
myModel = uq_createModel(ModelOpts);
Because apparently during the object initialization, the value to ModelOpts.Output.Parser
is checked if it’s a char array; if not, an error is thrown. This is despite Table 3 of the UQLink User Manual stating the option may accept a function handle (we’ll check it out!)