1 | package de.uka.ipd.sdq.dsexplore.opt4j.representation; |
2 | |
3 | import org.opt4j.core.AbstractIndividualBuilder; |
4 | import org.opt4j.core.problem.Genotype; |
5 | import org.opt4j.core.problem.Creator; |
6 | |
7 | |
8 | import com.google.inject.Inject; |
9 | import com.google.inject.Provider; |
10 | |
11 | import de.uka.ipd.sdq.dsexplore.opt4j.optimizer.heuristic.operators.TacticsResultCandidate; |
12 | import de.uka.ipd.sdq.dsexplore.opt4j.start.Opt4JStarter; |
13 | import de.uka.ipd.sdq.pcm.designdecision.DecisionSpace; |
14 | |
15 | public class DSEIndividualBuilder extends AbstractIndividualBuilder<DSEIndividual> { |
16 | |
17 | private DecisionSpace problem; |
18 | |
19 | @SuppressWarnings("unchecked") |
20 | @Inject |
21 | public DSEIndividualBuilder(Provider<DSEIndividual> individualProvider, |
22 | Creator creator) { |
23 | super(individualProvider, creator); |
24 | this.problem = Opt4JStarter.getProblem().getEMFProblem(); |
25 | } |
26 | |
27 | /* |
28 | * (non-Javadoc) |
29 | * |
30 | * @see org.opt4j.core.IndividualBuilder#build() |
31 | */ |
32 | @Override |
33 | public DSEIndividual build() { |
34 | DSEIndividual individual = new DSEIndividual(problem); |
35 | individual.setIndividualStatusListeners(individualStateListeners); |
36 | Genotype genotype = creator.create(); |
37 | individual.setGenotype(genotype); |
38 | |
39 | return individual; |
40 | } |
41 | |
42 | /* |
43 | * (non-Javadoc) |
44 | * |
45 | * @see org.opt4j.core.IndividualBuilder#build(org.opt4j.core.Genotype) |
46 | */ |
47 | @Override |
48 | public DSEIndividual build(Genotype genotype) { |
49 | DSEIndividual individual = new DSEIndividual(problem); |
50 | individual.setIndividualStatusListeners(individualStateListeners); |
51 | individual.setGenotype(genotype); |
52 | return individual; |
53 | } |
54 | |
55 | public TacticsResultCandidate buildCandidate(Genotype genotype, DSEIndividual parent) { |
56 | TacticsResultCandidate individual = new TacticsResultCandidate(problem, parent); |
57 | individual.setIndividualStatusListeners(individualStateListeners); |
58 | individual.setGenotype(genotype); |
59 | return individual; |
60 | } |
61 | |
62 | } |