# Python optimization libraries

Python optimization libraries find the inputs that minimize or maximize an objective, subject to constraints. A dedicated solver handles one class of problem, such as linear, quadratic, or conic programs, rather than an arbitrary function. These libraries let engineers and data scientists tune models, schedules, and designs toward the best result.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [SciPy](#scipy) | 392.1M | 15.2K | Aug 2026 | BSD-3-Clause |
| [Optuna](#optuna) | 14.5M | 15.1K | Nov 2026 | MIT |
| [OR-Tools](#ortools) | 8.4M | 14.4K | Jan 2026 | Apache-2.0 |
| [HiGHS](#highspy) | 7.2M | 1.9K | Nov 2026 | MIT |
| [OSQP](#osqp) | 6.6M | 130 | Jun 2026 | Apache-2.0 |
| [PuLP](#pulp) | 6.4M | 2.5K | Oct 2026 | MIT |
| [Clarabel](#clarabel) | 5.4M | 629 | Jun 2025 | Apache-2.0 |
| [SCS](#scs) | 5.3M | 48 | Nov 2026 | MIT |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[SciPy](#scipy) has the most monthly downloads in this comparison, at 392.1M, a count that covers all its scientific computing.

## Capabilities

| Library | Mathematical-programming integer variables | Arbitrary objective callbacks |
| --- | --- | --- |
| [SciPy](#scipy) | Yes | Yes |
| [Optuna](#optuna) | No | Yes |
| [OR-Tools](#ortools) | Yes | No |
| [HiGHS](#highspy) | Yes | No |
| [OSQP](#osqp) | No | No |
| [PuLP](#pulp) | Yes | No |
| [Clarabel](#clarabel) | No | No |
| [SCS](#scs) | No | No |

## Libraries

### SciPy

[GitHub](https://github.com/scipy/scipy) · [PyPI](https://pypi.org/project/scipy) · [Docs](https://docs.scipy.org/doc/scipy/reference/optimize.html)

Provides numerical optimization routines for objectives, constraints, and mixed-integer linear programs.

- Downloads / mo: 392.1M
- Stars: 15.2K
- Last release: 1.18.1
- License: BSD-3-Clause
- Capabilities: [From the SciPy docs](https://docs.scipy.org/doc/scipy/reference/optimize.html)

**Strengths**

- **Optimizes Python objective functions.** Pass an objective function directly to minimize.
- **Includes mixed-integer linear optimization.** Use milp for linear models with integer decisions.

**Watch out for**

- **Minimize targets local minima.** Choose a global optimizer when a local minimum is insufficient.

```sh
pip install scipy==1.18.1
```

**scikit-learn/scikit-learn** (68.2K stars)

[scikit-learn/scikit-learn](https://github.com/scikit-learn/scikit-learn) 

```python
def _constrained_optimization(self, obj_func, initial_theta, bounds):
    if self.optimizer == "fmin_l_bfgs_b":
        opt_res = scipy.optimize.minimize(
            obj_func,
            initial_theta,
            method="L-BFGS-B",
            jac=True,
            bounds=bounds,
        )
        _check_optimize_result("lbfgs", opt_res)
        theta_opt, func_min = opt_res.x, opt_res.fun
    elif callable(self.optimizer):
        theta_opt, func_min = self.optimizer(obj_func, initial_theta, bounds=bounds)
    else:
        raise ValueError(f"Unknown optimizer {self.optimizer}.")

    return theta_opt, func_min
```

[sklearn/gaussian_process/_gpr.py](https://github.com/scikit-learn/scikit-learn/blob/a30a70e39ef550a01ea7234e9cf10d3d821df9cd/sklearn/gaussian_process/_gpr.py) · [More projects using SciPy →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20scipy%20to%20build%20constrained%20models%20and%20optimize%20objectives&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from scipy.optimize import minimize
result = minimize(lambda x: (x[0] - 2.0) ** 2, x0=[0.0])
print(result.x)

```

From [optimize.html](https://docs.scipy.org/doc/scipy/reference/optimize.html)

### Optuna

[GitHub](https://github.com/optuna/optuna) · [PyPI](https://pypi.org/project/optuna) · [Docs](https://optuna.readthedocs.io/en/stable/reference/generated/optuna.trial.Trial.html)

Optimizes hyperparameters.

- Downloads / mo: 14.5M
- Stars: 15.1K
- Last release: 5.1.0
- License: MIT
- Capabilities: [From the Optuna docs](https://optuna.readthedocs.io/en/stable/reference/generated/optuna.trial.Trial.html)

```sh
pip install optuna==5.1.0
```

**optuna/optuna-examples** (870 stars)

[optuna/optuna-examples](https://github.com/optuna/optuna-examples) 

```python
def objective(trial):
    iris = sklearn.datasets.load_iris()
    x, y = iris.data, iris.target

    classifier_name = trial.suggest_categorical("classifier", ["SVC", "RandomForest"])
    if classifier_name == "SVC":
        svc_c = trial.suggest_float("svc_c", 1e-10, 1e10, log=True)
        classifier_obj = sklearn.svm.SVC(C=svc_c, gamma="auto")
    else:
        rf_max_depth = trial.suggest_int("rf_max_depth", 2, 32, log=True)
        classifier_obj = sklearn.ensemble.RandomForestClassifier(
            max_depth=rf_max_depth, n_estimators=10
        )

    score = sklearn.model_selection.cross_val_score(classifier_obj, x, y, n_jobs=-1, cv=3)
    accuracy = score.mean()
    return accuracy
```

[sklearn/sklearn_simple.py](https://github.com/optuna/optuna-examples/blob/9450de9b8b042e396bb816fdbe7fb4b5227b3323/sklearn/sklearn_simple.py) · [More projects using Optuna →](https://dashboard.exa.ai/playground/search?q=optuna%20GitHub%20projects)

**Quickstart**

```python
import optuna
def objective(trial):
    x = trial.suggest_float("x", -10.0, 10.0)
    return (x - 2.0) ** 2
study = optuna.create_study()
study.optimize(objective, n_trials=10)
print(study.best_params)

```

From [README.md](https://optuna.readthedocs.io/en/stable/reference/generated/optuna.trial.Trial.html)

### OR-Tools

[GitHub](https://github.com/google/or-tools) · [PyPI](https://pypi.org/project/ortools) · [Docs](https://developers.google.com/optimization/lp/lp_example)

Provides the Google OR-Tools Python libraries and modules.

- Downloads / mo: 8.4M
- Stars: 14.4K
- Last release: 9.15.6755
- License: Apache-2.0
- Capabilities: [From the OR-Tools docs](https://developers.google.com/optimization/lp/lp_example)

```sh
pip install ortools==9.15.6755
```

**guillermo-navas-palencia/optbinning** (539 stars)

[guillermo-navas-palencia/optbinning](https://github.com/guillermo-navas-palencia/optbinning) 

```python
def build_model(self, divergence, n_nonevent, n_event, trend_change):
    # Parameters
    [D, V, pvalue_violation_indices,
     min_diff_violation_indices] = model_data(
        divergence, n_nonevent, n_event, self.max_pvalue,
        self.max_pvalue_policy, self.min_event_rate_diff)

    n = len(n_nonevent)
    n_records = n_nonevent + n_event

    # Initialize solver
    if self.mip_solver == "bop":
        solver = pywraplp.Solver(
            'BinningMIP', pywraplp.Solver.BOP_INTEGER_PROGRAMMING)
    elif self.mip_solver == "cbc":
        solver = pywraplp.Solver(
            'BinningMIP', pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)

    # Decision variables
    x, y, t, d, u, bin_size_diff = self.decision_variables(solver, n)

    # Objective function
    if self.gamma:
        total_records = int(n_records.sum())
        regularization = self.gamma / total_records
        pmax = solver.IntVar(0, total_records, "pmax")
        pmin = solver.IntVar(0, total_records, "pmin")

        solver.Maximize(solver.Sum([(V[i][i] * x[i, i]) +
                        solver.Sum([(V[i][j] - V[i][j+1]) * x[i, j]
                                    for j in range(i)])
                                    for i in range(n)]) -
                        regularization * (pmax - pmin))
    else:
        solver.Maximize(solver.Sum([(V[i][i] * x[i, i]) +
                        solver.Sum([(V[i][j] - V[i][j+1]) * x[i, j]
                                    for j in range(i)])
                                    for i in range(n)]))

    # Constraint: unique assignment
    self.add_constraint_unique_assignment(solver, n, x)

    # Constraint: continuity
    self.add_constraint_continuity(solver, n, x)

    # Constraint: min / max bins
    self.add_constraint_min_max_bins(solver, n, x, d)

    # Constraint: min / max bin size
    self.add_constraint_min_max_bin_size(solver, n, x, u, n_records,
                                         bin_size_diff)

    # Constraint: min / max n_nonevent per bin
    if (self.min_bin_n_nonevent is not None or
            self.max_bin_n_nonevent is not None):
        for i in range(n):
            bin_ne_size = solver.Sum([n_nonevent[j] * x[i, j]
                                      for j in range(i + 1)])

            if self.min_bin_n_nonevent is not None:
                solver.Add(bin_ne_size >= self.min_bin_n_nonevent*x[i, i])

            if self.max_bin_n_nonevent is not None:
                solver.Add(bin_ne_size <= self.max_bin_n_nonevent*x[i, i])

    # Constraint: min / max n_event per bin
    if (self.min_bin_n_event is not None or
            self.max_bin_n_event is not None):
        for i in range(n):
            bin_e_size = solver.Sum([n_event[j] * x[i, j]
                                     for j in range(i + 1)])

            if self.min_bin_n_event is not None:
                solver.Add(bin_e_size >= self.min_bin_n_event * x[i, i])

            if self.max_bin_n_event is not None:
                solver.Add(bin_e_size <= self.max_bin_n_event * x[i, i])

    # Constraints: monotonicity
    if self.monotonic_trend == "ascending":
        self.add_constraint_monotonic_ascending(solver, n, D, x)

    elif self.monotonic_trend == "descending":
        self.add_constraint_monotonic_descending(solver, n, D, x)

    elif self.monotonic_trend == "concave":
        self.add_constraint_monotonic_concave(solver, n, D, x)

    elif self.monotonic_trend == "convex":
        self.add_constraint_monotonic_convex(solver, n, D, x)

    elif self.monotonic_trend in ("peak", "valley"):
        for i in range(n):
            solver.Add(t >= i - n * (1 - y[i]))
            solver.Add(t <= i + n * y[i])

        if self.monotonic_trend == "peak":
            self.add_constraint_monotonic_peak(solver, n, D, x, y)
        else:
            self.add_constraint_monotonic_valley(solver, n, D, x, y)

    elif self.monotonic_trend == "peak_heuristic":
        self.add_constraint_monotonic_peak_heuristic(
            solver, n, D, x, trend_change)

    elif self.monotonic_trend == "valley_heuristic":
        self.add_constraint_monotonic_valley_heuristic(
            solver, n, D, x, trend_change)

    # Constraint: reduction of dominating bins
    if self.gamma:
        for i in range(n):
            bin_size = solver.Sum([n_records[j] * x[i, j]
                                   for j in range(i + 1)])

            solver.Add(pmin <= total_records * (1 - x[i, i]) + bin_size)
            solver.Add(pmax >= bin_size)
        solver.Add(pmin <= pmax)

    # Constraint: max-pvalue
    self.add_constraint_violation(solver, x, pvalue_violation_indices)

    # Constraint: min diff
    self.add_constraint_violation(solver, x, min_diff_violation_indices)

    # Constraint: fixed splits
    self.add_constraint_fixed_splits(solver, n, x)

    self.solver_ = solver
    self._n = n
    self._x = x
```

[optbinning/binning/mip.py](https://github.com/guillermo-navas-palencia/optbinning/blob/b5d8458454728a3a5be2bbde45ba5384663f1346/optbinning/binning/mip.py#L48-L178) · [More projects using OR-Tools →](https://dashboard.exa.ai/playground/search?q=ortools%20GitHub%20projects)

**Quickstart**

```python
from ortools.linear_solver import pywraplp
solver = pywraplp.Solver.CreateSolver("GLOP")
x = solver.NumVar(0.0, 3.0, "x")
solver.Add(x >= 1.0)
solver.Minimize(x)
status = solver.Solve()
if status == pywraplp.Solver.OPTIMAL:
    print(x.solution_value())

```

From [README.md](https://developers.google.com/optimization/lp/lp_example)

### HiGHS

[GitHub](https://github.com/ERGO-Code/HiGHS) · [PyPI](https://pypi.org/project/highspy) · [Docs](https://ergo-code.github.io/HiGHS/stable/interfaces/python/example-py/)

Wraps HiGHS in a thin set of pybind11 bindings.

- Downloads / mo: 7.2M
- Stars: 1.9K
- Last release: 1.16.0
- License: MIT
- Capabilities: [From the HiGHS docs](https://ergo-code.github.io/HiGHS/stable/interfaces/python/example-py/)

```sh
pip install highspy==1.16.0
```

**cvxpy/cvxpy** (6.4K stars)

[cvxpy/cvxpy](https://github.com/cvxpy/cvxpy) 

```python
def solve_via_data(
    self, data, warm_start: bool, verbose: bool, solver_opts, solver_cache=None
):
    """Returns the result of the call to the solver.

    minimize          cx
        subject to    A x <=  b

    in HiGHS, the opt problem format is,

    minimize          cx
        subject to    lboundA <= A x <= uboundA

    Parameters
    ----------
    data : dict
        Data used by the solver.
    warm_start : bool
        Whether to warm_start HiGHS.
    verbose : bool
        Should the solver print output?
    solver_opts : dict
        Additional arguments for the solver.

    Returns
    -------
    tuple
        (status, optimal value, primal, equality dual, inequality dual)
    """
    import highspy as hp

    # setup problem data
    inf = hp.Highs().inf
    dims = dims_to_solver_dict(data[s.DIMS])

    c = data[s.C]
    # A = sp.vstack([data[s.A], data[s.F]]).tocsc()
    A = data[s.A].tocsc()
    data["Ax"] = A

    leq_start = dims[s.EQ_DIM]
    leq_end = dims[s.EQ_DIM] + dims[s.LEQ_DIM]
    uboundA = data[s.B]
    data["u"] = uboundA
    lboundA = np.concatenate(
        [data[s.B][:leq_start], -inf * np.ones(data[s.B][leq_start:leq_end].shape)]
    )
    data["l"] = lboundA

    # setup highs model
    model = hp.HighsModel()
    lp = model.lp_
    lp.num_col_ = A.shape[1]
    # assert data['n_var'] == A.shape[1]
    lp.num_row_ = A.shape[0]
    # assert data['n_eq'] + data['n_ineq'] == A.shape[0]

    # offset already applied in invert()
    lp.offset_ = 0
    lp.col_cost_ = c
    lp.row_lower_ = lboundA
    lp.row_upper_ = uboundA

    assert A.format == "csc"
    lp.a_matrix_.format_ = hp.MatrixFormat.kColwise
    lp.a_matrix_.start_ = A.indptr
    lp.a_matrix_.index_ = A.indices
    lp.a_matrix_.value_ = A.data

    # Define Variable bounds
    lb = data[s.LOWER_BOUNDS]
    ub = data[s.UPPER_BOUNDS]
    col_lower = np.full(lp.num_col_, -inf, dtype=c.dtype) if lb is None else lb.copy()
    col_upper = np.full(lp.num_col_, inf, dtype=c.dtype) if ub is None else ub.copy()
    # update col_lower and col_upper to account for boolean variables,
    # also set integrality_ for boolean or integers variables
    if data[s.BOOL_IDX] or data[s.INT_IDX]:
        # note that integrality_ can only be assigned a list
        integrality = [hp.HighsVarType.kContinuous] * lp.num_col_
        if data[s.BOOL_IDX]:
            for ind in data[s.BOOL_IDX]:
                integrality[ind] = hp.HighsVarType.kInteger
            bool_mask = np.array(data[s.BOOL_IDX], dtype=int)
            col_lower[bool_mask] = np.maximum(col_lower[bool_mask], 0)
            col_upper[bool_mask] = np.minimum(col_upper[bool_mask], 1)
        for ind in data[s.INT_IDX]:
            integrality[ind] = hp.HighsVarType.kInteger
        lp.integrality_ = integrality
    lp.col_lower_ = col_lower
    lp.col_upper_ = col_upper

    solver = hp.Highs()

    # setup options
    unpack_highs_options_inplace(solver_opts)
    write_model_file = solver_opts.pop("write_model_file", None)
    solver.setOptionValue("log_to_console", verbose)
    for name, value in solver_opts.items():
        # note that calling setOptionValue directly on the solver
        # allows one to pass advanced options that aren't available
        # on the HighOptions class (e.g., presolve_rule_off)
        if solver.setOptionValue(name, value) == hp.HighsStatus.kError:
            raise ValueError(
                f"HIGHS returned status kError for option (name, value): ({name}, {value})"
            )

    if write_model_file:
        # TODO: Names can be collected upstream more systematically
        # (or in the parent class) to be used by all solvers.
        set_column_names_from_variables(lp, data[s.PARAM_PROB].variables)

    solver.passModel(model)

    if write_model_file:
        solver.writeModel(write_model_file)

    if warm_start and solver_cache is not None and self.name() in solver_cache:
        old_solver, old_data, old_result = solver_cache[self.name()]
        old_status = self.STATUS_MAP.get(old_result["model_status"], s.SOLVER_ERROR)
        if old_status in s.SOLUTION_PRESENT:
            solver.setSolution(old_result["solution"])

    # initialize and solve problem
    try:
        solver.run()
        results = {
            "solution": solver.getSolution(),
            "basis": solver.getBasis(),
            "info": solver.getInfo(),
            "model_status": solver.getModelStatus().name,
            "run_time": solver.getRunTime(),
        }
        if results["model_status"] == "kInfeasible":
            results["dual_ray"] = solver.getDualRay()
    except ValueError as e:
        raise SolverError(e)

    if solver_cache is not None:
        solver_cache[self.name()] = (solver, data, results)

    return results
```

[cvxpy/reductions/solvers/conic_solvers/highs_conif.py](https://github.com/cvxpy/cvxpy/blob/0fc467a64a66f5a0f3b7cc721779dca5f1b7ce6f/cvxpy/reductions/solvers/conic_solvers/highs_conif.py) · [More projects using HiGHS →](https://dashboard.exa.ai/playground/search?q=highspy%20GitHub%20projects)

**Quickstart**

```python
import highspy
solver = highspy.Highs()
x = solver.addVariable(lb=0.0, ub=3.0)
solver.addConstr(x >= 1.0)
solver.minimize(x)
print(solver.val(x))

```

From [README.md](https://ergo-code.github.io/HiGHS/stable/interfaces/python/example-py/)

### OSQP

[GitHub](https://github.com/osqp/osqp-python) · [PyPI](https://pypi.org/project/osqp) · [Docs](https://osqp.org/docs/interfaces/python.html)

Solves quadratic programs with operator splitting.

- Downloads / mo: 6.6M
- Stars: 130
- Last release: 1.1.3
- License: Apache-2.0
- Capabilities: [From the OSQP docs](https://osqp.org/docs/interfaces/python.html)

```sh
pip install osqp==1.1.3
```

**cvxpy/cvxpy** (6.4K stars)

[cvxpy/cvxpy](https://github.com/cvxpy/cvxpy) 

```python
def solve_via_data(self, data, warm_start: bool, verbose: bool, solver_opts,
                   solver_cache=None):
    import osqp
    is_pre_v1 = float(osqp.__version__.split('.')[0]) < 1

    P = data[s.P]
    q = data[s.Q]
    A = sp.vstack([data[s.A], data[s.F]]).tocsc()
    data['Ax'] = A
    uA = np.concatenate((data[s.B], data[s.G]))
    data['u'] = uA
    lA = np.concatenate([data[s.B], -np.inf*np.ones(data[s.G].shape)])
    data['l'] = lA

    if P is not None:
        P = sp.csc_matrix((P.data, P.indices, P.indptr), shape=P.shape)
    if A is not None:
        A = sp.csc_matrix((A.data, A.indices, A.indptr), shape=A.shape)

    # Overwrite defaults eps_abs=eps_rel=1e-3, max_iter=4000
    solver_opts['eps_abs'] = solver_opts.get('eps_abs', 1e-5)
    solver_opts['eps_rel'] = solver_opts.get('eps_rel', 1e-5)
    solver_opts['max_iter'] = solver_opts.get('max_iter', 10000)

    # Use cached data
    if warm_start and solver_cache is not None and self.name() in solver_cache:
        solver, old_data, results = solver_cache[self.name()]
        new_args = {}
        for key in ['q', 'l', 'u']:
            if any(data[key] != old_data[key]):
                new_args[key] = data[key]
        factorizing = False
        if P.data.shape != old_data[s.P].data.shape or any(
                P.data != old_data[s.P].data):
            P_triu = sp.csc_array(sp.triu(P, format='csc'))
            new_args['Px'] = P_triu.data
            factorizing = True
        if A.data.shape != old_data['Ax'].data.shape or any(
                A.data != old_data['Ax'].data):
            new_args['Ax'] = A.data
            factorizing = True

        if new_args:
            solver.update(**new_args)
        # Map OSQP statuses back to CVXPY statuses
        status_map = self.STATUS_MAP_PRE_V1 if is_pre_v1 else self.STATUS_MAP
        status = status_map.get(results.info.status_val, s.SOLVER_ERROR)
        if status == s.OPTIMAL:
            solver.warm_start(results.x, results.y)
        # Polish if factorizing.
        polish_param = 'polish' if is_pre_v1 else 'polishing'
        solver_opts[polish_param] = solver_opts.get(polish_param, factorizing)
        solver.update_settings(verbose=verbose, **solver_opts)
    else:
        # Initialize and solve problem
        polish_param = 'polish' if is_pre_v1 else 'polishing'
        solver_opts[polish_param] = solver_opts.get(polish_param, True)
        solver = osqp.OSQP()
        try:
            solver.setup(P, q, A, lA, uA, verbose=verbose, **solver_opts)
        except Exception as e:
            raise SolverError(e)

    results = solver.solve(raise_error=False)

    if solver_cache is not None:
        solver_cache[self.name()] = (solver, data, results)
    return results
```

[cvxpy/reductions/solvers/qp_solvers/osqp_qpif.py](https://github.com/cvxpy/cvxpy/blob/0fc467a64a66f5a0f3b7cc721779dca5f1b7ce6f/cvxpy/reductions/solvers/qp_solvers/osqp_qpif.py) · [More projects using OSQP →](https://dashboard.exa.ai/playground/search?q=osqp%20GitHub%20projects)

**Quickstart**

```python
import numpy as np
from scipy import sparse
import osqp
solver = osqp.OSQP()
solver.setup(P=sparse.csc_matrix([[1.0]]), q=np.array([0.0]), A=sparse.csc_matrix([[1.0]]), l=np.array([1.0]), u=np.array([np.inf]), verbose=False)
print(solver.solve(raise_error=False).x)

```

From [python.rst](https://osqp.org/docs/interfaces/python.html)

### PuLP

[GitHub](https://github.com/coin-or/pulp) · [PyPI](https://pypi.org/project/pulp) · [Docs](https://coin-or.github.io/pulp/technical/pulp.html)

Builds linear and mixed-integer models and sends them to selected solvers.

- Downloads / mo: 6.4M
- Stars: 2.5K
- Last release: 4.2.0
- License: MIT
- Capabilities: [From the PuLP docs](https://coin-or.github.io/pulp/technical/pulp.html)

**Strengths**

- **Defines integer decisions.** Set integer variable types when building a linear model.
- **Exports solver-ready models.** Write LP or MPS files for external solver workflows.

**Watch out for**

- **Solver binaries are installed separately.** Install a solver extra or supply an accessible solver.
- **Native expressions stay linear.** Use Pyomo for nonlinear objectives or constraints.

```sh
pip install "pulp[cbc]==4.2.0"
```

**snakemake/snakemake** (2.9K stars)

[snakemake/snakemake](https://github.com/snakemake/snakemake) 

```python
def __contains__(self, x: object) -> bool:
        try:
            import pulp

            return pulp.getSolver(x).available()
        except Exception:  # noqa: BLE001
            return False
```

[src/snakemake/scheduling/milp.py](https://github.com/snakemake/snakemake/blob/6d007cf012b0d4dfb80d3a7a21c2cd39bec8f7c8/src/snakemake/scheduling/milp.py#L49-L55) · [More projects using PuLP →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20pulp%20to%20build%20constrained%20models%20and%20optimize%20objectives&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from pulp import LpProblem, LpMinimize, COIN_CMD, value
problem = LpProblem("demo", LpMinimize)
x = problem.add_variable("x", 0.0, 3.0)
problem += x
problem += x >= 1.0
stats = problem.solve(COIN_CMD(msg=False))
print(stats.status_str, value(x))

```

From [README.rst](https://coin-or.github.io/pulp/technical/pulp.html)

### Clarabel

[GitHub](https://github.com/oxfordcontrol/Clarabel.rs) · [PyPI](https://pypi.org/project/clarabel) · [Docs](https://oxfordcontrol.github.io/ClarabelDocs/stable/python/getting_started_py/)

Solves conic problems with an interior-point method.

- Downloads / mo: 5.4M
- Stars: 629
- Last release: 0.11.1
- License: Apache-2.0
- Capabilities: [From the Clarabel docs](https://oxfordcontrol.github.io/ClarabelDocs/stable/python/getting_started_py/)

```sh
pip install clarabel==0.11.1
```

**cvxpy/cvxpy** (6.4K stars)

[cvxpy/cvxpy](https://github.com/cvxpy/cvxpy) 

```python
def solve_via_data(self, data, warm_start: bool, verbose: bool, solver_opts, solver_cache=None):
    """Returns the result of the call to the solver.

    Parameters
    ----------
    data : dict
        Data generated via an apply call.
    warm_start : Bool
        Whether to warm_start Clarabel.
    verbose : Bool
        Control the verbosity.
    solver_opts : dict
        Clarabel-specific solver options.

    Returns
    -------
    The result returned by a call to clarabel.solve().
    """
    import clarabel

    A = data[s.A]
    b = data[s.B]
    q = data[s.C]

    if s.P in data:
        P = data[s.P]
    else:
        nvars = q.size
        P = sp.csc_array((nvars, nvars))

    P = sp.triu(P).tocsc()

    cones = dims_to_solver_cones(data[ConicSolver.DIMS])

    def new_solver():

        _settings = self.parse_solver_opts(verbose, solver_opts)
        _solver = clarabel.DefaultSolver(P, q, A, b, cones, _settings)
        return _solver

    def updated_solver():

        if (not warm_start) or (solver_cache is None) or (self.name() not in solver_cache):
            return None

        _solver = solver_cache[self.name()]

        if not hasattr(_solver, "update"):
            return None
        elif not _solver.is_data_update_allowed():
            # disallow when presolve or chordal decomposition is used
            return None
        else:
            # current internal settings, to be updated if needed
            oldsettings = _solver.get_settings()
            newsettings = self.parse_solver_opts(verbose, solver_opts, oldsettings)

            # this overwrites all data in the solver but will not
            # reallocate internal memory.  Could be faster if it
            # were known which terms (or partial terms) have changed.
            try:
                _solver.update(P=P, q=q, A=A, b=b, settings=newsettings)
                return _solver
            except Exception:
                # If sparsity pattern or dimensions changed, update() fails.
                # Return None to trigger a full new_solver() re-initialization.
                return None

    # Try to get cached data
    solver = updated_solver()

    if solver is None:
        solver = new_solver()

    results = solver.solve()

    if solver_cache is not None:
        solver_cache[self.name()] = solver

    return results
```

[cvxpy/reductions/solvers/conic_solvers/clarabel_conif.py](https://github.com/cvxpy/cvxpy/blob/0fc467a64a66f5a0f3b7cc721779dca5f1b7ce6f/cvxpy/reductions/solvers/conic_solvers/clarabel_conif.py) · [More projects using Clarabel →](https://dashboard.exa.ai/playground/search?q=clarabel%20GitHub%20projects)

**Quickstart**

```python
import numpy as np
from scipy import sparse
import clarabel
settings = clarabel.DefaultSettings()
settings.verbose = False
solver = clarabel.DefaultSolver(sparse.csc_matrix((1, 1)), np.array([1.0]), sparse.csc_matrix([[-1.0]]), np.array([-1.0]), [clarabel.NonnegativeConeT(1)], settings)
print(solver.solve().x)

```

From [getting_started_py.md](https://oxfordcontrol.github.io/ClarabelDocs/stable/python/getting_started_py/)

### SCS

[GitHub](https://github.com/bodono/scs-python) · [PyPI](https://pypi.org/project/scs) · [Docs](https://www.cvxgrp.org/scs/api/python.html)

Solves conic problems with a splitting method.

- Downloads / mo: 5.3M
- Stars: 48
- Last release: 3.3.2
- License: MIT
- Capabilities: [From the SCS docs](https://www.cvxgrp.org/scs/api/python.html)

```sh
pip install scs==3.3.2
```

**cvxpy/cvxpy** (6.4K stars)

[cvxpy/cvxpy](https://github.com/cvxpy/cvxpy) 

```python
def solve_via_data(self, data, warm_start: bool, verbose: bool, solver_opts, solver_cache=None):
    """Returns the result of the call to the solver.

    Parameters
    ----------
    data : dict
        Data generated via an apply call.
    warm_start : Bool
        Whether to warm_start SCS.
    verbose : Bool
        Control the verbosity.
    solver_opts : dict
        SCS-specific solver options.

    Returns
    -------
    The result returned by a call to scs.solve().
    """
    import scs
    args = {"A": data[s.A], "b": data[s.B], "c": data[s.C]}
    if s.P in data:
        args["P"] = data[s.P]
    if warm_start and solver_cache is not None and \
            self.name() in solver_cache:
        args["x"] = solver_cache[self.name()]["x"]
        args["y"] = solver_cache[self.name()]["y"]
        args["s"] = solver_cache[self.name()]["s"]
    cones = dims_to_solver_dict(data[ConicSolver.DIMS])

    def solve(_solver_opts):
        _results = scs.solve(args, cones, verbose=verbose, **_solver_opts)
        _status = self.STATUS_MAP[_results["info"]["status_val"]]
        return _results, _status

    solver_opts = SCS.parse_solver_options(solver_opts)
    results, status = solve(solver_opts)
    if solver_cache is not None and status == s.OPTIMAL:
        solver_cache[self.name()] = results
    return results
```

[cvxpy/reductions/solvers/conic_solvers/scs_conif.py](https://github.com/cvxpy/cvxpy/blob/0fc467a64a66f5a0f3b7cc721779dca5f1b7ce6f/cvxpy/reductions/solvers/conic_solvers/scs_conif.py#L200-L238) · [More projects using SCS →](https://dashboard.exa.ai/playground/search?q=scs%20GitHub%20projects)

**Quickstart**

```python
import numpy as np
from scipy import sparse
import scs
data = {"A": sparse.csc_matrix([[-1.0]]), "b": np.array([-1.0]), "c": np.array([1.0])}
solver = scs.SCS(data, {"l": 1}, verbose=False)
print(solver.solve()["x"])

```

From [python.rst](https://www.cvxgrp.org/scs/api/python.html)

## FAQ

### Which Python optimization library should I use?

[SciPy](#scipy) suits general objective functions, least squares, and linear programs. [OR-Tools](#ortools) suits scheduling, routing, and other discrete models. [Optuna](#optuna) suits tuning hyperparameters and other black-box objectives.

### What is Optuna?

[Optuna](#optuna) optimizes black-box objectives through trials that sample float, integer, and categorical parameters. It prunes unpromising trials and supports custom samplers.

### What is scipy.optimize?

The scipy.optimize module in [SciPy](#scipy) minimizes objective functions with local and global methods. It also handles nonlinear constraints, least squares, linear programming, and mixed-integer linear programming.

### What is OSQP?

[OSQP](#osqp) solves convex quadratic programs from sparse matrix inputs. It can update the problem data and solve again without repeating the setup.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Python optimization libraries SciPy CVXPY Pyomo PuLP code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
