Skip to content

Commit

Permalink
Fixing issues #16 and #19 on github
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcantin committed Aug 28, 2018
1 parent b8e5e9a commit 1326549
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
20 changes: 10 additions & 10 deletions python/demo_quad.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env python
# -------------------------------------------------------------------------
# This file is part of BayesOpt, an efficient C++ library for
# This file is part of BayesOpt, an efficient C++ library for
# Bayesian optimization.
#
# Copyright (C) 2011-2015 Ruben Martinez-Cantin <[email protected]>
#
# BayesOpt is free software: you can redistribute it and/or modify it
#
# BayesOpt is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BayesOpt is distributed in the hope that it will be useful, but
# BayesOpt is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
Expand All @@ -27,14 +27,14 @@
from time import clock

# Python3 compat
if sys.version_info[0] == 3:
raw_input = input
if hasattr(__builtins__, 'raw_input'):
input = raw_input

# Function for testing.
def testfunc(Xin):
total = 5.0
for value in Xin:
total = total + (value -0.33)*(value-0.33)
total = total + (value - 0.33) * (value - 0.33)

return total

Expand Down Expand Up @@ -64,7 +64,7 @@ def evaluateSample(self,Xin):

print("Result", mvalue, "at", x_out)
print("Running time:", clock() - start, "seconds")
raw_input('Press INTRO to continue')
input('Press INTRO to continue')

print("OO implementation")
bo_test = BayesOptTest(n)
Expand All @@ -77,10 +77,10 @@ def evaluateSample(self,Xin):

print("Result", mvalue, "at", x_out)
print("Running time:", clock() - start, "seconds")
raw_input('Press INTRO to continue')
input('Press INTRO to continue')

print("Callback discrete implementation")
x_set = np.random.rand(100,n)
x_set = np.random.rand(100, n)
start = clock()

mvalue, x_out, error = bayesopt.optimize_discrete(testfunc, x_set, params)
Expand Down
4 changes: 1 addition & 3 deletions utils/fileparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ namespace bayesopt
/* Checks if a file exists */
bool FileParser::fileExists(){
std::ifstream ifile(filename.c_str());
bool result = ifile;
ifile.close();
return result;
return ifile.good();
}

/* Data write/read function */
Expand Down

0 comments on commit 1326549

Please sign in to comment.