problem with implementing non linear constraints in a minimization problem using genetic algorithms
Show older comments
Hi, and sorry for my bad english. I have to minimize a function error(var,input):=(input=0 to N) max(error(var,input))
Basically I am designing a steering mechanism that needs to satisfy an input/output function relation called the Ackerman Law. By comparing the output of the actual mechanism and the output given by the Ackerman Law I define an objective error function for each input angle. For each iteration "var" vector is defined (it contains a set of 3 lenghts), I want a function that evaluates the error for each input angle. At first i had problems defining this function but by reading this thread: https://it.mathworks.com/matlabcentral/answers/16613-minimize-the-sum-of-functions-fmincon I solved it.
so my error is defined as
error=@(var) abs(max(arrayfun(@(input) error(var,input), deg2rad(0):deg2rad(1):deg2rad(25))));
By doing this at each iteration of the algorithm for the fixed index var, the function returns the maximum error.
The problem is that in order to return an acceptable set of lenghts for my mechanism, the vector var needs to satisfy 3 non linear inequality constraints (that basically allow the mechanism to work in the real world) for each input angle!!
I tried to vectorize and call the constraints as follows:
constrain1=@(var) (-deltainiziale(var));
constrain2=@(var) arrayfun(@(input) -deltab(var,input), deg2rad(0):deg2rad(1):deg2rad(40));
constrain3=@(var) arrayfun(@(input) -deltaout(var,input), deg2rad(0):deg2rad(1):deg2rad(40));
c=@(var) [constrain1(var), constrain2(var), constrain3(var)];
ceq=@(var) [];
nonlinearconstraints=@(var) [c(var),ceq(var)];
but when i call the ga
risultati=ga(error,nvars,[],[],[],[],lb,ub,nonlinearconstraints)
I keep getting errors. I tried to solve the nonconstrained problem and it seems to work, but I need to include those constraints. Thanks and Regards, Eskander Meddeb
Accepted Answer
More Answers (0)
Categories
Find more on Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!