1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
// -*- C++ -*-
// $Id$
//=============================================================================
/**
* @file SA_Builder.h
*
* This file contains the definition of the SA_Builder concrete class,
* which implements a Builder creating SA_Planner and associated
* objects for planning with spreading activation networks and scheduling
* with precedence graphs.
*
* @author John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
*/
//=============================================================================
#ifndef SA_POP_SA_BUILDER_H_
#define SA_POP_SA_BUILDER_H_
#include "SA_POP_Types.h"
#include "Builder.h"
#include "Planner.h"
#include "SANet/SANet.h"
#include "SA_PlanHeuristics.h"
#include "SA_PlanStrategy.h"
#include "SA_SchedStrategy.h"
#include "SA_WorkingPlan.h"
#include "TaskMap.h"
namespace SA_POP {
/**
* @class SA_Builder
*
* @brief Builder concrete class for creating SA_Planner and
* associated objects for planning with spreading activation networks
* and scheduling with precedence graphs.
*/
class SA_Builder : public Builder {
public:
/// Constructor.
SA_Builder (void);
/// Destructor.
virtual ~SA_Builder (void);
/// Reset for building a new set of SA-POP objects.
virtual void reset (void);
/// Get Planner object.
/**
* @return Pointer to the configured planner object.
*/
virtual Planner *get_planner (void);
// ************************************************************************
// Problem construction methods (tasks, conditions, & links between them).
// ************************************************************************
/// Add a task.
/**
* @param id The unique task id.
*
* @param prior_prob The prior probability of this task succeeding.
*
* @param name The task name.
*
* @exception Duplicate_Task The given task id already exists.
*/
virtual void add_task (TaskID id, double prior_prob,
std::string name = "");
/// Add a condition.
/**
* @param id The unique condition id.
*
* @param name The condition name.
*
* @param utility The (goal) utility of the condition.
*
* @param init_prob_true The initial probability that the condition
* is true.
*
* @param cond_kind The type of condition.
*
* @exception Duplicate_Cond The given condition id already exists.
*/
virtual void add_cond (CondID id, Utility utility = 0,
double init_prob_true = 0, std::string name = "", CondKind cond_kind = SA_POP::DATA);
/// Add a link between a precondition and task.
/**
* @param cond_id The precondition id.
*
* @param task_id The task id.
*
* @param port The receiving port id (on the task for this precondition).
*
* @param true_prob Conditional probability of task success given
* condition = true.
*
* @param false_prob Conditional probability of task success given
* condition = false.
*
* @exception Unknown_Cond Unknown condition id.
*/
virtual void set_precond (CondID cond_id, TaskID task_id,
PortID port, double true_prob, double false_prob);
/// Add a link between a task and an effect.
/**
* @param cond_id The effect condition id.
*
* @param task_id The task id.
*
* @param port The sending port id (on the task for this effect).
*
* @param weight Positive probability that task sets condition to true, or
* negative of probability that task sets condition to false.
*/
virtual void set_effect (TaskID task_id, CondID cond_id,
PortID port, double weight);
// ************************************************************************
// TaskMap construction methods (resources, task->implementations,
// and implementation->resources).
// ************************************************************************
/// Add a resource.
/**
* @param resource The resource info.
*/
virtual void add_resource (Resource resource);
/// Add an implementation.
/**
* @param task_impl The task implementation info.
*/
virtual void add_task_impl (TaskImpl *task_impl);
/// Associate a task with a task implementation.
/**
* @param task_id ID of the task.
*
* @param task_impl_id ID of the task implementation.
*
* @param duration The duration of the task implementation for this task.
*/
virtual void assoc_task_with_impl (TaskID task_id, TaskImplID task_impl_id,
TimeValue duration);
/// Associate a task implementation with its utilization of a resource.
/**
* @param impl_id ID of the task implementation.
*
* @param resource_id ID of the associated resource.
*
* @param resource_usage The quantity of resource used.
*/
virtual void assoc_impl_with_resource (TaskImplID impl_id,
ResourceID resource_id, ResourceValue resource_usage);
protected:
/// Planner object to centralize/mediate planning.
Planner *planner_;
/// Spreading activation network.
SANet::Network *sanet_;
/// Condition choice strategy used by PlanStrategy.
SA_CondStrategy *cond_choice_;
/// Task choice strategy used by PlanStrategy.
SA_TaskStrategy *task_choice_;
/// Task implementation choice strategy used by PlanStrategy.
SA_ImplStrategy *impl_choice_;
/// PlanStrategy object for planning.
SA_PlanStrategy *plan_strat_;
/// SchedStrategy object for scheduling.
SA_SchedStrategy *sched_strat_;
/// WorkingPlan object for holding plan in progress.
SA_WorkingPlan *working_plan_;
/// TaskMap object for associating tasks with implementations and resources.
TaskMap *task_map_;
/// Create SA-POP objects.
virtual void init (void);
};
}; /* SA_POP namespace */
#endif /* SA_POP_SA_BUILDER_H_ */
|