MATLAB GA error help!
Mostrar comentarios más antiguos
Note: Updated the files and error message
Like the Subject says, I need help in sorting out the errors. Basically I'm trying to find the optimal bidding coefficients bd with the purpose of enhancing the profit F for the 2nd player (the 2 in Custom_Fitness_Fcn). Now the problem is that whenever I try to run main I get these errors:
>> main
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in Custom_Constraint_Fcn (line 10)
P(n) = (R-ac(n))/bd(n);
Error in main>@(bd)Custom_Constraint_Fcn(ac,bd,limit,i,l,Q0,K)
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 125)
[LinearConstr, Iterate,nineqcstr,neqcstr,ncstr] = constrValidate(NonconFcn, ...
Error in ga (line 336)
NonconFcn,options,Iterate,type] = gacommon(nvars,fun,Aineq,bineq,Aeq,beq,lb,ub, ...
Error in main (line 9)
[bd,F] = ga(FitnessFcn,nvars,[],[],[],[],[],[],ConstraintFcn,options);
Caused by:
Failure in initial user-supplied nonlinear constraint function evaluation.
>>
I've been trying to debug this thing for days, and I really need it in less than 2. Somebody please help!
14 comentarios
joichiro nishi
el 5 de Dic. de 2018
Walter Roberson
el 5 de Dic. de 2018
need dataread as well as it initializing the key variables
joichiro nishi
el 5 de Dic. de 2018
joichiro nishi
el 5 de Dic. de 2018
Walter Roberson
el 5 de Dic. de 2018
Your custom create function internally creates aa matrix of values. It extracts column 2 and transposes. The result is a single row . Therefore your population size is 1.
by the way the second parameter that ga passes to the create function is the fitness function . Your anonymous wrapper calls thar objective function and ignores it and passes fitness function in to your custom function . Which ignores it anyhow .
joichiro nishi
el 5 de Dic. de 2018
Editada: joichiro nishi
el 5 de Dic. de 2018
Walter Roberson
el 5 de Dic. de 2018
not sure at the moment .
Why does your comment in the constraint function say it generates a column vector of constraints ? you are horzcat aa series of column vectors so you get a 2d array.
Walter Roberson
el 5 de Dic. de 2018
why is your genome length only 1 ? The genome length is the number of variables and so the length of bd but the length of bd needs to match the length of ac because you index those two together .
joichiro nishi
el 5 de Dic. de 2018
Editada: joichiro nishi
el 5 de Dic. de 2018
joichiro nishi
el 5 de Dic. de 2018
Editada: joichiro nishi
el 5 de Dic. de 2018
joichiro nishi
el 5 de Dic. de 2018
Walter Roberson
el 5 de Dic. de 2018
The first two matrices being vertcat are i(end) by max(i) with all rows having the same value.
The third and fourth are l(end)-i(end) by max(l) with all rows having the same value.
You will not be able to horzcat or vertcat this collection together.
joichiro nishi
el 6 de Dic. de 2018
Walter Roberson
el 6 de Dic. de 2018
your posted attached custom constraint function passes ac bd . your debugging snapshot shows aa custom constraint that expects bd ac.
Respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



