1 | package de.uka.ipd.sdq.tcfmoop.config; |
2 | |
3 | import de.uka.ipd.sdq.tcfmoop.config.exceptions.InvalidConfigException; |
4 | |
5 | /** |
6 | * Configuration class for MaxGenerationNumber termination criterion. |
7 | * @author Atanas Dimitrov |
8 | */ |
9 | public class MaxGenerationNumberConfig extends AbstractConfiguration { |
10 | |
11 | private Integer maximumNumberOfIterations; |
12 | |
13 | public MaxGenerationNumberConfig(){ |
14 | super(TerminationCriteriaNames.MAXIMUM_NUMBER_OF_GENERATIONS); |
15 | |
16 | } |
17 | |
18 | /** |
19 | * {@inheritDoc} |
20 | */ |
21 | @Override |
22 | public boolean validateConfiguration() { |
23 | if(this.getTerminationCriterionName() != TerminationCriteriaNames.MAXIMUM_NUMBER_OF_GENERATIONS || |
24 | this.maximumNumberOfIterations == null){ |
25 | return false; |
26 | }else{ |
27 | return true; |
28 | } |
29 | } |
30 | |
31 | /** |
32 | * Set the maximum number of iterations that the optimization algorithm |
33 | * will perform before terminating. |
34 | * @param maximumNumberOfIterations if parameter is less then 1, an Exception is thrown. |
35 | * @throws InvalidConfigException if the supplied parameter do not conform to the required conditions. |
36 | */ |
37 | public void setMaximumNumberOfIterations(int maximumNumberOfIterations) throws InvalidConfigException{ |
38 | if(maximumNumberOfIterations > 0){ |
39 | this.maximumNumberOfIterations = maximumNumberOfIterations; |
40 | }else{ |
41 | throw new InvalidConfigException("MaxGenerationNumberConfig.setMaximumNumberOfIterations: The supplied Parameter is < 1"); |
42 | } |
43 | } |
44 | |
45 | /** |
46 | * Returns the number of iterations that the optimization framework should execute. |
47 | * @return the number of iterations that the optimization framework should execute. |
48 | */ |
49 | public int getMaximumNumberOfIterations(){ |
50 | return this.maximumNumberOfIterations; |
51 | } |
52 | |
53 | } |