{"id":16653099,"url":"https://github.com/nitin-bommi/computer-based-optimization-techniques","last_synced_at":"2025-09-11T11:30:55.050Z","repository":{"id":112157686,"uuid":"253150470","full_name":"nitin-bommi/Computer-Based-Optimization-Techniques","owner":"nitin-bommi","description":"Computing the optimized values using Simplex method","archived":false,"fork":false,"pushed_at":"2020-06-03T17:17:20.000Z","size":906,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T08:44:52.860Z","etag":null,"topics":["elementary","gauss-jordan","inverse","optimization","optimization-algorithms","python","revised-simplex-algorithm","simplex","sympy","time"],"latest_commit_sha":null,"homepage":"","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/nitin-bommi.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":"2020-04-05T03:49:10.000Z","updated_at":"2023-11-26T20:19:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"721b53d8-e91d-4732-b4c0-64cce2b388ea","html_url":"https://github.com/nitin-bommi/Computer-Based-Optimization-Techniques","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nitin-bommi/Computer-Based-Optimization-Techniques","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitin-bommi%2FComputer-Based-Optimization-Techniques","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitin-bommi%2FComputer-Based-Optimization-Techniques/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitin-bommi%2FComputer-Based-Optimization-Techniques/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitin-bommi%2FComputer-Based-Optimization-Techniques/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nitin-bommi","download_url":"https://codeload.github.com/nitin-bommi/Computer-Based-Optimization-Techniques/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitin-bommi%2FComputer-Based-Optimization-Techniques/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274624689,"owners_count":25319702,"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-11T02:00:13.660Z","response_time":74,"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":["elementary","gauss-jordan","inverse","optimization","optimization-algorithms","python","revised-simplex-algorithm","simplex","sympy","time"],"created_at":"2024-10-12T09:43:05.683Z","updated_at":"2025-09-11T11:30:54.775Z","avatar_url":"https://github.com/nitin-bommi.png","language":"Python","readme":"# Revised simplex \n\nTo find the inverse of intermediate matrices, two approaches are used with time compexities __O(n)__ and __O(n\u003csup\u003e2\u003c/sup\u003e)__ respectively.\n\n### Libraries used\n\n+ ```time```\n+ ```sympy``` (sub-modules)\n\n__SymPy__ is a Python library for symbolic mathematics. Since a number of variables are used (x\u003csub\u003e1\u003c/sub\u003e, x\u003csub\u003e2\u003c/sub\u003e...) this library provides efficient way of interpreting the variales for computation. It supports formatted matrix printing, easy interpretation of matrices, its inverse and sub-matrices. \n\nThe time is started after all the libraries are imported and before the function definition. It is stopped at the end of the program after some interations. The overall time is interpreted in *milli-seconds* as it is an interpretable scale for such computations.\n\n### How the input is taken?\n\nThe input file can be viewed [here.](https://github.com/Yashi1011/Computer-Based-Optimization-Techniques/blob/master/input.txt)\n\nThe text under '\\*\\*\\*' is viewed as comment and it represents the format of the input with some examples (along with solutions). \nThe code checks for the type of the problem (i.e., minimisation or maximisation) and then computes the result. \n\nThe problem to be solved has to be appended below the final '\\*\\*\\*'. And it should contain the type of the problem and the constraints.\n\nOnce the file is read, it checks for the lines below the final '\\*\\*\\*' and then converts that into matrices form by a library ```linear_eq_to_matrix``` on which computations are performed. This library takes input in the form of equations and converts them into matrices of coefficients.\n\n### Output \n\nWith the help of SymPy, the output is formatted in matrix form. \n\nWhen the input is taken as:\n\nMaximize:\nz = 5x\u003csub\u003e1\u003c/sub\u003e+4x\u003csub\u003e2\u003c/sub\u003e\n      \ns.t.\n\n6x\u003csub\u003e1\u003c/sub\u003e + 4x\u003csub\u003e2\u003c/sub\u003e \u0026le; 24\n\nx\u003csub\u003e1\u003c/sub\u003e + 2x\u003csub\u003e2\u003c/sub\u003e \u0026le; 6\n\n-x\u003csub\u003e1\u003c/sub\u003e + x\u003csub\u003e2\u003c/sub\u003e \u0026le; 1\n\nx\u003csub\u003e2\u003c/sub\u003e \u0026le; 2\n\nThe matrices A, b, c are printed as:\n\n\u003cimg src=\"https://github.com/Yashi1011/Computer-Based-Optimization-Techniques/blob/master/samples/abc.PNG\" height = 500\u003e\n\nThe output and intermediate matrix after each iteration is printed:\n\n\u003cimg src=\"https://github.com/Yashi1011/Computer-Based-Optimization-Techniques/blob/master/samples/output.PNG\" height = 500\u003e\n\n### Time complexity\n\nWhen we found the inverse using both the functions on the same matrix. The following results were obtained:\n\n+ Elementary method:\n\n```python\ndef inverse1(mat,entering,leaving):\n    \n    dim = mat.shape[0]\n    \n    X = mat.row(leaving)/mat.row(leaving)[entering]\n    mat.row_del(leaving)\n    mat = mat.row_insert(leaving,X)\n    \n    for j in range(dim):\n        if(leaving!=j):\n            con=mat.row(j)[entering]\n            X = mat.row(j)-mat.row(leaving)*con\n            mat.row_del(j)\n            mat = mat.row_insert(j,X)\n            \n    return mat\n```\n\nThe execution time was `0.9977817 ms`\n\n+ Gauss Jordan method:\n\n```python\ndef inverse2(A):\n    \n    size = A.shape[0]\n    \n    B = eye(size)\n    \n    for x in range(0,size):\n        V = B*A.col(x)\n        W = V*1\n        item = V[x]\n        for y in range(0,size):\n            if item != 0:\n                if y == x:\n                    W[y] = 1/item\n                else:\n                    W[y] =- V[y]/item\n                    \n        T = B*1\n        T.row_del(x)\n        T = T*1\n        B = T.row_insert(x,zeros(1,size)) + (W*B.row(x))\n        \n    return B\n```\n\nThe execution time was `3.027201 ms`\n\ni.e., Elementary method is ~3.1 times faster.\n\nJustification - In elementary method, we used a single for loop whereas in gauss jordan method we used two for loops. (O(n) vs O(n\u003csup\u003e2\u003c/sup\u003e))\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitin-bommi%2Fcomputer-based-optimization-techniques","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnitin-bommi%2Fcomputer-based-optimization-techniques","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitin-bommi%2Fcomputer-based-optimization-techniques/lists"}