simpy

Simpy - accessing multiple resources

给你一囗甜甜゛ 提交于 2021-02-11 08:42:42
问题 I am starting to learn SimPy DES framework.I want to implement a simulation in which requests arrive at different times to the server. There are different types of requests, each one of them loads server with specific memory/cpu load. So, for instance, there might be requests that typically use 10% of CPU and 100MB of mem, while other requests might need 15% of CPU and 150MB of RAM (those are just example numbers). Server has its own characteristics and some ammount of memory. If a request

How can I have a process wait for multiple resources?

时间秒杀一切 提交于 2021-02-07 19:53:56
问题 I am currently using SimPy to model and simulate a server process and I would like this process to execute a different action depending on where it receives this message from. The SimPy documentation shows how to wait for multiple events: Ex: yield event1 | event2 However I am currently trying to wait for a resource to become available from multiple Stores. The scenario is as follows: Server S is waiting for messages that can come from various channels. Each of these channels may have

How can I have a process wait for multiple resources?

て烟熏妆下的殇ゞ 提交于 2021-02-07 19:53:26
问题 I am currently using SimPy to model and simulate a server process and I would like this process to execute a different action depending on where it receives this message from. The SimPy documentation shows how to wait for multiple events: Ex: yield event1 | event2 However I am currently trying to wait for a resource to become available from multiple Stores. The scenario is as follows: Server S is waiting for messages that can come from various channels. Each of these channels may have

Simpy: Possible to do priority requests with filterstore?

試著忘記壹切 提交于 2021-01-29 06:00:40
问题 I have a get request for one of two objects inside a filterstore that looks like this: req = yield depot.get(lambda req: req['id'] == 's38' or 's39') I want to make this particular request a priority so that it queue jumps all other requests. Is this possible? 回答1: Yes, this is possible if you create a sub-class of FilterStore similarly to PriorityQueue. 回答2: Here is an example that worked for me import simpy import bisect class PriorityFilterStore(simpy.FilterStore): def _do_put(self, event)

将PostgreSQL数据库复制到另一台服务器

孤街醉人 提交于 2020-02-25 19:58:05
我正在将生产PostgreSQL数据库复制到开发服务器。 什么是最快,最简单的方法? #1楼 pg_dump the_db_name > the_backup.sql 然后将备份复制到您的开发服务器,并使用以下命令进行还原: psql the_new_dev_db < the_backup.sql #2楼 使用 pg_dump ,然后使用 psql 或 pg_restore- 取决于是否为pg_dump选择-Fp或-Fc选项。 用法示例: ssh production pg_dump -C -Fp -f dump.sql -U postgres some_database_name scp dump.sql development: rm dump.sql ssh development psql -U postgres -f dump.sql #3楼 您无需创建中间文件。 你可以做 pg_dump -C -h localhost -U localuser dbname | psql -h remotehost -U remoteuser dbname 要么 pg_dump -C -h remotehost -U remoteuser dbname | psql -h localhost -U localuser dbname 使用 psql 或 pg_dump 连接到远程主机。

What is the easiest way to copy a class instance that contains SimPy processes?

天涯浪子 提交于 2020-01-24 20:14:45
问题 I'm trying to create a copy of a class instance that I can simulate without affecting the original instance of the class. I've tried using copy.copy , but I run into this problem: system.simulate(until=100) print(system.env.now) # prints 100 copy_of_system = copy.copy(system) copy_of_system.simulate(until=200) print(copy_of_system.env.now) # prints 200 print(system.env.now) # prints 200, but should print 100 When I use copy.deepcopy I get TypeError: can't pickle generator objects . Is there

Interrelated resources

邮差的信 提交于 2019-12-12 04:53:13
问题 I am modelling a train station(using simpy, with python 2.7) where there are some incoming routes, some outgoing routes and some platforms. Now, when one of these resources is occupied, I can't assign a train to certain other resources. Now when a train engages a route - i.e. traverses it - some other routes in the stations area become unusable for some time. If I were to model a route as a resource, then a request yielded at that resource will affect/engage other resources as well. Is there

how can I set priority on simpy process callbacks?

一曲冷凌霜 提交于 2019-12-11 11:48:52
问题 The default order in which processes are triggered in simpy seems to rely on the order they were created? I want to expressly rank processes so they are triggered in a precise order, regardless of when they were created. If you need an example, here's a simulation with 3 processes: eat food, refill plate, remove plate. the eat() process triggers the plateEmpty event, expecting it to be refilled. But if the removePlate() process happens before refillPlate() , then refill can't happen. I want

Simpy Store Batch Processing

限于喜欢 提交于 2019-12-08 07:16:34
问题 I'm trying to create a producer/consumer simulation where the consumer processes items in batches. The problem is that the Store.get() function removes items from the Store as soon as it is called, but I need it to wait until I've called yield: import simpy def producer(env, Q): item = 0 while True: yield Q.put(item) print('Submit item:%d'%item) item += 1 def consumer(env, Q): while True: yield env.timeout(20) events = [Q.get() for i in range(4)] items = yield env.all_of(events) print([items

Python, SimPy: Using yield inside functions

有些话、适合烂在心里 提交于 2019-12-08 03:56:45
问题 Helo, I'm building a relatively complex Discrete Event Simulation Model in SimPy. When I try to put my yield statements inside functions, my program doesn't seem to work. Below shows an example. import SimPy.SimulationTrace as Sim import random ## Model components ## class Customer(Sim.Process): def visit(self): yield Sim.hold, self, 2.0 if random.random()<0.5: self.holdLong() else: self.holdShort() def holdLong(self): yield Sim.hold, self, 1.0 # more yeild statements to follow def holdShort