Invalid value for OPTIONS parameter PopInitRange: must be an array of finite doubles with two rows.
2 次查看(过去 30 天)
显示 更早的评论
hello everyone i have problem with this error in genetic algorithm(Invalid value for OPTIONS parameter PopInitRange: must be an array of finite doubles with two rows)
the code is
%To minimize our fitness function using the ga function, we need to pass in a function handle to the fitness function as well as specifying the number of variables as the second argument. Lower and upper bounds are provided as LB and UB respectively. In addition, we also need to pass in a function handle to the nonlinear constraint function.
ObjectiveFunction = @simple_fitness;
nvars = 14; % Number of variables
LB = [0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]; % Lower bound for (x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14)
UB = [1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1]; % Upper bound for (x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14)
A=[-4.111 2.633;-4.870 2.992;-2.178 2.992;-3.857 3.130;-3.989 3.678;-4.979 3.620;-5.756 2.948;-5.826 1.607;-2.150 2.948;-6.920 1.607;-2.144 2.952;-5.365 2.952;-4.863 3.348;-5.073 3.680;-3.774 3.774;-6.920 2.995;-2.151 2.995;-4.288 3.237;-4.870 1.608;-5.365 1.608];
b=[-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3;-0.3];
Aeq=[];
beq=[];
nonlcon=[];
IntCon=[];
rng default % For reproducibility
options=gaoptimset('plotfcns',{'gaplotgenealogy','gaplotselection', 'gaplotbestf' ,@gaplotscorediversity});
options= gaoptimset(options,'Tolfun',1e-4,'TolCon',1e-3,'stallGenlimit',1000);
options= gaoptimset(options,'paretoFraction',0.5);
options=gaoptimset(options,'PopInitRang',[0.1 ; 1.1;0.1 ; 1.1;0.1 ;1.1;0.1 ;1.1;0.1 ; 1.1;0.1 ; 1.1;0.1 ; 1.1;0.1 ;1.1;0.1 ; 1.1;0.1 ; 1.1]);
options=gaoptimset(options,'PopulationSize',200);
options=gaoptimset(options,'Display', 'iter');
[x,fval,exitflag,output,population,scores] = ga(ObjectiveFunction,nvars,A,b,Aeq,beq,LB,UB,nonlcon,IntCon,options)
the problem in PopInitRange
many thanks
0 个评论
采纳的回答
Matt J
2018-10-16
编辑:Matt J
2018-10-16
The error message is telling you that PopInitRange must have two rows, but the value you have given has 20 rows.
ans =
0.1000
1.1000
0.1000
1.1000
0.1000
1.1000
0.1000
1.1000
0.1000
1.1000
0.1000
1.1000
0.1000
1.1000
0.1000
1.1000
0.1000
1.1000
0.1000
1.1000
16 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!