Skip to content

How could I obtain 2 or more observation points at a single iteration? #340

Closed

Description

@UCASAlbert

Dear guys:
I found that the function "next_point_to_probe = optimizer.suggest(utility)" can only give one suggesting observation point. However, in my experiment, I want 5 observation points during each iteration.
How could I fix that?
1658910645017(1)

Activity

  1. bwheelz36 commented on Jul 27, 2022

    @bwheelz36
    Collaborator

    interesting question, which was also asked in #327 (I closed that because no one was writing back but possibly should have left it open!).
    I think maybe at the moment you can't do this.

    In principle you could add a parameter to suggest like n_suggest=5, and based on some criteria get back the five best candidates. But figuring out what this criteria should be could be tricky.
    One option could be choose the five best points based on increasingly exploratory weighting in the acquisition function... e.g. in UCB, say the user has kappa =5 and requests n_suggestions, you could do something like:

    for suggestion in n_suggestions:
        kappa_temp = kappa + some_number
        # now solve acquisition function with kappa temp

    But it would need some work on this feature, which to be clear I don't have time to do! But pull requests are welcome...

  2. UCASAlbert commented on Jul 28, 2022

    @UCASAlbert
    Author

    Thanks a lot. I will try this and come back to tell the results.

  3. UCASAlbert commented on Jul 28, 2022

    @UCASAlbert
    Author

    @bwheelz36
    thanks a lot. I fix this point by writing a new function "acq_max_plus" in the source code util.py as following:

    def acq_max_plus(ac, gp, y_max, bounds, random_state, n_warmup=10000, n_iter=10, n_suggestion=10):
    # Warm up with random points
    x_tries = random_state.uniform(bounds[:, 0], bounds[:, 1],
    size=(n_warmup, bounds.shape[0]))
    x_tries = np.around(x_tries,5)
    ys = ac(x_tries, gp=gp, y_max=y_max)
    # x_max = x_tries[ys.argmax()]
    # max_acq = ys.max()
    acq_list.extend(ys)
    x_list.extend(x_tries)
    
    # Explore the parameter space more throughly
    x_seeds = random_state.uniform(bounds[:, 0], bounds[:, 1],
                                   size=(n_iter, bounds.shape[0]))
    x_seeds = np.around(x_seeds,5)
    
    for x_try in x_seeds:
        # Find the minimum of minus the acquisition function
        res = minimize(
            lambda x: -ac(np.around(x,5).reshape(1, -1), gp=gp, y_max=y_max),
                       x_try.reshape(1, -1),
                       bounds=bounds,
                       method="L-BFGS-B"
        )
    
        # See if success
        if not res.success:
            continue
    
        acq_list.append(-res.fun[0])
        x_list.append(res.x)
    
    acq_ind = np.argsort(acq_list)[::-1]
    x_sort = np.asarray(x_list)[acq_ind][:n_suggestion]
    acq_sort = np.asarray(acq_list)[acq_ind]
    
    return np.clip(x_sort, bounds[:, 0], bounds[:, 1])

    the logic is to give out the points with 'top n_suggestion' acquisition function values.

  4. bwheelz36 commented on Jul 28, 2022

    @bwheelz36
    Collaborator

    ok, glad it worked - I will close this now then :-)

  5. bwheelz36 commented on Aug 17, 2022

    @bwheelz36
    Collaborator

    Hey @UCASAlbert see #347 - I hadn't thought of this but essentially you could create a temporary acquisition function and use the kappa decay functionality to get multiple suggestions

  6. means-to-meaning commented on Jan 20, 2024

    @means-to-meaning

    Perhaps a silly question, but my first go to idea would not be to use 5 different kappas, but take n local maxima from the given utility function. This would not work in later stages of the optimization where there is one dominant candidate location though..

  7. bwheelz36 commented on Jan 23, 2024

    @bwheelz36
    Collaborator

    Hey @means-to-meaning,
    the underlying gaussian process has both an estimate and and uncertainty for the objective function at each point. kappa defines how you choose to trade off these two things - you can choose a highly uncertain point (high kappa) or ignore uncertainty and pick a point with a high predicted value (low kappa). The other issue with "n local maxima" is that n local maxima may not exist.

    Having said this, ultimately this behavior only makes sense if you are able to do parallel optimization, and in that case you should see #347 for a much better thought out approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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