Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SKOptLearner doesn't work for multi variate domain #233

Closed
caenrigen opened this issue Dec 5, 2019 · 1 comment
Closed

SKOptLearner doesn't work for multi variate domain #233

caenrigen opened this issue Dec 5, 2019 · 1 comment
Labels

Comments

@caenrigen
Copy link
Contributor

The code below shows the issue.
I will do a pull request for a possible fix

import adaptive
from adaptive.learner import SKOptLearner
def F_1D(x):
    return x**2
def F_2D(x):
    return x[0]**2 + x[1]**2

# Works
learner = SKOptLearner(F_1D, dimensions=[(-20., 20.)])
runner = adaptive.runner.simple(learner, goal=lambda l: l.npoints > 10)
# Doesn't work
learner = SKOptLearner(F_2D, dimensions=[(-20., 20.),(-10., 10.)])
runner = adaptive.runner.simple(learner, goal=lambda l: l.npoints > 10)

Error output:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-1fecee9ed826> in <module>
     35 try:
     36     learner = SKOptLearner(F_2D, dimensions=[(-20., 20.),(-10., 10.)])
---> 37     runner = adaptive.runner.simple(learner, goal=lambda l: l.npoints > 10)
        global runner = None
        global adaptive.runner.simple = <function simple at 0xb1565f8c0>
        global learner = <adaptive.learner.skopt_learner.SKOptLearner object at 0x1a197df990>
        global goal = undefined
        global l = undefined
        global l.npoints = undefined
     38 except:
     39     text_file = open("exeption.txt", "w")

/usr/local/anaconda3/envs/conda-dicarlo-lab/lib/python3.7/site-packages/adaptive/runner.py in simple(learner=<adaptive.learner.skopt_learner.SKOptLearner object>, goal=<function <lambda>>)
    681         for x in xs:
    682             y = learner.function(x)
--> 683             learner.tell(x, y)
        learner.tell = <bound method SKOptLearner.tell of <adaptive.learner.skopt_learner.SKOptLearner object at 0x1a197df990>>
        x = [-3.866859822710609, 2.529043603793383]
        y = 21.34866643838174
    684 
    685 

/usr/local/anaconda3/envs/conda-dicarlo-lab/lib/python3.7/site-packages/adaptive/learner/skopt_learner.py in tell(self=<adaptive.learner.skopt_learner.SKOptLearner object>, x=[-3.866859822710609, 2.529043603793383], y=21.34866643838174, fit=True)
     30 
     31     def tell(self, x, y, fit=True):
---> 32         self.pending_points.discard(x)
        self.pending_points.discard = <built-in method discard of set object at 0x1c1c69e500>
        x = [-3.866859822710609, 2.529043603793383]
     33         super().tell([x], y, fit)
     34 

TypeError: unhashable type: 'list'
jbweston added a commit that referenced this issue Dec 8, 2019
Fix SKOptLearner for multi variate domain (issue #233)
@jbweston
Copy link
Contributor

Closed by #234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants