简体   繁体   English

智能代理如何与数据库一起工作?

[英]How do intelligent Agents work with data base?

I am working with JADE framework and I want to know is there any way for intelligent agents to work with some kind of data base, where they can read from it and write some information?..我正在使用 JADE 框架,我想知道智能代理有没有办法使用某种数据库,他们可以从中读取并写入一些信息?..

I tried to make a connection between excel (using jxl) and my project but there is a problem: below is the code for writing in excel file:我试图在excel(使用jxl)和我的项目之间建立连接,但有一个问题:下面是在excel文件中写入的代码:

public static void write(String[] args) throws Exception {
    // TODO code application logic here
    File f = new File("C:\\Users\\Mastisa\\Desktop\\Master.xls");
    WritableWorkbook  Master = Workbook.createWorkbook(f);
    WritableSheet History_Table = Master.createSheet("History_Table", 0);

    Label L00 = new Label (0,0,"RUN#");

    History_Table.addCell(L00);


    Master.write();

    System.out.println("finished...");

    Master.close();
}

} }

but I want agents to do something like this:但我希望代理做这样的事情:

Database D;
D.add(myAgent.getLocalName);

but it is not possible as jxl doesn't provide functions for working with agents.但这是不可能的,因为 jxl 不提供与代理一起工作的功能。 and it looks like that everything must be written in that excel file manually.... but it is not what I want.. I want agents comfortably read and write...看起来所有内容都必须手动写入该excel文件中....但这不是我想要的..我希望代理可以轻松地读写...

Is there any other way?有没有其他办法?

Yes basically when you create a JADE agent, you can add behaviors to those Agents, There are several types of behaviors, you should be choosing them based on your requirement.是的,基本上当您创建 JADE 代理时,您可以向这些代理添加行为,行为有多种类型,您应该根据需要选择它们。 You can find the list of behaviors here您可以在此处找到行为列表

For an Example,例如,

public class MyAgent extends Agent
{
    @Override
    protected void setup()
    {
         addBehaviour( new InformBehaviour() );
    }
    private class InformBehaviour extends CyclicBehaviour
    {
        //dostuff
    }
}

So basic idea is you need to do all these inside a behavior of a agent.所以基本的想法是你需要在代理的行为中完成所有这些。

Make sure you choose right behaviour which suites your requirement.确保选择适合您要求的正确行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM