qss


Nameqss JSON
Version 0.2.4 PyPI version JSON
download
home_pageNone
SummaryQSS: Quadratic-Separable Solver
upload_time2024-09-18 19:52:21
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseApache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # QSS: Quadratic-Separable Solver
QSS solves problems of the form 

$$\begin{equation*} \begin{array}{ll} \text{minimize} & (1/2) x^T P x + q^T x + r + g(x) \\\\ \text{subject to} & Ax = b \end{array} \end{equation*}$$

where $x \in \bf{R}^n$ is the decision variable being optimized over. The
objective is defined by a positive definite matrix $P \in \bf{S}^n_+$, a vector
$q \in \bf{R}^n$, a scalar $r \in \bf{R}$, and a $g$ that is separable in the
entries of $x$, i.e., $g$ can be written as 
$$g(x) = \sum_{i=1}^n g_i(x_i).$$
The constraints are defined by a matrix $A \in \bf{R}^{m \times n}$ and a vector
$b \in \bf{R}^m$. 

To use QSS, the user must specify $P$, $q$, $r$, $A$, $b$, as well as the $g_i$ from a built-in collection of separable functions. 

## Installation
```
pip install qss
```

## Usage
After installing `qss`, import it with
```python
import qss
```
This will expose the QSS class which is used to instantiate a solver object:
```python
solver = qss.QSS(data)
```
Use the `solve()` method when ready to solve:
```python
results = solver.solve(eps_abs=1e-5,
                       eps_rel=1e-5,
                       alpha=1.4,
                       rho=0.1,
                       max_iter=np.inf,
                       precond=True,
                       warm_start=False,
                       reg=True,
                       use_iter_refinement=False,
                       verbose=False,
                       )
```

### Parameters
- `data`: dictionary with the following keys:
    - `'P'`, `'q'`, `'r'`, `'A'`, `'b'` specify the quadratic part of the objective and the linear constraint as in the problem formulation above. `'P'` and `'A'` should be `scipy.sparse` CSC matrices or QSS `LinearOperator`s (see below), `'q'` and `'b'` should be `numpy` arrays,  and `'r'` should be a scalar. `'A'` and `'b'` can be excluded from `data` or set to `None` if the linear equality constraints are not needed. 
    - `'g'` is a list of separable function definitions. Each separable function is declared as a dictionary with the following keys:
        - `'g'`: string that corresponds to a valid separable function name (see below for a list of supported functions).
        - `'args'`: `'weight'` (default 1), `'scale'` (default 1), `'shift'` (default 0) allow the `'g'` function to be applied in a weighted manner to a shifted and scaled input. Some functions take additional arguments, see below. 
        - `'range'`: tuple specifying the start index and end index that the function should be applied to.
    
        Note that the zero function will be applied to any indices that don't have another function specified for them.
- `eps_abs`: scalar specifying absolute tolerance.
- `eps_abs`: scalar specifying relative tolerance.
- `alpha`: scalar specifying overstep size.
- `rho`: scalar specifying ADMM step size.
- `max_iter`: maximum number of ADMM iterations to perform.
- `precond`: boolean specifying whether to perform matrix equilibration.
- `warm_start`: boolean specifying whether to warm start upon a repeat call of
  `solve()`.
- `reg`: boolean specifying whether to regularize KKT matrix. May fail on certain problem instances if set to `False`.
- `use_iter_refinement`: boolean, only matters if `reg` is `True`. Helps mitigate some of the accuracy loss due to regularization. 
- `verbose`: boolean specifying whether to print verbose output.

### Returns
A list containing the following:
- `objective`: the objective value attained by the solution found by `qss`. 
- `solution`: the solution vector.

### Separable functions
The following convex separable functions are supported ( $\mathcal{I}$ is the $\\{0, \infty\\}$ indicator function):
Function | Parameters | $g_i(x)$
--- | --- | ---
`zero` | | $0$
`abs` | | $\|x\|$
`is_pos` | | $\mathcal I(x \geq 0)$
`is_neg` | | $\mathcal I(x \leq 0)$
`is_bound` | `lb`: lower bound (default 0), `ub`: upper bound (default 1) | $\mathcal I(l \leq x \leq u)$
`is_zero` | | $\mathcal I(x = 0)$
`pos` | | $\max\\{x, 0\\}$
`neg` | | $\max\\{-x, 0\\}$
`quantile` | `tau`: scalar in $(0, 1)$ | $0.5 \|x\| + (\tau - 0.5) x$
`huber` | `M`: positive scalar | $x^2 \text{ if } \|x\| \leq M, 2M\|x\| - M^2 \text{ else}$

The following nonconvex separable functions are supported:
Function | Parameters | $g_i(x)$
--- | --- | ---
`card` | | $0$ for $x = 0$; $1$ for $x \neq 0$
`is_int` | | $\mathcal I(x \text{ is an integer})$
`is_finite_set` | `S`: Python list of scalars | $\mathcal I(x \in S)$
`is_bool` | | $\mathcal I(x \in \\{0,1\\})$

The `t` (weight), `a` (scale), `b` (shift) parameters are used to shift and scale the above as follows: `t * g(ax - b)`.

#### Example
Applying the Huber function to a shifted version of the first 100 entries:
```python
[{"g": "huber", "args": {"M": 2, "shift": -5}, "range": (0, 100)}]
```

### Abstract linear operators
QSS comes with built-in support for abstract linear operators via the `qss.linearoperator.LinearOperator` class (hereafter referred to simply as `LinearOperator`).

The easiest way to build a `LinearOperator` is via its constructor. The argument to the constructor should be a list of lists representing a block matrix, in which each block is one of the following:
- SciPy sparse matrix or
- [`scipy.sparse.linalg.LinearOperator`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.LinearOperator.html) or
- `qss.linearoperator.LinearOperator` or
- `None`.

As an example, a constraint matrix `A` could be built as follows:
```python
from qss.linearoperator import LinearOperator

A = LinearOperator([
    [None, F, -I],
    [I, I, None]
])
```
Where `F` is a `scipy.sparse.linalg.LinearOperator` that implements the Fourier transform and `I` is a SciPy sparse identity matrix. 

There are several helper functions available to facilitate the creation of `LinearOperator`s, all accessible through `qss.linearoperator`: 
- `block_diag(D)`: Returns a block diagonal `LinearOperator` from `D`, a list of linear operators (SciPy sparse matrix, `scipy.sparse.linalg.LinearOperator`, or `qss.linearoperator.LinearOperator`).
- `hstack(D)`: Horizontally concatenates list of linear operators `D` into a single `LinearOperator`.
- `vstack(D)`: Vertically concatenates a list of linear operators `D` into a single `LinearOperator`.

Left and right matrix multiplication between a `LinearOperator` and a NumPy array is supported. Multiplication between `LinearOperator`s is currently not supported. Matrix-vector multiplication between a `LinearOperator` `F` and a NumPy array `v` can be achieved with `F.matvec(v)` or `F @ v`. Multiplication with the adjoint of `F` can be achieved with `F.rmatvec(v)` or `v @ F`. 

Note that solve times may be slower when `LinearOperator`s are involved. If either `P` or `A` is a `LinearOperator`, the linear KKT system central to the QSS algorithm is solved indirectly, as opposed to directly via a factorization. 


### Example
Nonnegative least squares is a problem of the form

$$\begin{equation*} \begin{array}{ll} \text{minimize} & (1/2) \Vert Gx - h \Vert_2^2 \\\\ \text{subject to} & x \geq 0. \end{array} \end{equation*} $$

`qss` can be used to solve this problem as follows:
```python
import numpy as np
import scipy as sp
import qss

p = 100
n = 500
G = sp.sparse.random(n, p, density=0.2, format="csc")
h = np.random.rand(n)

data = {}
data["P"] = G.T @ G
data["q"] = -h.T @ G
data["r"] = 0.5 * h.T @ h
data["g"] = [{"g": "is_pos", "range": (0, p)}] # Enforce x >= 0

solver = qss.QSS(data)
objective, x = solver.solve()
print(objective)
```

## Development
To create a virtual environment, run
```
python3 -m venv env
```
Activate it with 
```
source env/bin/activate
```
Clone the `qss` repository, `cd` into it, and install `qss` in development mode:
```
pip install -e ./ -r requirements.txt
```
Finally, test to make sure the installation worked:
```
pytest tests/
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "qss",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "Sara Miskovich <smiskov@slac.stanford.edu>",
    "keywords": null,
    "author": null,
    "author_email": "Luke Volpatti <bennetm@stanford.edu>",
    "download_url": "https://files.pythonhosted.org/packages/bf/1f/79ff852493deccc948807a5fa339696d1af5b41a4d8329fdfeed135123f8/qss-0.2.4.tar.gz",
    "platform": null,
    "description": "# QSS: Quadratic-Separable Solver\nQSS solves problems of the form \n\n$$\\begin{equation*} \\begin{array}{ll} \\text{minimize} & (1/2) x^T P x + q^T x + r + g(x) \\\\\\\\ \\text{subject to} & Ax = b \\end{array} \\end{equation*}$$\n\nwhere $x \\in \\bf{R}^n$ is the decision variable being optimized over. The\nobjective is defined by a positive definite matrix $P \\in \\bf{S}^n_+$, a vector\n$q \\in \\bf{R}^n$, a scalar $r \\in \\bf{R}$, and a $g$ that is separable in the\nentries of $x$, i.e., $g$ can be written as \n$$g(x) = \\sum_{i=1}^n g_i(x_i).$$\nThe constraints are defined by a matrix $A \\in \\bf{R}^{m \\times n}$ and a vector\n$b \\in \\bf{R}^m$. \n\nTo use QSS, the user must specify $P$, $q$, $r$, $A$, $b$, as well as the $g_i$ from a built-in collection of separable functions. \n\n## Installation\n```\npip install qss\n```\n\n## Usage\nAfter installing `qss`, import it with\n```python\nimport qss\n```\nThis will expose the QSS class which is used to instantiate a solver object:\n```python\nsolver = qss.QSS(data)\n```\nUse the `solve()` method when ready to solve:\n```python\nresults = solver.solve(eps_abs=1e-5,\n                       eps_rel=1e-5,\n                       alpha=1.4,\n                       rho=0.1,\n                       max_iter=np.inf,\n                       precond=True,\n                       warm_start=False,\n                       reg=True,\n                       use_iter_refinement=False,\n                       verbose=False,\n                       )\n```\n\n### Parameters\n- `data`: dictionary with the following keys:\n    - `'P'`, `'q'`, `'r'`, `'A'`, `'b'` specify the quadratic part of the objective and the linear constraint as in the problem formulation above. `'P'` and `'A'` should be `scipy.sparse` CSC matrices or QSS `LinearOperator`s (see below), `'q'` and `'b'` should be `numpy` arrays,  and `'r'` should be a scalar. `'A'` and `'b'` can be excluded from `data` or set to `None` if the linear equality constraints are not needed. \n    - `'g'` is a list of separable function definitions. Each separable function is declared as a dictionary with the following keys:\n        - `'g'`: string that corresponds to a valid separable function name (see below for a list of supported functions).\n        - `'args'`: `'weight'` (default 1), `'scale'` (default 1), `'shift'` (default 0) allow the `'g'` function to be applied in a weighted manner to a shifted and scaled input. Some functions take additional arguments, see below. \n        - `'range'`: tuple specifying the start index and end index that the function should be applied to.\n    \n        Note that the zero function will be applied to any indices that don't have another function specified for them.\n- `eps_abs`: scalar specifying absolute tolerance.\n- `eps_abs`: scalar specifying relative tolerance.\n- `alpha`: scalar specifying overstep size.\n- `rho`: scalar specifying ADMM step size.\n- `max_iter`: maximum number of ADMM iterations to perform.\n- `precond`: boolean specifying whether to perform matrix equilibration.\n- `warm_start`: boolean specifying whether to warm start upon a repeat call of\n  `solve()`.\n- `reg`: boolean specifying whether to regularize KKT matrix. May fail on certain problem instances if set to `False`.\n- `use_iter_refinement`: boolean, only matters if `reg` is `True`. Helps mitigate some of the accuracy loss due to regularization. \n- `verbose`: boolean specifying whether to print verbose output.\n\n### Returns\nA list containing the following:\n- `objective`: the objective value attained by the solution found by `qss`. \n- `solution`: the solution vector.\n\n### Separable functions\nThe following convex separable functions are supported ( $\\mathcal{I}$ is the $\\\\{0, \\infty\\\\}$ indicator function):\nFunction | Parameters | $g_i(x)$\n--- | --- | ---\n`zero` | | $0$\n`abs` | | $\\|x\\|$\n`is_pos` | | $\\mathcal I(x \\geq 0)$\n`is_neg` | | $\\mathcal I(x \\leq 0)$\n`is_bound` | `lb`: lower bound (default 0), `ub`: upper bound (default 1) | $\\mathcal I(l \\leq x \\leq u)$\n`is_zero` | | $\\mathcal I(x = 0)$\n`pos` | | $\\max\\\\{x, 0\\\\}$\n`neg` | | $\\max\\\\{-x, 0\\\\}$\n`quantile` | `tau`: scalar in $(0, 1)$ | $0.5 \\|x\\| + (\\tau - 0.5) x$\n`huber` | `M`: positive scalar | $x^2 \\text{ if } \\|x\\| \\leq M, 2M\\|x\\| - M^2 \\text{ else}$\n\nThe following nonconvex separable functions are supported:\nFunction | Parameters | $g_i(x)$\n--- | --- | ---\n`card` | | $0$ for $x = 0$; $1$ for $x \\neq 0$\n`is_int` | | $\\mathcal I(x \\text{ is an integer})$\n`is_finite_set` | `S`: Python list of scalars | $\\mathcal I(x \\in S)$\n`is_bool` | | $\\mathcal I(x \\in \\\\{0,1\\\\})$\n\nThe `t` (weight), `a` (scale), `b` (shift) parameters are used to shift and scale the above as follows: `t * g(ax - b)`.\n\n#### Example\nApplying the Huber function to a shifted version of the first 100 entries:\n```python\n[{\"g\": \"huber\", \"args\": {\"M\": 2, \"shift\": -5}, \"range\": (0, 100)}]\n```\n\n### Abstract linear operators\nQSS comes with built-in support for abstract linear operators via the `qss.linearoperator.LinearOperator` class (hereafter referred to simply as `LinearOperator`).\n\nThe easiest way to build a `LinearOperator` is via its constructor. The argument to the constructor should be a list of lists representing a block matrix, in which each block is one of the following:\n- SciPy sparse matrix or\n- [`scipy.sparse.linalg.LinearOperator`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.LinearOperator.html) or\n- `qss.linearoperator.LinearOperator` or\n- `None`.\n\nAs an example, a constraint matrix `A` could be built as follows:\n```python\nfrom qss.linearoperator import LinearOperator\n\nA = LinearOperator([\n    [None, F, -I],\n    [I, I, None]\n])\n```\nWhere `F` is a `scipy.sparse.linalg.LinearOperator` that implements the Fourier transform and `I` is a SciPy sparse identity matrix. \n\nThere are several helper functions available to facilitate the creation of `LinearOperator`s, all accessible through `qss.linearoperator`: \n- `block_diag(D)`: Returns a block diagonal `LinearOperator` from `D`, a list of linear operators (SciPy sparse matrix, `scipy.sparse.linalg.LinearOperator`, or `qss.linearoperator.LinearOperator`).\n- `hstack(D)`: Horizontally concatenates list of linear operators `D` into a single `LinearOperator`.\n- `vstack(D)`: Vertically concatenates a list of linear operators `D` into a single `LinearOperator`.\n\nLeft and right matrix multiplication between a `LinearOperator` and a NumPy array is supported. Multiplication between `LinearOperator`s is currently not supported. Matrix-vector multiplication between a `LinearOperator` `F` and a NumPy array `v` can be achieved with `F.matvec(v)` or `F @ v`. Multiplication with the adjoint of `F` can be achieved with `F.rmatvec(v)` or `v @ F`. \n\nNote that solve times may be slower when `LinearOperator`s are involved. If either `P` or `A` is a `LinearOperator`, the linear KKT system central to the QSS algorithm is solved indirectly, as opposed to directly via a factorization. \n\n\n### Example\nNonnegative least squares is a problem of the form\n\n$$\\begin{equation*} \\begin{array}{ll} \\text{minimize} & (1/2) \\Vert Gx - h \\Vert_2^2 \\\\\\\\ \\text{subject to} & x \\geq 0. \\end{array} \\end{equation*} $$\n\n`qss` can be used to solve this problem as follows:\n```python\nimport numpy as np\nimport scipy as sp\nimport qss\n\np = 100\nn = 500\nG = sp.sparse.random(n, p, density=0.2, format=\"csc\")\nh = np.random.rand(n)\n\ndata = {}\ndata[\"P\"] = G.T @ G\ndata[\"q\"] = -h.T @ G\ndata[\"r\"] = 0.5 * h.T @ h\ndata[\"g\"] = [{\"g\": \"is_pos\", \"range\": (0, p)}] # Enforce x >= 0\n\nsolver = qss.QSS(data)\nobjective, x = solver.solve()\nprint(objective)\n```\n\n## Development\nTo create a virtual environment, run\n```\npython3 -m venv env\n```\nActivate it with \n```\nsource env/bin/activate\n```\nClone the `qss` repository, `cd` into it, and install `qss` in development mode:\n```\npip install -e ./ -r requirements.txt\n```\nFinally, test to make sure the installation worked:\n```\npytest tests/\n```\n",
    "bugtrack_url": null,
    "license": "Apache License Version 2.0, January 2004 http://www.apache.org/licenses/  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION  1. Definitions.  \"License\" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.  \"Licensor\" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.  \"Legal Entity\" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, \"control\" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.  \"You\" (or \"Your\") shall mean an individual or Legal Entity exercising permissions granted by this License.  \"Source\" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.  \"Object\" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.  \"Work\" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).  \"Derivative Works\" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.  \"Contribution\" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, \"submitted\" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as \"Not a Contribution.\"  \"Contributor\" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.  2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.  3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.  4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:  (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and  (b) You must cause any modified files to carry prominent notices stating that You changed the files; and  (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and  (d) If the Work includes a \"NOTICE\" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.  You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.  5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.  6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.  7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.  8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.  9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.  END OF TERMS AND CONDITIONS  APPENDIX: How to apply the Apache License to your work.  To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets \"[]\" replaced with your own identifying information. (Don't include the brackets!)  The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same \"printed page\" as the copyright notice for easier identification within third-party archives.  Copyright [yyyy] [name of copyright owner]  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.",
    "summary": "QSS: Quadratic-Separable Solver",
    "version": "0.2.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/cvxgrp/qss/issues",
        "Homepage": "https://github.com/cvxgrp/qss"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aea52e8ef35f079799d8e03e6e3d638b3e68654d7d71401f7e4480c21dae5d73",
                "md5": "877191df52d3d2df0ae4bd624ad66abf",
                "sha256": "c9cf5360d3a84526c94f95e6020e780e11410c0aea6b7c07ebae125c5f2af7c2"
            },
            "downloads": -1,
            "filename": "qss-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "877191df52d3d2df0ae4bd624ad66abf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 29853,
            "upload_time": "2024-09-18T19:52:18",
            "upload_time_iso_8601": "2024-09-18T19:52:18.788321Z",
            "url": "https://files.pythonhosted.org/packages/ae/a5/2e8ef35f079799d8e03e6e3d638b3e68654d7d71401f7e4480c21dae5d73/qss-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf1f79ff852493deccc948807a5fa339696d1af5b41a4d8329fdfeed135123f8",
                "md5": "fc01c349eb4036afa3af484245f23a95",
                "sha256": "1e8ce6866cb6aaced39d317798a4d359d13363ae593496c514cf252bc7011d65"
            },
            "downloads": -1,
            "filename": "qss-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "fc01c349eb4036afa3af484245f23a95",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 2343637,
            "upload_time": "2024-09-18T19:52:21",
            "upload_time_iso_8601": "2024-09-18T19:52:21.009411Z",
            "url": "https://files.pythonhosted.org/packages/bf/1f/79ff852493deccc948807a5fa339696d1af5b41a4d8329fdfeed135123f8/qss-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-18 19:52:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cvxgrp",
    "github_project": "qss",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "qss"
}
        
Elapsed time: 1.31270s