MCPcopy
hub / github.com/hyperopt/hyperopt / fmin

Method fmin

hyperopt/ipy.py:88–172  ·  view source on GitHub ↗
(self, fn, space, **kw)

Source from the content-addressed store, hash-verified

86 Trials.refresh(self)
87
88 def fmin(self, fn, space, **kw):
89 # TODO: all underscore variables are completely unused throughout.
90 algo = kw.get("algo")
91 max_evals = kw.get("max_evals")
92 rstate = kw.get("rstate", None)
93 _allow_trials_fmin = (True,)
94 _pass_expr_memo_ctrl = (None,)
95 _catch_eval_exceptions = (False,)
96 verbose = kw.get("verbose", 0)
97 _return_argmin = (True,)
98 wait = (True,)
99 pass_expr_memo_ctrl = (None,)
100
101 if rstate is None:
102 rstate = np.random
103
104 # -- used in test_ipy
105 self._testing_fmin_was_called = True
106
107 if pass_expr_memo_ctrl is None:
108 try:
109 pass_expr_memo_ctrl = fn.pass_expr_memo_ctrl
110 except AttributeError:
111 pass_expr_memo_ctrl = False
112
113 domain = Domain(fn, space, None, pass_expr_memo_ctrl=False)
114
115 last_print_time = 0
116
117 while len(self._dynamic_trials) < max_evals:
118 self.refresh()
119
120 if verbose and last_print_time + 1 < time():
121 print(
122 "fmin: %4i/%4i/%4i/%4i %f"
123 % (
124 self.count_by_state_unsynced(JOB_STATE_NEW),
125 self.count_by_state_unsynced(JOB_STATE_RUNNING),
126 self.count_by_state_unsynced(JOB_STATE_DONE),
127 self.count_by_state_unsynced(JOB_STATE_ERROR),
128 min(
129 [float("inf")] + [l for l in self.losses() if l is not None]
130 ),
131 )
132 )
133 last_print_time = time()
134
135 idles = [eid for (eid, (p, tt)) in list(self.job_map.items()) if p is None]
136
137 if idles:
138 new_ids = self.new_trial_ids(len(idles))
139 new_trials = algo(new_ids, domain, self, rstate.integers(2 ** 31 - 1))
140 if len(new_trials) == 0:
141 break
142 assert len(idles) >= len(new_trials)
143 for eid, new_trial in zip(idles, new_trials):
144 now = coarse_utcnow()
145 new_trial["book_time"] = now

Callers 1

test0Function · 0.95

Calls 13

refreshMethod · 0.95
waitMethod · 0.95
DomainClass · 0.85
coarse_utcnowFunction · 0.85
call_domainFunction · 0.85
spec_from_miscFunction · 0.85
CtrlClass · 0.85
getMethod · 0.80
lossesMethod · 0.80
itemsMethod · 0.80
insert_trial_docsMethod · 0.80

Tested by 1

test0Function · 0.76