{"id":30699938,"url":"https://github.com/econcz/pylppinv","last_synced_at":"2025-09-02T11:43:21.858Z","repository":{"id":310689765,"uuid":"371573356","full_name":"econcz/pylppinv","owner":"econcz","description":"Linear Programming via Pseudoinverse Estimation","archived":false,"fork":false,"pushed_at":"2025-08-22T12:04:17.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-22T13:39:42.197Z","etag":null,"topics":["convex-optimization","generalized-inverse","least-squares","linear-programing","regularization"],"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/econcz.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,"zenodo":null}},"created_at":"2021-05-28T03:52:44.000Z","updated_at":"2025-08-22T11:54:23.000Z","dependencies_parsed_at":"2025-08-22T13:39:48.546Z","dependency_job_id":"c83daac1-b042-4ded-8749-294960de51b2","html_url":"https://github.com/econcz/pylppinv","commit_stats":null,"previous_names":["econcz/lppinv","econcz/pylppinv"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/econcz/pylppinv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/econcz%2Fpylppinv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/econcz%2Fpylppinv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/econcz%2Fpylppinv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/econcz%2Fpylppinv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/econcz","download_url":"https://codeload.github.com/econcz/pylppinv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/econcz%2Fpylppinv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273279804,"owners_count":25077318,"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-02T02:00:09.530Z","response_time":77,"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":["convex-optimization","generalized-inverse","least-squares","linear-programing","regularization"],"created_at":"2025-09-02T11:43:20.699Z","updated_at":"2025-09-02T11:43:21.845Z","avatar_url":"https://github.com/econcz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linear Programming via Pseudoinverse Estimation\n\nThe **Linear Programming via Pseudoinverse Estimation (LPPinv)** is a two-stage estimation method that reformulates linear programs as structured least-squares problems. Based on the [Convex Least Squares Programming (CLSP)](https://pypi.org/project/pyclsp/ \"Convex Least Squares Programming\") framework, LPPinv solves linear inequality, equality, and bound constraints by (1) constructing a canonical constraint system and computing a pseudoinverse projection, followed by (2) a convex-programming correction stage to refine the solution under additional regularization (e.g., Lasso, Ridge, or Elastic Net).  \nLPPinv is intended for **underdetermined** and **ill-posed** linear problems, for which standard solvers fail.\n\n## Installation\n\n```bash\npip install pylppinv\n```\n\n## Quick Example\n\n```python\nfrom lppinv import lppinv\nimport numpy as np\n\n# Define inequality constraints A_ub @ x \u003c= b_ub\nA_ub = [\n    [1, 1],\n    [2, 1]\n]\nb_ub = [5, 8]\n\n# Define equality constraints A_eq @ x = b_eq\nA_eq = [\n    [1, -1]\n]\nb_eq = [1]\n\n# Define bounds for x1 and x2\nbounds = [(0, 5), (0, None)]\n\n# Run the LP via CLSP\nresult = lppinv(\n    c      = [1, 1],  # not used in CLSP but included for compatibility\n    A_ub   = A_ub,\n    b_ub   = b_ub,\n    A_eq   = A_eq,\n    b_eq   = b_eq,\n    bounds = bounds\n)\n\n# Output solution\nprint(\"Solution vector (x):\")\nprint(result.x.flatten())\n```\n\n## User Reference\n\nFor comprehensive information on the estimator’s capabilities, advanced configuration options, and implementation details, please refer to the [pyclsp module](https://pypi.org/project/pyclsp/ \"Convex Least Squares Programming\"), on which LPPinv is based.\n\n**LPPINV Parameters:**\n\n`c` : *array_like* of shape *(p,)*, optional  \nObjective function coefficients. Accepted for API parity; not used by CLSP.\n\n`A_ub` : *array_like* of shape *(i, p)*, optional  \nMatrix for inequality constraints `A_ub @ x \u003c= b_ub`.\n\n`b_ub` : *array_like* of shape *(i,)*, optional  \nRight-hand side vector for inequality constraints.\n\n`A_eq` : *array_like* of shape *(j, p)*, optional  \nMatrix for equality constraints `A_eq @ x = b_eq`.\n\n`b_eq` : *array_like* of shape *(j,)*, optional  \nRight-hand side vector for equality constraints.\n\n`bounds` : *sequence* of *(low, high)*, optional  \nBounds on variables. If a single tuple **(low, high)** is given, it is applied to all variables. If None, defaults to *(0, None)* for each variable (non-negativity).\n\nPlease note that either `A_ub` and `b_ub` or `A_eq` and `b_eq` must be provided.\n\n**CLSP Parameters:**  \n\n`r` : *int*, default = *1*  \nNumber of refinement iterations for the pseudoinverse-based estimator.\n\n`Z` : *np.ndarray* or *None*  \nA symmetric idempotent matrix (projector) defining the subspace for Bott–Duffin pseudoinversion. If *None*, the identity matrix is used, reducing the Bott–Duffin inverse to the Moore–Penrose case.\n\n`tolerance` : *float*, default = *square root of machine epsilon*  \nConvergence tolerance for NRMSE change between refinement iterations.\n\n`iteration_limit` : *int*, default = *50*  \nMaximum number of iterations allowed in the refinement loop.\n\n`final` : *bool*, default = *True*  \nIf *True*, a convex programming problem is solved to refine `zhat`. The resulting solution `z` minimizes a weighted L1/L2 norm around `zhat` subject to `Az = b`.\n\n`alpha` : *float*, default = *1.0*  \nRegularization parameter (weight) in the final convex program:  \n- `α = 0`: Lasso (L1 norm)  \n- `α = 1`: Tikhonov Regularization/Ridge (L2 norm)  \n- `0 \u003c α \u003c 1`: Elastic Net\n\n`*args`, `**kwargs` : optional  \nCVXPY arguments passed to the CVXPY solver.\n\n**Returns:**  \n*self*\n\n`self.A`             : *np.ndarray*  \nDesign matrix `A` = [`C` | `S`; `M` | `Q`], where `Q` is either a zero matrix or *S_residual*.\n\n`self.b`             : *np.ndarray*  \nVector of the right-hand side.\n\n`self.zhat`          : *np.ndarray*  \nVector of the first-step estimate.\n\n`self.r`             : *int*  \nNumber of refinement iterations performed in the first step.\n\n`self.z`             : *np.ndarray*  \nVector of the final solution. If the second step is disabled, it equals `self.zhat`.\n\n`self.x`             : *np.ndarray*  \n`m × p` matrix or vector containing the variable component of `z`.\n\n`self.y`             : *np.ndarray*  \nVector containing the slack component of `z`.\n\n`self.kappaC`        : *float*  \nSpectral κ() for *C_canon*.\n\n`self.kappaB`        : *float*  \nSpectral κ() for *B* = *C_canon^+ A*.\n\n`self.kappaA`        : *float*  \nSpectral κ() for `A`.\n\n`self.rmsa`          : *float*  \nTotal root mean square alignment (RMSA).\n\n`self.r2_partial`    : *float*  \nR² for the `M` block in `A`.\n\n`self.nrmse`         : *float*  \nMean square error calculated from `A` and normalized by standard deviation (NRMSE).\n\n`self.nrmse_partial` : *float*  \nMean square error from the `M` block in `A` and normalized by standard deviation (NRMSE).\n\n`self.z_lower`       : *np.ndarray*  \nLower bound of the diagnostic interval (confidence band) based on κ(`A`).\n\n`self.z_upper`       : *np.ndarray*  \nUpper bound of the diagnostic interval (confidence band) based on κ(`A`).\n\n`self.x_lower`       : *np.ndarray*  \nLower bound of the diagnostic interval (confidence band) based on κ(`A`).\n\n`self.x_upper`       : *np.ndarray*  \nUpper bound of the diagnostic interval (confidence band) based on κ(`A`).\n\n`self.y_lower`       : *np.ndarray*  \nLower bound of the diagnostic interval (confidence band) based on κ(`A`).\n\n`self.y_upper`       : *np.ndarray*  \nUpper bound of the diagnostic interval (confidence band) based on κ(`A`).\n\n## Bibliography\n\nTo be added.\n\n## License\n\nMIT License — see the [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feconcz%2Fpylppinv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feconcz%2Fpylppinv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feconcz%2Fpylppinv/lists"}