Skip to main content

This Python library provides an implementation of the proximity operator of several functions to solve non-smooth optimization problems.

Project description

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 ?

To import the package:

import proxop

Please visit our website for more tutorial and more details.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

proxop-1.0.5.tar.gz (79.4 kB view details)

Uploaded Source

Built Distribution

proxop-1.0.5-py3-none-any.whl (200.2 kB view details)

Uploaded Python 3

File details

Details for the file proxop-1.0.5.tar.gz.

File metadata

  • Download URL: proxop-1.0.5.tar.gz
  • Upload date:
  • Size: 79.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for proxop-1.0.5.tar.gz
Algorithm Hash digest
SHA256 2e66a22cc0329c1b61e80ddabc500802381e1d659c745e59365ce0820a4a6558
MD5 ab8922a8abfe7cb52cc98e4a4c5e2cb4
BLAKE2b-256 385554135943b2b9e39dd04c39a92e17b3eb2b46b6bba19eba494e2a6d7c11cf

See more details on using hashes here.

File details

Details for the file proxop-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: proxop-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 200.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for proxop-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c6aca788b74e44c9b9077f2fd5699e27cf3acdcdea03726121eefc06bf93defa
MD5 821150a84e336ecf6c3cf088907438ef
BLAKE2b-256 202aca5a604cb4d738d7e05ca6596fdc2f45b5ec0d9843b92bfd59501efbad74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page