{"id":18900241,"url":"https://github.com/grosquildu/agh_linear_programming","last_synced_at":"2025-09-15T00:07:29.050Z","repository":{"id":89132118,"uuid":"89727148","full_name":"GrosQuildu/agh_linear_programming","owner":"GrosQuildu","description":"Solver for linear problems, uses monte-carlo method","archived":false,"fork":false,"pushed_at":"2017-05-15T17:06:09.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-24T09:39:37.456Z","etag":null,"topics":["agh","equation-solver","linear-programming","monte-carlo"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GrosQuildu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-28T17:01:39.000Z","updated_at":"2018-06-12T13:24:06.000Z","dependencies_parsed_at":"2023-03-04T22:45:19.278Z","dependency_job_id":null,"html_url":"https://github.com/GrosQuildu/agh_linear_programming","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GrosQuildu/agh_linear_programming","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrosQuildu%2Fagh_linear_programming","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrosQuildu%2Fagh_linear_programming/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrosQuildu%2Fagh_linear_programming/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrosQuildu%2Fagh_linear_programming/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GrosQuildu","download_url":"https://codeload.github.com/GrosQuildu/agh_linear_programming/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrosQuildu%2Fagh_linear_programming/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275185399,"owners_count":25419919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agh","equation-solver","linear-programming","monte-carlo"],"created_at":"2024-11-08T08:50:40.948Z","updated_at":"2025-09-15T00:07:29.017Z","avatar_url":"https://github.com/GrosQuildu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AGH linear programming\nSolver for (not necessary) linear problems, using monte-carlo method. University project.\n\n```\npip install -r requirements.txt\npython ./main.py\n```\n\n### Linear problems\nLinear programming is a method to obtain \"the best\" set of values restricted to some linear conditions.\nIt's may be useful in decision making. Let's consider example:\n\nFirm can create n products. For production it uses r means of production, which are bounded to some limits. Let's put\n```\na[i][j] - consumption of i-th means of production for creation j-th product (i=1..r, j=1..n)\nb[i] - owned resource of i-th means of production\nc[j] - income from j-th product sales\nd[j]/g[j] - min/max amount of j-th product that can be sell\nx[j] - volume of production of j-th product\n```\nThe firm wants to find out amount of the products (x variables) it has to produce to maximalize it's profits.\nWe can construct math equations for given problem:\n```\na[1][i]*x[1] + a[1][2]*x[2] + ... + a[1][n]*x[n] \u003c= b[1]\n........................................................\na[r][i]*x[1] + a[r][2]*x[2] + ... + a[r][n]*x[n] \u003c= b[r]\n\nd[1] \u003c= x[1] \u003c= g[1]\n....................\nd[n] \u003c= x[n] \u003c= g[n]\n\nc[1]*x[1] + c[2]*x[2] + ... + c[n]*x[n] -\u003e max\n```\n\nThe most popular method for solving problems of that type is called simplex. However, this code uses monte-carlo method.\nTherefore it can be used with non-linear equations.\n\n### Solver\n\nRun `main.py` for interactive session or `main.py --help` to pass args in command line.\n\nProgram works by drawing set of variables `x[j]` (each in range `\u003cd[j], g[j]\u003e`) and choosing the best set meeting all inequalities.\nThen new set (narrower) of boundaries d[x],g[x] is constructed around each x[j] and the algorithm is repeated.\n\nThe program can use multiple processes to speed up computations. The work is spread by splitting the biggest boundary between them.\n\nParameters:\n```\nEpsilon - program will end if all boundaries sizes (g[j]-d[j]) are smaller than epsilon\nMultiprocessing epsilon - end multiprocessing if biggest boundary size is smaller than this value\nRecursion limit - you know\nDelta - new boundaries are constructed as (x - boundary_size/delta, x + boundary_size/delta)\n\nNumber of variables - number of products (x)\nNumber of equations - number of equations restricting means of production\nGoal function - this function will be (min)maximalized\n\nAmount of random points at each level - how many sets of x-es to rand\nNumber of processes - 1 for one process\nType of multiprocessing - if breadth, processes will be created and joined at each level\n(for computing the best variables with current boundaries), if deep, processes will be created at first level\nand joined after each of them reach epsilon\n```\n\nExample run: `python main.py test_inputs/p1.txt 2000 -p 4`\n\n### Reverse polish notation\nParsing of equations is done by translating them into prefix (rpn) notation. Implementation supports variables,\nconstants and functions (from math module).\n\nExample usage:\n```python\nfrom rpn import RPN, RPNError\n\ninfix_equation_string = \"A + 2*B + pi*sin(tan(3))\"\nrpn = RPN(infix_equation_string)\nprint rpn.infix()\nprint rpn.compute(A=3, B=4.1)\n```\n\nOr run `python rpn.py`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrosquildu%2Fagh_linear_programming","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrosquildu%2Fagh_linear_programming","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrosquildu%2Fagh_linear_programming/lists"}