Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] NAR answering with precondition_beliefs about "do nothing operator" #286

Open
ARCJ137442 opened this issue Oct 1, 2024 · 2 comments

Comments

@ARCJ137442
Copy link
Contributor

Background Information

I noticed that ONA has a concept of operations called "do nothing operator", which is related to NAL-8 and can be seen at:

//assumption of failure, also works for "do nothing operator"
void Decision_Anticipate(int operationID, Term op_term, long currentTime);

In normal code logic, the integer "operator id" corresponding to this "do nothing operator" is 0, and in many places "is do-nothing operator or not" is distinguished by op or !op:

int op_id = Memory_getOperationID(&postcondition.term);
Term op_term = Narsese_getOperationTerm(&postcondition.term);
conceptProcessID2++;
for(int j=0; !op_id && j<occurrenceTimeIndex.itemsAmount; j++) //search for op
{

Some code refers to "traversing all real operators" by explicitly traversing 1 through OPERATIONS_MAX:

for(int opi=1; opi<=OPERATIONS_MAX && operations[opi-1].term.atoms[0] != 0; opi++)

The Main Issue

The main issue happens in the following code:

for(int op_k = 0; op_k<OPERATIONS_MAX; op_k++)
{
for(int j=0; j<c->precondition_beliefs[op_k].itemsAmount; j++)
{
Implication *imp = &c->precondition_beliefs[op_k].array[j];
if(!Variable_Unify2(unused, &term, &imp->term, true).success)
{
continue;
}
if(queryCommand && Truth_Expectation(imp->truth) > answerTruthExpThreshold)
{
NAR_PrintAnswer(imp->stamp, imp->term, imp->truth, answerOccurrenceTime, imp->creationTime);
}
if(Truth_Expectation(imp->truth) >= Truth_Expectation(best_truth))
{
best_stamp = imp->stamp;
best_truth = imp->truth;
best_term = imp->term;
answerCreationTime = imp->creationTime;
}
}
}

Notice the int op_k = 0; op_k<OPERATIONS_MAX in the code, which actually means "traverse the previous operator from the do-nothing operator to the last operator"
when the field precondition_beliefs in struct Concept is defined to allow "do nothing operator" in index 0:

Table precondition_beliefs[OPERATIONS_MAX+1];

So,
Do we need to prohibit traversing "do nothing operator" here?
Like the following:

for(int op_k = 1; op_k<=OPERATIONS_MAX; op_k++)

Or do you want to allow all operations including "do nothing operator"?

for(int op_k = 0; op_k<=OPERATIONS_MAX; op_k++)

(like above)

Or,
Do we need to make a clear distinction between "real operators" and "do nothing operator" and "no operation id found"?

@patham9
Copy link
Member

patham9 commented Oct 10, 2024

The code does the right thing there, the code piece you reference searches the implication tables for a link which unifies with the users's question. But I agree this index trickery sucks and can potentially be improved at some point. :)

@patham9
Copy link
Member

patham9 commented Oct 10, 2024

Also: your observation that index 0 is reserved for temporal implications without operation (which is like a do-nothing operator almost) is valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants