I definited a function by COMSOL .m file , whose varibles are geometrical parameters of model. Then, geometrical parameters are optimized by a genetic algorithm written by matlab. There are big computional costs, therefore I want to use a parallel computing for MATLAB. But occur errors when calling function in parallel environment. Without error in serial environment (is for not parfor), this is why? The parallel computing for MATLAB results in calling multiple comsol servers simultaneously.
Is this reason for occuring error?
matlab pool open;
parfor i=1:NP
fitnessX(i)=optimization(X(i,:));
end
matlab pool close;
??? Error using ==> parallel_function at 598
Error in ==> optimization at 10
Undefined variable "ModelUtil" or class "ModelUtil.create".
where optimization is the function ,
function Q = optimization(X)
import com.comsol.model.*
import com.comsol.model.util.*
model = ModelUtil.create('Model');
model.param.set('mug', '2.1e-5[Pa*s]');
model.param.set('kF', '1e-10[m^2]');
model.param.set('k', '1e-18');...
...................................................
Is this reason for occuring error?
matlab pool open;
parfor i=1:NP
fitnessX(i)=optimization(X(i,:));
end
matlab pool close;
??? Error using ==> parallel_function at 598
Error in ==> optimization at 10
Undefined variable "ModelUtil" or class "ModelUtil.create".
where optimization is the function ,
function Q = optimization(X)
import com.comsol.model.*
import com.comsol.model.util.*
model = ModelUtil.create('Model');
model.param.set('mug', '2.1e-5[Pa*s]');
model.param.set('kF', '1e-10[m^2]');
model.param.set('k', '1e-18');...
...................................................