using parfor inside constraint function for gamultiobj

1 visualización (últimos 30 días)
Pourshid Fani
Pourshid Fani el 5 de Jun. de 2017
Respondida: Arnav Mendiratta el 12 de Jun. de 2017
Hi,
I'm currently trying to run a simscape simulation inside of my constraint function for my multi objective genetic algorithm (gamultiobj). The ga runs in vectorized 'mode', but the simscape simulation inside the constraint function runs in a for loop (which I'm trying to make a parfor loop).
I'm wondering why I get the following error.
Error using lmConstraintMGAp1 (line 24)
Error detected on workers 1 2 3 4.
Error in linkmass_optimizationMGAp1>@(x)lmConstraintMGAp1(x,cd,E,l,qdata)
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11)
fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in constrValidate (line 21)
[tmpCineq,tmpCeq] = nonlcon([Iterate.x Iterate.x]');
Error in gacommon (line 132)
[LinearConstr, Iterate,nineqcstr,neqcstr,ncstr] = constrValidate(NonconFcn, ...
Error in gamultiobj (line 260)
~,options] = gacommon(nvars,fun,Aineq,bineq,Aeq,beq,lb,ub,nonlcon,[],options,user_options);
Error in linkmass_optimizationMGAp1 (line 30)
[x,fval, eflag] = gamultiobj(objf, nvars, A, b, Aeq, beq, lb, ub, cfunc,opts);
Caused by:
Error using lmConstraintMGAp1 (line 24)
Index exceeds matrix dimensions.
Error using lmConstraintMGAp1 (line 24)
Index exceeds matrix dimensions.
Error using lmConstraintMGAp1 (line 24)
Index exceeds matrix dimensions.
Error using lmConstraintMGAp1 (line 24)
Index exceeds matrix dimensions.
Failure in initial user-supplied nonlinear constraint function evaluation.
linkmass_optimizationMGAp1 is the script that calls the optimization lmConstraintMGAp1 is the constraint function.
thanks

Respuestas (1)

Arnav Mendiratta
Arnav Mendiratta el 12 de Jun. de 2017
It is not recommended to run the simulations in a parfor loop. There are many things that might break because all the Simulink features might not support parfor workflows.
If you want to simulate dynamic systems in parallel, use parsim instead.
If you do want to use the "sim" command in "parfor" loop, make sure you are using the recommended workflows documented here:
https://www.mathworks.com/help/simulink/ug/running-parallel-simulations.html#bt33wws

Categorías

Más información sobre Simulation and Analysis en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by