{"id":34028774,"url":"https://github.com/landonclark97/nvxpy","last_synced_at":"2026-04-05T01:34:42.704Z","repository":{"id":298044471,"uuid":"998670038","full_name":"landonclark97/nvxpy","owner":"landonclark97","description":"A Python DSL for easily formulating and solving non-convex optimization problems.","archived":false,"fork":false,"pushed_at":"2026-02-17T17:50:47.000Z","size":339,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-17T21:45:15.287Z","etag":null,"topics":["mixed-integer-programming","nonlinear-optimization","nonlinear-programming","nvxpy","optimization","optimization-modeling","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/landonclark97.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-09T04:09:53.000Z","updated_at":"2026-02-17T17:10:22.000Z","dependencies_parsed_at":"2025-06-09T05:31:53.017Z","dependency_job_id":null,"html_url":"https://github.com/landonclark97/nvxpy","commit_stats":null,"previous_names":["landonclark97/nvxpy"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/landonclark97/nvxpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/landonclark97%2Fnvxpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/landonclark97%2Fnvxpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/landonclark97%2Fnvxpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/landonclark97%2Fnvxpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/landonclark97","download_url":"https://codeload.github.com/landonclark97/nvxpy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/landonclark97%2Fnvxpy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31421869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T00:25:07.052Z","status":"ssl_error","status_checked_at":"2026-04-05T00:25:05.923Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["mixed-integer-programming","nonlinear-optimization","nonlinear-programming","nvxpy","optimization","optimization-modeling","python"],"created_at":"2025-12-13T17:18:49.089Z","updated_at":"2026-04-05T01:34:42.697Z","avatar_url":"https://github.com/landonclark97.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NVXPY\n\n[![Build Status](https://github.com/landonclark97/nvxpy/actions/workflows/test.yaml/badge.svg?branch=main)](https://github.com/landonclark97/nvxpy/actions/workflows/test.yaml)\n[![codecov](https://codecov.io/gh/landonclark97/nvxpy/branch/main/graph/badge.svg)](https://codecov.io/gh/landonclark97/nvxpy)\n\n## Overview\n\nNVXPY is a Python-based Domain Specific Language (DSL) designed for formulating and solving non-convex programs using a natural, math-inspired API. It is designed to have as similar an interface to [CVXPY](https://www.cvxpy.org/) as possible.\n\nNVXPY is not a solver, it uses solvers from other packages (such as SLSQP, IPOPT, etc.), and includes a built-in Branch-and-Bound solver for mixed-integer nonlinear programs (MINLP).\n\n\n## Features\n\n* Simple, concise, and math-inspired interface\n* Codegen compiler for efficient evaluation (85%-99% as fast as native Python)\n* Built-in Branch-and-Bound MINLP solver with discrete value constraints\n* Graph constructs for clean MIP formulations (wraps [networkx](https://networkx.org/en/))\n* Handles gradients seamlessly, even for custom functions\n\n\n## Installation\n\nNVXPY can be installed from PyPi using:\n\n```bash\npip install nvxpy\n```\n\nand has the following dependencies:\n\n* Python \u003e= 3.11\n* NumPy \u003e= 2.3\n* SciPy \u003e= 1.15\n* Autograd \u003e= 1.8\n* NetworkX \u003e= 3.0\n* cyipopt (optional, for IPOPT solver)\n\n## Usage\n\n### Basic NLP Example\n\n```python\nimport numpy as np\nimport nvxpy as nvx\n\nx = nvx.Variable((3,))\nx.value = np.array([-5.0, 0.0, 0.0])  # NLPs require a seed\n\nx_d = np.array([5.0, 0.0, 0.0])\n\nobj = nvx.norm(x - x_d)\nconstraints = [nvx.norm(x) \u003e= 1.0]  # Non-convex!\n\nprob = nvx.Problem(nvx.Minimize(obj), constraints)\nprob.solve(solver=nvx.SLSQP)\n\nprint(f'optimized value of x: {x.value}')\n```\n\n### Mixed-Integer Programming\n\nNVXPY supports integer and binary variables with a built-in Branch-and-Bound solver:\n\n```python\nimport nvxpy as nvx\n\n# Binary knapsack problem\nx = nvx.Variable(integer=True, name=\"x\")\ny = nvx.Variable(integer=True, name=\"y\")\n\nprob = nvx.Problem(\n    nvx.Maximize(10*x + 6*y),\n    [\n        5*x + 3*y \u003c= 15,\n        x ^ [0, 1],  # x in {0, 1}\n        y ^ [0, 1],  # y in {0, 1}\n    ]\n)\nprob.solve(solver=nvx.BNB)\n```\n\n### Discrete Value Constraints\n\nVariables can be constrained to discrete sets of values:\n\n```python\nx = nvx.Variable(integer=True)\n\n# x must be one of these values\nprob = nvx.Problem(\n    nvx.Minimize((x - 7)**2),\n    [x ^ [1, 5, 10, 15]]  # x in {1, 5, 10, 15}\n)\nprob.solve(solver=nvx.BNB)  # Optimal: x = 5\n```\n\n### Graph-Based MIP Formulations\n\nNVXPY provides `Graph` and `DiGraph` constructs for clean graph optimization problems:\n\n```python\nimport networkx as nx\nimport nvxpy as nvx\n\n# Maximum Independent Set\nnxg = nx.petersen_graph()\nG = nvx.Graph(nxg)\ny = G.node_vars(binary=True)\n\nprob = nvx.Problem(\n    nvx.Maximize(nvx.sum([y[i] for i in G.nodes])),\n    G.independent(y)  # y[i] + y[j] \u003c= 1 for all edges\n)\nprob.solve(solver=nvx.BNB)\n```\n\nAvailable graph helpers:\n- `G.edge_vars(binary=True)` / `G.node_vars(binary=True)` - Create decision variables\n- `G.degree(x) == k` - Degree constraints (undirected)\n- `G.in_degree(x)` / `G.out_degree(x)` - For directed graphs\n- `G.independent(y)` - Independent set constraints\n- `G.covers(x, y)` - Vertex cover constraints\n- `G.total_weight(x)` - Sum of edge weights for objectives\n\n\n### Custom Functions\n\nWrap arbitrary Python functions using the `@nvx.function` decorator:\n\n```python\nimport autograd.numpy as np\nimport nvxpy as nvx\n\n@nvx.function(jac=\"autograd\")\ndef rosenbrock(x):\n    return (1 - x[0])**2 + 100 * (x[1] - x[0]**2)**2\n\nx = nvx.Variable(shape=(2,))\nx.value = np.array([0.0, 0.0])\n\nprob = nvx.Problem(nvx.Minimize(rosenbrock(x)))\nprob.solve(solver=nvx.LBFGSB)\n```\n\nOptions:\n- `jac=\"numerical\"` - Finite difference gradients (default)\n- `jac=\"autograd\"` - Automatic differentiation via autograd\n- `jac=callable` - User-provided Jacobian function\n\n\n### Compilation\n\nPass `compile=True` to `Problem` to compile expression trees into generated Python code, avoiding interpreter overhead on each evaluation:\n\n```python\nprob = nvx.Problem(nvx.Minimize(obj), constraints, compile=True)\nprob.solve(solver=nvx.SLSQP)\n```\n\n\n## Available Solvers\n\n### Gradient-Free\n\n| Solver | Description |\n|--------|-------------|\n| `nvx.NELDER_MEAD` | Derivative-free simplex method |\n| `nvx.POWELL` | Derivative-free conjugate direction method |\n| `nvx.COBYLA` | Constrained Optimization BY Linear Approximation |\n| `nvx.COBYQA` | Constrained Optimization BY Quadratic Approximation |\n\n### Gradient-Based\n\n| Solver | Description |\n|--------|-------------|\n| `nvx.CG` | Conjugate gradient method |\n| `nvx.BFGS` | Quasi-Newton method |\n| `nvx.LBFGSB` | Limited-memory BFGS with bounds |\n| `nvx.TNC` | Truncated Newton method |\n| `nvx.SLSQP` | Sequential Least Squares Programming (supports constraints) |\n\n### Hessian-Based\n\n| Solver | Description |\n|--------|-------------|\n| `nvx.NEWTON_CG` | Newton-CG trust region method |\n| `nvx.DOGLEG` | Dogleg trust region method |\n| `nvx.TRUST_NCG` | Trust-region Newton-CG |\n| `nvx.TRUST_KRYLOV` | Trust-region with Krylov subspace |\n| `nvx.TRUST_EXACT` | Trust-region with exact Hessian |\n| `nvx.TRUST_CONSTR` | Trust-region constrained algorithm |\n\n### Global Optimizers\n\n| Solver | Description |\n|--------|-------------|\n| `nvx.DIFF_EVOLUTION` | Differential evolution |\n| `nvx.DUAL_ANNEALING` | Dual annealing |\n| `nvx.SHGO` | Simplicial homology global optimization |\n| `nvx.BASINHOPPING` | Basin-hopping with local minimization |\n\n### Other\n\n| Solver | Description |\n|--------|-------------|\n| `nvx.IPOPT` | Interior Point Optimizer (requires cyipopt) |\n| `nvx.BNB` | Built-in Branch-and-Bound MINLP solver |\n\n\n## Limitations\n\nNVXPY is in active development. Current limitations:\n\n* Branch-and-Bound solver is basic and may struggle with large problems\n* Limited set of atomic operations\n* Some edge cases may be untested\n\n\n## Development\n\nTo contribute to NVXPY, clone the repository and install the development dependencies:\n\n```bash\ngit clone https://github.com/landonclark97/nvxpy.git\ncd nvxpy\npoetry install --with dev\n```\n\n### Running Tests\n\nTests are written using `pytest`. To run the tests, execute:\n\n```bash\npoetry run pytest\n```\n\n## License\n\n[Apache 2.0](LICENSE)\n\n## Contact\n\nFor any inquiries or issues, please contact Landon Clark at [landonclark97@gmail.com](mailto:landonclark97@gmail.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flandonclark97%2Fnvxpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flandonclark97%2Fnvxpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flandonclark97%2Fnvxpy/lists"}