示例#1
0
    def __init__(self, interface, **kwargs):
        super(DifferentialEvolutionController,
              self).__init__(interface, **kwargs)

        self.learner = mll.DifferentialEvolutionLearner(
            start_datetime=self.start_datetime, **self.remaining_kwargs)

        self._update_controller_with_learner_attributes()
        self.out_type.append('differential_evolution')
示例#2
0
    def __init__(
            self,
            interface,
            training_type='differential_evolution',
            machine_learner_type='machine_learner',
            num_training_runs=None,
            no_delay=True,
            num_params=None,
            min_boundary=None,
            max_boundary=None,
            trust_region=None,
            learner_archive_filename=mll.default_learner_archive_filename,
            learner_archive_file_type=mll.default_learner_archive_file_type,
            param_names=None,
            **kwargs):

        super(MachineLearnerController, self).__init__(interface, **kwargs)
        self.machine_learner_type = machine_learner_type

        self.last_training_cost = None
        self.last_training_bad = None
        self.last_training_run_flag = False

        if num_training_runs is None:
            if num_params is None:
                self.num_training_runs = 10
            else:
                self.num_training_runs = max(10, 2 * int(num_params))
        else:
            self.num_training_runs = int(num_training_runs)
        if self.num_training_runs <= 0:
            self.log.error(
                'Number of training runs must be larger than zero:' +
                repr(self.num_training_runs))
            raise ValueError
        self.no_delay = bool(no_delay)

        self.training_type = str(training_type)
        if self.training_type == 'random':
            self.learner = mll.RandomLearner(
                start_datetime=self.start_datetime,
                num_params=num_params,
                min_boundary=min_boundary,
                max_boundary=max_boundary,
                trust_region=trust_region,
                learner_archive_filename=None,
                learner_archive_file_type=learner_archive_file_type,
                param_names=param_names,
                **self.remaining_kwargs)

        elif self.training_type == 'nelder_mead':
            self.learner = mll.NelderMeadLearner(
                start_datetime=self.start_datetime,
                num_params=num_params,
                min_boundary=min_boundary,
                max_boundary=max_boundary,
                learner_archive_filename=None,
                learner_archive_file_type=learner_archive_file_type,
                param_names=param_names,
                **self.remaining_kwargs)

        elif self.training_type == 'differential_evolution':
            self.learner = mll.DifferentialEvolutionLearner(
                start_datetime=self.start_datetime,
                num_params=num_params,
                min_boundary=min_boundary,
                max_boundary=max_boundary,
                trust_region=trust_region,
                evolution_strategy='rand2',
                learner_archive_filename=None,
                learner_archive_file_type=learner_archive_file_type,
                param_names=param_names,
                **self.remaining_kwargs)

        else:
            self.log.error(
                'Unknown training type provided to machine learning controller:'
                + repr(training_type))

        self.archive_dict.update({'training_type': self.training_type})
        self._update_controller_with_learner_attributes()