- Error using rand - Size inputs must be integers: This error is occurring because the "tournamentSize" parameter for the selection method in your GA options is not an integer. In your options definition, you have specified "EliteCount", 0.04, which is not a valid integer value for the "EliteCount" parameter.
- Error in stepGA (line 20): This error occurs due to the previous error in the "selectiontournament" function, which is called by the GA solver. Fixing the first error should resolve this one as well.
- Error: Wrong input values: If you see this error, it means that the conditions in your if statement are not being met, and the code is raising this error message.
Μultiple errors (error in rand, selectiontournament, stepGA, galincon, gaminlpengine, gaminlp, ga) when i try to use the ga toolbox
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
clear all
clc
[inc,onc,net]=nn_creator_func(1);
prompt1='Give the thickness of the plate: \n';
pt=input(prompt1);
prompt2='Give the y coordinate of all points in the junction area: \n';
jpcy=input(prompt2);
prompt3='Give the x coordinate of a point: \n';
pcx=input(prompt3);
prompt4='Give the z coordinate of the same point: \n';
pcz=input(prompt4);
if (jpcy+0.004<=0.026 && (pcx>=0 && pcx<=0.039) && (jpcy>=0 && jpcy<=0.026) && (pcz>=0 && pcz<=pt));
%res=objective_cost_func(in_var,pt,jpcy,pcx,pcz,inc,onc,net);
%[x,fval]=ga(@(in_var)objective_cost_func(in_var,pt,jpcy,pcx,pcz,inc,onc,net),3);
options=struct('PopulationSize',70, 'InitailPopulationRange',[807 0.0026 187;992 0.0037 219],....
'EliteCount',0.04,'CrossoverFraction',0.7,....
'MaxGenerations',400,'MaxTime',180,'FitnessLimit',0.5,....
'MaxStallGenerations',10,'FunctionTolerance',0.0001,....
'MaxStallTime',15,'Display','diagnose',....
'PlotFcn',{@gaplotrange, @gaplotbestf});
[x,fval]=ga(@(in_var)objective_cost_func(in_var,pt,jpcy,pcx,pcz,inc,onc,net),3,[],[],[],[],[807 0.0026 187],[992 0.0037 219],[],1:2:3,options);
else
error('Error: Wrong input values')
end
The function nn_creator_func trains a neural network and returns the normalization constants of the input and output and the object of the neural network.
When i run the programm i get the following errors
Error using rand
Size inputs must be integers.
Error in selectiontournament (line 28)
playerlist = ceil(size(expectation,1) * rand(nParents,tournamentSize));
Error in stepGA (line 20)
parents = feval(options.SelectionFcn,state.Expectation,nParents,options,options.SelectionFcnArgs{:});
Error in galincon (line 62)
[score,population,state] = stepGA(score,population,options,state,GenomeLength,FitnessFcn);
Error in gaminlpengine (line 36)
Error in gaminlp (line 34)
Error in ga (line 351)
[x,fval,exitFlag,output,population,scores] = gaminlp(FitnessFcn,nvars, ...
Error in ga_code (line 23)
[x,fval]=ga(@(in_var)objective_cost_func(in_var,pt,jpcy,pcx,pcz,inc,onc,net),3,[],[],[],[],[807 0.0026 187],[992 0.0037 219],[],1:2:3,options);
Does anyone know why these errors occur? It will help a lot.
0 Kommentare
Antworten (1)
Yash
am 6 Sep. 2023
Hi Stathis
The errors you are encountering seem to be related to the options you have set for the Genetic Algorithm (GA) solver in MATLAB. Let's go through the errors one by one and see how to resolve them:
After fixing the issues mentioned above, your code should run without errors related to the GA solver.
Please refer to the documentation below for more information:
I hope this helps.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!