1
|
|
|
package it.cnr.istc.pst.platinum.ai.framework.domain.component.pdb; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* |
5
|
|
|
* @author alessandroumbrico |
6
|
|
|
* |
7
|
|
|
*/ |
8
|
|
|
public class DecisionVariable implements Comparable<DecisionVariable> |
9
|
|
|
{ |
10
|
|
|
private int id; |
11
|
|
|
private String component; |
12
|
|
|
private String predicate; // grounded predicate |
13
|
|
|
private long[] start; |
14
|
|
|
private long[] end; |
15
|
|
|
private long[] duration; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* |
19
|
|
|
* @param id |
20
|
|
|
* @param component |
21
|
|
|
* @param value |
22
|
|
|
* @param start |
23
|
|
|
* @param end |
24
|
|
|
* @param duration |
25
|
|
|
*/ |
26
|
|
|
protected DecisionVariable( |
27
|
|
|
int id, |
28
|
|
|
String component, |
29
|
|
|
String value, |
30
|
|
|
long[] start, |
31
|
|
|
long[] end, |
32
|
|
|
long[] duration) { |
33
|
|
|
|
34
|
|
|
this.id = id; |
35
|
|
|
this.component = component; |
36
|
|
|
this.predicate = value; |
37
|
|
|
this.start = start; |
38
|
|
|
this.end = end; |
39
|
|
|
this.duration = duration; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* |
44
|
|
|
* @return |
45
|
|
|
*/ |
46
|
|
|
public int getId() { |
47
|
|
|
return id; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* |
52
|
|
|
* @return |
53
|
|
|
*/ |
54
|
|
|
public String getComponent() { |
55
|
|
|
return component; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* |
60
|
|
|
* @return |
61
|
|
|
*/ |
62
|
|
|
public String getValue() { |
63
|
|
|
return predicate; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* |
68
|
|
|
* @return |
69
|
|
|
*/ |
70
|
|
|
public long[] getStart() { |
71
|
|
|
return start; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* |
76
|
|
|
* @return |
77
|
|
|
*/ |
78
|
|
|
public long[] getEnd() { |
79
|
|
|
return end; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* |
84
|
|
|
* @return |
85
|
|
|
*/ |
86
|
|
|
public long[] getDuration() { |
87
|
|
|
return duration; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* |
92
|
|
|
*/ |
93
|
|
|
@Override |
94
|
|
|
public int hashCode() { |
95
|
|
|
final int prime = 31; |
96
|
|
|
int result = 1; |
97
|
|
|
result = prime * result + id; |
98
|
|
|
return result; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* |
103
|
|
|
*/ |
104
|
|
|
@Override |
105
|
|
|
public boolean equals(Object obj) { |
106
|
|
|
if (this == obj) |
107
|
|
|
return true; |
108
|
|
|
if (obj == null) |
109
|
|
|
return false; |
110
|
|
|
if (getClass() != obj.getClass()) |
111
|
|
|
return false; |
112
|
|
|
DecisionVariable other = (DecisionVariable) obj; |
113
|
|
|
if (id != other.id) |
114
|
|
|
return false; |
115
|
|
|
return true; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* |
121
|
|
|
*/ |
122
|
|
|
@Override |
123
|
|
|
public int compareTo(DecisionVariable o) { |
124
|
|
|
// compare start and end bounds |
125
|
|
|
return this.start[0] < o.start[0] ? -1 : |
126
|
|
|
this.start[0] > o.start[0] ? 1 : |
127
|
|
|
this.end[0] < o.end[0] ? -1 : |
128
|
|
|
this.end[0] > o.end[0] ? 1 : 0; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* |
133
|
|
|
*/ |
134
|
|
|
@Override |
135
|
|
|
public String toString() { |
136
|
|
|
// JSON style object description |
137
|
|
|
return "{ " |
138
|
|
|
+ "\"id\": " + this.id + ", " |
139
|
|
|
+ "\"component\": \"" + this.component + "\", " |
140
|
|
|
+ "\"predicate\": \"" + this.predicate + "\", " |
141
|
|
|
+ "\"start\": [" + this.start[0] + ", " + this.start[1] + "], " |
142
|
|
|
+ "\"end\": [" + this.end[0] + ", " + this.end[1] + "], " |
143
|
|
|
+ "\"duration\": [" + this.duration[0] + ", " + this.duration[1] + "]" |
144
|
|
|
+ " }"; |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|