Hello, Iman. If x(1)=1, the x(3), x(4), x(6), x(7) values do not affect the objective values. These design variables can be ignored when you process the optimzation results. The optimization progress is not affected except for the efficiency. You may need more optimzation generations to get a good result.
The original code could not get the correct Pareto-front because the crossover and mutation strategies I used do not fit for the ZDT problem. In original code, all variables of an individual would mutate if it was selected to be mutated. In the version 1.3 code, I change the strategies to mutate several variables instead, and the correct solution could be get now.
I confirm, there is a small (but potentially dangerous) bug. The value of the constraint violation is not inserted into the individual info, thus it is zero both in the txt file and in the result Matlab variable.
Just add a line:
at the end of the evaluate.m file
Hi, thanks for the code i like it a lot. I had to take a deeper look at the code, because in the populations.txt file the constraints are always zero. even for the TP_CONSTR example when the c in the function evaluation is not zero.
i think there should be another line on the bottom in the evaluation.m file.
% Save the objective values and constraint violations
indi.obj = y;
if( ~isempty(indi.cons) )
idx = find( cons );
if( ~isempty(idx) )
indi.nViol = length(idx);
indi.violSum = sum( abs(cons) );
indi.cons =cons; %added line!
indi.nViol = 0;
indi.violSum = 0;
Could you or some body else please also check if that is right? and that i am not messing up something else by doing this?