ciwpython / ciw Goto Github PK
View Code? Open in Web Editor NEWCiw is a simulation library for open queueing networks.
Home Page: http://ciw.readthedocs.io
License: MIT License
Ciw is a simulation library for open queueing networks.
Home Page: http://ciw.readthedocs.io
License: MIT License
can be called in init, can then clean up a lot of error-checking stuff.
Works similar to the Baulking function, takes in the current time, and then returns a random sample.
should be able to pass name of parameters file in.
True pre-emptive vacations, with holder for servers.
@drvinceknight
(moving @sluenenglish 's issue from ASQ)
Each class can have priority associated with it.
Essentially a separate queue for each priority level at each service centre
I imagine a new key in the parameters dictionary:
'Balking_functions':[function_n1, function_n2]
where the functions take in N (number of customers in the queue currently) return a probability of balking.
(moving @drvinceknight 's issue from ASQ)
More realistic
Something like this.
Rather than simply write them.
Then can simply write the records that are already found to file.
(moving @sluenenglish 's issue from ASQ)
I have no clue at the moment how this would work. Something about ghosts ๐ป
_BIG PROJECT_
A submodule that provides functions / classes and methods that operate on the list of records obtained using Q.get_all_records().
Some essential features::
Also maybe include some time series analysis? All with the option of adding a warmup period.
_MUCH BIGGER PROJECT_
Also include ability to take in multiple lists of records (in order to analyse multiple trials).
e.g.
mydist = [3.0, 3.0, 3.0, 3.0, 3.5, 3.5, 3.6, 3.7, 3.7]
{'Service_distributions': [['Empirical', mydist]]}
Problematic parameters:
params = {
'Arrival_distributions': {'Class 0': [['Exponential', 1.0],
['Exponential', 1.0],
['Exponential', 1.0],
['Exponential', 1.0]],
'Class 1': ['NoArrivals',
'NoArrivals',
'NoArrivals',
'NoArrivals']},
'Service_distributions': {'Class 0': [['Uniform', 0.6, 1.1],
['Uniform', 0.6, 1.1],
['Uniform', 0.6, 1.1],
['Uniform', 0.6, 1.1]],
'Class 1': [['Uniform', 0.6, 1.1],
['Uniform', 0.6, 1.1],
['Uniform', 0.6, 1.1],
['Uniform', 0.6, 1.1]]},
'Number_of_servers': [1, 1, 1, 1],
'Transition_matrices': {'Class 0': [[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0],
[1.0, 0.0, 0.0, 0.0]],
'Class 1': [[0.0, 0.3, 0.0, 0.0],
[0.0, 0.0, 0.3, 0.0],
[0.0, 0.0, 0.0, 0.3],
[0.3, 0.0, 0.0, 0.0]]},
'Priority_classes': {'Class 1': 0,
'Class 0': 1},
'Class_change_matrices': {'Node 1': [[0.0, 1.0], [0.0, 1.0]],
'Node 2': [[0.0, 1.0], [0.0, 1.0]],
'Node 3': [[0.0, 1.0], [0.0, 1.0]],
'Node 4': [[0.0, 1.0], [0.0, 1.0]]}
}
Problem: Once changed class, customers in wrong priority queue.
Solution: Need a prev_priority_class OR current_priority_class or something in addition.
May improve performance... not sure.
Suggestion by @sluenenglish
An extremely basic one for the complete beginner.
For data validation.
When giving a parameter dictionary to Ciw it doesn't explain that a Transition_matrix should be given
This would tap in to the networkx code and produce a graphics object:
So something like:
>>> Q = asq.Simulation(params_dict)
>>> p = Q.plot() # This would return a networkx/matplotlib plot
>>> p.show()
>>> p.save() # etc...
Just a nice quick way to get a visualisation of the network? As it's already networkx underneath this would be easy enough to implement (I'd like to take this one). What do you think?
When running without installing from the base get:
======================================================================
ERROR: test_simulate_until_deadlock_method (asq.tests.test_simulation.TestSimulation)
----------------------------------------------------------------------
Traceback (most recent call last):
File "asq/tests/test_simulation.py", line 85, in test_simulate_until_deadlock_method
Q = asq.Simulation(asq.load_parameters('tests/datafortesting/logs_test_for_deadlock_sim/'))
File "asq/import_params.py", line 16, in load_parameters
parameter_file = open(parameter_file_name, 'r')
IOError: [Errno 2] No such file or directory: '/Users/vince/src/Ciw/tests/datafortesting/logs_test_for_deadlock_sim/parameters.yml'
======================================================================
ERROR: test_simulate_until_max_time_method (asq.tests.test_simulation.TestSimulation)
----------------------------------------------------------------------
Traceback (most recent call last):
File "asq/tests/test_simulation.py", line 70, in test_simulate_until_max_time_method
Q = asq.Simulation(asq.load_parameters('tests/datafortesting/logs_test_for_simulation/'))
File "asq/import_params.py", line 16, in load_parameters
parameter_file = open(parameter_file_name, 'r')
IOError: [Errno 2] No such file or directory: '/Users/vince/src/Ciw/tests/datafortesting/logs_test_for_simulation/parameters.yml'
----------------------------------------------------------------------
Ran 26 tests in 0.003s
FAILED (errors=18)
In other words the tests fail because of being able to find the yml
files.
Add option to sample from phase-type distributions.
Server schedules crash if at any point 0 servers are on duty.
Option to pass Ciw a function to sample from to obtain service / inter-arrival times
Getting:
error: The 'hypothesis' distribution was not found and is required by Ciw
Currently needs a dictionary, should be able to just pass parameters (also).
Needs also to have a bunch of defaults so that can create simple models easily.
Tutorial on how to make customers have a behaviour.
Therefore can recreate other deadlock detection methods, and compare.
Works exactly like Service_distributions
This tests that the library runs on Windows.
Hi @drvinceknight would like your opinion on this.
We currently (on restructure-inputs branch) have the following functions:
Network_From_Dictionary
Network_From_File
which both return a Network object. I don't like the names of these things.
I propose the following change:
Network_From_Dictionary -> create_network_from_dictionary
Network_From_File -> create_network_from_yml_file
and then have another main function that might look like this::
def create_network(input):
if input is yml:
create_network_from_yml_file(input)
if input is dictionary:
create_network_from_dictionary(input)
And it'll be this create_network function that most users will use.
Putting this here to keep track for our next sprint :) ๐ฅ ๐ฃ ๐ฅ ๐
Ciw uses two random number streams, one from the random module and one from numpy.random module. Therefore in order to replicate results users need to:
from random import seed
from numpy import random
seed(5)
random.seed(5)
I would rather this be wrapped up in ciw, so user's simply need to:
ciw.set_seed(5)
I already have this defined and using it in the test suite only. @drvinceknight you mentioned you didn't like this idea, but can't remember why? Any thoughts?
That way data records are ordered sensibly.
Also add and 'origin' entry.
Use tqdm to implement optional progress bar. (basically just merge in #44 from @drvinceknight once we figure out how to test it.)
Instead of parameters dictionary having:
Detect_deadlock: 'StateDigraph'
should just do
Q.simulate_until_deadlock(deadlock_detection='StateDigraph')
Network object instead of dictionary
have create_network_from_dictionary() method, create_network_from_yml() method, etc.
Instead of a bunch of boilerplate for a hypothesis test you could simple have:
@given(sim=simulations(max_nodes=2))
def test_...
Working on this on Axelrod at the moment it's actually pretty straightforward, here's how to build a decorator that creates a matches
strategy:
from hypothesis.strategies import composite, integers, tuples, sampled_from, floats
import axelrod as axl
@composite
def matches(draw, players=axl.strategies, min_turns=1, max_turns=200, noise=False):
strategies = draw(tuples(sampled_from(players), sampled_from(players)))
players = [s() for s in strategies]
turns = draw(integers(min_value=min_turns, max_value=max_turns))
if noise:
noise = draw(floats(min_value=0.05, max_value=1))
else:
noise = 0
match = axl.Match(players, turns=turns, noise=noise)
return match
print(matches().example())
print(matches().example().play())
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.