离散事件模拟问题 [英] discrete event simulation question

查看:88
本文介绍了离散事件模拟问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在开发一个项目,需要在C中使用链接列表实现离散的

事件模拟。如果有人可以提供有关如何处理DES的一些消息来源,我将不胜感激。请

帮帮我。


谢谢,

杰克

Hi guys,
I am working on a project which requires an implementation of discrete
event simulation in C using linked lists. I would greatly appreciate if
someone could provide with some sources on how to approach DES. Please
help me out.

Thanks,
Jack

推荐答案

jack写道:
大家好,

我正在研究一个需要实施离散
事件的项目使用链表在C中进行模拟。如果某人可以提供有关如何处理DES的一些消息来源,我将不胜感激。请
帮帮我。
Hi guys,
I am working on a project which requires an implementation of discrete
event simulation in C using linked lists. I would greatly appreciate if
someone could provide with some sources on how to approach DES. Please
help me out.




你没有C问题(但是 - 一旦开始就会

实施,你可能有C问题),但问题是关于算法和/或数据结构的问题。


< off-topic>


离散事件模拟的基本形式是

在模拟的

中有不同时间安排的事件队列未来。你从队列中移除最早的那些事件,推进全球时钟。到该活动的预定时间

,并执行

事件所需的任何特定事件处理。此处理可能会将新事件添加到

队列(计划时间不早于时间,

课程),可能会取消尚未发生的预定事件,

并且可能会改变未来某些事件的预定时间(

可视为取消加上添加新事件,如果

表示'很方便)。事件处理还以任何适当的方式修改模拟系统的状态,

甚至可能导致模拟终止。


所以:模拟框架的中央数据结构

是一个优先级队列,按事件的预定时间排序。

其他数据结构通常是问题 - 特定的,保持

跟踪汽车或介子或任何小玩意儿

在模拟系统中循环。有许多*数据

结构可以实现这些功能;你需要选择一个

少,然后(如果感到困惑)回到这里,问题是你在为他们编写代码时遇到的问题



(在我的简短和不光彩的职业生涯中,作为讲师在

数学中,我曾经教过这些东西。当时,它是

用了0.5学期小时的积分;现在,我理解

只是学习编程语言或学习如何操作电子表格获得更多的收益.O tempora !O mores!)


< / off-topic>


-

Eric Sosman
es*****@acm-dot-org.inva 盖子


非常感谢Eric的努力。我将开始研究

算法,并回答一些C问题。


杰克

Thanks a lot Eric for your effort. I shall start working on the
algorithm and get back to you with some C questions.

Jack





我一直在使用链接的

列表(LL)处理离散事件模拟问题。该算法如下所示:


struct linkedlist

{

int event;

int queue ; //事件发生的FIFO

双计时器; // LL中每个节点中嵌入的时间值

LL已排序。

};


计时器field具有基于其设置特定

节点的时间的时间。节点的计时器值指示节点何时读取
并执行相应的事件。事件循环看起来像这样:
struct linkedlist * ptr;

ptr =(struct linkedlist *)head; (指向LL的开头)

while(1)

{

ptr = ptr-> next(推进链表)

执行ptr->事件在ptr->队列

从gettimeval获取时间(global_time)

添加执行时间一个事件到全球时间

用另一个事件创建新节点,事件

行为的队列和时间值。

添加基于时间的链接列表的新节点(列表是根据增加的时间订购的


从gettimeval获取时间(global_time)

sleep(ptr-> time - global_time)

}


现在,这是我们在事件调度算法中安排时间的方式吗?
如果不是,我们该怎么做?如果你能提供给我带来一些文件的话,我会非常高兴.....在这个东西上,即时间安排......我是

问这个问题。 ..我正在获得(ptr-> time - global_time)

..这意味着该活动花费的时间超过了需要的时间

take 。但是,那么..我们如何预先设定该事件的时间,并将
存储在节点中?有关此...的任何信息都是受欢迎的。


杰克

Hi,

I''ve been working on an Discrete event simulation problem using linked
lists(LL). The algorithm looks as follows:

struct linkedlist
{
int event;
int queue; //FIFO on which the event acts
double timer; // time value embedded in each node in the LL on
which the LL is sorted.
};

The timer field has the time based on which, the time for a particular
node is set. The timer value for a node indicates when the node is to
be read and the corresponding event executed. The event loop looks
something like this:

struct linkedlist *ptr;
ptr = (struct linkedlist *)head; (points to the beginning of LL)
while(1)
{
ptr = ptr->next ( advance the linked list)
execute ptr->event on ptr->queue
get time from gettimeval (global_time)
add the time taken for execution of one event to the global time
create new node with another event, the queue on which the event
acts and the time value.
Add the new node to the linked list based on time (The list is
ordered based on increasing time)
get time from gettimeval (global_time)
sleep(ptr->time - global_time)
}

Now, is this the way we schedule time in a event scheduling algorithm?
If not how do we do it? I would be more than glad if you can provide me
with some documentation.....on this stuff i.e., time scheduling..I am
asking this coz...I am getting -ve vlaues of (ptr->time - global_time)
.. This means that the event is taking more time than its required to
take. But, then..how do we set the time for that event before hand and
store it in the node? Any info on this...is welcome.

Jack


这篇关于离散事件模拟问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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