def present_results(analysis):
    import pprint
    pprint.pprint(analysis)
    from presenter.charts import wykres
    wykres(analysis, "iteration", "ill percentage")
示例#2
0
文件: grupy.py 项目: martaczc/grupy
def present_results(analysis):
    pprint.pprint(analysis)
    wykres(analysis[0], "time", "cooperation")  
    wykres(analysis[1], "time", "number of agents")
示例#3
0
文件: analyzer.py 项目: mroja/cog-abm
def main():

	import optparse
	
	usage = "%prog [-c] [-v] -f FILE statistic1 statistic2 ...\n"+\
			"where statistic in {"+";".join(fun_map.keys())+"}"
	optp = optparse.OptionParser(usage = usage)
	
	optp.add_option('-v', '--verbose', dest='verbose', action='count',
			help="increase verbosity (specify multiple times for more)")
	
	optp.add_option('-c','--chart', action="store_true", dest='chart',
			help="specifies output to be a chart")
	
	optp.add_option('-f','--file', action="store", dest='file', type="string",
			help="input file with results. THIS OPTION IS NECESSARY!")
	
	optp.add_option('--xlabel', action="store", dest='xlabel', type="string",
			help="Label of x-axis")
	
	optp.add_option('--ylabel', action="store", dest='ylabel', type="string",
			help="Label of y-axis")
	

	opts, args = optp.parse_args()
	
	if len(args) == 0:
		optp.error("No argument given!")

	
	if opts.file is None or opts.file == "":
		optp.error("No or wrong file specified (option -f)")
	
	if opts.chart == True and len(args)<2:
		optp.error("Can't draw a chart with one dimension data")



	log_level = logging.INFO #logging.DEBUG # default logging.WARNING


	if opts.verbose == 1:
		log_level = logging.INFO
		
	elif opts.verbose >= 2:
		log_level = logging.DEBUG

	
	# Set up basic configuration, out to stderr with a reasonable default format.
	logging.basicConfig(level=log_level)
	
	f = open(opts.file)
	res, params = cPickle.load(f)
	f.close()
	
	funcs = []
	for arg in args:
		ind = arg.find("_")
		fun = None
		if  ind != -1:
			p_fun = pref_fun_map.get(arg[0:ind])
			
			m_fun = fun_map.get(arg[ind+1:len(arg)])

			if p_fun is not None and m_fun is not None:
				fun = compose(p_fun, m_fun)


		if fun is None:
			fun = fun_map.get(arg, None)
			
		if fun is not None:
			funcs.append(fun)
		else:
			logging.warning("Unrecognized option %s - ignoring", arg)

	wyn = gen_res(res, params, funcs)
	
	if opts.chart is not None:
		from presenter.charts import wykres
		data = []
		#print wyn
		map(lambda x: data.append((x[0], x[1:])), wyn)
		wykres(data, opts.xlabel, opts.ylabel)
		
	else:
		for r in wyn:
			print "\t".join(imap(str, r))
示例#4
0
def main():

    import optparse

    usage = "%prog [-c] [-v] -f FILE statistic1 statistic2 ...\n"+\
                    "where statistic in {"+";".join(fun_map.keys())+"}"
    optp = optparse.OptionParser(usage = usage)

    optp.add_option('-v', '--verbose', dest='verbose', action='count',
                    help="increase verbosity (specify multiple times for more)")

    optp.add_option('-c','--chart', action="store_true", dest='chart',
                    help="specifies output to be a chart")

    optp.add_option('-f','--file', action="store", dest='file', type="string",
                    help="input file with results. THIS OPTION IS NECESSARY!")

    optp.add_option('--xlabel', action="store", dest='xlabel', type="string",
                    help="Label of x-axis")

    optp.add_option('--ylabel', action="store", dest='ylabel', type="string",
                    help="Label of y-axis")


    opts, args = optp.parse_args()

    if len(args) == 0:
        optp.error("No argument given!")


    if opts.file is None or opts.file == "":
        optp.error("No or wrong file specified (option -f)")

    if opts.chart == True and len(args)<2:
        optp.error("Can't draw a chart with one dimension data")



    log_level = logging.INFO #logging.DEBUG # default logging.WARNING


    if opts.verbose == 1:
        log_level = logging.INFO

    elif opts.verbose >= 2:
        log_level = logging.DEBUG


    # Set up basic configuration, out to stderr with a reasonable default format.
    logging.basicConfig(level=log_level)

    f = open(opts.file)
    res, params = cPickle.load(f)
    f.close()

    funcs = []
    for arg in args:
        ind = arg.find("_")
        fun = None
        if  ind != -1:
            p_fun = pref_fun_map.get(arg[0:ind])

            m_fun = fun_map.get(arg[ind+1:len(arg)])

            if p_fun is not None and m_fun is not None:
                fun = compose(p_fun, m_fun)


        if fun is None:
            fun = fun_map.get(arg, None)

        if fun is not None:
            funcs.append(fun)
        else:
            logging.warning("Unrecognized option %s - ignoring", arg)

    wyn = gen_res(res, params, funcs)

    if opts.chart is not None:
        from presenter.charts import wykres
        data = []
        #print wyn
        map(lambda x: data.append((x[0], x[1:])), wyn)
        wykres(data, opts.xlabel, opts.ylabel)

    else:
        for r in wyn:
            print "\t".join(imap(str, r))