第一范文网 - 专业文章范例文档资料分享平台

关于多Agent系统的研究

来源:用户分享 时间:2025/5/20 19:19:42 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

@Plan(trigger = @Trigger(goals = TranslateGoal.class)) public String translatePlan(String ewordString) { return wordTable.get(ewordString); } }

然后创建一个BDI文件,直接把capability嵌入到Agent的一个成员使用。非常简单方便。

package a2;

import jadex.bdiv3.BDIAgent;

import jadex.bdiv3.annotation.Capability; import jadex.micro.annotation.Agent; import jadex.micro.annotation.AgentBody; import jadex.micro.annotation.Description; @Agent

@Description(\) publicclassTranslateBDI { @Agent

protected BDIAgent translateAgent;

@Capability

protected TranslateCapa capa = new TranslateCapa();

@AgentBody

publicvoidbody(){

String eword = \;

String cnword = (String) translateAgent.dispatchTopLevelGoal(capa.new TranslateGoal(eword)).get();

System.out.println(\翻译完成:\ + eword + \ + cnword); } }

总结一下:capability就是一个模块,大家都可以调用来使用。好处减少了开发的资源浪费。但是需要很好的设计基础,才可以使用capability。

本篇主要是讲解一下,关于两个或者多个Agent之间,是如何进行通信的。

1. 简单介绍

对于Agent之间的交互是很有必要得。当今社会没有任何一件事情可以让单独的个体来完成。生活在一个community环境里,就需要相互之间的信息传递。那么在Jadex中,交互是一种服务,service。而这种service是被定义为接口类型的。具体的交互实现是需要单独来完成。单单理解起来可能还是比较困难的,可以看一下多代理系统的BDI介绍。

2. 实例讲解

这里主要实现的是两个Agent之间的交互。我们定义一个用户Agent,和一个翻译Agent。用户Agent发出一个翻译请求之后,翻译Agent就会自动查找自己的词典库,知道找到相应的翻译结果之后,返回给用户Agent,进而实现两个Agent之间的交互。 首先是接口,长这个样:

package a3;

import jadex.commons.future.IFuture;

publicinterfaceITranslateServ {

public IFuturetranslateEnglishChinese(String ewordString); }

其次是翻译Agent,长成这个样:

package a3;

import java.util.HashMap; import java.util.Map;

import jadex.bdiv3.BDIAgent;

import jadex.bridge.service.annotation.Service; import jadex.commons.future.Future; import jadex.commons.future.IFuture; import jadex.micro.annotation.Agent;

import jadex.micro.annotation.AgentCreated; import jadex.micro.annotation.Description; import jadex.micro.annotation.ProvidedService; import jadex.micro.annotation.ProvidedServices; @Agent

@Description(\) @Service

@ProvidedServices(@ProvidedService(type = ITranslateServ.class))

publicclassTranslateBDIimplementsITranslateServ { @Agent

protected BDIAgent translateAgent;

protected Map wordTable;

@AgentCreated publicvoidinit() {

this.wordTable = new HashMap(); wordTable.put(\, \牛奶\);

wordTable.put(\, \香蕉\);

wordTable.put(\, \学校\);

wordTable.put(\, \老师\);

wordTable.put(\, \科学\); }

publicTranslateBDI() { }

@Override

搜索更多关于: 关于多Agent系统的研究 的文档
关于多Agent系统的研究.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1lk0k3qn733pebe0ilea_11.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top