Skip to main content

Proximity Operator Repository

Proximity operators have become increasingly important tools as basic building blocks of proximal splitting algorithms, a class of algorithms that decompose complex composite convex optimization methods into simple steps involving one of the functions present in the model. This package provides implementations of the proximity operator of various functions (function of scalar variable or multivariate,convex and non-convex functions, indicator functions...).

For more information see the full project containing technical details, a tutorial and code implantation in matlab.

Installation

To install package (require python 3.8.0 or a later version):

pip install proxop

To update, one should add the option "--upgrade":

pip install proxop --upgrade

How to use it ?

Please visit our website for more tutorial and more details.

To import the package:

import proxop

Examples:

Evaluates the function 'AbsValue': >>> import proxop >>> proxop.AbsValue()(-3) 3

Use a scale factor 'gamma': >>> proxop.AbsValue(gamma=2)(-3) 6

When the input is a vector, the result is the sum of the outputs obtained by applying the function to each element :

 >>> from proxop import AbsValue
 >>> import numpy as np
 >>> AbsValue()( np.array([-1, 2, 3., -4.]) )
 10.0

Compute the proximity operator by using the method 'prox' :

>>> AbsValue().prox( 3)
2
>>> AbsValue().prox(np.array([ -3., 1., 6., 3.]))
array([-2.,  0.,  5., 2.])

Use a scale factor 'gamma'>0 to commute the proximity operator of th function "gamma*f" :

>>> AbsValue(gamma=2).prox([ -3., 1., 6.])
 array([-1.,  0.,  4.])

Example 2: Projection onto a set

Since proximity operator is a generalization of the notion of projection onto a (convex) set, one can easily interpret the result with an indicator function. For example, the affine barrier is defined as:

                   / -log(b- a.T*x)    if u.T*x < b
            f(x) =|
                   \   + inf            otherwise


 >>> import numpy as np
 >>> from proxop import AffineBarrier
 >>>
 >>> x=np.array([1,2,3])
 >>> a= np.array([-1, 5, 3])
 >>> b= 3.5
 >>> AffineBarrier(a,b)(x)
 inf  

The result below is infinite, which means 'x' does not belong to the affine set.

Projection of 'x' onto the affine set:

 >>> px= AffineBarrier(x,b).prox(x) 
 >>> px
 >>> AffineBarrier(a,b)(px)
 0.61828190224889

As expected, the result is finite, meaning the projection of 'x' belongs to the affine set.

Example 3: Matrix variable

 >>> x=np.arange(6)
 >>> x=x.reshape((2,3))
 >>> x
 array([[0, 1, 2],
       [3, 4, 5]])
 >>> a =np.ones_like(x)
 >>> a[0,:]=2
 >>> a
 array([[2., 2., 2.],
        [1., 1., 1.]])
 >>> b=np.array([-1, 2, 4])

Set 'axis=0' to process along the rows of the matrix 'x' (note the dimension of 'b' must be compatible with the shape of 'x'):

 >>> AffineBarrier(a,b, axis=0)(x)
 inf

Projection of x onton the affine set:

 >>> px = AffineBarrier(a,b, axis=0).prox(x)  
 >>> AffineBariier(x,b, axis=0)(px)
  0.157704693902156

Metadata

Release files for proxop 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for proxop 1.0.1
File Size Uploaded Provenance Actions
proxop-1.0.1.tar.gz 79.1 kB Without provenance Details for proxop-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for proxop 1.0.1
File Interpreter ABI Platform Actions
proxop-1.0.1-py3-none-any.whl Python 3 none any Details for proxop-1.0.1-py3-none-any.whl

Total release size: 276.8 kB

Release files / proxop-1.0.1.tar.gz

Download URL proxop-1.0.1.tar.gz
Size 79.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ad4a7677defc2395996c71b2953ccadd3e88a342edd24ce3685a6abffbc38c06
BLAKE2b-256 checksum
How to use checksums
b56863cd343ac419e1ba3cefbd350a3842c25ca50f4068c86e962f19c5ac597e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / proxop-1.0.1-py3-none-any.whl

Download URL proxop-1.0.1-py3-none-any.whl
Size 197.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2e4a061af97426847f8c08806a218c1b6cd457a825622b06b66a3b52bcb4220
BLAKE2b-256 checksum
How to use checksums
53123af4a63c531fbc95fb60c859249232ed0813318d6d0154f314a824e78974
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Security for proxop 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page