Failure in initial user-supplied fitness function evaluation. GA cannot continue.

Hello, I have a problem when applying Useparallel in genetic algorithms. This is my code:
i
ObjFcn = @myFitness;
IntCon=[1 2 3 4 5];
nvars = 5;
LB= [lb1 lb2 lb3 lb4 lb5];
UB= [20 100 100 100 100];
ConsFcn= @Repecarga;
opts = gaoptimset('PlotFcns',{@gaplotbestf,@gaplotbestindiv},'UseParallel',true);
opts.PopulationSize = 30;
[ho,fval]=ga(ObjFcn,nvars,[],[],[],[],LB,UB,ConsFcn,IntCon,opts)
My objective function is as follows:
i
function y = myFitness(ho)
y = 65*ho(1)+15*ho(2)+13*ho(3)+ 7*ho(4)+2*ho(5)
end
The error I get is this
Error in ga (line 351)
[x,fval,exitFlag,output,population,scores] = gaminlp(FitnessFcn,nvars, ...
Error in EJECUTABLE (line 136)
[ho, fval]=ga(ObjFcn,nvars,[],[],[],[],LB,UB,ConsFcn,IntCon,opts)
Caused by:
Failure in user-supplied fitness function evaluation. Cannot continue.
Failure in initial user-supplied fitness function evaluation. GA cannot continue.
Regards.

9 commentaires

Undefined function or variable 'lb1'.
Error in fit_driver (line 4)
LB= [lb1 lb2 lb3 lb4 lb5];
"Lb1" refers to the lower limits of the variables, for the case I am analyzing is LB = [9 16 0 0 0]. I do not know if it is necessary to put all the code, because it is something extensive.
Undefined function or variable 'Repecarga'.
You did not post a complete copy of your error message, so all we can do is run the code you provided hoping that we see the same error you saw.
Sorry. This is the complete error that appears. Attachments bring the complete code, the file "EJECUTABLE" is the one that starts the algorithm.
Error using Repecarga (line 33) Subscripted assignment dimension mismatch.
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11) fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in objAndConVectorizer>(parfor body) (line 39) [thisc, thisceq] = feval(nonlconFcn,pop(i, :));
Error in objAndConVectorizer (line 37) parfor (i = 1:popSize)
Error in gaminlppenaltyfcn (line 90)
Error in gapenalty>@(x)gaminlppenaltyfcn(x,problem,conScale) (line 117)
Error in makeState (line 64) Score = FitnessFcn(state.Population(initScoreProvided+1:end,:));
Error in galincon (line 17) state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in gapenalty (line 50)
Error in gaminlp (line 37)
Error in ga (line 351) [x,fval,exitFlag,output,population,scores] = gaminlp(FitnessFcn,nvars, ...
Error in EJECUTABLE (line 143) [ho,fval]=ga(ObjFcn,nvars,[],[],[],[],LB,UB,ConsFcn,IntCon,opts)
Caused by: Failure in user-supplied fitness function evaluation. Cannot continue. Failure in initial user-supplied fitness function evaluation. GA cannot continue.
Which MATLAB version are you using? That problem does not occur for me when I use your code.
Note: you do not initialize the global Ejes_equivalentes so it is initialized to [] automatically. All of the tests along the lines of
(Ejes_equivalentes>150001) & (Ejes_equivalentes<=500000)
fail because the variable is empty. You end up using the "else" clause.
Note that your code
else Ejes_equivalentes>50000000
lb1 = 5
lb2 = 15
lb3 = 15
lb4 = 30
lb5 = 0
means the same thing as
else
disp( Ejes_equivalentes>50000000 )
lb1 = 5
lb2 = 15
lb3 = 15
lb4 = 30
lb5 = 0
because it is not an "elseif".
If it were an elseif then your code would fail to initialize lbl1 and so on.
Thanks for the remarks, Im using Matlab R2015a
I do not encounter any problems when I use your code in MATLAB R2015a.
your 'ga' toolbox have error
Try using process-based parallel computing mode or turn off parallel computing.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Entering Commands dans Centre d'aide et File Exchange

Produits

Question posée :

le 20 Août 2017

Commenté :

le 30 Mai 2024

Community Treasure Hunt

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

Start Hunting!

Translated by