1 | package de.uka.ipd.sdq.dsexplore.opt4j.representation; |
2 | |
3 | import org.opt4j.core.IndividualBuilder; |
4 | import org.opt4j.operator.copy.CopyModule; |
5 | import org.opt4j.operator.crossover.CrossoverModule; |
6 | import org.opt4j.operator.mutate.MutateModule; |
7 | import org.opt4j.optimizer.ea.ConstantCrossoverRate; |
8 | import org.opt4j.optimizer.ea.CrossoverRate; |
9 | import org.opt4j.optimizer.ea.EvolutionaryAlgorithmModule; |
10 | import org.opt4j.optimizer.ea.Mating; |
11 | |
12 | import de.uka.ipd.sdq.dsexplore.opt4j.operator.CopyDesignDecisionGenotype; |
13 | import de.uka.ipd.sdq.dsexplore.opt4j.operator.MutateDesignDecisionGenotype; |
14 | import de.uka.ipd.sdq.dsexplore.opt4j.operator.UniformDesignDecisionGenotypeCrossover; |
15 | import de.uka.ipd.sdq.dsexplore.opt4j.optimizer.MatingWithHeuristics; |
16 | import de.uka.ipd.sdq.dsexplore.opt4j.optimizer.NoDuplicatesEvolutionaryAlgorithm; |
17 | import de.uka.ipd.sdq.tcfmoop.tcmanager.TerminationCriteriaManager; |
18 | |
19 | public class DSEEvolutionaryAlgorithmModule extends EvolutionaryAlgorithmModule { |
20 | |
21 | |
22 | /* |
23 | * (non-Javadoc) |
24 | * |
25 | * @see org.opt4j.start.Opt4JModule#config() |
26 | */ |
27 | @Override |
28 | public void config() { |
29 | |
30 | bindOptimizer(NoDuplicatesEvolutionaryAlgorithm.class); |
31 | bind(Mating.class).to(MatingWithHeuristics.class).in(SINGLETON); |
32 | |
33 | bind(CrossoverRate.class).to(ConstantCrossoverRate.class).in(SINGLETON); |
34 | |
35 | bind(IndividualBuilder.class).to(DSEIndividualBuilder.class); |
36 | |
37 | CrossoverModule.addCrossover(binder(),UniformDesignDecisionGenotypeCrossover.class); |
38 | //CrossoverModule.addCrossover(binder(),DesignDecisionCrossover.class); |
39 | MutateModule.addMutate(binder(),MutateDesignDecisionGenotype.class); |
40 | |
41 | CopyModule.addCopy(binder(), CopyDesignDecisionGenotype.class); |
42 | |
43 | addOptimizerIterationListener(TerminationCriteriaManager.class); |
44 | |
45 | // To exchange the selector, we cannot do the following because then the binding will be attempted twice and an exception is thrown. Thus, reimplement the selector module. |
46 | //bind(Selector.class).to(Nsga2.class).in(SINGLETON); |
47 | //bind(Selector.class).to(Spea2.class).in(SINGLETON); |
48 | } |
49 | |
50 | } |