How to use the established meta-model (such as Kriging) as Conventional Function in Matlab?

Hello everyone. I’m new UQ man.
I used UQLab to establish a Kriging metamodel. And I want use this metamodel to find the position where the variation is maximum, by adopting Genetic Algorithm. Then I use this maximum varation point as next sample point, evaluate the interested quantity at this new sample point, and refine my meta-model sequentially.
Could anybody give some advices? Where can I find the cases that similar to my situation?

Hi @GPLai,

Referring to the title of your question, I assume you want to use the predictor part of Kriging. As you know, this prediction is made by calling uq_evalModel on a UQLab model and metamodel objects (not just Kriging).

So the easiest way to directly call this predictor as a MATLAB function is by using an anonymous function to wrap the call to uq_evalModel. Let’s suppose you already have a Kriging metamodel object myKriging, then you can write:

myKrigingPredictor = @(X) uq_evalModel(myKriging,X);

Then you can pass this function handle to your optimization function.

However, if you want to get the Kriging variance, which is the second output, for an optimization purpose, I think you might need to use a MATLAB normal function to wrap things first before passing the function handle to an optimization function. For instance, such a function can be:

function krigingVar = getKrigingVar(KrigingObj,X)
[~,krigingVar] = uq_evalModel(KrigingObj,X)

and then use an anonymous function to bring a particular Kriging object (say, myKriging) into the function: krigingVar = @(X) getKrigingVar(myKriging,X) before passing the handle to an optimization function.

BTW, There was once a question similar to yours here:

UQLab does not have a built-in support for such a refinement scheme to create a metamodel, although a similar scheme is used specifically in the context of reliability analysis. I think your approach makes sense. In any case, we’ll sure be glad to hear about your experience on whether you manage to improve the metamodel :wink:.

Hope this helps!

PS: Your question would be more fitting to be in the UQLab Community Q&A, and not in the general forum section. So I took the liberty of moving it there :smiley: .

Hi @damarginal . Thanks for your nice reply. Yes you do understand my points. And I have found the solution for it after I asked question here. And my solution is same as you proposed here, and it does work. BTW, UQLab is really a nice tool!