예제 #1
0
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))