| 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 InsignificantParetoFrontChange termination criterion. |
| 10 | * @author Atanas Dimitrov |
| 11 | */ |
| 12 | public class InsignificantParetoFrontChangeConfig extends AbstractConfiguration { |
| 13 | |
| 14 | //Difference between the pareto front from the n-x. generation and the one from the n. generation |
| 15 | private Double percentageDifference; |
| 16 | //the n-x. pareto front to compare with |
| 17 | private Integer pastInterationNumber; |
| 18 | |
| 19 | public InsignificantParetoFrontChangeConfig(){ |
| 20 | super(TerminationCriteriaNames.INSIGNIFICANT_PARETO_FRONT_CHANGE); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * {@inheritDoc} |
| 25 | */ |
| 26 | @Override |
| 27 | public boolean validateConfiguration() { |
| 28 | if (this.getTerminationCriterionName() != TerminationCriteriaNames.INSIGNIFICANT_PARETO_FRONT_CHANGE || |
| 29 | this.percentageDifference == null || |
| 30 | this.pastInterationNumber == null){ |
| 31 | return false; |
| 32 | } else { |
| 33 | return true; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Set the minimum allowed difference between the two fronts. If the difference, measured in coverage |
| 39 | * percentages is smaller then the one entered here, then the improvement is considered insignificant. |
| 40 | * Else it is not. The parameter is a percentage value and is exacted to be in the interval [0, 1]. |
| 41 | * @param percentages Minimum allowed difference between the two pareto fronts. A percentage value in the interval [0, 1] |
| 42 | * @throws InvalidConfigException if the supplied parameter do not conform to the required conditions. |
| 43 | */ |
| 44 | public void setMinimumAllowedDifference(double percentages) throws InvalidConfigException{ |
| 45 | if(percentages < 0 || percentages > 1){ |
| 46 | throw new InvalidConfigException("InsignificantParetoFrontChangeConfig.setDifference: " + |
| 47 | "the supplied parameter should be in range 0 - 1"); |
| 48 | } |
| 49 | |
| 50 | this.percentageDifference = percentages; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Returns the minimum allowed difference, measured in coverage percentages between the two fronts. |
| 55 | * The value is guaranteed to be in the interval [0, 1] |
| 56 | * @return the minimum allowed difference, measured in coverage percentages between the two fronts. |
| 57 | */ |
| 58 | public double getMinimumAllowedDifference(){ |
| 59 | return this.percentageDifference; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Sets the number for the x. past iteration to compare the current pareto front with. |
| 64 | * @param compareWithIterationsAgo the number for the x. past generation to compare the current pareto front with. |
| 65 | * @throws InvalidConfigException if the supplied parameter do not conform to the required conditions. |
| 66 | */ |
| 67 | public void setPastIterationNumber(int pastInterationNumber) throws InvalidConfigException{ |
| 68 | if(pastInterationNumber < 1){ |
| 69 | throw new InvalidConfigException("InsignificantParetoFrontChangeConfig.setDifference: " + |
| 70 | "the supplied parameter should be >= 1"); |
| 71 | } |
| 72 | |
| 73 | this.pastInterationNumber = pastInterationNumber; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Get the number for the x. past generation to compare the current pareto front with. |
| 78 | * @return the number for the x. past generation to compare the current pareto front with. |
| 79 | */ |
| 80 | public int getPastIterationNumber(){ |
| 81 | return this.pastInterationNumber; |
| 82 | } |
| 83 | |
| 84 | } |