Hi
So I was using matlab's ga to solve an optimization problem with 40 variables. Before I set it up like so
LB = .05e-6*ones(1,nvars); UB = 1e-6*ones(1,nvars);Length = 20e-6;Aeq = ones(1,nvars);opts = gaoptimset('OutputFcns',@myOutFun,'TolCon',.01e-6);[x,fval,exitFlag,Output,population] = ga(@grating_cost_function_arb,nvars,[],[],Aeq,Length,LB,UB,[],opts);
And it was working fine, but it ended up generating variations in the variables on the order of 1e-10 (a scale that I don't want the ga to even consider because the cost function that I use in the ga uses a simulation program that results in practically the same cost when the variables are changed like this). So I changed my ga to an integer problem like so:
LB = 5*ones(1,nvars);UB = 100*ones(1,nvars);Length = 2000;AintIneq = ones(2,nvars);AintIneq(1,:) = -1*AintIneq(1,:);bIntIneq = [-Length; Length];intCon = 1:nvars;opts = gaoptimset('OutputFcns',@myOutFun,'TolCon',1);[x,fval,exitFlag,Output,population] = ga(@grating_cost_function_arb,nvars,AintIneq,bIntIneq,[],[],LB,UB,[],intCon,opts);
In my cost function now I convert the integers back to non-integer values by multiplying the generated variables by 1e-6/100. The ga still works but for some reason now, instead of running the simulation for each member of the population it runs approximately 15 of each generation. What's really confusing me is that even though it runs my cost function (the simulation) for only like 15 population members, the state variable has function values (cost function values) for all 100 members of each generation (100 because of changing my problem to an integer problem). Is there any reason why this is happening? Can I change this so it runs the cost function for each member? Also if it doesn't run the cost function for each member how does it generate the next generation?
Thanks Yanni
Best Answer