forked from HIPS/Spearmint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Gelbart
committed
Aug 8, 2014
1 parent
0b386d9
commit a2c2a8f
Showing
99 changed files
with
567,370 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.pyc | ||
*.log | ||
*.out | ||
*.blg | ||
*.aux | ||
*.bib | ||
#*# | ||
*.DS_Store | ||
*.py~ | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
spearmint | ||
========= | ||
spearmint: Bayesian optimization codebase | ||
========================================= | ||
|
||
Spearmint Bayesian optimization codebase for eventual release | ||
|
||
STEP 1: Installation<br> | ||
1) Install python, numpy, scipy. For academic users, the anaconda distribution is great. Use numpy 1.8 or higher. | ||
2) Download/clone the spearmint code<br> | ||
3) Install the spearmint package using pip: "pip install -e \</path/to/spearmint/root\>" (the -e means changes will be reflected automatically)<br> | ||
4) Download and install MongoDB: https://www.mongodb.org/<br> | ||
5) Install the pymongo package using e.g., pip or anaconda | ||
|
||
STEP 2: Setting up your experiment<br> | ||
1) Create a callable objective function. See ../examples/branin/branin.py as an example<br> | ||
2) Create a config file. There are 3 example config files in the ../examples directory. | ||
|
||
STEP 3: Running spearmint<br> | ||
1) Start up a MongoDB daemon instance: mongod --fork --logpath \<path/to/logfile\> --dbpath \<path/to/dbfolder\><br> | ||
2) Run spearmint: "python main.py \</path/to/experiment/directory\>" | ||
|
||
STEP 4: Looking at your results | ||
Spearmint will output results to standard out / standard err. You can also load the results from the database and manipulate them directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import math | ||
import numpy as np | ||
|
||
def evaluate(job_id, params): | ||
|
||
x = params['X'] | ||
y = params['Y'] | ||
|
||
print 'Evaluating at (%f, %f)' % (x, y) | ||
|
||
if x < 0 or x > 5.0 or y > 5.0: | ||
return np.nan | ||
# Feasible region: x in [0,5] and y in [0,5] | ||
|
||
obj = float(np.square(y - (5.1/(4*np.square(math.pi)))*np.square(x) + (5/math.pi)*x- 6) + 10*(1-(1./(8*math.pi)))*np.cos(x) + 10) | ||
|
||
con1 = float(y-x) # y >= x | ||
|
||
con2 = float(10.0-y) # y <= 10 | ||
|
||
return { | ||
"branin" : obj, | ||
"y_at_least_x" : con1, | ||
"y_at_most_10" : con2 | ||
} | ||
|
||
# True minimum is at 2.945, 2.945, with a value of 0.8447 | ||
|
||
def main(job_id, params): | ||
try: | ||
return evaluate(job_id, params) | ||
except Exception as ex: | ||
print ex | ||
print 'An error occurred in branin_con.py' | ||
return np.nan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"language" : "PYTHON", | ||
"main-file" : "branin_con", | ||
"experiment-name" : "branin-constrained-example", | ||
"variables": { | ||
"X": { | ||
"type": "FLOAT", | ||
"size": 1, | ||
"min": -5, | ||
"max": 10 | ||
}, | ||
"Y": { | ||
"type": "FLOAT", | ||
"size": 1, | ||
"min": 0, | ||
"max": 15 | ||
} | ||
}, | ||
"tasks": { | ||
"branin" : { | ||
"type" : "OBJECTIVE", | ||
"likelihood" : "NOISELESS" | ||
}, | ||
"y_at_least_x" : { | ||
"type" : "CONSTRAINT", | ||
"likelihood" : "NOISELESS" | ||
}, | ||
"y_at_most_10" : { | ||
"type" : "CONSTRAINT", | ||
"likelihood" : "NOISELESS" | ||
} | ||
}, | ||
"polling-time" : 1 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import numpy as np | ||
import sys | ||
import math | ||
import time | ||
|
||
def branin(x, y): | ||
|
||
result = np.square(y - (5.1/(4*np.square(math.pi)))*np.square(x) + | ||
(5/math.pi)*x - 6) + 10*(1-(1./(8*math.pi)))*np.cos(x) + 10 | ||
|
||
result = float(result) | ||
|
||
#if np.random.rand > 0.75: | ||
# raise Exception('Blah!') | ||
|
||
print 'Result = %f' % result | ||
time.sleep(np.random.randint(30)) | ||
return {'branin' : result} | ||
|
||
# Write a function like this called 'main' | ||
def main(job_id, params): | ||
print 'Anything printed here will end up in the output directory for job #%d' % job_id | ||
print params | ||
return branin(params['x'], params['y']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"language" : "PYTHON", | ||
"experiment-name" : "branin-distributed-example", | ||
"polling-time" : 1, | ||
"resources" : { | ||
"my-machine" : { | ||
"scheduler" : "local", | ||
"max-concurrent" : 1, | ||
"max-finished-jobs" : 100 | ||
}, | ||
"cluster" : { | ||
"scheduler" : "SLURM", | ||
"max-concurrent" : 3, | ||
"max-finished-jobs" : 1000 | ||
} | ||
}, | ||
"tasks": { | ||
"branin" : { | ||
"type" : "OBJECTIVE", | ||
"likelihood" : "NOISELESS", | ||
"main-file" : "branin", | ||
"resources" : ["my-machine", "cluster"] | ||
} | ||
}, | ||
"variables": { | ||
"x" : { | ||
"type" : "FLOAT", | ||
"size" : 1, | ||
"min" : -5, | ||
"max" : 10 | ||
}, | ||
"y" : { | ||
"type" : "FLOAT", | ||
"size" : 1, | ||
"min" : 0, | ||
"max" : 15 | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import numpy as np | ||
import sys | ||
import math | ||
import time | ||
|
||
def branin(x, y): | ||
|
||
result = np.square(y - (5.1/(4*np.square(math.pi)))*np.square(x) + | ||
(5/math.pi)*x - 6) + 10*(1-(1./(8*math.pi)))*np.cos(x) + 10 | ||
|
||
result = float(result) | ||
|
||
print 'Result = %f' % result | ||
#time.sleep(np.random.randint(60)) | ||
return result | ||
|
||
# Write a function like this called 'main' | ||
def main(job_id, params): | ||
print 'Anything printed here will end up in the output directory for job #%d' % job_id | ||
print params | ||
return branin(params['x'], params['y']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"language" : "PYTHON", | ||
"main-file" : "branin.py", | ||
"experiment-name" : "simple-braninhoo-example", | ||
"variables" : { | ||
"x" : { | ||
"type" : "FLOAT", | ||
"size" : 1, | ||
"min" : -5, | ||
"max" : 10 | ||
}, | ||
"y" : { | ||
"type" : "FLOAT", | ||
"size" : 1, | ||
"min" : 0, | ||
"max" : 15 | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.