资源规范和代理跟踪 [英] RESOURCE specifications and tracking of agent
问题描述
我需要解决一个问题,由于我缺乏 Java 培训,我无法解决.编写什么代码来跟踪获取资源的代理?让我更好地解释一下......我有一系列房间,每个进入结构的代理都会占用一个他在整个逗留期间保留的房间,我想实时查看哪些房间被占用以及被哪个代理占用.我怎样才能做到这一点?谢谢
I need to solve a problem, which due to my lack of Java training I can't solve. What is the code to write to trace the agent who took a resource? Let me explain better...I have a series of rooms, each agent who enters the structure takes a room which he keeps for his entire stay, and I would like to see in real time, which rooms are occupied and by which agent. How can I do this? Thank you
推荐答案
您可以在 seize 块中使用变量简单地将占用的资源保存到代理,反之亦然.
You can simply save the resource seized to the agent and vice versa using variables, in the seize block.
这是一个简单的例子
我有一个 Person 和一个 RoomResource 代理,每个代理都有一个对方类型的变量.
I have a Person and a RoomResource agent, each with a variable of the other's type.
在这个非常简单的流程图中,有一个创建人员的源,一个连接到 RoomResource 代理资源池的捕获,资源单元位于一个名为 roomResource
的群体中.
In this very simple flow chart with a source that creates persons, and a seize connected to a resource pool of RoomResource agents, and the resource units live in a population called roomResource
.
您只需在 seize 块中指定以下内容
You simply specify the following in the seize block
agent.room = unit;
unit.agent = agent;
你会看到agent代表block中的agent,unit代表从资源池中获取的unit
You will see that agent represents the agent in the block, and unit represents the unit being seized from the resource pool
现在您可以直观地将其用于您的代理
Now you can visually use this for your agents
现在你可以通过访问变量来查看Person占用了哪个房间以及每个人使用了哪个房间
Now you can see what Person occupies which room and which room is used for each person by accessing the variable
这篇关于资源规范和代理跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!