Exemplo n.º 1
0
    def __detailsXCSP(self, doc, options, optPerSol, fnames, maxtime,
                      bestever):
        section = Section('Details')
        doc.append(section)
        print("create section: \"Details\"")

        coords = {}
        objs = {}
        for o in options:
            coords[o] = []
            objs[o] = []
        objs['syb'] = []
        # Third problem per problem
        k = 0
        for fname in fnames:
            solutions = optPerSol[fname]
            if len(solutions) == 0:
                continue
            subsection = Subsection('%s' % (fname))  # .replace("_", "\_")))
            section.append(subsection)
            print("create subsection: " + fname)
            if solutions[0][3] == 'SAT':
                solutions.sort(key=lambda x: (x[3], x[1]))
                table = Tabular('l|r|l|r|r|r')
                table.color = True  # to deal with colors in table
                subsection.append(table)
                table.add_hline()
                table.add_row(("Config.", 'Status', "#Sol", 'Time(sec)',
                               'Build(sec)', 'Nodes'))
                table.add_hline()
                for i in range(0, len(solutions)):
                    table.add_row(
                        (solutions[i][6], solutions[i][5], solutions[i][0],
                         solutions[i][1], solutions[i][7], solutions[i][2]),
                        color=solutions[i][6])
                    coords[solutions[i][6]].append((k, solutions[i][1]))
                table.add_hline()
                table.add_hline()
                # add syb
                if fname in bestever:
                    table.add_row("syb", bestever[fname][0], "--", "--", "--",
                                  "--")
                table.add_hline()
            else:
                # sort for MIN
                type = 'MIN'
                solutions.sort(key=lambda x: (x[3], x[4], x[1]))
                best = solutions[0][4]
                # check first row and last row
                if solutions[0][3] == 'MAX' or solutions[len(solutions) -
                                                         1][3] == 'MAX':
                    solutions.sort(key=lambda x: (x[3], -x[4], x[1]))
                    best = solutions[0][4]
                    type = 'MAX'

                table = Tabular('l|r|l|r|r|r|r')
                table.color = True  # to deal with colors in table
                subsection.append(table)

                table.add_hline()
                table.add_row(("Config.", type, 'Status', "#Sol", 'Time(sec)',
                               'Build(sec)', 'Nodes'))
                table.add_hline()
                for i in range(0, len(solutions)):
                    table.add_row(
                        (solutions[i][6], solutions[i][4], solutions[i][5],
                         solutions[i][0], solutions[i][1], solutions[i][7],
                         solutions[i][2]),
                        color=solutions[i][6])
                    if solutions[i][4] == best:
                        coords[solutions[i][6]].append((k, solutions[i][1]))
                    else:
                        coords[solutions[i][6]].append((k, maxtime))
                    if int(solutions[i][0]) > 0:
                        objs[solutions[i][6]].append((k, solutions[i][4]))
                table.add_hline()
                table.add_hline()
                # add syb
                if fname in bestever:
                    if len(bestever[fname]) > 1:
                        table.add_row("syb", bestever[fname][1],
                                      bestever[fname][0], "--", "--", "--",
                                      "--")
                        objs['syb'].append((k, bestever[fname][1]))
                    else:
                        table.add_row("syb", "--", bestever[fname][0], "--",
                                      "--", "--", "--")
                table.add_hline()

            # self.__addTimePlots(doc, options, coords)
            for o in options:
                coords[o].clear()
Exemplo n.º 2
0
    def __sybil(self, doc, options, optPerSol, fnames, maxtime, bestever):
        # Second summary
        section = Section('Summary : %d problems, %d configurations.' %
                          (len(fnames), len(options)))
        doc.append(section)
        table = Tabular('|l||c|c||c|c||c|')
        table.color = True  # to deal with colors in table

        table.add_hline()
        table.add_row(("", MultiColumn(2, align='c||', data="CSP"),
                       MultiColumn(2, align='c||', data='COP'), "Times best"))
        table.add_row(
            ("Config.", 'sat', "unsat", "best", "proof", "< %.1f" % maxtime))
        table.add_hline()
        for opt in options:
            sat = 0
            unsat = 0
            proof = 0
            fbest = 0
            tbest = 0
            for fname in fnames:
                print(opt + '->' + fname)
                solutions = optPerSol[fname]
                if len(solutions) == 0:
                    continue
                gbest = solutions[0][4]
                mybest = gbest
                gtime = solutions[0][1]
                mytime = gtime
                b = 0
                for i in range(0, len(solutions)):
                    if solutions[i][6] == opt:
                        if solutions[i][5] == 'proof':
                            proof += 1
                            b += 1
                            if solutions[i][3] is 'SAT':
                                if int(solutions[i][0]) == 0:
                                    unsat += 1
                                elif int(solutions[i][0]) == 1:
                                    sat += 1
                        elif solutions[i][5] != 'unknown':
                            b += 1
                        mybest = solutions[i][4]
                        mytime = solutions[i][1]
                    gtime = min(gtime, solutions[i][1])
                    if solutions[0][3] is 'MIN':
                        gbest = min(gbest, solutions[i][4])
                    elif solutions[0][3] is 'MAX':
                        gbest = max(gbest, solutions[i][4])
                if gbest == mybest and b > 0:
                    fbest += 1
                if gtime == mytime and mytime < maxtime:
                    tbest += 1
            table.add_row((opt, sat, unsat, fbest, proof, tbest), color=opt)
        # now VBS
        sat = 0
        unsat = 0
        proof = 0
        fbest = 0
        tbest = 0
        for fname in fnames:
            solutions = optPerSol[fname]
            if len(solutions) == 0:
                continue
            gbest = solutions[0][4]
            gtime = solutions[0][1]
            p = 0
            b = 0
            for i in range(0, len(solutions)):
                if solutions[i][5] == 'proof':
                    p += 1
                    b += 1
                    if solutions[i][3] is 'SAT':
                        if int(solutions[i][0]) == 0:
                            unsat += 1
                        elif int(solutions[i][0]) == 1:
                            sat += 1
                elif solutions[i][5] != 'unknown':
                    b += 1
                gtime = min(gtime, solutions[i][1])
                if solutions[0][3] is 'MIN':
                    gbest = min(gbest, solutions[i][4])
                elif solutions[0][3] is 'MAX':
                    gbest = max(gbest, solutions[i][4])

            if p > 0:
                proof += 1
            if b > 0:
                fbest += 1
            if gtime < maxtime:
                tbest += 1
        table.add_hline()
        table.add_hline()
        table.add_row(('VBS', sat, unsat, fbest, proof, tbest))
        # now Sybille
        sat = 0
        unsat = 0
        proof = 0
        fbest = 0
        for fname in fnames:
            if fname in bestever:
                if len(bestever[fname]) > 1:
                    fbest += 1
                if 'C' in bestever[fname][0]:
                    proof += 1
        table.add_hline()
        table.add_hline()
        table.add_row(('syb', sat, unsat, fbest, proof, "--"))

        table.add_hline()
        section.append(table)