I wanted to run the main function (TP_CONSTR.m)of (NGPM -- A NSGA-II Program in Matlab v1.4) but it doesn't working I get the following error message:
??? Error: File: ndsort.m Line: 259 Column: 11
Expression or statement is incorrect--possibly unbalanced (, {, or [.
Error in ==> nsga2 at 82
[opt, pop] = ndsort(opt, pop);
Error in ==> TP_CONSTR at 24
result = nsga2(options); % begin the optimization!
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!
else
indi.nViol = 0;
indi.violSum = 0;
end
end
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?
Cheers
it can work if change "1-sum(x)=0" into " 1-sum(x)>0 and sum(x)-1>0 " , and it can't get your result if just express one of the variables as one minus the sum of the rest. I have varified the two above methods. in addition, I have tried to turn the constraints to one of the objection, such as y=1/(abs(1-sum(x))+eps), also failed.
Comment only