1 | package de.uka.ipd.sdq.workflow.pcm.runconfig; |
2 | |
3 | public class SensitivityAnalysisConfiguration implements Cloneable { |
4 | double max; |
5 | double step; |
6 | private String variableURI; |
7 | private double min; |
8 | private int runNo; |
9 | private String shortName; |
10 | |
11 | public SensitivityAnalysisConfiguration(String shortName, String variableURI, double min, |
12 | double max, double step) { |
13 | super(); |
14 | if (shortName == null || shortName.equals("")){ |
15 | this.shortName = variableURI; |
16 | } else { |
17 | this.shortName = shortName; |
18 | } |
19 | this.variableURI = variableURI; |
20 | this.runNo = 0; |
21 | this.max = max; |
22 | this.min = min; |
23 | this.step = step; |
24 | } |
25 | |
26 | public double getCurrent() { |
27 | return Math.min(min + runNo * step, max); |
28 | } |
29 | |
30 | public double getMax() { |
31 | return max; |
32 | } |
33 | |
34 | public double getMin() { |
35 | return min; |
36 | } |
37 | |
38 | public double getStep() { |
39 | return step; |
40 | } |
41 | |
42 | public String getVariable() { |
43 | return variableURI; |
44 | } |
45 | |
46 | public int getRunNo() { |
47 | return runNo; |
48 | } |
49 | |
50 | public SensitivityAnalysisConfiguration getNext() { |
51 | SensitivityAnalysisConfiguration result = new SensitivityAnalysisConfiguration(shortName, variableURI, min, max, step); |
52 | result.runNo = this.runNo + 1; |
53 | return result; |
54 | } |
55 | |
56 | public SensitivityAnalysisConfiguration getFirst(){ |
57 | return new SensitivityAnalysisConfiguration(shortName, variableURI, min, max, step); |
58 | } |
59 | |
60 | @Override |
61 | public String toString() { |
62 | return shortName+ "(" + this.runNo + ", " + this.getCurrent() + ")"; |
63 | } |
64 | |
65 | public String getShortName() { |
66 | return this.shortName; |
67 | } |
68 | |
69 | @Override |
70 | protected Object clone() throws CloneNotSupportedException { |
71 | SensitivityAnalysisConfiguration config = (SensitivityAnalysisConfiguration) super.clone(); |
72 | config.max = this.max; |
73 | config.min = this.min; |
74 | config.runNo = this.runNo; |
75 | config.shortName = new String(this.shortName); |
76 | config.step = this.step; |
77 | config.variableURI = new String(this.variableURI); |
78 | return config; |
79 | } |
80 | |
81 | /** |
82 | * @return A clone of this instance. |
83 | */ |
84 | public SensitivityAnalysisConfiguration getClone() { |
85 | try { |
86 | return (SensitivityAnalysisConfiguration) this.clone(); |
87 | } catch (CloneNotSupportedException e) { |
88 | return null; |
89 | } |
90 | } |
91 | } |