|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.util.Dictionary
java.util.Hashtable
zeus.actors.ResourceDb
This class implements the Resource Database component, whose role is to
store the resources owned by the agent, (which are Fact objects).
The Resource Database is simply an extended Hashtable with the fact
objects held indexed by their types.
Developers will probably interact the Resource Database on a regular basis,
as it both contains the agent's knowledge and provides a means of altering it.
A reference to the Resource Database can be obtained from the agent's
AgentContext object, allowing access to the methods described below;
(The methods without descriptions are primarily used by other agent components
and so are unlikely to be useful to developers).
Change log
19/08/00 - added some code to the any(Fact) method at about line 580 - 590 this is to stop an unnecessary exception being thrown, the new behavior is that if the method is called and there are no facts of that type in the resourcedb then a new fact of that type will be returned instead.
Change log ---------- 13/06/01 added a number of fields (name,planner,ontologyDb, gensym,externaldb) which are used to store references that would be obtained from the AgentContext object, but cannot be if the context is not available at initialisation. I hope that this will enable better extensibility, but it might cause problems if the agent architecture is altered at run time. Added isSet method to allow programmers to check to see if Added setPlanner to permit this reference to be updated easily Added setName Added setOntologyDb Added setGenSym
| Nested Class Summary |
| Nested classes inherited from class java.util.Hashtable |
|
| Field Summary | |
private static int |
ACCESS
|
private static int |
ADD
|
protected AgentContext |
context
|
private static int |
DELETE
|
private HSet[] |
eventMonitor
|
protected GenSym |
gensym
|
private static int |
MODIFY
|
protected java.lang.String |
name
|
protected OntologyDb |
ontologyDb
|
protected Planner |
planner
|
| Fields inherited from class java.util.Hashtable |
|
| Constructor Summary | |
ResourceDb()
|
|
ResourceDb(AgentContext context)
|
|
| Method Summary | |
ResourceItem |
add(Fact fact)
The primary method for adding new facts to the Resource Database was synchronized |
ResourceItem |
add(Fact[] List)
was synchronized |
ResourceItem |
add(java.util.Vector List)
was synchronized |
void |
addFactMonitor(FactMonitor monitor,
long event_type)
|
void |
addFactMonitor(FactMonitor monitor,
long event_type,
boolean notify_previous)
Use this if your code needs to react to changes in the Resource Database. |
Fact[] |
all(Fact fact)
Use this to retrieve all the facts in the database that match the parameter |
Fact[] |
all(java.lang.String type)
|
Goal |
allocateResource(PlanRecord rec,
int position,
int required)
|
java.util.Vector |
allocateResources(PlanRecord rec)
|
Fact |
any(Fact fact)
Use this to randomly retrieve a fact that matches the parameter |
Fact |
any(java.lang.String type)
Randomly retrieves a fact with the same type as the parameter |
void |
consume(DataRec rec)
|
boolean |
contains(Fact fact,
int start)
Use this to test whether a particular fact exists in the database |
Fact |
debit(double amount)
Special purpose method to decrease the value of the amount attribute of MONEY facts |
private void |
debug(java.lang.String str)
|
void |
del(Fact fact)
The primary method for permanently removing facts from the Resource Database |
void |
del(Fact[] List)
|
void |
del(java.util.Vector List)
|
void |
deleteAll(java.lang.String type)
Deletes all facts matching the parameter type, should obviously be used with caution |
Fact |
evalLocal(Fact fact)
|
boolean |
evalNegative(Fact fact)
|
int |
findAll(PlanRecord rec,
int precond_position,
int required)
|
void |
free(DataRec rec)
|
AgentContext |
getAgentContext()
Use this to obtain handles to the other internal components of agent |
boolean |
isContextSet()
check that the AgentContext context field is set. |
boolean |
isGenSymSet()
check that the gensym refernece is set |
boolean |
isNameSet()
check that the name refernce is set |
boolean |
isOntologyDbSet()
check that the ontologyDb reference is set |
boolean |
isPlannerSet()
check that the planner reference is set |
boolean |
isSet()
check to see if all necessary fields are set |
void |
modify(Fact f1,
Fact f2)
Use this if facts have changed and you need to update the Resource Database |
private void |
notifyMonitors(ResourceItem item,
int type)
|
void |
removeFactMonitor(FactMonitor monitor,
long event_type)
|
(package private) void |
replaceOrAdd(Fact fact)
was synchronized |
int |
reserve(DataRec datarec,
int start,
int required)
|
int |
reserve(DataRec datarec,
PlanRecord rec,
int start,
int required)
Enables a resource to be secured at a certain time period, (this is provided primarily for internal use) |
void |
setGenSym(GenSym gensym)
this allows you to set the gensym referencce |
void |
setName(java.lang.String name)
this allows you to set the name reference |
void |
setOntologyDb(OntologyDb ontologyDb)
this allows you to set the ontolgyDb reference |
void |
setPlanner(Planner planner)
this allows you to set the planner reference |
| Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
private HSet[] eventMonitor
private static final int ADD
private static final int MODIFY
private static final int DELETE
private static final int ACCESS
protected AgentContext context
protected java.lang.String name
protected Planner planner
protected OntologyDb ontologyDb
protected GenSym gensym
| Constructor Detail |
public ResourceDb()
public ResourceDb(AgentContext context)
| Method Detail |
public void setPlanner(Planner planner)
public void setName(java.lang.String name)
public void setGenSym(GenSym gensym)
public void setOntologyDb(OntologyDb ontologyDb)
public boolean isNameSet()
public boolean isGenSymSet()
public boolean isPlannerSet()
public boolean isOntologyDbSet()
public boolean isContextSet()
public boolean isSet()
public AgentContext getAgentContext()
public ResourceItem add(java.util.Vector List)
public ResourceItem add(Fact[] List)
public ResourceItem add(Fact fact)
void replaceOrAdd(Fact fact)
public void del(java.util.Vector List)
public void del(Fact[] List)
public void del(Fact fact)
public void modify(Fact f1,
Fact f2)
public void free(DataRec rec)
public void consume(DataRec rec)
public int findAll(PlanRecord rec,
int precond_position,
int required)
public int reserve(DataRec datarec,
PlanRecord rec,
int start,
int required)
public int reserve(DataRec datarec,
int start,
int required)
public java.util.Vector allocateResources(PlanRecord rec)
public Goal allocateResource(PlanRecord rec,
int position,
int required)
public Fact debit(double amount)
public Fact evalLocal(Fact fact)
public boolean evalNegative(Fact fact)
public Fact[] all(java.lang.String type)
public Fact[] all(Fact fact)
public void deleteAll(java.lang.String type)
public Fact any(java.lang.String type)
public Fact any(Fact fact)
public boolean contains(Fact fact,
int start)
public void addFactMonitor(FactMonitor monitor,
long event_type,
boolean notify_previous)
public void addFactMonitor(FactMonitor monitor,
long event_type)
public void removeFactMonitor(FactMonitor monitor,
long event_type)
private void notifyMonitors(ResourceItem item,
int type)
private void debug(java.lang.String str)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||