Registry / ai-ml / directsearch

directsearch

JSON →
library1.1pypypi✓ verified 90d ago

directsearch is a Python package for solving unconstrained minimization problems without requiring derivatives of the objective function. It is particularly useful when objective function evaluations are expensive or noisy, implementing a family of direct search methods. The current version is 1.0.1, with releases focused on stability and compatibility.

pip install directsearch
INSTALL
IMPORT
SIG · DIRECTSEARCH
D
directsearch
ai-mlpythonv1.1
Install
7.7s avg
Import
1243ms
Disk
234MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 1.272s · 230.9MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 7.7s · import 1.214s · 222MB
234MB installed
● package 234MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

solve
✓ from directsearch import solve
The primary function for initiating a direct search optimization.

This example demonstrates how to use `directsearch.solve` to minimize the Rosenbrock function. The objective function `f` must take a one-dimensional NumPy array and return a single float. The initial guess `x0` must also be a one-dimensional NumPy array.

import numpy as np from directsearch import solve def rosenbrock(x): # The Rosenbrock function (a common optimization test problem) return (1.0 - x[0])**2 + 100.0 * (x[1] - x[0]**2)**2 # Initial guess for the minimizer x0 = np.array([0.0, 0.0]) # Solve the optimization problem soln = solve(rosenbrock, x0) print(f"Optimal value: {soln.f}") print(f"Optimal solution: {soln.x}")
Debug
Known issues
gotchaOlder versions of directsearch (e.g., v1.0.0) may encounter errors or deprecation warnings with newer NumPy versions due to internal API changes in NumPy. Version 1.0.1 specifically addresses this.
fix
Upgrade to directsearch v1.0.1 or newer: `pip install --upgrade directsearch`.
affects: <1.0.1
gotchaThe initial guess `x0` passed to `directsearch.solve` must be a one-dimensional `numpy.ndarray`.
fix
Ensure `x0` is created as `np.array([...])` and `len(x0.shape) == 1`.
affects: All
gotchaThe objective function `f` passed to `directsearch.solve` must return a single `float` value.
fix
Verify that your objective function's return type is a scalar float.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'directsearch'
The 'directsearch' package is not installed in your Python environment or is not accessible via the Python path.
fix
Run `pip install directsearch` to install the package.
AttributeError: module 'numpy' has no attribute 'bool'
This error occurs when an older version of `directsearch` or one of its dependencies attempts to use `np.bool`, which was deprecated and removed in recent NumPy versions.
fix
Upgrade `directsearch` to its latest version (e.g., `pip install --upgrade directsearch`) and ensure NumPy is updated to a compatible version (e.g., `pip install --upgrade numpy`). If the issue persists due to other dependencies, consider creating a dedicated virtual environment or downgrading numpy to a version compatible with all installed packages (e.g., `pip install numpy==1.23.0` if necessary, though this is less ideal).
TypeError: 'float' object is not callable
You are passing the result of a function call (a float value) instead of the function object itself to a `directsearch` optimization method, which expects a callable objective function.
fix
Ensure you pass the objective function without parentheses, for example: `result = directsearch.solve_directsearch(my_objective_function, initial_point)` instead of `result = directsearch.solve_directsearch(my_objective_function(), initial_point)`.
Upgrade
Version history
1.1latest on PyPI · released Jun 4, 2026
Audit
Dependencies
numpyrequiredRequired for defining initial points (x0) and handling objective function inputs/outputs.
pythonrequiredRequires Python 3.9 or higher.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources