1
|
|
|
package it.cnr.istc.pst.platinum.ai.framework.microkernel.resolver.plan; |
2
|
|
|
|
3
|
|
|
import java.util.ArrayList; |
4
|
|
|
import java.util.List; |
5
|
|
|
|
6
|
|
|
import it.cnr.istc.pst.platinum.ai.framework.domain.component.Decision; |
7
|
|
|
import it.cnr.istc.pst.platinum.ai.framework.domain.component.pdb.SynchronizationRule; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* |
11
|
|
|
* @author alessandro |
12
|
|
|
* |
13
|
|
|
*/ |
14
|
|
|
public class GoalExpansion extends GoalJustification { |
|
|
|
|
15
|
|
|
|
16
|
|
|
private SynchronizationRule rule; |
17
|
|
|
private List<GoalSchedule> schedules; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* |
21
|
|
|
* @param goal |
22
|
|
|
* @param rule |
23
|
|
|
* @param cost |
24
|
|
|
*/ |
25
|
|
|
protected GoalExpansion(Goal goal, SynchronizationRule rule, double cost) { |
26
|
|
|
super(goal, JustificationType.EXPANSION, cost); |
27
|
|
|
this.rule = rule; |
28
|
|
|
this.schedules = new ArrayList<>(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* |
33
|
|
|
* @param goal |
34
|
|
|
* @param cost |
35
|
|
|
*/ |
36
|
|
|
protected GoalExpansion(Goal goal, double cost) { |
37
|
|
|
super(goal, JustificationType.EXPANSION, cost); |
38
|
|
|
this.rule = null; |
39
|
|
|
this.schedules = new ArrayList<>(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* |
44
|
|
|
* @param schedule |
45
|
|
|
*/ |
46
|
|
|
public void addGoalSchedule(GoalSchedule schedule) { |
47
|
|
|
this.schedules.add(schedule); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* |
52
|
|
|
*/ |
53
|
|
|
public List<GoalSchedule> getGoalSchedules() { |
54
|
|
|
return new ArrayList<>(this.schedules); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* |
59
|
|
|
* @return |
60
|
|
|
*/ |
61
|
|
|
public SynchronizationRule getRule() { |
62
|
|
|
return rule; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* |
67
|
|
|
* @return |
68
|
|
|
*/ |
69
|
|
|
public boolean hasSubGoals() { |
70
|
|
|
return this.rule != null; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* |
75
|
|
|
* @return |
76
|
|
|
*/ |
77
|
|
|
public Decision getGoalDecision() { |
78
|
|
|
return decision; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* |
83
|
|
|
* @return |
84
|
|
|
*/ |
85
|
|
|
public SynchronizationRule getSynchronizationRule() { |
86
|
|
|
return rule; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* |
91
|
|
|
*/ |
92
|
|
|
@Override |
93
|
|
|
public String toString() { |
94
|
|
|
// JSON style object description |
95
|
|
|
return "{ " |
96
|
|
|
+ "\"type\": \"EXPANSION\", " |
97
|
|
|
+ "\"goal\": " + this.decision + ", " |
98
|
|
|
+ "\"rule\": " + this.rule +" }"; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|