{ "info": { "author": "Julian Maerte", "author_email": "maertej@students.uni-marburg.de", "bugtrack_url": null, "classifiers": [], "description": "# pysmps\n\nThis is a utility script for parsing MPS and SMPS file formats. It offers two main functions `load_mps` for loading mps files and `load_smps` for loading smps file directory.\n\n### `load_mps`\n\nThe `load_mps(path)` method takes a `path` variable as input. It should be a .cor or .mps file.\nIt opens the file with read-permissions and parses the described linear program into the following format:\n\n- `name`: The name given to the linear program (can't be blank)\n- `objective_name`: The name of the objective function value\n- `row_names`: list of row names\n- `col_names`: list of column names\n- `types`: list of constraint type indicators, i.e. either \"E\", \"L\" or \"G\" for equality, lower/equal or greater/equal constraint respectively.\n- `c`: the objective function coefficients\n- `A`: the constraint matrix\n- `rhs_names`: list of names of right hand sides (there can be multiple right hand side components be defined, seldom more than one though)\n- `rhs`: dictionary `(rhs_name) => b`, where `b` is the vector of constraint values for that given right hand side name.\n- `bnd_names`: list of names of box-bounds (seldom more than one)\n- `bnd`: dictionary `(bnd_name) => {\"LO\": v_l, \"UP\": v_u}` where `v_l` is the vector of lower bounds and `v_u` is the vector of upper bound values (defaults to `v_l = 0` and `v_u = +inf`).\n\nFinally this corresponds to the linear program\n\n```python\nmin \tc * x\n\ns.t.\tfor each rhs_name with corresponding b:\n\n\t\t\tA[types == \"E\",:] * x = b[types == \"E\"]\n\t\t\tA[types == \"L\",:] * x <= b[types == \"L\"]\n\t\t\tA[types == \"G\",:] * x >= b[types == \"G\"]\n\n\t\tfor each bnd_name with corresponding v_l and v_u:\n\n\t\t\tv_l <= x < v_u\n\n```\n\n### `load_smps`\n\nThis function makes use of the `load_mps` function for parsing the .cor file. The SMPS file format consists of three files, a .cor, .tim and .sto file. The .cor file is in MPS format. Further the function expects a parameter `path` to be such that `path + \".cor\"` is the core file, `path + \".tim\"` the time file and `path + \".sto\"` is the stochastic file.\nIt *does not* support scenarios yet!\nIt returns a stochastic multi-stage problem in the following format\n\n- `name`: name of the program (must be the same in all 3 files)\n\n- `objective_name`: name of the objective function value\n\n- `constraints`: list of tuples `(name, period, type)` for each constraint. It gives a name, a period in which the constraints appears and a type, i.e. \"E\", \"L\" or \"G\" as in MPS.\n\n- `variables`: list of tuples `(name, period)` for each variable. It defines a name and a period in which the variable joins the program.\n\n- `c`: vector of objective function coefficients (of all periods)\n\n- `A`: matrix of constraint coefficients (of all periods)\n\n- `rhs_names`: list of rhs names as in MPS\n\n- `rhs`: dictionary as in MPS\n\n- `bounds`: dictionary as in MPS\n\n- `periods`: list of all periods appearing. `len(periods)` is the number stages.\n\n- `blocks`: dictionary of `Block`,`LinearTransform` or `SubRoutine` objects. Dependent on what the .sto file defined. `Blocks` are independent random variables (every case of a `Block` must be combined with each case of another `Block` to get all possible appearences; the probabilities multiply), `LinearTransform` are linear transformations of continuous random variables. The user needs to write the sample script on his own. `SubRoutine` is a left-out in the file; it presupposes the user to know what to do with these values.\n\n- `independent_variables`: dictionary `((i,j)) => {position, period, distrib}`, where `(i,j)` is the tuple of row/column indices. If one of them is `-1` this means that it's either an objective value or a rhs-value respectively. `position` is a dictionary adapting to where the entry is (objective value, rhs value or matrix value), `period` defines the period in which this variable is stochastic, `distrib` is either a definition of a continuous random variables\n\n ```python\n distrib: {type: \"N(mu, sigma**2)\"/\"U(a, b)\"/\"B(p, q)\"/\"G(p, b)\"/\"LN(mu, sigma**2)\", parameters}\n ```\n\n where parameters is a dictionary defining the required parameters. In the discrete case it is a list of tuples `(v,p)`, where `v` is the value of this position and `p` is the probability of it appearing.\n\nFor an example on how to use this format i recommand looking at the code for `load_2stage_problem`.\n\n### `load_2stage_problem`\n\nLoads a SMPS directory and tries to bring it into a 2-staged stochastic linear program with fixed recourse. Output is a dictionary containing the values\n\n- `c`: first stage objective function value\n- `A`: first stage (equality) constraint coefficient matrix\n- `b`: first stage constraint values\n- `q`: list of second stage objective function coefficients (each case one entry)\n- `h`: list of second stage constraint values (each case one entry)\n- `T`: list of second stage constraint values for deterministic variables (each case one entry)\n- `W`: recourse matrix (since it's fixed recourse this is not a list)\n- `p`: list of probabilities for each case\n\nThe constellations in which `(q,h,T,W)` appear are the realizations given by `(q[k], h[k], T[k], W)`.\nThe problem then resembles one of the form\n\n```python\nmin\t\tc * x + E_p[q * y]\n\ns.t.\tA * x = b\n \tT * x + W * y = h\n \tx, y >= 0\n```\n\nwhich is a formal expression since T and h are also stochastic. In fact this notation means we assert the stochastic constraints inside of the expectation, making it a function of x only.\n\nFor casting the SMPS files into such a form we need to make certain assertments:\n\n- The upper right matrix needs to be zeroes only.\n- We only have one righthand side defined (`len(rhs_names) == 1`).\n- There are no boundaries or if we defined some they are the default values.\n- The first period parsed from the time file is the deterministic one, the other one is the stochastic one (especially there can only be two periods).\n- `A` and `W` are not stochastic.\n\nThis script however does\n\n- convert inequality constraints (deterministic and stochastic) into equality constraints by adding slack variables at the right places\n- calculate all combinations of independent accurances of stochastic components (BLOCKS and INDEP)\n- calculate the probabilities as products of independent elementary probabilities alongside.\n\n\n\n", "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/jmaerte/pysmps", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pysmps", "package_url": "https://pypi.org/project/pysmps/", "platform": "", "project_url": "https://pypi.org/project/pysmps/", "project_urls": { "Homepage": "https://github.com/jmaerte/pysmps" }, "release_url": "https://pypi.org/project/pysmps/1.5/", "requires_dist": null, "requires_python": "", "summary": "Utilities for parsing MPS and SMPS file formats.", "version": "1.5" }, "last_serial": 5862209, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "8eb8a846f32d0b347b8780966301eedb", "sha256": "768c85632ae5c800b36d234d593607678beb77a0ce06dd2dc773c0ef890fb117" }, "downloads": -1, "filename": "pysmps-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "8eb8a846f32d0b347b8780966301eedb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7225, "upload_time": "2019-09-10T19:10:17", "url": "https://files.pythonhosted.org/packages/4a/d7/397206c3df36096b9207bff1647160934d2e94838296fbf335f0f0e89d22/pysmps-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "231a8a055058c0702cbc2bd95c020b73", "sha256": "6c4a7a9950d005b661348bcb0240440759dd47546c52e0d56a31decc59d3f229" }, "downloads": -1, "filename": "pysmps-0.1.tar.gz", "has_sig": false, "md5_digest": "231a8a055058c0702cbc2bd95c020b73", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6078, "upload_time": "2019-09-10T19:10:23", "url": "https://files.pythonhosted.org/packages/2d/0f/306c409a6346a71e83af96027db5361ead3715806d8ec614b9dc9e03d686/pysmps-0.1.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "e3fdfba19762b6da8cf07686f81da1ac", "sha256": "8736a78d1233bb5663c186192f65ca1bc70c8a685617eff92543f5cd255ecf84" }, "downloads": -1, "filename": "pysmps-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e3fdfba19762b6da8cf07686f81da1ac", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7221, "upload_time": "2019-09-10T19:24:13", "url": "https://files.pythonhosted.org/packages/b8/ac/e17f1e1a0ba62aa0ff5d095e7730cd23db20d1d9e4824b82642c9e590987/pysmps-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "175393697a1c6dea1256750cc642c6cd", "sha256": "6c8b45de9ff30f92b60a2026850a8d9405816e30a00c8175fca44356d4b665da" }, "downloads": -1, "filename": "pysmps-1.0.tar.gz", "has_sig": false, "md5_digest": "175393697a1c6dea1256750cc642c6cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6070, "upload_time": "2019-09-10T19:24:14", "url": "https://files.pythonhosted.org/packages/30/5a/4a1ede32adb296effb2a8a53a5ba025eae683e521d3c2a8e0f084e246462/pysmps-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "faf9330c07341e2dfe4477f6cb988b31", "sha256": "476cd79ab0560559a1f20ce84f2ecd5d674390814d1cfae0fe31a454abdc32e0" }, "downloads": -1, "filename": "pysmps-1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "faf9330c07341e2dfe4477f6cb988b31", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7218, "upload_time": "2019-09-10T19:52:57", "url": "https://files.pythonhosted.org/packages/42/95/f409aa75178f88d6b9b1f000c2ce50e71d4aa483254f4b25d57d326a7f1d/pysmps-1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ff34a98ccab94dec8503373278cc8405", "sha256": "99b28e6a2d288c6d87bf3b640100a3aa78c0163b3c394160592ef20a231852c9" }, "downloads": -1, "filename": "pysmps-1.1.tar.gz", "has_sig": false, "md5_digest": "ff34a98ccab94dec8503373278cc8405", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5972, "upload_time": "2019-09-10T19:52:59", "url": "https://files.pythonhosted.org/packages/7d/ed/6d06710605dc087cde7898f012a6e9216658685b2741a732fa6efd99f544/pysmps-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "01893bac0eeebe1f73604fb39d4dfb6c", "sha256": "cd0387db56a8675f4d1ec12f6f1aafed11b48a65df608a489c72cc91d7868040" }, "downloads": -1, "filename": "pysmps-1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "01893bac0eeebe1f73604fb39d4dfb6c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7219, "upload_time": "2019-09-10T20:03:29", "url": "https://files.pythonhosted.org/packages/88/81/e7846ca8fd56f82c3dfc5f4573ea44062109dc751c7a0e32c52915b56ca9/pysmps-1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "37b4355c3178d136ee3d54c873966e47", "sha256": "6936b10f010033689d8e556cabab7c8e162d97868534660aa25f6d408667e5c9" }, "downloads": -1, "filename": "pysmps-1.2.tar.gz", "has_sig": false, "md5_digest": "37b4355c3178d136ee3d54c873966e47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5960, "upload_time": "2019-09-10T20:03:30", "url": "https://files.pythonhosted.org/packages/4d/1a/50a3bf746456f5b3ca2aaa206ce8bd27e85e792c79843edde2952c0175bd/pysmps-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "7da1ae470c3df99bf8bf4b4ad61bad56", "sha256": "99068dae87a5db44671b9fca6a1dec62a6d4a379494626197b583bbd02c6e228" }, "downloads": -1, "filename": "pysmps-1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "7da1ae470c3df99bf8bf4b4ad61bad56", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8758, "upload_time": "2019-09-11T07:55:34", "url": "https://files.pythonhosted.org/packages/a1/8d/8c2d2509b2177428868bd70b8656f610ab4beddcc02a3ecdfba72deeedc3/pysmps-1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6a11c84321df0bba5401fbfca6ade0fc", "sha256": "de3fbab31b9ce60157c29221d5e8e0a652a1ef71db8517baaf308e93289ad6d0" }, "downloads": -1, "filename": "pysmps-1.3.tar.gz", "has_sig": false, "md5_digest": "6a11c84321df0bba5401fbfca6ade0fc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9523, "upload_time": "2019-09-11T07:55:36", "url": "https://files.pythonhosted.org/packages/ea/c5/ef6cfa96042838e618d11b24458ab5123818e02bc2ccb7dbd610c0492d89/pysmps-1.3.tar.gz" } ], "1.4": [ { "comment_text": "", "digests": { "md5": "77ad161c1ecd323fcc73875b9113df49", "sha256": "da1f3a9634b4d3f9ff38779fc56b65d51f1ba84e843fe90c57ea2d1073e03306" }, "downloads": -1, "filename": "pysmps-1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "77ad161c1ecd323fcc73875b9113df49", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9251, "upload_time": "2019-09-11T15:37:44", "url": "https://files.pythonhosted.org/packages/f2/3b/1d4656d002f14ecb8cafae07bccc85cd92b4b08ab97e0da45c588ac04c37/pysmps-1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ce20cad142396ea4f2c39cf5fb0e732a", "sha256": "9402b2f9c94350b1839e6a4d355a17a63594cb572088db3d98ef9cec87272dad" }, "downloads": -1, "filename": "pysmps-1.4.tar.gz", "has_sig": false, "md5_digest": "ce20cad142396ea4f2c39cf5fb0e732a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10506, "upload_time": "2019-09-11T15:37:46", "url": "https://files.pythonhosted.org/packages/6e/91/fe24b1bcbca909202534c904e61335e1673211ac53f00fa37138fd73d6dc/pysmps-1.4.tar.gz" } ], "1.5": [ { "comment_text": "", "digests": { "md5": "745363707920b4af7319fa7a7b34f644", "sha256": "bd0b0b0ade14ccd74dff3693e8125f7c3021396ab9471825d8581e4098faa9aa" }, "downloads": -1, "filename": "pysmps-1.5-py3-none-any.whl", "has_sig": false, "md5_digest": "745363707920b4af7319fa7a7b34f644", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9256, "upload_time": "2019-09-20T13:05:53", "url": "https://files.pythonhosted.org/packages/75/53/19abce0e4696d75c78c4910befff63ac8df14ccca823cb12858781b25891/pysmps-1.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fb6e7bd3998260bf68bca9b2e828a7c2", "sha256": "be1374a5e5fd2b1dc1467935c24c1861f3f0234afb346b884987e616e56e6bee" }, "downloads": -1, "filename": "pysmps-1.5.tar.gz", "has_sig": false, "md5_digest": "fb6e7bd3998260bf68bca9b2e828a7c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10497, "upload_time": "2019-09-20T13:05:55", "url": "https://files.pythonhosted.org/packages/3c/a6/270565fb7e4f398ab8dc7b20674d238bf9d8a12d293297d40538f45dfe14/pysmps-1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "745363707920b4af7319fa7a7b34f644", "sha256": "bd0b0b0ade14ccd74dff3693e8125f7c3021396ab9471825d8581e4098faa9aa" }, "downloads": -1, "filename": "pysmps-1.5-py3-none-any.whl", "has_sig": false, "md5_digest": "745363707920b4af7319fa7a7b34f644", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9256, "upload_time": "2019-09-20T13:05:53", "url": "https://files.pythonhosted.org/packages/75/53/19abce0e4696d75c78c4910befff63ac8df14ccca823cb12858781b25891/pysmps-1.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fb6e7bd3998260bf68bca9b2e828a7c2", "sha256": "be1374a5e5fd2b1dc1467935c24c1861f3f0234afb346b884987e616e56e6bee" }, "downloads": -1, "filename": "pysmps-1.5.tar.gz", "has_sig": false, "md5_digest": "fb6e7bd3998260bf68bca9b2e828a7c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10497, "upload_time": "2019-09-20T13:05:55", "url": "https://files.pythonhosted.org/packages/3c/a6/270565fb7e4f398ab8dc7b20674d238bf9d8a12d293297d40538f45dfe14/pysmps-1.5.tar.gz" } ] }