Esempio n. 1
0
    def __init__(self, arguments, import_manager):
        """
        Initialize the reconstruction planning problem.

        The number of measurements that we intend to make is a fixed parameter
        and cannot be optimized by the current algorithm in one run.

        The network size is defined in the same way as in the weight matrix
        of the reconstruction problem itself.
        """

        if not isinstance(arguments, Arguments):
            raise ValueError("'arguments' must be an instance of Arguments")

        # Import the settings for the planning problem.
        self.arguments = arguments
        self._import_manager = import_manager

        # Always use the ellipse model for the reconstruction weight model.
        # This is a fast weight model, and it does not have a lot of modeling
        # of attenuation and log path loss weighting that would easily make all
        # pixels be intersected by lines at low weight.
        reconstruction_settings = self.arguments.get_settings("reconstruction")
        reconstruction_settings.set("model_class", "Ellipse_Model")

        self.settings = self.arguments.get_settings("planning_problem")
        self.N = self.settings.get("number_of_measurements")
        self.network_size = self.settings.get("network_size")
        self.padding = self.settings.get("network_padding")

        num_variables, domain = self.get_domain()
        super(Reconstruction_Plan, self).__init__(num_variables, domain)

        # The actual network sizes excluding the padding.
        self.network_width = self.network_size[0] - self.padding[0] * 2
        self.network_height = self.network_size[1] - self.padding[1] * 2
        self.size = [self.network_width, self.network_height]

        # Initial weight matrix object which can be filled with current
        # locations during evaluations and reset to be reused.
        self.weight_matrix = self.get_weight_matrix()

        # Resulting output from the weight matrix.
        self.matrix = None
        self.unsnappable = 0
        self.distances = None

        # The maximum number of unsnappable points in an individual.
        self.unsnappable_max = self.N * self.settings.get("unsnappable_rate")

        # A grid-based Geometry object that the Problem instance can use to
        # make lines and points, if necessary.
        self.geometry = Geometry_Grid()

        self.assigner = Greedy_Assignment(self.arguments, self.geometry,
                                          self._import_manager)
        self.delta_rate = self.settings.get("delta_rate")

        self.travel_distance = 0.0
        self.sensor_distances = np.empty(0)