def setUpClass(cls):
        Config._instance = Config.from_dictionary({
            "BEHAVIOUR": {
                "save": "false"
            },
            "POPULATION": {
                "size": "3",
                "range": 0,
                "precision": 0
            },
            "OPTIMIZATION": {
                "probrep": 0,
                "probmut": 0,
                "probcro": 0,
                "cascade": "1,1",
                "simplify": "false"
            }
        })

        set_working_directory(MLCRepositoryTest.WORKSPACE_DIR)
        if not os.path.exists(MLCRepositoryTest.WORKSPACE_DIR):
            os.makedirs(MLCRepositoryTest.WORKSPACE_DIR)

        os.makedirs(
            os.path.join(MLCRepositoryTest.WORKSPACE_DIR,
                         MLCRepositoryTest.EXPERIMENT_NAME))
Пример #2
0
    def make(working_dir, experiment_name, experiment_configuration,
             evaluation_script, preevaluation_script):
        # Obtain experiment filenames
        experiment_dir = os.path.join(working_dir, experiment_name)
        experiment_cf, experiment_db = Experiment.get_experiment_files(experiment_dir, experiment_name)

        # Put DB parameters in the configuration file
        if "BEHAVIOUR" not in experiment_configuration:
            experiment_configuration["BEHAVIOUR"] = {}

        experiment_configuration["BEHAVIOUR"]["save"] = "true"
        # FIXME: Remove this parameter. It is no longer necessary
        experiment_configuration["BEHAVIOUR"]["savedir"] = experiment_name + ".db"
        new_configuration = Config.from_dictionary(experiment_configuration)

        # Save experiment configuration file
        new_configuration.write(open(experiment_cf, "wt"))

        # Create an empty simulation in order to create the experiment database
        Config._instance = None
        Config.get_instance().read(experiment_cf)
        simulation = Simulation(experiment_name)

        def folder_structure_creator(folder_to_create, file_to_copy):
            folder_path = os.path.join(experiment_dir, folder_to_create)
            os.makedirs(folder_path)
            shutil.copy(file_to_copy, folder_path)
            init_file = os.path.join(folder_path, "__init__.py")
            open(init_file, "w").close()

        folder_structure_creator("Evaluation", evaluation_script)
        folder_structure_creator("Preevaluation", preevaluation_script)

        # Load experiment
        try:
            return Experiment(experiment_dir, experiment_name)
        except Exception, err:
            logger.error("Cannot create a new experiment. Error message: %s " % err)
            raise
Пример #3
0
    def set_configuration(self, new_configuration):
        self._configuration = Config.from_dictionary(new_configuration, config_type=ConfigParser.ConfigParser)
        self._configuration.write(open(self._config_file, "wt"))

        # Reload the configuration
        Config.get_instance().read(self._config_file)