Example #1
0
def testcIntegerOutrankingDigraph():
    print('==>> Testing IntegerBipolarOutrankingDigraph instantiation')
    tc = cR3ObjPT(seed=1)
    print(tc)
    gi = IntegerBipolarOutrankingDigraph(tc, Threading=True, nbrCores=4)
    print(gi)
    gi.showRelationTable()
    tcstd = tc.convert2Standard()
    g = BipolarOutrankingDigraph(tcstd)
    print(g)
    g.showRelationTable()
Example #2
0
def testCBPerformanceTableau():
    print('*==>> random CB Performance Tableaux ------------*')
    t = RandomCBPerformanceTableau(numberOfActions=10,\
                                   commonPercentiles={'ind':5,'pref':10,'veto':95},\
                                   weightDistribution="random",\
                                   weightScale=[1,2],\
                                   IntegerWeights=True,\
                                   commonMode=["normal",50.0,25.0])
    t.showCriteria(Debug=False)
    g = BipolarOutrankingDigraph(t)
    g.exportGraphViz()
    #t.showPerformanceTableau()
    g.showRelationTable()
Example #3
0
def testFullRandomOutrankingDigraph():
    print('*==>> testing full random outranking Digraphs ----*')
    t = FullRandomPerformanceTableau()
    #t = RandomCBPerformanceTableau()
    t.showAll()
    g = BipolarOutrankingDigraph(t)
    g.showCriteria()
    g.showPerformanceTableau()
    g.showEvaluationStatistics()
    ## g.showStatistics()
    g.showVetos(realVetosOnly=True)
    print('criteria significance concentration: ',
          g.computeWeightsConcentrationIndex())
Example #4
0
def testExportPrincipalImage():
    print('*------- test exportRelationPCAImage --------*')
    t = RandomCBPerformanceTableau(numberOfActions=10,
                                   weightDistribution="equiobjectives")
    g = BipolarOutrankingDigraph(t)
    g.save('test')
    g = Digraph('test')
    g.showRelationTable()
    g.exportPrincipalImage('bipolar', bgcolor='lightblue')
    g.recodeValuation(0, 2)
    g.exportPrincipalImage('monopolar',
                           pictureFormat='xfig',
                           fontcolor='black',
                           fontsize='1.2')
def testSparseOutrankingDigraph():
    print('==>> Testing SparseOutrankingDigraph instantiation')
    MP = True
    t0 = time()
    tp = Random3ObjectivesPerformanceTableau(numberOfActions=100, BigData=True)
    print(time() - t0)
    print(total_size(tp.evaluation))
    bg1 = PreRankedOutrankingDigraph(tp,
                                     quantiles=10,
                                     quantilesOrderingStrategy='average',
                                     LowerClosed=True,
                                     minimalComponentSize=1,
                                     Threading=MP,
                                     Debug=False)
    print(bg1.computeDecompositionSummaryStatistics())
    bg1.showDecomposition()
    print(bg1)
    t0 = time()
    g = BipolarOutrankingDigraph(tp, Normalized=True, Threading=MP)
    print(time() - t0)
    print(total_size(g))
    t0 = time()
    print(
        "Big outranking digraph's correlation with standard outranking digraph"
    )
    print(bg1.computeOrdinalCorrelation(g, Debug=False))
    print(time() - t0)
    nf = bg1.computeBoostedOrdering(orderingRule="NetFlows")
    preordering1 = bg1.ordering2Preorder(nf)
    print(nf, preordering1)
    print(
        'Boosted Netflows ranking correlation with complete outranking relation'
    )
    print(g.computeOrdinalCorrelation(g.computePreorderRelation(preordering1)))
    ko = bg1.computeBoostedOrdering(orderingRule="Kohler")
    preordering2 = bg1.ordering2Preorder(ko)
    print(ko, preordering2)
    print(
        'Boosted Kohler ranking correlation with complete outranking relation')
    print(g.computeOrdinalCorrelation(g.computePreorderRelation(preordering2)))
def testEstimateRankingCorrelation():
    print('====> Testing estimateRankingCorrelation')
    MP = True
    nbrActions = 1000
    tp = Random3ObjectivesPerformanceTableau(numberOfActions=nbrActions,
                                             seed=100)
    bg1 = PreRankedOutrankingDigraph(
        tp,
        CopyPerfTab=True,
        quantiles=4,
        quantilesOrderingStrategy='optimal',
        componentRankingRule='NetFlows',
        LowerClosed=True,
        minimalComponentSize=1,
        Threading=MP,
        nbrOfCPUs=8,
        #tempDir='.',
        nbrOfThreads=8,
        Comments=True,
        Debug=False,
        save2File='testbgMP')
    seed = 1
    sampleSize = 100
    import random
    random.seed(seed)
    actionKeys = [x for x in bg1.actions]
    sample = random.sample(actionKeys, sampleSize)
    print(sample)
    print(bg1.boostedRanking)
    preRankedSample = []
    for x in bg1.boostedRanking:
        if x in sample:
            preRankedSample.append(x)
    print(preRankedSample)
    ptp = PartialPerformanceTableau(tp, sample)
    from outrankingDigraphs import BipolarOutrankingDigraph
    pg = BipolarOutrankingDigraph(ptp, Normalized=True)
    print(pg.computeRankingCorrelation(preRankedSample))
    print(bg1.estimateRankingCorrelation(sampleSize, seed))
Example #7
0
def testCompleteness():
    print('*------- test (Weakly) Completeness ------*')
    g = RandomValuationDigraph()
    g.showRelationTable()
    print('Relation %s is complete ? %s' %
          (g.name, str(g.isComplete(Debug=True))))
    print('Relation %s is weakly complete ? %s' %
          (g.name, str(g.isWeaklyComplete(Debug=True))))
    t = RandomCBPerformanceTableau(numberOfActions=9,
                                   numberOfCriteria=5,
                                   weightDistribution='equiobjectives')
    g = BipolarOutrankingDigraph(t, Normalized=True)
    g.showRelationTable()
    print('Relation %s is complete ? %s' %
          (g.name, str(g.isComplete(Debug=True))))
    print('Relation %s is weakly complete ? %s' %
          (g.name, str(g.isWeaklyComplete(Debug=True))))
    gcd = CoDualDigraph(g)
    gcd.showRelationTable()
    print('Relation %s is complete ? %s' %
          (gcd.name, str(gcd.isComplete(Debug=True))))
    print('Relation %s is weakly complete ? %s' %
          (gcd.name, str(gcd.isWeaklyComplete(Debug=True))))
Example #8
0
def testLinearVotingBallots():
    print("*==>> testing linear voting profiles ----*")
    lvp = RandomLinearVotingProfile(numberOfVoters=100,
                                    numberOfCandidates=10,
                                    WithPolls=True,
                                    partyRepartition=0.6,
                                    other=0.1,
                                    seed=None)
    lvp.save()
    lvp = LinearVotingProfile('templinearprofile')
    lvp.showLinearBallots()
    print(lvp.computeRankAnalysis())
    lvp.showRankAnalysisTable(Debug=True)
    print(lvp.computeBordaScores())
    print(lvp.computeBordaWinners())
    c = MajorityMarginsDigraph(lvp)
    c.exportGraphViz()
    print(c.computeChordlessCircuits())
    lvp.save2PerfTab()
    t = PerformanceTableau('votingPerfTab')
    from outrankingDigraphs import BipolarOutrankingDigraph
    g = BipolarOutrankingDigraph(t)
    lvp.showHTMLVotingHeatmap()
    print(c.computeCopelandRanking())
pt.showCriteria()
print('')

printline()
print('Actions')
printline()
pt.showActions()
print('')

printline()
print('Statistics')
printline()
pt.showStatistics()
print('')

full_digraph = BipolarOutrankingDigraph(pt)

html_heatmap = pt.htmlPerformanceHeatmap(RankingRule='Kohler')
fwrite(html_heatmap, make_path("full_heatmap.html"))

html_relationtable = full_digraph.htmlRelationTable(isColored=True)
fwrite(html_relationtable, make_path("full_bipolar_adj_matrix.html"))

weak_condorcet_winners = full_digraph.weakCondorcetWinners()
printline()
print("Weak Condorcet winners from a multi-objectives point of view -> {}".
      format(weak_condorcet_winners))
printline()

condorcet_winners = full_digraph.condorcetWinners()
printline()
Example #10
0
def fwrite(string, file):
  with open(file, 'w') as f:
    f.write(string)

pt = XMCDA2PerformanceTableau('project_2')

for ct in ['Eco', 'Soc', 'Env']:
    
  printline()
  print('RUBIS Best Choice Recommendation from {} point of view'.format(ct))
  printline()

  criterias = [c for c, val in pt.criteria.items() if ct in val['name']]
  ppt = PartialPerformanceTableau(pt,criteriaSubset=criterias)

  partial_digraph = BipolarOutrankingDigraph(ppt)

  html_heatmap = ppt.htmlPerformanceHeatmap(colorLevels=5)
  fwrite(html_heatmap, make_path(ct+"_heatmap.html"))

  html_relationtable = partial_digraph.htmlRelationTable(isColored=True)
  fwrite(html_relationtable, make_path(ct+"_bipolar_adj_matrix.html"))

  condorcet_winners = partial_digraph.condorcetWinners()
  printline()
  print("Condorcet winners for {} -> {}".format(ct, condorcet_winners))
  printline()

  weak_condorcet_winners = partial_digraph.weakCondorcetWinners()
  printline()
  print("Weak Condorcet winners for {} -> {}".format(ct, weak_condorcet_winners))