1 | package de.uka.ipd.sdq.dsexplore.analysis.reliability; |
2 | |
3 | import java.math.BigDecimal; |
4 | import java.math.RoundingMode; |
5 | |
6 | import org.apache.log4j.Logger; |
7 | import org.opt4j.core.Criterion; |
8 | |
9 | import de.uka.ipd.sdq.dsexplore.analysis.IAnalysisResult; |
10 | import de.uka.ipd.sdq.pcm.resourceenvironment.ProcessingResourceSpecification; |
11 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer; |
12 | import de.uka.ipd.sdq.pcmsolver.runconfig.PCMSolverWorkflowRunConfiguration; |
13 | |
14 | /** |
15 | * This class represents the result of a LQN Solver analysis. |
16 | * |
17 | * @author anne |
18 | * |
19 | */ |
20 | public class ReliabilityAnalysisResult implements IAnalysisResult { |
21 | |
22 | protected static Logger logger = Logger |
23 | .getLogger("de.uka.ipd.sdq.dsexplore"); |
24 | |
25 | |
26 | private double pofod; |
27 | |
28 | /** |
29 | * Store the reliability result. If the number of exact decimal places has been limited in the |
30 | * {@link PCMSolverWorkflowRunConfiguration}, the result is rounded to that value by cutting all following places. |
31 | * @param d |
32 | * @param lastPCMSolverConfigurationconfiguration to determine whether to round the result. |
33 | */ |
34 | public ReliabilityAnalysisResult(double d, PCMSolverWorkflowRunConfiguration lastPCMSolverConfiguration) { |
35 | boolean limitedNumberOfExactDecimalPlaces = lastPCMSolverConfiguration.isNumberOfExactDecimalPlacesEnabled(); |
36 | if (limitedNumberOfExactDecimalPlaces){ |
37 | // +1 to not loose any information, because the solver is accurate to at least the given number of places. |
38 | int numberOfPlaces = lastPCMSolverConfiguration.getNumberOfExactDecimalPlaces()+1; |
39 | BigDecimal bigD = new BigDecimal(d); |
40 | bigD = bigD.setScale(numberOfPlaces, RoundingMode.FLOOR); |
41 | d = bigD.doubleValue(); |
42 | } |
43 | this.pofod = d; |
44 | } |
45 | |
46 | /** |
47 | * {@inheritDoc} |
48 | * TODO: check correct criterion |
49 | */ |
50 | @Override |
51 | public double getValueFor(Criterion criterion) { |
52 | return this.pofod; |
53 | |
54 | } |
55 | |
56 | |
57 | /** |
58 | * Not applicable to Reliability results. |
59 | * @return -1 |
60 | */ |
61 | public double getUtilisationOfResource(ResourceContainer container, |
62 | ProcessingResourceSpecification resource) |
63 | { |
64 | // TODO Implement |
65 | return -1; |
66 | } |
67 | |
68 | } |