xopt-org / Xopt

Flexible high-level optimization in Python
Apache License 2.0
71 stars 24 forks source link

`Nelder-Mead`: Start from Last Evaluated Point? #206

Open ax3l opened 8 months ago

ax3l commented 8 months ago

Hi,

I am writing a generic optimization example for ImpactX using xopt :tada:. I tried out a BO generator (TuRBO) and an algorithmic optimizer (Nelder-Mead).

I realized that the syntax to start is a bit different under the condition that I can provide a few educated guesses.

# Initial guess for the quadrople strengths
initial_quad_strengths = {
    "q1_k": np.array([-3]),
    "q2_k": np.array([3]),
}
if gen_name == "TuRBO":
    # a few somewhat educated guesses
    X.evaluate_data(initial_quad_strengths)
elif gen_name == "Nelder-Mead":
    # a few somewhat educated guesses
    X.generator.initial_point = initial_quad_strengths

This makes such algorithmic swaps a bit more verbose than maybe needed. Could we potentially add support for X.evaluate_data(initial_quad_strengths) for Nelder-Mead as well, then using the last evaluated point as the initial starting point?