Пример #1
0
    def __init__(self, config_element):
        pysage.Arena.__init__(self, config_element)

        self.exploitation_rate = 1 if config_element.attrib.get(
            "exploitation_rate") is None else float(
                config_element.attrib["exploitation_rate"])

        self.timestep_length = 0.5 if config_element.attrib.get(
            "timestep_length") is None else float(
                config_element.attrib.get("timestep_length"))

        self.integration_step = 0.001 if config_element.attrib.get(
            "integration_step") is None else float(
                config_element.attrib.get("integration_step"))

        self.size_radius = 0.7506 if config_element.attrib.get(
            "size_radius") is None else float(
                config_element.attrib.get("size_radius"))

        self.results_filename = "CRWLEVY" if config_element.attrib.get(
            "results") is None else config_element.attrib.get("results")
        self.results = Results()

        # initialise num runs from the configuration file
        nnruns = config_element.attrib.get("num_runs")
        if nnruns is not None:
            self.num_runs = int(nnruns)
        else:
            self.num_runs = 1

        #  size_radius
        ssize_radius = config_element.attrib.get("size_radius")
        if ssize_radius is not None:
            self.dimensions_radius = float(ssize_radius)
        elif ssize_radius is None:
            self.dimensions_radius = float(self.dimensions.x / 2.0)

        # initialise targets from the configuration file
        self.targets = []
        self.num_targets = 0
        for target_element in config_element.iter("target"):  # python 2.7
            num_targets_to_configure = 1 if target_element.attrib.get(
                "num_elements") is None else int(
                    target_element.attrib.get("num_elements"))
            for i in range(num_targets_to_configure):
                new_target = Target(target_element)
                self.targets.append(new_target)
                new_target.id = self.num_targets
                self.num_targets += 1
                print "Initalised target", new_target.id, "(quality value:", new_target.value, ")"