在java中使用优先级队列进行仿真 [英] Simulation in java using priority queues

查看:170
本文介绍了在java中使用优先级队列进行仿真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被要求使用优先级队列在java中使用一个计数器来模拟一个商店的事件。在某人被服务的时候,如果有人在这段时间内到达,我会增加队列中的人数。我猜想我必须使用比较器,但到目前为止,我只能使用比较器进行排序,而不是排队DE-queuing events。

I've been asked to simulate the events for a store with one counter in java using a priority queue. Where a person is being served and if someone arrives during this time i increment the number of people in the queue.I figured out that I have to use Comparator but so far it seems like i can only use comparator for sorting and not for queuing and DE-queuing events.

推荐答案

如果您使用离散事件建模视角,则使用优先级队列来计划驱动系统的事件。您可以在Java实现中找到有关如何执行此操作的教程文章对于具有指数间隔和服务时间的单个服务器队列,在冬季模拟会议论文档案中。

If you are using a discrete event modeling perspective, you use a priority queue to schedule the sequence of events that drive the system. You can find a tutorial paper on how to do this, along with a Java implementation for a single server queue with exponential interarrival and service times, in the Winter Simulation Conference paper archives.

这篇关于在java中使用优先级队列进行仿真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆