Esempio n. 1
0
def call_partition_trajectory(trajectory_point_list):
    if len(trajectory_point_list) < 2:
        raise ValueError("didn't provide a trajectory with enough points")
    
    traj_line_iterable_getter = TrajectoryLineSegmentIteratorGetter(trajectory_point_list)
    
    cum_dist_getter_func = \
    cummulative_distance_function_getter_adapter(perp_distance_func=lambda x, y: perpendicular_distance(x, y), \
                                                                             angle_distance_func=lambda x, y: \
                                                                             angular_distance(x, y), \
                                                                             accumulator_wrapper=lambda x: \
                                                                             -(math.pow(2, 32) - 1) if x == 0 else math.log(x, 2), \
                                                                             accumulator_func_getter=get_number_list_reducer_that_returns_each_midway_val)

    partition_from_index_getter = get_partition_from_index_creator(get_line_segment_from_points)
    
    partition_cost_computer_func = part_cost_computer_adapter(part_cost_func=partition_cost_computer, \
                                                              line_segment_iterable_getter=traj_line_iterable_getter.get_iterable, \
                                                              partition_line_getter=partition_from_index_getter, \
                                                              distance_func_computer_getter=cum_dist_getter_func, \
                                                              line_segment_creator=get_line_segment_from_points)
    no_par_cost_computer_func = no_part_cost_computer_adapter(no_part_cost_func=no_partition_cost_computer, \
                                                              line_segment_iterable_getter=traj_line_iterable_getter.get_iterable, \
                                                              line_segment_creator=get_line_segment_from_points)
    
    return partition_trajectory(trajectory_point_list=trajectory_point_list, \
                                partition_cost_func=partition_cost_computer_func, \
                                no_partition_cost_func=no_par_cost_computer_func, \
                                get_model_cost_computer_func=get_model_cost_computer, \
                                individual_line_seg_model_cost_computer=individual_line_seg_model_cost_computer)
 def encoding_cost(self, start, end):
     self.check_indice_args(start, end)
     approximation_line = LineSegment.from_points([self.points[start], self.points[end]])
     
     total_perp = 0.0
     total_angular = 0.0
     for i in xrange(start, end):
         line_seg = LineSegment.from_points([self.points[i], self.points[i + 1]])
         total_perp += perpendicular_distance(approximation_line, line_seg)
         total_angular += angular_distance(approximation_line, line_seg)
         
     if total_perp < 1.0:
         total_perp = 1.0
     if total_angular < 1.0:
         total_angular = 1.0
         
     return math.log(total_perp, 2) + math.log(total_angular, 2)
Esempio n. 3
0
 def encoding_cost(self, start, end):
     self.check_indice_args(start, end)
     approximation_line = LineSegment.from_points([self.points[start], self.points[end]])
     
     total_perp = 0.0
     total_angular = 0.0
     for i in xrange(start, end):
         line_seg = LineSegment.from_points([self.points[i], self.points[i + 1]])
         total_perp += perpendicular_distance(approximation_line, line_seg)
         total_angular += angular_distance(approximation_line, line_seg)
         
     if total_perp < 1.0:
         total_perp = 1.0
     if total_angular < 1.0:
         total_angular = 1.0
         
     return math.log(total_perp, 2) + math.log(total_angular, 2)
Esempio n. 4
0
 def distance_to_candidate(self, other_candidate):
     if other_candidate == None or other_candidate.line_segment == None or self.line_segment == None:
         raise Exception()
     return perpendicular_distance(self.line_segment, other_candidate.line_segment) + \
         angular_distance(self.line_segment, other_candidate.line_segment) + \
         parrallel_distance(self.line_segment, other_candidate.line_segment)
Esempio n. 5
0
 def distance_to_candidate(self, other_candidate):
     if other_candidate == None or other_candidate.line_segment == None or self.line_segment == None:
         raise Exception()
     return perpendicular_distance(self.line_segment, other_candidate.line_segment) + \
         angular_distance(self.line_segment, other_candidate.line_segment) + \
         parrallel_distance(self.line_segment, other_candidate.line_segment)