Object for conducting search experiments.
| 110 | |
| 111 | |
| 112 | class FMinIter: |
| 113 | """Object for conducting search experiments.""" |
| 114 | |
| 115 | catch_eval_exceptions = False |
| 116 | pickle_protocol = -1 |
| 117 | |
| 118 | def __init__( |
| 119 | self, |
| 120 | algo, |
| 121 | domain, |
| 122 | trials, |
| 123 | rstate, |
| 124 | asynchronous=None, |
| 125 | max_queue_len=1, |
| 126 | poll_interval_secs=1.0, |
| 127 | max_evals=sys.maxsize, |
| 128 | timeout=None, |
| 129 | loss_threshold=None, |
| 130 | verbose=False, |
| 131 | show_progressbar=True, |
| 132 | early_stop_fn=None, |
| 133 | trials_save_file="", |
| 134 | ): |
| 135 | self.algo = algo |
| 136 | self.domain = domain |
| 137 | self.trials = trials |
| 138 | if not show_progressbar or not verbose: |
| 139 | self.progress_callback = progress.no_progress_callback |
| 140 | elif show_progressbar is True: |
| 141 | self.progress_callback = progress.default_callback |
| 142 | else: |
| 143 | self.progress_callback = show_progressbar |
| 144 | if asynchronous is None: |
| 145 | self.asynchronous = trials.asynchronous |
| 146 | else: |
| 147 | self.asynchronous = asynchronous |
| 148 | self.poll_interval_secs = poll_interval_secs |
| 149 | self.max_queue_len = max_queue_len |
| 150 | self.max_evals = max_evals |
| 151 | self.early_stop_fn = early_stop_fn |
| 152 | self.early_stop_args = [] |
| 153 | self.trials_save_file = trials_save_file |
| 154 | self.timeout = timeout |
| 155 | self.loss_threshold = loss_threshold |
| 156 | self.start_time = timer() |
| 157 | self.rstate = rstate |
| 158 | self.verbose = verbose |
| 159 | |
| 160 | if self.asynchronous: |
| 161 | if "FMinIter_Domain" in trials.attachments: |
| 162 | logger.warning("over-writing old domain trials attachment") |
| 163 | msg = pickler.dumps(domain) |
| 164 | # -- sanity check for unpickling |
| 165 | pickler.loads(msg) |
| 166 | trials.attachments["FMinIter_Domain"] = msg |
| 167 | |
| 168 | def serial_evaluate(self, N=-1): |
| 169 | for trial in self.trials._dynamic_trials: |