{ "info": { "author": "Michael Hoffman", "author_email": "MichaelHoffman@psu.edu", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# maintsim\n\n`maintsim` can be used to model a discrete manufacturing system where components degrade over time and receive maintenance. Users can define the configuration and parameters of the system, as well as the maintenance policy to be carried out. It is built on the `SimPy` discrete-event simulation package.\n\n## Installing maintsim\n\n`pip install maintsim`\n\n## Using this package\n\n### Requirements\n\nmaintsim relies on the following packages in addition to Python 3.6+:\n\n- [SimPy](https://simpy.readthedocs.io/en/latest/) version 3.0.11\n- [pandas](https://pandas.pydata.org/) version >= 0.23.4\n- [SciPy](https://www.scipy.org) version >= 1.1.0 (if specifying random repair times)\n\n### Setting up a manufacturing system\n\nThe workflow begins by creating a `System` object that is defined by the following parameters:\n\n#### Configuration parameters\n- `process_times` - a list of process times for each machine in a serial line.\n- `interarrival_time` - the time between part arrivals to the first machine in the system. The default is 1, which ensures the first machine is never starved.\n- `buffer_sizes` - a list of buffer sizes for each machine, or an integer value for the buffer size of all machines. Default is 1. For n machines there are n-1 buffers.\n\n#### Failure parameters\n- `failure_mode` - currently either `'degradation'` or `None`. Each machine is subject to the same mode of degradation. By default machines do not degrade.\n - `'degradation'` - machine degradation occurs according to a discrete-state Markovian process. Currently only Markovian degradation is supported. Requires specification of `failure_params`, described in the following subsection.\n- `planned_failures` - a list of planned failures to occur during the simulation time. Each of the form `(location, time, duration)`. Planned failures do not adhere to maintenance capacity constraints and have not been thoroughly tested in tandem with random failures.\n\n##### Markovian degradation parameters\n\nThere are several options for specifying the mode of degradation using the `failure_params` argument which should be passed as a dictionary.\n- Constant degradation rate - passed as the value of the `degradation rate` key either as a single float or list of floats for each machine. The value is the probability of degrading by one unit at each time step and so should be between 0 and 1. Creates an upper bidiangonal degradation transition matrix.\n- Failed state - if the degradation rate is specified, the maximum health (failed) state for each machine can be passed as the value of the `failed state` key. The default failed state is 10. \n- Complete degradation transition matrix - can be specified as a single `numpy` array (in which case each machine will be subject to the same degradation profile) or a list of arrays for each machine as the value of the `degradation transition` key. \n\nIf `failure_mode = 'degradation'` is passed to a `System` object, either the `degradation rate` or `degradation transition` must be defined. Degradation profiles beyond a constant degradation rate have not yet been thoroughly tested.\n\n#### Maintenance parameters\n- `maintenance_policy` - currently either `'CM'` or `'CBM'`.\n - `'CM'` - \"corrective maintenance\", the default policy, machines will only be repaired upon complete failure, as determined by the mode of degradation.\n - `'CBM'` - \"condition-based maintenance\", preventive maintenance is performed once a machine's condition reached a prescribed threshold.\n- `maintenance_params` - the parameters that define the specified maintenance policy. For `CBM`, a list of thresholds at which to schedule maintenance.\n - Currently each machine has 11 health states, with 0 being perfect health and 10 being the failed state. The maintenance threshold should be in this range.\n- `repair_params` - a dictionary of `scipy.stats` frozen discrete distributions of time to repair based on repair type.\n - For example, `repair_params = {'CM': stats.randint(10, 20), 'CBM': stats.randint(20, 40)}`.\n- `maintenance_capacity` - the maximum number of maintenance jobs that can be executed simultaneously. Currently if the number of simultaneously scheduled maintenance jobs exceeds the capacity they will be handled in a first in, first out (FIFO) manner.\n- `maintenance_costs` - a dictionary of the cost of each type of maintenance job by type.\n\n#### System state parameters\n\nThese parameters can be set to initialize the system state before simulation. By default the system begins with empty buffers and machines in perfect health. \n- `initial_remaining_process` - a list of remaining processing times for each machine. By default this is equal to the machine's total processing time when it does not have a part. \n- `initial_buffer` - a list of initial levels for each buffer. \n- `initial_health` - a list of initial health states for each machine.\nValid settings for the initial system state are not currently verified automatically. \n\n\n### Creating a custom maintenance scheduler\n\nThe `System` object can take an additional `scheduler` object that will determine how maintenance jobs are scheduled when the number of machines due for maintenance exceeds the maintenance capacity. By default a system will use a FIFO scheduler as defined by the `Scheduler` class. A custom scheduler can also be created that inherits from the `maintsim.Scheduler` class. This new class should include a `choose_next` method that accepts the current maintenance queue as an argument. This method should then return a list of machine objects that are to be assigned maintenance. The `choose_next` method is executed each time a maintenance resource is release from a job.\n\nAn example of a custom scheduler that uses Monte Carlo tree search (as implemented by the [MCTS](https://github.com/pbsinclair42/MCTS) package) is shown below:\n\n```python\nimport maintsim\nimport mcts\n\nclass MCTSScheduler(maintsim.Scheduler):\n '''\n Resolves maintenance scheduling conflicts using Monte Carlo tree search.\n '''\n def __init__(self, time_limit=None, iteration_limit=None, **kwds):\n '''\n Must specify either a time limit (in seconds) or iteration limit for the\n MCTS.\n '''\n super().__init__(**kwds)\n self.limit = {}\n if time_limit and iteration_limit:\n print('Error: cannot specify time and iteration limit.')\n elif time_limit:\n self.limit['timeLimit'] = time_limit * 1000\n else:\n self.limit['iterationLimit'] = iteration_limit\n\n def choose_next(self, queue):\n # formulate and solve MCTS\n mcts_schedule = mcts.mcts(**self.limit)\n best_action = mcts_schedule.search(initialState=MaintenanceState(self.system))\n next_machine = [self.system.machines[best_action-1]]\n\n return next_machine\n```\n\n### Simulating the system\n\nWhen the system is instantiated, it will initialize by creating the necessary objects including the SimPy `Environment`, the maintenance resource, machines, and buffers. The simulation can be run by calling the `simulate` method of the `System` object with the following parameters:\n\n- `title` - the tile of the simulation, used for naming any files that are saved.\n- `warmup_time` - the time that the simulation will run before collecting data. Useful for ensuring the system is in steady state before observation.\n- `sim_time` - the duration of time that simulation will run once the warmup is completed. Metrics will be determined based on the system performance during this time.\n- `seed` - random seed for the simulation. A given seed should always produce the same results.\n- `verbose` - boolean. `True` will print out a summary of the simulation run. `False` will suppress all printed output, which may be preferred if many replications are being run.\n\n\n#### Simulation data\n\nSeveral data frames are created to record data of a simulation run and stored as attributes of the `System` object.\n\n- `state_data` - remaining processing time of each machine and buffer levels at each time step.\n- `production_data` - production volume (in units) and throughput (in units/time) of each machine at every time step.\n- `machine_data` - status of each machine at every time step, including if machines are function and blocked or starved.\n- `queue_data` - the number of machines waiting for maintenance at each time step.\n- `maintenance_data` - the log of maintenance activities including the time at which the activity occurred, the type of activity (corrective, preventive, etc.), what the activity was (failure or repair), and the duration or time to failure.\n\n#### Iterating the simulation\n\nA system can be simulated several times using the `System.iterate_simulation` method. The arguments for this method are:\n\n- `replications` - number of times to run the simulation.\n- `warmup_time` - the time that the simulation will run before collecting data. Performance statistics are only collected after this time has elapsed.\n- `sim_time` - the duration of time each replication will be simulated.\n- `objective` - the objective values that will be returned once all replications are complete. Options include:\n - `production` - the production volume in units of the system.\n - `ppl` - the permanent production loss of the system over the specified simulation time. \n - `availability` - the overall availability of machines in the system as a percentage.\n- `verbose` - `True` or `False`, determines whether or not summary statistics will be displayed once all replications are completed. \n\n## A simple example\n\nHere is a minimum example for implmenting a CBM policy:\n\n```python\n>>> import maintsim\n>>> from scipy import stats\n>>> \n>>> system = maintsim.System(process_times=[3, 5, 4],\n... buffer_sizes=5,\n... failure_mode='degradation',\n... failure_params={'degradation rate':[0.25, 0.1, 0.2]},\n... maintenance_policy='CBM',\n... maintenance_params={'CBM threshold': [8, 6, 7]},\n... repair_params={'CM': stats.randint(20,30),\n... 'CBM': stats.randint(10,20)},\n... maintenance_capacity=1)\n>>> system.simulate(warmup_time=100, sim_time=500)\nSimulation complete in 0.89 s\n \n Units produced: 31\n System availability: 68.93%\n```\n\n## Planned features\n\nKey planned features include\n\n- Parallelization of simulation iterations\n- Improved efficiency for iterating a simulation\n- Exporting system model for reuse", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/m-hoff/maintsim", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "maintsim", "package_url": "https://pypi.org/project/maintsim/", "platform": "", "project_url": "https://pypi.org/project/maintsim/", "project_urls": { "Homepage": "https://github.com/m-hoff/maintsim" }, "release_url": "https://pypi.org/project/maintsim/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "Simulation of maintenance for manufacturing", "version": "0.1.3" }, "last_serial": 5640999, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "2a2974aec1b7b5227db907ff145c9fb5", "sha256": "b84619e0c47c1bdda2b299b570c5854e2962aa16a19d8a21054277793b1f86cb" }, "downloads": -1, "filename": "maintsim-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "2a2974aec1b7b5227db907ff145c9fb5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13811, "upload_time": "2019-06-05T01:07:00", "url": "https://files.pythonhosted.org/packages/ea/1f/e2a9dd408af4bb6e211c62c7084418f9607769512d5b52a05f12ea334ef8/maintsim-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "647ad1a2830fa5ebe500427dc98dc22f", "sha256": "82697db506c31b23ace4cdd3cb125d886c52140aa9e4e8668dd882d7037c993d" }, "downloads": -1, "filename": "maintsim-0.1.1.tar.gz", "has_sig": false, "md5_digest": "647ad1a2830fa5ebe500427dc98dc22f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12648, "upload_time": "2019-06-05T01:07:13", "url": "https://files.pythonhosted.org/packages/ef/ef/b1c574d55c17e7299ec4a85b2888fad1c650c57fe0a3ded9087754b3b6c6/maintsim-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "11af1af2b6a47cc47717fb86e26133dc", "sha256": "4dfeeeab4bb2be49e7fdb65f91c24f3d4eb3db520a0ccf7042aa3faac387c816" }, "downloads": -1, "filename": "maintsim-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "11af1af2b6a47cc47717fb86e26133dc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15018, "upload_time": "2019-06-05T19:51:32", "url": "https://files.pythonhosted.org/packages/74/25/18bbb911a1f7656c8aa0703d299a213f06990e5a816cfb1b1a74131f24d8/maintsim-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c2636be87253d679cdfea0c14ae3ba09", "sha256": "cd4d16f5c56aa9e5bcfa33a47bee31c7fcd1c37b08dd9105a0d38c3b8d3c88c9" }, "downloads": -1, "filename": "maintsim-0.1.2.tar.gz", "has_sig": false, "md5_digest": "c2636be87253d679cdfea0c14ae3ba09", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13024, "upload_time": "2019-06-05T19:51:33", "url": "https://files.pythonhosted.org/packages/06/da/461c9c1b6b5290cbe094835f1cc476f399cab110bc6517016fb850203f38/maintsim-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "a17f9dd05d9b9401f942220b4ad325d3", "sha256": "32ec13d934eb3224fdd663a6513bf75622249a9432990e4bdad1b01483498b37" }, "downloads": -1, "filename": "maintsim-0.1.3.tar.gz", "has_sig": false, "md5_digest": "a17f9dd05d9b9401f942220b4ad325d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15787, "upload_time": "2019-08-06T18:05:38", "url": "https://files.pythonhosted.org/packages/30/dd/061bc8ac0717de87b8894dcfc20cc8b155b20ae00f2a6ff1778f7f256d54/maintsim-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a17f9dd05d9b9401f942220b4ad325d3", "sha256": "32ec13d934eb3224fdd663a6513bf75622249a9432990e4bdad1b01483498b37" }, "downloads": -1, "filename": "maintsim-0.1.3.tar.gz", "has_sig": false, "md5_digest": "a17f9dd05d9b9401f942220b4ad325d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15787, "upload_time": "2019-08-06T18:05:38", "url": "https://files.pythonhosted.org/packages/30/dd/061bc8ac0717de87b8894dcfc20cc8b155b20ae00f2a6ff1778f7f256d54/maintsim-0.1.3.tar.gz" } ] }