def _set_data(self):
        self._data['r_payoffs'] = p.receiver_sim(self._options.lam, self._options.rc_cost, self._options.rnc_cost)

        if self._options.routine == "simil0": #common interest
            self._data['s_payoffs'] = p.sender_sim_0()

        elif self._options.routine == "simil1": #sender map 1
            self._data['s_payoffs'] = p.sender_sim_1()

        elif self._options.routine == "simil2": #sender map 3
            self._data['s_payoffs'] = p.sender_sim_2()

        self._data['gphx_file'] = "{0}/{1}".format(self._options.output_dir, self._options.graph_file)
        self._data['gphx_skip'] = self._options.graph_skip
Exemplo n.º 2
0
    def _set_data(self):
        self._data['r_payoffs'] = p.receiver_sim(self._options.lam,
                                                 self._options.rc_cost,
                                                 self._options.rnc_cost)

        if self._options.routine == "simil0":  #common interest
            self._data['s_payoffs'] = p.sender_sim_0()

        elif self._options.routine == "simil1":  #sender map 1
            self._data['s_payoffs'] = p.sender_sim_1()

        elif self._options.routine == "simil2":  #sender map 3
            self._data['s_payoffs'] = p.sender_sim_2()

        self._data['gphx_file'] = "{0}/{1}".format(self._options.output_dir,
                                                   self._options.graph_file)
        self._data['gphx_skip'] = self._options.graph_skip
Exemplo n.º 3
0
def run():
    import cPickle
    from optparse import OptionParser

    oparser = OptionParser()
    oparser.add_option("-f", "--statsfile", action="store", dest="stats_file", default="../output/aggregate", help="file holding aggregate stats to be parsed")
    oparser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="detailed output?")
    oparser.add_option("-b", "--voistats", action="store_true", dest="voi", default=False, help="calculate value of information stats")
    oparser.add_option("-n", "--nosumm", action="store_false", dest="summary", default=True, help="do not output summary statistics")
    oparser.add_option("-k", "--klstats", action="store_true", dest="kl", default=False, help="caluclate KL value stats")
    oparser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, help="only output VoI / KL aggregates")

    (options,args) = oparser.parse_args()

    #of = open(options.out_file,"w")
    sf = open(options.stats_file,"rb")
    run_options = None
    duplications = []
    pickle = ""
    i = 0
    for line in sf:
        if line != "\n":
            pickle += line
        else:
            i += 1
            if i == 1:
                run_options = cPickle.loads(pickle)
            else:
                duplications.append((i, cPickle.loads(pickle)))
            pickle = ""

    if i <= 1:
        print "error"
    sf.close()

    massaged_dups = []

    for dup in duplications:
        ps = [0., 0.]
        #initial_sender, initial_receiver = dup[1][0]
        final_sender, final_receiver = dup[1][1]
        generations = dup[1][2]

        final_sender = [(j, st) for (j, st) in enumerate(final_sender) if st >= 10. * effective_zero]
        final_receiver = [((j,typ), st) for (j,(st, typ)) in enumerate(final_receiver) if st >= 10. * effective_zero]

        for (j, typ), st in final_receiver:
            ps[typ] += st

        massaged_dups.append(((final_sender, final_receiver, generations), ps))

    print "Total Duplications: %i, avg generations: %.2f" % (len(massaged_dups), float(sum(i[2] for i, ps in massaged_dups)) / float(len(massaged_dups)))


    r_payoffs = p.receiver_sim(run_options.lam, run_options.rc_cost, run_options.rnc_cost)
    rstars = range(4)

    if options.summary:
        output_summary(massaged_dups, options)

    if options.voi:
        output_voistats(massaged_dups, options, r_payoffs, rstars)

    if options.kl:
        if run_options.routine == "simil0":
            s_payoffs = p.sender_sim_0()
        elif run_options.routine == "simil1":
            s_payoffs = p.sender_sim_1()
        elif run_options.routine == "simil2":
            s_payoffs = p.sender_sim_2()

        output_klstats(massaged_dups, options, r_payoffs, s_payoffs)
Exemplo n.º 4
0
def run():
    import cPickle
    from optparse import OptionParser

    oparser = OptionParser()
    oparser.add_option("-f",
                       "--statsfile",
                       action="store",
                       dest="stats_file",
                       default="../output/aggregate",
                       help="file holding aggregate stats to be parsed")
    oparser.add_option("-v",
                       "--verbose",
                       action="store_true",
                       dest="verbose",
                       default=False,
                       help="detailed output?")
    oparser.add_option("-b",
                       "--voistats",
                       action="store_true",
                       dest="voi",
                       default=False,
                       help="calculate value of information stats")
    oparser.add_option("-n",
                       "--nosumm",
                       action="store_false",
                       dest="summary",
                       default=True,
                       help="do not output summary statistics")
    oparser.add_option("-k",
                       "--klstats",
                       action="store_true",
                       dest="kl",
                       default=False,
                       help="caluclate KL value stats")
    oparser.add_option("-q",
                       "--quiet",
                       action="store_true",
                       dest="quiet",
                       default=False,
                       help="only output VoI / KL aggregates")

    (options, args) = oparser.parse_args()

    #of = open(options.out_file,"w")
    sf = open(options.stats_file, "rb")
    run_options = None
    duplications = []
    pickle = ""
    i = 0
    for line in sf:
        if line != "\n":
            pickle += line
        else:
            i += 1
            if i == 1:
                run_options = cPickle.loads(pickle)
            else:
                duplications.append((i, cPickle.loads(pickle)))
            pickle = ""

    if i <= 1:
        print "error"
    sf.close()

    massaged_dups = []

    for dup in duplications:
        ps = [0., 0.]
        #initial_sender, initial_receiver = dup[1][0]
        final_sender, final_receiver = dup[1][1]
        generations = dup[1][2]

        final_sender = [(j, st) for (j, st) in enumerate(final_sender)
                        if st >= 10. * effective_zero]
        final_receiver = [((j, typ), st)
                          for (j, (st, typ)) in enumerate(final_receiver)
                          if st >= 10. * effective_zero]

        for (j, typ), st in final_receiver:
            ps[typ] += st

        massaged_dups.append(((final_sender, final_receiver, generations), ps))

    print "Total Duplications: %i, avg generations: %.2f" % (
        len(massaged_dups),
        float(sum(i[2]
                  for i, ps in massaged_dups)) / float(len(massaged_dups)))

    r_payoffs = p.receiver_sim(run_options.lam, run_options.rc_cost,
                               run_options.rnc_cost)
    rstars = range(4)

    if options.summary:
        output_summary(massaged_dups, options)

    if options.voi:
        output_voistats(massaged_dups, options, r_payoffs, rstars)

    if options.kl:
        if run_options.routine == "simil0":
            s_payoffs = p.sender_sim_0()
        elif run_options.routine == "simil1":
            s_payoffs = p.sender_sim_1()
        elif run_options.routine == "simil2":
            s_payoffs = p.sender_sim_2()

        output_klstats(massaged_dups, options, r_payoffs, s_payoffs)