Beispiel #1
0
    def _setup_zoopt(self):
        if self._metric is None and self._mode:
            # If only a mode was passed, use anonymous metric
            self._metric = DEFAULT_METRIC

        _dim_list = []
        for k in self._dim_dict:
            self._dim_keys.append(k)
            _dim_list.append(self._dim_dict[k])

        init_samples = None
        if self._points_to_evaluate:
            logger.warning(
                "`points_to_evaluate` seems to be ignored by ZOOpt.")
            init_samples = [
                Solution(x=tuple(point[dim] for dim in self._dim_keys))
                for point in self._points_to_evaluate
            ]
        dim = zoopt.Dimension2(_dim_list)
        par = zoopt.Parameter(budget=self._budget, init_samples=init_samples)
        if self._algo == "sracos" or self._algo == "asracos":
            from zoopt.algos.opt_algorithms.racos.sracos import SRacosTune
            self.optimizer = SRacosTune(dimension=dim,
                                        parameter=par,
                                        parallel_num=self.parallel_num,
                                        **self.kwargs)
            if init_samples:
                self.optimizer.init_attribute()
Beispiel #2
0
    def setup_zoopt(self):
        _dim_list = []
        for k in self._dim_dict:
            self._dim_keys.append(k)
            _dim_list.append(self._dim_dict[k])

        dim = zoopt.Dimension2(_dim_list)
        par = zoopt.Parameter(budget=self._budget)
        if self._algo == "sracos" or self._algo == "asracos":
            from zoopt.algos.opt_algorithms.racos.sracos import SRacosTune
            self.optimizer = SRacosTune(dimension=dim, parameter=par)
Beispiel #3
0
    def _setup_zoopt(self):
        if self._metric is None and self._mode:
            # If only a mode was passed, use anonymous metric
            self._metric = DEFAULT_METRIC

        _dim_list = []
        for k in self._dim_dict:
            self._dim_keys.append(k)
            _dim_list.append(self._dim_dict[k])

        dim = zoopt.Dimension2(_dim_list)
        par = zoopt.Parameter(budget=self._budget)
        if self._algo == "sracos" or self._algo == "asracos":
            from zoopt.algos.opt_algorithms.racos.sracos import SRacosTune
            self.optimizer = SRacosTune(
                dimension=dim, parameter=par, **self.kwargs)
Beispiel #4
0
    def __init__(self,
                 algo="asracos",
                 budget=None,
                 dim_dict=None,
                 max_concurrent=10,
                 metric="episode_reward_mean",
                 mode="min",
                 **kwargs):
        assert zoopt is not None, "Zoopt not found - please install zoopt."
        assert budget is not None, "`budget` should not be None!"
        assert dim_dict is not None, "`dim_list` should not be None!"
        assert type(max_concurrent) is int and max_concurrent > 0
        assert mode in ["min", "max"], "`mode` must be 'min' or 'max'!"
        _algo = algo.lower()
        assert _algo in ["asracos", "sracos"
                         ], "`algo` must be in ['asracos', 'sracos'] currently"

        self._max_concurrent = max_concurrent
        self._metric = metric
        if mode == "max":
            self._metric_op = -1.
        elif mode == "min":
            self._metric_op = 1.
        self._live_trial_mapping = {}

        self._dim_keys = []
        _dim_list = []
        for k in dim_dict:
            self._dim_keys.append(k)
            _dim_list.append(dim_dict[k])

        dim = zoopt.Dimension2(_dim_list)
        par = zoopt.Parameter(budget=budget)
        if _algo == "sracos" or _algo == "asracos":
            from zoopt.algos.opt_algorithms.racos.sracos import SRacosTune
            self.optimizer = SRacosTune(dimension=dim, parameter=par)

        self.solution_dict = {}
        self.best_solution_list = []

        super(ZOOptSearch, self).__init__(
            metric=self._metric, mode=mode, **kwargs)