如何为Jason中的另一个业务代表发送规则?

时间:2019-04-07 15:45:38

标签: agent multi-agent

Jason附带了一个演示,该演示使用高性能的“ tellRule”发送规则,但是在我的测试中,它不起作用。我试图这样发送给自我代理:

.send(self,tellRule, [{a :- b & c}])

结果是:

Command .send(self,tellRule, [{a :- b & c}]): included for execution
Communication error -- no_applicable: Found a goal for which there is no applicable plan:+!kqml_received(self,tellRule,[{ a :- (b & c)}],mid511)

1 个答案:

答案 0 :(得分:2)

实际上,Jason默认情况下没有定义“ tellRule”性能。实际上,所提到的demo在教导如何添加KQML执行器。因此,对于您的代码工作,您应该首先创建“ tellRule”,如下所示:

.send(self, tellHow, {+!kqml_received(A,tellRule,Rules,_) <- 
    .print("Received rule(s) ",Rules, " from ",A); 
    for ( .member(R, Rules) ) 
    {+R[source(A)];}  
    .relevant_rules(_,LR);       
    .print("Rules: ",LR)}).

之后,您可以运行命令:

.send(self,tellRule, [{a :- b & c}]).

顺便说一句,相同的想法可用于创建类似“ untellRule”的内容:

.send(self, tellHow, {+!kqml_received(A,untellRule,Rules,_) <-      
    .print("Removing rule(s) ",Rules, " from ",A);      
    for ( .member(R, Rules) )      
    {-R}}).
.send(self,untellRule,[{a :- b & c}]).