ERROR : Constraint function must return real value

3 vues (au cours des 30 derniers jours)
Hamid
Hamid le 25 Déc 2015
Commenté : Hamid le 25 Déc 2015
I'm using genetic algorithm as my optimization solver but I keep getting this error and I don't know why.
??? Error using ==> constrValidate at 30 Constraint function must return real value.
any suggestion.

Réponses (1)

Walter Roberson
Walter Roberson le 25 Déc 2015
Your constraint function is returning a complex value (or possibly a NaN). Remember that the constraint function may be executed with values that are out of range, with it being the responsibility of the constraint function to say whether they are in range.
  1 commentaire
Hamid
Hamid le 25 Déc 2015
thank you Walter, my constraint is something like this :
y(1)=x(1)*a;
y(2)=x(1)*b;
c(1)=y(1)-y(2);
I set a breakpoint and c(1) will be always NaN.
what do you recommend to get rid out this error?
thank you my friend.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by