1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.tcfmoop.config; |
5 | |
6 | import de.uka.ipd.sdq.tcfmoop.config.exceptions.InvalidConfigException; |
7 | |
8 | /** |
9 | * Configuration class for NoNewParetoOptimalCandidatesFound termination criterion. |
10 | * @author Atanas Dimitrov |
11 | */ |
12 | public class NoNewParetoOptimalCandidatesFoundConfig extends |
13 | AbstractConfiguration { |
14 | |
15 | //Number of iterations without a new pareto optimal candidate |
16 | private Integer iterationsWithoutNewCandidates; |
17 | |
18 | public NoNewParetoOptimalCandidatesFoundConfig(){ |
19 | super(TerminationCriteriaNames.NO_NEW_PARETO_OPTIMAL_CANDIDATES_FOUND); |
20 | } |
21 | |
22 | /** |
23 | * {@inheritDoc} |
24 | */ |
25 | @Override |
26 | public boolean validateConfiguration() { |
27 | if (this.getTerminationCriterionName() != TerminationCriteriaNames.NO_NEW_PARETO_OPTIMAL_CANDIDATES_FOUND |
28 | || this.iterationsWithoutNewCandidates == null) { |
29 | return false; |
30 | } else { |
31 | return true; |
32 | } |
33 | } |
34 | |
35 | /** |
36 | * Set the required number of iterations without new pareto optimal candidates in the pareto optimal set. |
37 | * @param numberOfIterations required number of iterations without new pareto optimal candidates in the pareto optimal set. Must be a >=1. |
38 | * @throws InvalidConfigException if the supplied parameter do not conform to the required conditions. |
39 | */ |
40 | public void setIterationsWithoutNewCandidates(int numberOfIterations) throws InvalidConfigException{ |
41 | if(numberOfIterations < 1){ |
42 | throw new InvalidConfigException("NoNewParetoOptimalCandidatesFoundConfig.setNumberOfGenerationWithoutNewCandidates: " + |
43 | "The minimum number of generations without new pareto optimal candidate" + |
44 | " must be at least 1."); |
45 | }else{ |
46 | this.iterationsWithoutNewCandidates = numberOfIterations; |
47 | } |
48 | } |
49 | |
50 | /** |
51 | * Get the required number of iterations without new pareto optimal candidates in the pareto optimal set. |
52 | * @return the required number of iterations without new pareto optimal candidates in the pareto optimal set. Guaranteed to be >=1 |
53 | */ |
54 | public int getIterationsWithoutNewCandidates(){ |
55 | return this.iterationsWithoutNewCandidates; |
56 | } |
57 | |
58 | } |