how can i solve "Error using constrValidate" in genetic algorithm?
显示 更早的评论
I'm trying to minimaze a non linear function with non linear costraints with a ga (i have attached the files with the functions), but whenever i run the code i have the following errors:
Error using constrValidate (line 59)
Constraint function must return real value.
Error in gacommon (line 125)
[LinearConstr, Iterate,nineqcstr,neqcstr,ncstr] = constrValidate(NonconFcn, ...
Error in ga (line 363)
NonconFcn,options,Iterate,type] = gacommon(nvars,fun,Aineq,bineq,Aeq,beq,lb,ub, ...
Error in main (line 28)
[x, fval] = ga(ObjFcn,nvars,A, b, Aeq, beq, [], [], CostraintFunction);
How can i fix that?
Thanks for helping
1 个评论
This line in the error message is highly suggestive:
Constraint function must return real value.
Have you verified whether it is returning a real value? A good way to trap non-real values is to set a conditional breakpoint in the constraint function.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!