예제 #1
0
 def _RunOptimizationImpl(self):
     # Look for the minimum max_delta that results in a successful comparison
     # for each possible edge_threshold/max_diff combination.
     for edge_threshold in xrange(self._args.max_edge_threshold,
                                  self._args.min_edge_threshold,
                                  -1 * self._args.edge_threshold_step):
         should_continue = True
         for max_diff in xrange(self._args.min_max_diff,
                                self._args.max_max_diff,
                                self._args.max_diff_step):
             for max_delta in xrange(self._args.min_delta_threshold,
                                     self._args.max_delta_threshold,
                                     self._args.delta_threshold_step):
                 parameters = parameter_set.ParameterSet(
                     max_diff, max_delta, edge_threshold)
                 success, _, _ = self._RunComparisonForParameters(
                     parameters)
                 if success:
                     print 'Found good parameters %s' % parameters
                     should_continue = False
                     break
                 logging.info('Found bad parameters %s', parameters)
             # Increasing the max_diff for a given edge_threshold once we've found
             # a good max_delta won't give us any new information, so go on to the
             # next edge_threshold.
             if not should_continue:
                 break
예제 #2
0
    def _AdjacentParameters(self, starting_parameters):
        max_diff = starting_parameters.max_diff
        delta_threshold = starting_parameters.delta_threshold
        edge_threshold = starting_parameters.edge_threshold

        max_diff_step = self._args.max_diff_step
        delta_threshold_step = self._args.delta_threshold_step
        edge_threshold_step = self._args.edge_threshold_step

        max_diffs = [
            max(self._args.min_max_diff, max_diff - max_diff_step), max_diff,
            min(self._args.max_max_diff, max_diff + max_diff_step)
        ]
        delta_thresholds = [
            max(self._args.min_delta_threshold,
                delta_threshold - delta_threshold_step), delta_threshold,
            min(self._args.max_delta_threshold,
                delta_threshold + delta_threshold_step)
        ]
        edge_thresholds = [
            max(self._args.min_edge_threshold,
                edge_threshold - edge_threshold_step), edge_threshold,
            min(self._args.max_edge_threshold,
                edge_threshold + edge_threshold_step)
        ]
        for combo in itertools.product(max_diffs, delta_thresholds,
                                       edge_thresholds):
            adjacent = parameter_set.ParameterSet(combo[0], combo[1], combo[2])
            if adjacent != starting_parameters:
                yield adjacent
  def _CreateParameterSet(self, value):
    """Creates a parameter_set.ParameterSet to test.

    Args:
      value: The value to set the variable parameter to.

    Returns:
      A parameter_set.ParameterSet with the variable parameter set to |value|
      and the other parameters set to their fixed values.
    """
    if self._unlocked_parameter == self.UNLOCKED_PARAM_MAX_DIFF:
      return parameter_set.ParameterSet(value, self._args.min_delta_threshold,
                                        self._args.min_edge_threshold)
    elif self._unlocked_parameter == self.UNLOCKED_PARAM_DELTA_THRESHOLD:
      return parameter_set.ParameterSet(self._args.min_max_diff, value,
                                        self._args.min_edge_threshold)
    else:
      return parameter_set.ParameterSet(self._args.min_max_diff,
                                        self._args.min_delta_threshold, value)
예제 #4
0
 def _GetMostPermissiveParameters(self):
     return parameter_set.ParameterSet(self._args.max_max_diff,
                                       self._args.max_delta_threshold,
                                       self._args.min_edge_threshold)