Exemple #1
0
rows = []
header = [
    'filename','revenue','val_coalition','iterations','switches',
    'gwd_gap','sep_gap_last','vcg_gap_mean','sep_gap_mean',
    'vals_final_bid_median','vals_vcg_bid_median','vals_vcg_final_median'
] 
header += ['vals_final_bid_%d' % pct for pct in range(0,101,2)]
header += ['vals_vcg_bid_%d' % pct for pct in range(0,101,2)]
header += ['vals_vcg_final_%d' % pct for pct in range(0,101,2)]

rows.append(header)
for result_file_path in files:
    with closing(open(result_file_path,'r')) as result:
        res = result.read()
        data = json.decode(res)
        price_diff_final_to_bid = []
        price_diff_vcg_to_bid = []
        price_diff_vcg_to_final = []
        for w in data['winners']:
            price_bid = data['prices_bid'][w]
            price_vcg = data['prices_vcg'][w]
            price_final = data['prices_final'][w]
            price_diff_final_to_bid.append(round(float(price_final) / price_bid,4))
            price_diff_vcg_to_bid.append(round(float(price_vcg) / price_bid,4))
            price_diff_vcg_to_final.append(round(float(price_vcg) / price_final,4))

        vals_final_bid = OrderedDict()
        vals_vcg_bid = OrderedDict()
        vals_vcg_final = OrderedDict()
        for percstore,percread in zip(
Exemple #2
0
    result = sys.stdin.read()
#    options.scenarios = '/tmp/scen.data'
#    options.scenopts = '/tmp/scen.opts'
#    result = open('/tmp/scen.result').read()
    
    if not os.path.exists(options.graph_path): 
        raise Exception('%s not existing' % options.graph_path)

    # get sha1
    m = hashlib.md5(result)
    graph_file_prefix = m.hexdigest()[:10]
    
    if options.add_prefix: graph_file_prefix += options.add_prefix
        
    # decode the whole result as object
    result = json.decode(result)
    
    # prefix it with infos about the scenario if available
    if options.scenopts and options.offset is not None:
        with closing(open(options.scenopts,'r')) as scenopts_file:
            generated_options = json.decode(scenopts_file.read())
#            the generator loops first through all random seeds, and then through all distributions
            used_random_seed = generated_options['random_seeds'][
                int(math.ceil(options.offset / len(generated_options['distributions'])))
            ]
            used_distribution = generated_options['distributions'][options.offset - generated_options['random_seeds'].index(used_random_seed)]
            graph_file_scen_prefix = '%s_%s' % ('-'.join(map(str,used_distribution)),used_random_seed)
            graph_file_prefix = '%s_%s' % (graph_file_scen_prefix,graph_file_prefix)
    
    scenario = None
    if options.scenarios and options.offset is not None:
Exemple #3
0
 def convertJson(opt, opt_str, value, parser): setattr(parser.values, opt.dest, json.decode(value))
 parser = optparse.OptionParser()
Exemple #4
0
    return res


if __name__ == "__main__":
    import sys
    import os
    import optparse

    sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
    from tvauction.common import json, convertToNamedTuples

    log_level = int(os.environ["LOG_LEVEL"]) if "LOG_LEVEL" in os.environ else logging.WARN
    logging.basicConfig(level=log_level)

    parser = optparse.OptionParser()
    parser.set_usage("%prog [options] < scenarios.json")
    if sys.stdin.isatty():
        print parser.format_help()
        sys.exit()

    for option in parser.option_list:
        if option.default != ("NO", "DEFAULT"):
            option.help += (" " if option.help else "") + "[default: %default]"
    options = parser.parse_args(sys.argv)[0]
    scenarios = json.decode(sys.stdin.read())
    # convert
    for scenario in scenarios:
        convertToNamedTuples(scenario)
        res = analyze(scenario)
        print json.encode(res)