I have tried to solve the transcendental equation by Genetic algorithm. The fitness function used for the equations is given below:
function y = myFitnes(x)y = ((cos(x(1)) + cos(x(2)) + cos(x(3)) + cos(x(4))-0.9*(pi/2)))^2... +(cos(3*x(1)) + cos(3*x(2)) + cos(3*x(3)) + cos(3*x(4)))^2... +(cos(5*x(1)) + cos(5*x(2)) + cos(5*x(3)) + cos(5*x(4)))^2 ... + (cos(7*x(1)) + cos(7*x(2)) + cos(7*x(3)) + cos(7*x(4)))^2; end
The main code written to solve the above equation using Genetic algorithm is given below:
objFcn =@myFitnes;nvars = 4;LB = [0 0 0 0];UB = [pi/2 pi/2 pi/2 pi/2];[x, fval] = ga(objFcn,nvars,[],[],[],[],LB,UB);
How to add the constraint condition 0<x(1)<x(2)<x(3)<x(4)<pi/2; to solve the above equations.
Best Answer