Multi-criterial example for the Matlab interface

This commit is contained in:
Marcel Kronfeld
2011-02-16 12:47:15 +00:00
parent 749c75fe2a
commit 489e0a6f3f
4 changed files with 54 additions and 30 deletions

View File

@@ -17,4 +17,20 @@ switch y
end
case 5 % simple parabola
z (1)=sum( x .* x ) ;
end
case 6 % binary function with two criteria: longest sequence of zeros and number of ones
% Optimal solutions have the form 1*0*1* in {0,1}^length(x)
numOnes=0;
longestZeroLen=0;
currentZeroLen=0;
for i=1:length(x)
if x(i)=='1'
numOnes=numOnes+1;
currentZeroLen=0;
else
currentZeroLen=currentZeroLen+1;
if currentZeroLen>longestZeroLen ; longestZeroLen=currentZeroLen; end
end;
%disp(sprintf('at %f : numOnes=%f, currentZeroLen=%f, longest=%f ', i, numOnes, currentZeroLen, longestZeroLen));
end
z=[length(x)-longestZeroLen, length(x)-numOnes];
end