Beispiel #1
0
def bc_rel_aspect_fcns_gen(stats, metric):
    value_one = stats['data'][sorted(stats['group'])[0]][metric]['lowest']
    aspect_fcns = {
        'bc_rel': (lambda g, d, m: divide_def0(value_one, float(d[m]['lowest'])
                                               ) / float(g))
    }
    return aspect_fcns
Beispiel #2
0
def ft_cost_fcn(g, d, m1, m2, graph):
    '''
    m1 is the metric we use for comparison; m2 is the opponent.
    '''
    m1_opt_combo = d[m1]['lowest_combo']
    m2_opt_combo = d[m2]['lowest_combo']
    apsp = nx.all_pairs_dijkstra_path_length(graph)
    apsp_paths = nx.all_pairs_dijkstra_path(graph)
    weighted = True
    extra_params = None
    m1_opt_m1_value = d[m1]['lowest']
    m2_opt_m1_value = METRIC_FCNS[m1](graph, m2_opt_combo, apsp, apsp_paths, weighted, extra_params)
    print "metric values for %s" % (m1)
    print "  value for combo %s opt for %s: %s" % (m1_opt_combo, m1, m1_opt_m1_value)
    print "  value for combo %s opt for %s: %s" % (m2_opt_combo, m2, m2_opt_m1_value)
    value = divide_def0(m2_opt_m1_value, m1_opt_m1_value)
    print "    return value of: %s for k = %s" % (value, g)
    return value
Beispiel #3
0
def ft_cost_fcn(g, d, m1, m2, graph):
    '''
    m1 is the metric we use for comparison; m2 is the opponent.
    '''
    m1_opt_combo = d[m1]['lowest_combo']
    m2_opt_combo = d[m2]['lowest_combo']
    apsp = nx.all_pairs_dijkstra_path_length(graph)
    apsp_paths = nx.all_pairs_dijkstra_path(graph)
    weighted = True
    extra_params = None
    m1_opt_m1_value = d[m1]['lowest']
    m2_opt_m1_value = METRIC_FCNS[m1](graph, m2_opt_combo, apsp, apsp_paths,
                                      weighted, extra_params)
    print "metric values for %s" % (m1)
    print "  value for combo %s opt for %s: %s" % (m1_opt_combo, m1,
                                                   m1_opt_m1_value)
    print "  value for combo %s opt for %s: %s" % (m2_opt_combo, m2,
                                                   m2_opt_m1_value)
    value = divide_def0(m2_opt_m1_value, m1_opt_m1_value)
    print "    return value of: %s for k = %s" % (value, g)
    return value
Beispiel #4
0
         'miles_cost': 'rx'
     },
     'aspect_fcns': {
         'miles_cost': (lambda g, d, m: d[m]['lowest'] / float(g))
     },
     'ylabel': (lambda m: metric_fullname(m) + "\nmiles over cost")
 },
 'ratios': {
     'aspect_colors': {  #'highest': 'rx',
         'mean': 'bo',
         'one': 'g+'
     },
     'aspect_fcns':
     {  #'highest': (lambda g, d, m: divide_def0(d[m]['highest'], d[m]['lowest'])),
         'mean':
         (lambda g, d, m: divide_def0(d[m]['mean'], d[m]['lowest'])),
         'one': (lambda g, d, m: 1.0)
     },
     'ylabel': (lambda m: metric_fullname(m) + "/optimal"),
     'max_x': (lambda o: 12.0),
     'min_y': (lambda o: 1.0),
     'max_y': (lambda o: 2.5)
 },
 'durations': {
     'aspect_colors': {
         'duration': 'rx'
     },
     'aspect_fcns': {
         'duration': (lambda g, d, m: d[m]['duration'])
     },
     'ylabel': (lambda m: metric_fullname(m) + "duration (sec)")
Beispiel #5
0
     'aspect_fcns': {
         'lowest': (lambda g, d, m: d[m]['lowest'])
     },
     'aspect_colors': {
         'lowest': 'g+'
     },
     'get_data_fcns': ranges_get_data_fcns
 },
 'ratios_all': {
     'aspect_colors': {
         'highest': 'rx',
         'mean': 'bo',
         'one': 'g+'
     },
     'aspect_fcns': {
         'highest': (lambda g, d, m: divide_def0(d[m]['highest'], d[m]['lowest'])),
         'mean': (lambda g, d, m: divide_def0(d[m]['mean'], d[m]['lowest'])),
         'one': (lambda g, d, m: 1.0)
     },
     'ylabel': (lambda m: metric_fullname(m) + "/optimal"),
     'min_y': (lambda o: 0.8),
     'max_y': (lambda o: 6.0),
     'get_data_fcns': shared_get_data_fcns
 },
 'ratios_mean': {
     'aspect_colors': {
         'mean': 'b*',
         'one': 'g+'
     },
     'aspect_fcns': {
         'mean': (lambda g, d, m: divide_def0(d[m]['mean'], d[m]['lowest'])),
Beispiel #6
0
def bc_rel_aspect_fcns_gen(stats, metric):
    value_one = stats['data'][sorted(stats['group'])[0]][metric]['lowest']
    aspect_fcns = {'bc_rel': (lambda g, d, m: divide_def0(value_one, float(d[m]['lowest'])) / float(g))}
    return aspect_fcns