云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 关于多Agent系统的研究

关于多Agent系统的研究

  • 62 次阅读
  • 3 次下载
  • 2025/6/4 18:06:03

@AgentCreated publicvoid init() {

this.wordTable = new HashMap(); // add some examples of word pairs wordTable.put(\, \牛奶\);

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

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

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

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

publicvoid translateEngCh() { // Here we only test one example

System.out.println(\is \

+ wordTable.get(\)); } @AgentBody

publicvoid body(){

translateAgent.adoptPlan(\); }

}

作为方法使用是,在Agent的body方法中,要使用Plan方法的名字就可以。框架提供了自动检索的方法。

3.4 使用其他Plan的方法

除了已经学习到的使用方法外,下面介绍其他三个Plan的生命周期方法。 1. @PlanPassed Plan顺利执行的 2. @PlanFailed Plan执行失败

3. @PlanAborted Plan被取消,比如当Plan的上下文变得不可用的时候。

演示这个例子的时候,需要用到try-catch块,完成adoptPlan()的调用和等待Plan被执行完成的调用(在调用完成以后,使用get())。get() 是基于future的异步转同步的方法。

package a1;

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

import jadex.bdiv3.BDIAgent;

import jadex.bdiv3.annotation.Plan;

import jadex.bdiv3.annotation.PlanAborted; import jadex.bdiv3.annotation.PlanBody; import jadex.bdiv3.annotation.PlanFailed; import jadex.bdiv3.annotation.PlanPassed; import jadex.micro.annotation.Agent; import jadex.micro.annotation.AgentBody; import jadex.micro.annotation.Description;

@Agent

@Description(\) // @Plans(@Plan(body=@Body(TranslatePlan.class))) publicclassTranslateEngChBDI { @Agent

protected BDIAgent translateAgent; @Plan

publicclassTranslateEngChPlan {

protected Map wordTable;

public TranslateEngChPlan() {

this.wordTable = new HashMap(); // add some examples of word pairs wordTable.put(\, \牛奶\);

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

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

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

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

@PlanBody

publicvoid translateEngCh() { // Here we only test one example

System.out.println(\se is \

+ wordTable.get(\)); }

@PlanPassed

publicvoid passed(){

System.out.println(\\); } @PlanAborted

publicvoid aborted(){

System.out.println(\); } @PlanFailed

publicvoid failed(){

System.out.println(\); } }

@AgentBody

publicvoid body() { try {

搜索更多关于: 关于多Agent系统的研究 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

@AgentCreated publicvoid init() { this.wordTable = new HashMap(); // add some examples of word pairs wordTable.put(\, \牛奶\); wordTable.put(\, \香蕉\); wordTable.put(\, \学校\); wordTable.put(\, \老师\); wordTable.put(\, \科学\); } @Plan publicvoid translateEngCh() { // Here we only test one example

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com