Skip to content
Snippets Groups Projects
Commit 662ad2fd authored by Nikolaus Huber's avatar Nikolaus Huber
Browse files

minor refactorings

git-svn-id: https://se1.informatik.uni-wuerzburg.de/usvn/svn/code/code/DMM/trunk@11928 9e42b895-fcda-4063-8a3b-11be15eb1bbd
parent ade473f5
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ public class WeightingFunctionEvaluator implements IEvaluator {
public void evaluate(WeightedTactic tactic) {
WeightingFunction f = tactic.getParentStrategy().getWeightingFunction();
final String functionClassName = f.getWeightingFunction();
final String functionClassName = f.getWeightingFunctionImplementation();
Object o = null;
try {
......@@ -44,6 +44,7 @@ public class WeightingFunctionEvaluator implements IEvaluator {
}
calculator = (IWeightingFunction) o;
calculator.setWeightingFunction(f);
double newWeight = calculator.calculateWeight(tactic);
logger.debug("Setting new weight of " + tactic.getName() + " to " + newWeight);
tactic.setCurrentWeight(newWeight);
......
package edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction;
import edu.kit.ipd.descartes.mm.adaptation.Tactic;
import edu.kit.ipd.descartes.mm.adaptation.WeightedMetric;
import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic;
import edu.kit.ipd.descartes.mm.adaptation.WeightingFunction;
/**
* @author nhuber
*
*/
public interface IWeightingFunction {
/**
/**
* Sets the {@link WeightingFunction} that can be used
* by the {@link WeightingFunction} to derive the
* {@link WeightedMetric}s used to calculate the weight.
*
* @param function
*/
void setWeightingFunction(WeightingFunction function);
/**
* Calculates the new weight of the given {@link Tactic}.
*
* @param impact
* @return
*/
double calculateWeight(WeightedTactic weightedTactic);
double calculateWeight(WeightedTactic weightedTactic);
}
......@@ -3,6 +3,7 @@ package edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction;
import java.util.Random;
import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic;
import edu.kit.ipd.descartes.mm.adaptation.WeightingFunction;
public class RandomWeightsWeightingFunction implements IWeightingFunction {
......@@ -11,4 +12,9 @@ public class RandomWeightsWeightingFunction implements IWeightingFunction {
Random r = new Random(System.currentTimeMillis());
return r.nextDouble();
}
@Override
public void setWeightingFunction(WeightingFunction function) {
// Left empty intentionally
}
}
......@@ -14,14 +14,14 @@ public class WeightedSum implements IWeightingFunction {
private Logger logger = Logger.getLogger(WeightedSum.class);
private WeightingFunction weightingFunction = null;
public WeightedSum(WeightingFunction f) {
setWeightingFunction(f);
public WeightedSum() {
}
public WeightingFunction getWeightingFunction() {
return weightingFunction;
}
@Override
public void setWeightingFunction(WeightingFunction weightingFunction) {
this.weightingFunction = weightingFunction;
}
......@@ -58,4 +58,5 @@ public class WeightedSum implements IWeightingFunction {
return newWeight;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment