示例#1
0
    parser = OptionParser()
    parser.set_usage('%prog [options] < scenarios.json')
    parser.add_option('--initial-vector', dest='price_vector', choices=('vcg','zero'), default='vcg', help='the type of price vector used as a starting point for core price generation (vcg,zero)')
    parser.add_option('--core-algorithm', dest='core_algorithm', choices=('trim','switch','reuse'), default='reuse', help='which algorithm should be used in case a suboptimal winner determination is discovered during core pricing (trim: trim the values to be within a feasible region, switch: recreate the ebpo,reuse: recreate the ebpo and try to re-use already existing constraints)')
    parser.add_option('--time-limit-gwd',dest='time_limit_gwd', type='int', default='20', help='the time limit for the initial winner determination problem')
    parser.add_option('--time-limit',dest='time_limit', type='int', default='20', help='the time limit for all problems but the initial winner determination problem')
    parser.add_option('--epgap',dest='epgap', type='float', default=None, help='the epgap used for all problems')
    parser.add_option('--offset',dest='offset', type='int', default=0, help='the scenario offset used')
    for option in parser.option_list: 
        if option.default != ("NO", "DEFAULT"): option.help += (" " if option.help else "") + "[default: %default]"
    if sys.stdin.isatty():
        print parser.format_help()
        sys.exit()
    
    # parse scenario and options    
    scenarios = json.decode(sys.stdin.read())
    options = parser.parse_args()[0]

    scenario = scenarios[options.offset]
    convertToNamedTuples(scenario)
    slots, bidder_infos = scenario
    
    # create processor object and set values
    proc = TvAuctionProcessor()
    if options.price_vector=='vcg': proc.vcgClass = Vcg
    elif options.price_vector=='zero': proc.vcgClass = Zero
    
    if options.core_algorithm=='trim': proc.core_algorithm = CorePricing.TRIM_VALUES
    elif options.core_algorithm=='switch': proc.core_algorithm = CorePricing.SWITCH_COALITIONS
    elif options.core_algorithm=='reuse': proc.core_algorithm = CorePricing.REUSE_COALITIONS
    
示例#2
0
 def handle():
     data = json.decode(self.socket_rr.recv())
     self.assertEquals(['is_free', None, False], data)
     self.socket_rr.send('{"ui":2}')
     data = json.decode(self.socket_rr.recv())
     self.assertEquals(['solve', 'in_use', None], data)
示例#3
0
def unserialize(data):
    return json.decode(data)
示例#4
0
 def handle():
     data = json.decode(self.socket_rr.recv())
     self.assertEquals(['is_free', None, False], data)
     self.socket_rr.send('')