Skip to content

Shiwa and NGOpt give userwarnings if the budget is low #1702

@lesshaste

Description

@lesshaste

Both Shiwa and NGopt give a userwarning if the budget is below a certain level.

UserWarning: COBYLA: Invalid RHOEND; it should be a positive number and RHOEND <= RHOBEG; it is set to 1e-06
  warn(f'{solver}: Invalid RHOEND; it should be a positive number and RHOEND <= RHOBEG; it is set to {rhoend}')

For Shiwa this happens when budget < 60 and for NGOpt it happens when budget < 101.

Example code:

import numpy as np
import nevergrad as ng
from nevergrad.optimization.optimizerlib import Shiwa,NGOpt

def three_minima_function(params):
    x, y = params
    res = -2 * np.exp(-((x - 1) ** 2 + (y - 1) ** 2) / 0.2) - 1.5 * np.exp(-((x + 1) ** 2 + (y + 1) ** 2) / 0.5) - 1 * np.exp(-((x - 1) ** 2 + (y + 1) ** 2) / 1)
    res = np.ceil(res * 100) / 100
    return res

# Define the parameter space with bounds [-5, 5] for both x and y
parametrization = ng.p.Array(shape=(2,)).set_bounds(lower=[-5, -5], upper=[5, 5])

# Create the Shiwa optimizer
optimizer = NGOpt(parametrization=parametrization, budget=100)

# Run the optimization
recommendation = optimizer.minimize(three_minima_function)

# Get the optimal parameters and function value
optimal_params = recommendation.value
optimal_value = three_minima_function(optimal_params)

print(f"Optimal parameters: x = {optimal_params[0]:.6f}, y = {optimal_params[1]:.6f}")
print(f"Optimal function value: {optimal_value:.6f}")

Python 3.12.8
Ubuntu 24.04.2 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions