# Invalid value for OPTIONS parameter PopInitRange: must be an array of finite doubles with two rows.

조회 수: 4 (최근 30일)
tahseen alshmary 2018년 10월 16일
편집: Matt J 2018년 10월 16일
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

댓글을 달려면 로그인하십시오.

### 채택된 답변

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이전 댓글 14개 표시이전 댓글 14개 숨기기
Matt J 2018년 10월 16일
편집: Matt J 2018년 10월 16일
You can just omit it, and let Matlab use its own defaults, if you don't have any specific plans for what the PopInitRanges should be.
tahseen alshmary 2018년 10월 16일
okay i will try thank you so much

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by