Skip to main content

Converter from numpy to cvxopt.

Project description

NpyCVX

A small library to connect numpy and CVXOPT together and solves all messy conversions in between.

Install

pip install npycvx

Example usage

A simple example when maximizing w^T x over the same system of linear inequalities.

import numpy as np
import npycvx
import functools # <- built-in python lib... 

# Some dummy data...
A = np.array([
    [-1, 1, 1],
    [-2,-1,-1]
])
b = np.array([0,-3])
objectives = np.array([
    [ 0, 0, 0],
    [ 1, 1, 1],
    [-1,-1,-1],
    [ 1, 0, 1],
])

# Load solve-function with the now converted numpy
# matrices/vectors into cvxopt data type...
solve_part_fn = functools.partial(
    npycvx.solve_lp, 
    *npycvx.convert_numpy(A, b), 
    False
)

# Exectue each objective with solver function
solutions = list(
    map(
        solve_part_fn, 
        objectives
    )
)

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

npycvx-0.0.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

npycvx-0.0.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file npycvx-0.0.3.tar.gz.

File metadata

  • Download URL: npycvx-0.0.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.18 Darwin/23.1.0

File hashes

Hashes for npycvx-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cdfa603df8737eacea8d0160bc3f165f369ff3269205def9dfec4cfc25feb545
MD5 3647b66e78b77f12de31e6efc713f293
BLAKE2b-256 0a80d46c76882cae3c665d092a7ac2e1256dd47535733c890c39237ace62685c

See more details on using hashes here.

File details

Details for the file npycvx-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: npycvx-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.9.18 Darwin/23.1.0

File hashes

Hashes for npycvx-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4fe9196e8927db93dae323ee2d6b9b376e7aca9dd406cb52b72696c64386007a
MD5 3c97c199f978221f2b2ad7f9df96a231
BLAKE2b-256 ed209547f80a84f1325f3717472638687efb9a5afc30bc05e71798fabc73c831

See more details on using hashes here.

Supported by

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