using parfor inside constraint function for gamultiobj
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Arnav Mendiratta
le 12 Juin 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 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
0 commentaires
Voir également
Catégories
En savoir plus sur Simscape Multibody dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!