how can i solve "Error using constrValidate" in genetic algorithm?
Show older comments
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 Comment
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.
Accepted Answer
More Answers (0)
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!