2525
2626from time import clock
2727
28+ # Python3 compat
29+ if sys .version_info [0 ] == 3 :
30+ raw_input = input
31+
2832# Function for testing.
2933def testfunc (Xin ):
3034 total = 5.0
@@ -48,7 +52,7 @@ def evaluateSample(self,Xin):
4852params ['n_iter_relearn' ] = 5
4953params ['n_init_samples' ] = 2
5054
51- print "Callback implementation"
55+ print ( "Callback implementation" )
5256
5357n = 5 # n dimensions
5458lb = np .zeros ((n ,))
@@ -57,11 +61,11 @@ def evaluateSample(self,Xin):
5761start = clock ()
5862mvalue , x_out , error = bayesopt .optimize (testfunc , n , lb , ub , params )
5963
60- print "Result" , mvalue , "at" , x_out
61- print "Running time:" , clock () - start , "seconds"
64+ print ( "Result" , mvalue , "at" , x_out )
65+ print ( "Running time:" , clock () - start , "seconds" )
6266raw_input ('Press INTRO to continue' )
6367
64- print "OO implementation"
68+ print ( "OO implementation" )
6569bo_test = BayesOptTest (n )
6670bo_test .parameters = params
6771bo_test .lower_bound = lb
@@ -70,18 +74,18 @@ def evaluateSample(self,Xin):
7074start = clock ()
7175mvalue , x_out , error = bo_test .optimize ()
7276
73- print "Result" , mvalue , "at" , x_out
74- print "Running time:" , clock () - start , "seconds"
77+ print ( "Result" , mvalue , "at" , x_out )
78+ print ( "Running time:" , clock () - start , "seconds" )
7579raw_input ('Press INTRO to continue' )
7680
77- print "Callback discrete implementation"
81+ print ( "Callback discrete implementation" )
7882x_set = np .random .rand (100 ,n )
7983start = clock ()
8084
8185mvalue , x_out , error = bayesopt .optimize_discrete (testfunc , x_set , params )
8286
83- print "Result" , mvalue , "at" , x_out
84- print "Running time:" , clock () - start , "seconds"
87+ print ( "Result" , mvalue , "at" , x_out )
88+ print ( "Running time:" , clock () - start , "seconds" )
8589
8690value = np .array ([testfunc (i ) for i in x_set ])
87- print "Optimum" , value .min (), "at" , x_set [value .argmin ()]
91+ print ( "Optimum" , value .min (), "at" , x_set [value .argmin ()])
0 commit comments