{ "info": { "author": "Florian Berger", "author_email": "fberger@florian-berger.de", "bugtrack_url": null, "classifiers": [], "description": "About\n-----\n\nStepSim is a lightweight step-based simulation module written in Python.\nIt can do simple real-time simulations of discrete systems. StepSim\nsupports step-by-step simulation or can run until a break condition\noccurs.\n\nSimulations are made up of *containers* and *converters*. A *container*\nstores a discrete amount of units of a certain type. A *converter* draws\nunits from one or more containers and delivers the result to another\ncontainer.\n\nStepSim does not even attempt to do any parallel processing. It\nprocesses converters round-robin in a fixed order.\n\nPrerequisites\n-------------\n\nPython (tested on Python 3.1.2 and 2.6.5)\n`http://www.python.org `_\n\nInstallation\n------------\n\nUnzip the file, then at the command line run\n\n::\n\n python setup.py install\n\nRunning Tests\n-------------\n\nOpen a shell / DOS window, navigate to the stepsim directory, and run\n\n::\n\n python -m doctest README\n\nDocumentation\n-------------\n\nTo read the API documentation, open a shell / DOS window, navigate to\nthe stepsim directory, and run\n\n::\n\n pydoc stepsim\n\nYou can create a HTML version using\n\n::\n\n pydoc -w stepsim\n\nExample\n-------\n\nFirst import the stepsim module:\n\n::\n\n >>> import stepsim\n\nTo get verbose output, activate logging to console:\n\n::\n\n >>> stepsim.log_to_stdout()\n >>> stepsim.loglevel(\"debug\")\n\nNow create some containers:\n\n::\n\n >>> cashbox = stepsim.Container(\"cashbox\", \"EUR\", 10)\n >>> storage = stepsim.Container(\"storage\", \"parts\")\n\nThen create a converter and set up the draw-deliver-ratio:\n\n::\n\n >>> buyer = stepsim.Converter(\"buyer\", 2, (cashbox, 3), (storage, 2))\n buyer: Adding source 'cashbox', drawing 3 EUR per step.\n\nFrom any list of converters, we can get a list of simulation milestones\nthat lead to an end condition (without explicitly creating a\nsimulation):\n\n::\n\n >>> stepsim.loglevel(\"info\")\n >>> stepsim.milestones(\"storage == 3\", [buyer])\n ------------------------------\n Milestones to achieve storage == 3:\n \n Milestone:\n 6 EUR in cashbox (10 delivered, 166.67%)\n total: 100.0%\n \n Milestone:\n 3.0 parts in storage (0 delivered, 0.0%)\n total: 0.0%\n ------------------------------\n [, ]\n\nLet's create a simulation:\n\n::\n\n >>> stepsim.loglevel(\"debug\")\n >>> s = stepsim.Simulation(buyer)\n Adding converter 'buyer' to simulation.\n Current containers: ['cashbox', 'storage']\n >>> s\n ], containers: [, ]>\n\nThe step() method is used to advance the simulation by one step:\n\n::\n\n >>> stepsim.loglevel(\"info\")\n >>> s.step()\n buyer: Drawing 3 EUR from cashbox.\n\nIt is also possible to check conditions inbetween. The simulation\ninstance offers a convenience method to do this using a string\ndescribing the condition:\n\n::\n\n >>> s.check(\"cashbox == 10\")\n False\n >>> s.check(\"cashbox != 10\")\n True\n >>> s.check(\"storage >= 0\")\n True\n\nIt is possible to evaluate how many steps it will take until a certain\ncondition is met:\n\n::\n\n >>> stepsim.be_quiet()\n >>> s.estimate_finish(\"storage == 2\", 100)\n 4\n\nBehind the scenes, this will run a copy of the simulation. A maximum\nstep value will prevent hanging on impossible conditions:\n\n::\n\n >>> s.estimate_finish(\"cashbox < 1\", 100)\n 100\n\nWhen you remove a converter, its last step will be reverted. Note that\nthis does not rewind the simulation step counter.\n\n::\n\n >>> stepsim.log_to_stdout()\n >>> stepsim.loglevel(\"debug\")\n >>> s.step()\n buyer: Conversion in progress, 2 steps left.\n Active Container of buyer: None\n >>> s.remove_converter(\"buyer\")\n reverting last draw from 'buyer'\n buyer: returning 3 EUR to cashbox.\n Removing converter 'buyer' from simulation.\n Current containers: []\n\nIt is possible to limit the number of units that a converter will\ndeliver.\n\n::\n\n >>> buyer.set_max_units(3)\n buyer: setting max_units to 3\n\nNote that this command will reset the counter of units delivered.\n\nBy stepping through the simulation, we can check when the converter\nstops.\n\n::\n\n >>> s.add_converter(buyer)\n Adding converter 'buyer' to simulation.\n Current containers: ['cashbox', 'storage']\n >>> s.step()\n buyer: Ready to draw resources\n buyer: Drawing 3 EUR from cashbox.\n cashbox has 7 EUR left now.\n buyer: Setting processing countdown to 2 steps\n Active Container of buyer: \n >>> s.step()\n buyer: Conversion in progress, 2 steps left.\n Active Container of buyer: None\n >>> s.step()\n buyer: Conversion in progress, 1 steps left.\n Active Container of buyer: None\n >>> s.step()\n buyer: Delivering 2 parts to storage.\n storage stock is 2 parts now.\n buyer has delivered 2 units since last reset.\n Active Container of buyer: \n >>> s.step()\n buyer: delivered 2 units and would deliver 2 next step, max units is 3, no action.\n >>> s.step()\n buyer: delivered 2 units and would deliver 2 next step, max units is 3, no action.\n\nWith the maximum number of units set to -1, the converter will deliver\nan unlimited number. This is the default.\n\n::\n\n >>> buyer.set_max_units(-1)\n buyer: setting max_units to -1\n\nIt is possible to temporarily change the speed of the converter by\ngiving the temporary steps value and a duration. This method will return\nTrue if the change was successful:\n\n::\n\n >>> buyer.set_temporary_steps(4, 4)\n buyer: setting steps = 4 for 4 steps\n buyer: setting remaining countdown to -1\n True\n >>> s.step()\n buyer: Ready to draw resources\n buyer: Drawing 3 EUR from cashbox.\n cashbox has 4 EUR left now.\n buyer: Setting processing countdown to 4 steps\n Active Container of buyer: \n >>> s.step()\n buyer: Conversion in progress, 4 steps left.\n Active Container of buyer: None\n >>> s.step()\n buyer: Conversion in progress, 3 steps left.\n Active Container of buyer: None\n >>> s.step()\n buyer: Conversion in progress, 2 steps left.\n Active Container of buyer: None\n >>> s.step()\n buyer: Conversion in progress, 1 steps left.\n Active Container of buyer: None\n >>> s.step()\n buyer: Delivering 2 parts to storage.\n storage stock is 4 parts now.\n restoring buyer.steps to 2\n buyer has delivered 2 units since last reset.\n Active Container of buyer: \n\nWe can run the simulation from the current state until an end condition\nis satisfied. In this case we let it run until the buyer can not buy any\nmore parts:\n\n::\n\n >>> s.run(lambda: not buyer.last_step_successful)\n Starting simulation.\n --- Step 15: -----------------------------------------------\n buyer: Ready to draw resources\n buyer: Drawing 3 EUR from cashbox.\n cashbox has 1 EUR left now.\n buyer: Setting processing countdown to 2 steps\n Active Container of buyer: \n --- Step 16: -----------------------------------------------\n buyer: Conversion in progress, 2 steps left.\n Active Container of buyer: None\n --- Step 17: -----------------------------------------------\n buyer: Conversion in progress, 1 steps left.\n Active Container of buyer: None\n --- Step 18: -----------------------------------------------\n buyer: Delivering 2 parts to storage.\n storage stock is 6 parts now.\n buyer has delivered 4 units since last reset.\n Active Container of buyer: \n --- Step 19: -----------------------------------------------\n buyer: Ready to draw resources\n buyer: Cannot draw 3 EUR from cashbox, only 1 left.\n Active Container of buyer: None\n --- Break condition met, simulation finished. ---------------\n Final state after 19 steps:\n \n \n\nYou can export the simulation graph in the DOT graph language (see\n`http://www.graphviz.org/ `_):\n\n::\n\n >>> s.save_dot(\"part_buyer.dot\")\n Writing DOT file.\n digraph {\n graph [size=5] ;\n node [fontsize=10, fontname=\"Bitstream Vera Sans\"] ;\n \"cashbox\" [shape=box];\n \"cashbox\" -> \"buyer\" ;\n \"storage\" [shape=box];\n \"buyer\" -> \"storage\" ;\n }\n \n\nClean up:\n\n::\n\n >>> import os\n >>> os.remove(\"part_buyer.dot\")\n\nThe file 'making\\_cakes.py' shows a more elaborate example. It is\nincluded in the ZIP archive and will be installed in\n'share/doc/stepsim/examples'.\n\nLicense\n-------\n\nStepSim is licensed under the GPL. See the file COPYING for details.\n\nLinks\n-----\n\nStepSim on Launchpad: https://launchpad.net/stepsim\n\nStepSim on ohloh: https://www.ohloh.net/p/stepsim\n\nStepSim on Freecode: http://freecode.com/projects/stepsim\n\nStepSim in the Python Package Index: http://pypi.python.org/pypi/stepsim\n\nAuthor\n------\n\nFlorian Berger", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://florian-berger.de/en/software/stepsim", "keywords": null, "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "stepsim", "package_url": "https://pypi.org/project/stepsim/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/stepsim/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://florian-berger.de/en/software/stepsim" }, "release_url": "https://pypi.org/project/stepsim/0.5.7/", "requires_dist": null, "requires_python": null, "summary": "StepSim - Python Step-based Simulation Package", "version": "0.5.7" }, "last_serial": 783215, "releases": { "0.1.0": [], "0.2.0": [], "0.3.0": [], "0.3.1": [], "0.3.2": [], "0.4.0": [], "0.5.0": [], "0.5.1": [], "0.5.2": [], "0.5.3": [], "0.5.4": [], "0.5.5": [], "0.5.6": [], "0.5.7": [], "0.5.8a": [] }, "urls": [] }