Directsearch Optimization Solver

1.0.1 · active · verified Wed Apr 15

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.

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →