thanks for the more complete description of your problem.
I’ve had a look at your PCK script (
Regression_PCK.m). To use it under a
parfor loop you need to explicitly specify the INPUT object you created to the configuration option of the PCK metamodel. So:
function MyPCKriging_Gaussian= Regression_PCK(x,y)
myInput = uq_createInput(IOpts,'-private');
MetaOpts.Input = myInput;
MyPCKriging_Gaussian = uq_createModel(MetaOpts, '-private');
Note that you need to create the INPUT object inside the function as a private object to avoid UQLab trying to attach the object to the current UQLab session. In the
parfor setting, this seems to create a problem (not sure why; maybe a race condition?).
In the serial setting, creating the INPUT objects and adding it to the UQLab session happen one after the other so there’s no chance of conflict. At the end of the
for loop, a total of 8 additional INPUT objects have been created (
uq_listInputs to check). You don’t even need to specify this INPUT object to the configuration option in the case of serial
for loop because UQLab automatically getting the current INPUT object (the lastly created one by default) in the UQLab session and assign it to the option (this only works if you don’t use the
'-private' flag). In your case of Kriging, there’s no need to deal with an INPUT object, so there’s no problem there.
Alternatively, you can create an isolated UQLab session for each of the MATLAB parallel workers by first calling
Regression_PCK.m. This way you can use your old script as-is (i.e., no explicit INPUT specification on the configuration option but remove the
'private' flag on the INPUT object).
Now about the parallel GA of MATLAB. Currently, the option to activate the parallel option is not open to user. So you cannot access this option via the usual configuration option of UQLab. There’s a backdoor solution to this if you wish to use parallel GA; you can edit the function
uq_Kriging_initialize_optimizer.m and look for the relevant line for setting up the GA (around line 74) and add a new line:
'UseParallel', true to the list of options. I don’t know what’s the performance gain of using the parallel GA to optimize the hyperparameters of Kriging model, however. I’d happy to know what you find out!
I hope this helps!