HIPS / Spearmint

Spearmint Bayesian optimization codebase
Other
1.54k stars 328 forks source link

How to run PES without constraints? #80

Open ili3p opened 7 years ago

ili3p commented 7 years ago

I'm using the PESC branch and my configuration for running PES without constraints is this:

{
    "language"        : "PYTHON",
    "main_file"       : "branin.py",
    "experiment-name" : "simple-braninhoo-example",
    "likelihood"      : "NOISELESS",
    "acquisition"     : "PES",
    "variables" : {
        "x" : {
            "type" : "FLOAT",
            "size" : 1,
            "min"  : 5,
            "max"  : 10
        },
        "y" : {
            "type" : "FLOAT",
            "size" : 1,
            "min"  : 10,
            "max"  : 15
        }
    }
}

However, the algorithm sometimes proposes values for x and y that are out of range (e.g., (x,y)=(0,0)). Why is this happening? Is the configuration correct? If not, how to run the algorithm with PES?

Further, from the main README.md

Note: using PESC without constraints results in a method that is similar (but not exactly equivalent) to Predictive Entropy Search (http://arxiv.org/abs/1406.2541).

What exactly is the difference? Is there an exact implementation of that paper? If not, how to cite this PES implementation?

Thanks

ili3p commented 7 years ago

Further, if I return np.nan when Spearmint tries to evaluate out of range values I get this error:

Fitting GP to 0 data for Objective task...
Fitting GP to 1 data for NaN task...
Computing current best...

No feasible solution found (yet).

Maximum total probability of satisfying constraints = 0.50305
  Probability of satisfying                NaN constraint: 0.50305

At location:
                NAME          TYPE       VALUE
                ----          ----       -----
                0             float      0.000000
                1             float      0.001000
                2             float      0.001000
                3             float      0.800000
                4             int        8
                5             int        50
Traceback (most recent call last):
  File "main.py", line 591, in <module>
    main(expt_dir, kwargs.config_file, kwargs.no_output, kwargs.repeat)
  File "main.py", line 334, in main
    recommendation = chooser.best()
  File "/home/ilija/GP-PES/Spearmint/spearmint/choosers/default_chooser.py", line 872, in best
    val_o, loc_o = self.bestObservedConstrained()
  File "/home/ilija/GP-PES/Spearmint/spearmint/choosers/default_chooser.py", line 1301, in bestObservedConstrained
    all_constraints_satisfied = np.all([self.constraintSatisfiedAtObservedInputs(c) for c in self.constraints], axis=0)
  File "/home/ilija/GP-PES/Spearmint/spearmint/choosers/default_chooser.py", line 1354, in constraintSatisfiedAtObservedInputs
    sat = values/float(model.options['binomial_trials']) >= model._one_minus_epsilon
AttributeError: 'GP' object has no attribute '_one_minus_epsilon'

(This is for a different configuration, but the same applies)

So instead I just return a big number, but then PES performs poorly.

mgelbart commented 7 years ago

Hi @ilija139 I have pushed some changes that hopefully fix both issues you were having. Can you please pull and give it a shot, and let me know. If the issue is fixed I will close the issue.

Regarding you question

What exactly is the difference? Is there an exact implementation of that paper? If not, how to cite this PES implementation?

@jmhernandezlobato would be able to give a better answer; I'll see if I can get him on this thread. But, in brief, PES makes more simplifying assumptions than PESC when approximating the acquisition function, so we expect it to be slightly less accurate. Another difference is that the original PES assumes the gradient of the objective is zero at a minimum, but we realized this assumption is not valid when the minimum occurs along the boundary of the domain. Thus we do not make this assumption in this implementation (regardless of whether constraints are present).

The code for the original PES is not implemented in Spearmint. You can take a look at the original PES paper and see if code is provided. But I think if you want to use PES then using our implementation here is perfectly valid.

mgelbart commented 7 years ago

FYI @jmhernandezlobato