diff --git a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/weightingfunction/IWeightingFunctionCalculator.java b/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/weightingfunction/IWeightingFunctionCalculator.java deleted file mode 100644 index 72068f516abb3a19e789517b55b7328f73537995..0000000000000000000000000000000000000000 --- a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/weightingfunction/IWeightingFunctionCalculator.java +++ /dev/null @@ -1,24 +0,0 @@ -package edu.kit.ipd.descartes.adaptation.weightingfunction; - -import edu.kit.ipd.descartes.mm.adaptation.Tactic; -import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic; - -public interface IWeightingFunctionCalculator { - - /** - * Calculates the new weight of the given {@link Tactic}. - * - * @param impact - * @return - */ - double calculateWeight(WeightedTactic weightedTactic); - - /** - * Calculates and sets the new weight of the given {@link WeightedTactic}. - * - * @param impact - * @return - */ - void updateWeight(WeightedTactic weightedTactic); - -} diff --git a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/weightingfunction/RandomWeightCalculator.java b/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/weightingfunction/RandomWeightCalculator.java deleted file mode 100644 index 244fae639d4345fb210ad248387fda40355bd430..0000000000000000000000000000000000000000 --- a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/weightingfunction/RandomWeightCalculator.java +++ /dev/null @@ -1,19 +0,0 @@ -package edu.kit.ipd.descartes.adaptation.weightingfunction; - -import java.util.Random; - -import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic; - -public class RandomWeightCalculator implements IWeightingFunctionCalculator { - - @Override - public double calculateWeight(WeightedTactic weightedTactic) { - Random r = new Random(System.currentTimeMillis()); - return r.nextDouble(); - } - - @Override - public void updateWeight(WeightedTactic weightedTactic) { - weightedTactic.setCurrentWeight(calculateWeight(weightedTactic)); - } -} diff --git a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/weightingfunction/WeightedSumCalculator.java b/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/weightingfunction/WeightedSumCalculator.java deleted file mode 100644 index 0770ba64526c1f61009e16cd03c89a2eb23253f4..0000000000000000000000000000000000000000 --- a/edu.kit.ipd.descartes.adaptation/src/edu/kit/ipd/descartes/adaptation/weightingfunction/WeightedSumCalculator.java +++ /dev/null @@ -1,62 +0,0 @@ -package edu.kit.ipd.descartes.adaptation.weightingfunction; - -import org.apache.log4j.Logger; -import org.eclipse.emf.common.util.EList; - -import edu.kit.ipd.descartes.adaptation.model.dmm.util.WeightingFunctionHelper; -import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic; -import edu.kit.ipd.descartes.mm.adaptation.WeightingFunction; -import edu.kit.ipd.descartes.perfdatarepo.Impact; -import edu.kit.ipd.descartes.perfdatarepo.MetricValue; -import edu.kit.ipd.descartes.perfdatarepo.Result; - -public class WeightedSumCalculator implements IWeightingFunctionCalculator { - - private Logger logger = Logger.getLogger(WeightedSumCalculator.class); - private WeightingFunction weightingFunction = null; - - public WeightedSumCalculator(WeightingFunction weightingFunction) { - this.weightingFunction = weightingFunction; - } - - @Override - public double calculateWeight(WeightedTactic weightedtactic) { - - double newWeight = 0.0; - Impact impact = weightedtactic.getLastImpact(); - Result before = impact.getBefore(); - Result after = impact.getAfter(); - EList<MetricValue> afterMetricValues = after.getMetricValues(); - - for (MetricValue afterMetricValue : afterMetricValues) { - // calculated delta=(after-before) - double afterValue = afterMetricValue.getValue(); - double beforeValue = WeightingFunctionHelper - .getValueForMetricType(afterMetricValue.getMetricType(), before); - double delta = afterValue - beforeValue; - - // get the corresponding weight - double weightOfMetric = WeightingFunctionHelper.getWeightForMetricType(weightingFunction, - afterMetricValue.getMetricType()); - - if (Double.isNaN(weightOfMetric)) - logger.info("No weight found for metric type: " + afterMetricValue.getMetricType().getName() + ", skipping..."); - else { - // add it - newWeight += weightOfMetric * delta; - logger.debug("Delta for metric type " + afterMetricValue.getMetricType().getName() + " was: " + delta - + " and weight is " + weightOfMetric); - } - } - - return newWeight; - } - - @Override - public void updateWeight(WeightedTactic weightedTactic) { - double newWeight = calculateWeight(weightedTactic); - logger.debug("Setting new weight of " + weightedTactic.getName() + " to " + newWeight); - weightedTactic.setCurrentWeight(newWeight); - } - -}