Multi-criterial example for the Matlab interface
This commit is contained in:
parent
749c75fe2a
commit
489e0a6f3f
@ -16,12 +16,20 @@ JI=optimize(JI, 4);
|
||||
finalPop=getMultipleResults(JI);
|
||||
|
||||
% binary case
|
||||
R=20;
|
||||
R=30;
|
||||
JI=JEInterface(@testfun, 'binary', R, R, 4, 'Display', 'iter');
|
||||
JI=optimize(JI, 3);
|
||||
JI=setOutputAllStatsFields(JI, 0); % suppress output of additional statistics, spares runtime with large populations
|
||||
JI=optimizeWith(JI, 3, 'population', eva2.server.go.populations.Population(1000);
|
||||
[sol, fit]=getResult(JI);
|
||||
finalPop=getMultipleResults(JI);
|
||||
|
||||
% binary case with a multi-objective fitness function
|
||||
R=30;
|
||||
JI=JEInterface(@testfun, 'binary', R, R, 6, 'Display', 'iter', 'TolX', 0, 'TolFun', 0, 'MaxFunEvals', 3000);
|
||||
JI=optimizeWith(JI, 14);
|
||||
% The resulting solution set is a pareto dominant set found with NSGA-II
|
||||
[finalSols, finalFit]=getMultipleResults(JI);
|
||||
|
||||
% integer case with specific initialization range
|
||||
initR=[-15 -15 -15 -15 -15; -5 -5 -5 -5 -5];
|
||||
R=[-15 -15 -15 -15 -15; 15 15 15 15 15];
|
||||
|
@ -17,4 +17,20 @@ switch y
|
||||
end
|
||||
case 5 % simple parabola
|
||||
z (1)=sum( x .* x ) ;
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
package eva2.server.go.problems;
|
||||
|
||||
import eva2.server.go.individuals.AbstractEAIndividual;
|
||||
import eva2.server.go.individuals.GAIndividualIntegerData;
|
||||
import eva2.server.go.individuals.GIIndividualIntegerData;
|
||||
import eva2.server.go.individuals.InterfaceDataTypeInteger;
|
||||
import eva2.server.go.populations.Population;
|
||||
import eva2.server.go.strategies.InterfaceOptimizer;
|
||||
@ -20,7 +20,7 @@ public abstract class AbstractProblemInteger extends AbstractOptimizationProblem
|
||||
}
|
||||
|
||||
protected void initTemplate() {
|
||||
if (m_Template==null) m_Template = new GAIndividualIntegerData();
|
||||
if (m_Template==null) m_Template = new GIIndividualIntegerData();
|
||||
if (((InterfaceDataTypeInteger)this.m_Template).size()!=this.getProblemDimension()) {
|
||||
((InterfaceDataTypeInteger)this.m_Template).setIntegerDataLength(this.getProblemDimension());
|
||||
}
|
||||
|
@ -63,6 +63,6 @@ public class I1Problem extends AbstractProblemInteger implements java.io.Seriali
|
||||
}
|
||||
|
||||
public static String globalInfo() {
|
||||
return "I1(x) = x^2 is to be minimized.";
|
||||
return "A hyper parabola on integer values x with I1(x) = x^2 is to be minimized.";
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user