| 1 | package de.uka.ipd.sdq.dsexplore.opt4j.representation; |
| 2 | |
| 3 | import org.apache.log4j.Logger; |
| 4 | import org.opt4j.core.Objective; |
| 5 | import org.opt4j.core.Value; |
| 6 | |
| 7 | public class DSEConstraint { |
| 8 | |
| 9 | private Value<Double> lowerLimit; |
| 10 | private Value<Double> upperLimit; |
| 11 | private Objective objective; |
| 12 | |
| 13 | /** Logger for log4j. */ |
| 14 | private static Logger logger = |
| 15 | Logger.getLogger("de.uka.ipd.sdq.dsexplore"); |
| 16 | |
| 17 | |
| 18 | public DSEConstraint(Value<Double> lowerLimit, Value<Double> upperLimit, |
| 19 | Objective objective) { |
| 20 | super(); |
| 21 | this.lowerLimit = lowerLimit; |
| 22 | this.upperLimit = upperLimit; |
| 23 | this.objective = objective; |
| 24 | } |
| 25 | |
| 26 | public boolean isValid(Value<Double> value){ |
| 27 | if ((lowerLimit == null || lowerLimit.compareTo((Value<Double>) value)<=0) |
| 28 | && |
| 29 | (upperLimit == null || upperLimit.compareTo((Value<Double>) value)>=0)){ |
| 30 | return true; |
| 31 | } else { |
| 32 | logger.info("Objective "+objective.getName()+" does not fulfill the requirements with a value of "+value.toString()); |
| 33 | return false; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | } |