-
Hi all, apologies for the probably terribly simple and obvious question, but could anybody tell me more about what the "index" parameter to the BeliefBase add() method is for? I see we have two overrides of add(), like
and it's not immediately clear to me what the index is used for. Is it as simple as allowing the same belief to appear multiple times (and how would that work) or is there something more interesting going on here? EDIT: OK, reading the javadoc I see this bit:
for the version that takes the index parameter. As opposed to the other override, which says:
So it seems like the only difference is, if you call the single parameter version of the add() function, the new belief is added at the end of the BB by default, and if you pass an index, you get to specify the position in the BB? If I'm reading that right, I guess my follow-on question would be "when/why would I want to specify the index explicitly?" And, "is this useful for customized BB implementations that don't have an obvious notion of "position" like a JDBC backed BB, or one using an RDF triplestore? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi, first, Jason default implementation of BB only support add in the beginning or in the ending of the BB (other implementation may implement other uses of the The order is quite important for the queries. For instance, suppose a BB with
a query Moreover, if the agent runs I don't know if that reasons also apply to RDF.... |
Beta Was this translation helpful? Give feedback.
-
OK, I think I get it. Sounds like anyone implementing a custom BeliefBase should then store the index parameter (when provided) and then when returning query results sort by that index. I assume the index is intended to start at 0 (or 1) and increase monotonically? One other further question if y'all will bear with me here: is the index per-belief, or global across all beliefs in the BB? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Index starts at 0 and is related to a belief type (not all BB). belief type is functor+arity (class PredicateIndicator). |
Beta Was this translation helpful? Give feedback.
Hi,
first, Jason default implementation of BB only support add in the beginning or in the ending of the BB (other implementation may implement other uses of the
index
).The order is quite important for the queries. For instance, suppose a BB with
a query
.findall(X,b(X),L)
should returnL=[10,20]
, with this order of values.Moreover, if the agent runs
+b(30)
followed by (maybe in another intention)?b(X)
, I'd expect thatX=30
, the most recent value. Well, at least, we thought that is more "natural" :-) The+
operator adds the belief in the beginning of the BB. Anyway, the operator+>
can be used to some belief in the end of the BB (see operators).I don't know if that reaso…