当前位置: 首页>>代码示例>>Python>>正文


Python Stats.total_revenue方法代码示例

本文整理汇总了Python中stats.Stats.total_revenue方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.total_revenue方法的具体用法?Python Stats.total_revenue怎么用?Python Stats.total_revenue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stats.Stats的用法示例。


在下文中一共展示了Stats.total_revenue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import total_revenue [as 别名]
def main(args):

    usage_msg = "Usage:  %prog [options] PeerClass1[,cnt] PeerClass2[,cnt2] ..."
    parser = OptionParser(usage=usage_msg)

    def usage(msg):
        print "Error: %s\n" % msg
        parser.print_help()
        sys.exit()
    
    parser.add_option("--loglevel",
                      dest="loglevel", default="info",
                      help="Set the logging level: 'debug' or 'info'")

    parser.add_option("--mech",
                      dest="mechanism", default="gsp",
                      help="Set the mechanim: 'gsp' or 'vcg' or 'switch'")

    parser.add_option("--num-rounds",
                      dest="num_rounds", default=48, type="int",
                      help="Set number of rounds")

    parser.add_option("--min-val",
                      dest="min_val", default=25, type="int",
                      help="Min per-click value, in cents")

    parser.add_option("--max-val",
                      dest="max_val", default=175, type="int",
                      help="Max per-click value, in cents")

    parser.add_option("--budget",
                      dest="budget", default=500000, type="int",
                      help="Total budget, in cents")
    
    parser.add_option("--reserve",
                      dest="reserve", default=0, type="int",
                      help="Reserve price, in cents")

    parser.add_option("--perms",
                      dest="max_perms", default=120, type="int",
                      help="Max number of value permutations to run.  Set to 1 for debugging.")

    parser.add_option("--iters",
                      dest="iters", default=1, type="int",
                      help="Number of different value draws to sample. Set to 1 for debugging.")

    parser.add_option("--seed",
                      dest="seed", default=None, type="int",
                      help="seed for random numbers")


    (options, args) = parser.parse_args()

    # leftover args are class names:
    # e.g. "Truthful BBAgent CleverBidder Fred"

    if len(args) == 0:
        # default
        agents_to_run = ['Truthful', 'Truthful', 'Truthful']
    else:
        agents_to_run = parse_agents(args)

    configure_logging(options.loglevel)

    if options.seed != None:
        random.seed(options.seed)

    # Add some more config options
    options.agent_class_names = agents_to_run
    options.agent_classes = load_modules(options.agent_class_names)
    options.dropoff = 0.75

    logging.info("Starting simulation...")
    n = len(agents_to_run)

    totals = dict((id, 0) for id in range(n))
    total_revenues = []

    approx = math.factorial(n) > options.max_perms
    if approx:
        num_perms = options.max_perms
        logging.warning(
            "Running approximation: taking %d samples of value permutations"
            % options.max_perms)
    else:
        num_perms = math.factorial(n)

    av_value=range(0,n)
    total_spent = [0 for i in range(n)]

    ##  iters = no. of samples to take
    for i in range(options.iters):
        values = get_utils(n, options)
        logging.info("==== Iteration %d / %d.  Values %s ====" % (i, options.iters, values))
        ## Create permutations (permutes the random values, and assigns them to agents)
        if approx:
            perms = [shuffled(values) for i in range(options.max_perms)]
        else:
            perms = itertools.permutations(values)

#.........这里部分代码省略.........
开发者ID:aszanto9,项目名称:AdAuction,代码行数:103,代码来源:auction.py

示例2: main

# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import total_revenue [as 别名]
def main(args):

    usage_msg = "Usage: %prog [options] PeerClass1[,cnt] PeerClass2[,cnt2] ..."
    parser = OptionParser(usage=usage_msg)

    def usage(msg):
        print "Error: %s\n" % msg
        parser.print_help()
        sys.exit()
    
    parser.add_option("--loglevel",
                      dest="loglevel", default="info",
                      help="Set the logging level: 'debug' or 'info'")

    parser.add_option("--mech",
                      dest="mechanism", default="gsp",
                      help="Set the mechanim: 'gsp' or 'vcg' or 'switch'")

    parser.add_option("--num-rounds",
                      dest="num_rounds", default=48, type="int",
                      help="Set number of rounds")

    parser.add_option("--min-val",
                      dest="min_val", default=25, type="int",
                      help="Min per-click value, in cents")

    parser.add_option("--max-val",
                      dest="max_val", default=175, type="int",
                      help="Max per-click value, in cents")

    parser.add_option("--budget",
                      dest="budget", default=500000, type="int",
                      help="Total budget, in cents")
    
    parser.add_option("--reserve",
                      dest="reserve", default=0, type="int",
                      help="Reserve price, in cents")

    parser.add_option("--perms",
                      dest="max_perms", default=120, type="int",
                      help="Max number of value permutations to run.  Set to 1 for debugging.")

    parser.add_option("--iters",
                      dest="iters", default=1, type="int",
                      help="Number of different value draws to sample. Set to 1 for debugging.")

    parser.add_option("--seed",
                      dest="seed", default=None, type="int",
                      help="seed for random numbers")


    (options, args) = parser.parse_args()

    # leftover args are class names:
    # e.g. "Truthful BBAgent CleverBidder Fred"

    if len(args) == 0:
        # default
        agents_to_run = ['Truthful', 'Truthful', 'Truthful']
    else:
        agents_to_run = parse_agents(args)

    configure_logging(options.loglevel)

    if options.seed != None:
        random.seed(options.seed)

    # Add some more config options
    options.agent_class_names = agents_to_run
    options.agent_classes = load_modules(options.agent_class_names)
    options.dropoff = 0.75

    logging.info("Starting simulation...")
    n = len(agents_to_run)

    totals = dict((id, 0) for id in range(n))
    total_revenues = []

    approx = math.factorial(n) > options.max_perms
    if approx:
        num_perms = options.max_perms
        logging.warning(
            "Running approximation: taking %d samples of value permutations"
            % options.max_perms)
    else:
        num_perms = math.factorial(n)

    av_value=range(0,n)
    total_spent = [0 for i in range(n)]
    
    """ Additional statistics to follow """
    agents_spent_stats = [] ### For spending statistics information
    agents_util_stats = [] ### For utility statistics
    for i in range(n):
        agents_spent_stats.append([])
        agents_util_stats.append([])
    """ ------------------------------- """

    ##  iters = no. of samples to take
    for i in range(options.iters):
#.........这里部分代码省略.........
开发者ID:kojino,项目名称:CS136-projects,代码行数:103,代码来源:auction.py


注:本文中的stats.Stats.total_revenue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。