Skip to content

Commit 184994a

Browse files
author
Lindon Roberts
committed
Simplify evaluation database demo
1 parent a3a6274 commit 184994a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

examples/existing_evaluations.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ def watson(x):
3737
n = 6
3838
x0 = 0.5 * np.ones((n,), dtype=float)
3939

40-
# When n=6, we expect f(x0) ~ 16.4308 and f(xmin) ~ 0.00228767 at xmin ~ [ -0.0157, 1.0124, 1.2604, -1.5137, 0.992996]
41-
4240
# For optional extra output details
43-
import logging
44-
logging.basicConfig(level=logging.INFO, format='%(message)s')
41+
# import logging
42+
# logging.basicConfig(level=logging.INFO, format='%(message)s')
43+
44+
# Initial run: normal initialization from starting point x0
45+
soln = dfols.solve(watson, x0)
46+
print(soln)
4547

4648
# Now build a database of evaluations
4749
eval_db = dfols.EvaluationDatabase()
@@ -55,6 +57,7 @@ def watson(x):
5557
eval_db.append(x2, watson(x2))
5658
eval_db.append(x3, watson(x3))
5759

60+
# Alternative run: initialize using evaluation database
61+
# Turn on logging above to see which database points are selected to reduce the initialization cost
5862
soln = dfols.solve(watson, eval_db) # replace x0 with eval_db
59-
6063
print(soln)

0 commit comments

Comments
 (0)