votingDigraphs
index
/Users/bisdorff/Documents/LoewSVN/Digraph3/pyDoc/votingDigraphs.py

# Python 3 implementation of voting digraphs
# Refactored from revision 1.549 of the digraphs module
# Current revision $Revision: 2254 $
# Copyright (C) 2011  Raymond Bisdorff
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#######################

 
Modules
       
itertools
collections
decimal
xml.sax.handler
json
xml.sax.xmlreader

 
Classes
       
builtins.object
VotingProfile
ApprovalVotingProfile
RandomApprovalVotingProfile
LinearVotingProfile
RandomLinearVotingProfile
RandomVotingProfile
digraphs.Digraph(builtins.object)
CondorcetDigraph

 
class ApprovalVotingProfile(VotingProfile)
    A specialised class for approval voting profiles
 
Structure::
 
    candidates = OrderedDict([('a', {'name': ...}),
                  ('b', {'name': ...}),
                  ..., ...])
    voters = OrderedDict([('v1',{'weight':1.0}),('v2':{'weight':1.0}), ...])
    ## each specifies the subset of candidates he approves on
    approvalBallot = {
        'v1' : ['b'],
        'v2' : ['a','b'],
        ...
        }
 
    ## each specifies the subset -disjoint from the approvalBallot-  of candidates he disapproves on
    disApprovalBallot = {
        'v1' : ['a'],
        'v2' : [],
        ...
        }
 
 
Method resolution order:
ApprovalVotingProfile
VotingProfile
builtins.object

Methods defined here:
__init__(self, fileVotingProfile=None, seed=None)
Initialize self.  See help(type(self)) for accurate signature.
computeBallot(self)
Computes a complete ballot from the approval Ballot.
 
Parameters:
    approvalEquivalence=False, disapprovalEquivalence=False.
save(self, name='tempAVprofile')
Persistant storage of an approval voting profile.
 
Parameter:
    name of file (without <.py> extension!).
save2PerfTab(self, fileName='votingPerfTab', isDecimal=True, valueDigits=2)
Persistant storage of an approval voting profile in the format of a standard performance tableau.
For each voter *v*, the performance of candidate *x* corresponds to:
 
      1, if approved;
      0, if disapproved;
      -999, miising evalaution otherwise,
showApprovalResults(self)
Renders the approval obtained by each candidates.
showDisApprovalResults(self)
Renders the disapprovals obtained by each candidates.
showResults(self)

Methods inherited from VotingProfile:
showAll(self, WithBallots=True)
Show method for <VotingProfile> instances.
showVoterBallot(self, voter, hasIntegerValuation=False)
Show the actual voting of a voter.

Data descriptors inherited from VotingProfile:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class CondorcetDigraph(digraphs.Digraph)
    Specialization of the general Digraph class for generating
bipolar-valued marginal pairwise majority difference digraphs.
 
Parameters:
 
    | stored voting profile (fileName of valid py code) or voting profile object
    | optional, coalition (sublist of voters)
 
Example Python3 session
 
>>> from votingDigraphs import *
>>> v = RandomLinearVotingProfile(numberOfVoters=101,numberOfCandidates=5)
>>> v.showLinearBallots()
v101(1.0):   ['a5', 'a1', 'a2', 'a4', 'a3']
v100(1.0):   ['a4', 'a1', 'a5', 'a3', 'a2']
v89(1.0):    ['a4', 'a5', 'a1', 'a2', 'a3']
v88(1.0):    ['a3', 'a2', 'a5', 'a1', 'a4']
v87(1.0):    ['a5', 'a2', 'a4', 'a3', 'a1']
v86(1.0):    ['a5', 'a3', 'a1', 'a4', 'a2']
v85(1.0):    ['a5', 'a3', 'a2', 'a4', 'a1']
v84(1.0):    ['a3', 'a1', 'a2', 'a4', 'a5']
...
...
>>> g = CondorcetDigraph(v,hasIntegerValuation=True)
>>> g.showRelationTable()
* ---- Relation Table -----
 S   |  'a1'  'a2'   'a3'   'a4'  'a5'        
-----|------------------------------------------------------------
'a1' |   -     33     9      11    21        
'a2' |  -33    -     -19     -1    -5        
'a3' |  -9     19    -       5     -1        
'a4' |  -11    1      -5     -     -9        
'a5' |  -21    5       1     9      -
>>> g.computeCondorcetWinner()
['a1']
>>> g.exportGraphViz()
*---- exporting a dot file dor GraphViz tools ---------*
Exporting to rel_randLinearProfile.dot
dot -Grankdir=BT -Tpng rel_randLinearProfile.dot -o rel_randLinearProfile.png
 
.. image:: rel_randLinearProfile.png
 
 
Method resolution order:
CondorcetDigraph
digraphs.Digraph
builtins.object

Methods defined here:
__init__(self, argVotingProfile=None, approvalVoting=False, coalition=None, majorityMargins=True, hasIntegerValuation=True)
Initialize self.  See help(type(self)) for accurate signature.
computeArrowRaynaudRanking(self, linearOrdered=True, Debug=False)
Renders a ranking of the actions following Arrow&Raynaud's rule.
computeCondorcetWinner(self)
compute the Condorcet winner(s)
renders always a, potentially empty, list
computeKohlerRanking(self, linearOrdered=True, Debug=False)
Renders a ranking of the actions following Kohler's rule.
constructApprovalBallotRelation(self, hasIntegerValuation=False)
Renders the votes differences between candidates
on the basis of an approval ballot.
constructBallotRelation(self, hasIntegerValuation)
Renders the marginal majority between candidates
on the basis of a complete ballot.
constructMajorityMarginsRelation(self, hasIntegerValuation=True)
Renders the marginal majority between candidates
on the basis of an approval ballot.

Methods inherited from digraphs.Digraph:
MISgen(self, S, I)
generator of maximal independent choices (voir Byskov 2004):
    * S ::= remaining nodes;
    * I ::= current independent choice
 
.. note::
 
        Inititalize: self.MISgen(self.actions.copy(),set())
__invert__(self)
Make the inverting operator ~self available for Digraph instances. Returns a ConverseDigraph instance of self.
__neg__(self)
Make the negation operator -self available for Digraph instances. Returns a DualDigraph instance of self.
absirred(self, choice)
Renders the crips -irredundance degree of a choice.
absirredundant(self, U)
Generates all -irredundant choices of a digraph.
absirredval(self, choice, relation)
Renders the valued -irredundance degree of a choice.
absirredx(self, choice, x)
Computes the crips -irredundance degree of node x in a choice.
abskernelrestrict(self, choice)
Parameter: prekernel
Renders absorbent prekernel restricted relation.
absorb(self, choice)
Renders the absorbency degree of a choice.
absorbentChoices(self, S)
Generates all minimal absorbent choices of a bipolar valued digraph.
agglomerationDistribution(self)
Output: aggloCoeffDistribution, meanCoeff
Renders the distribution of agglomeration coefficients.
aneighbors(self, node)
Renders the set of absorbed in-neighbors of a node.
automorphismGenerators(self)
Adds automorphism group generators to the digraph instance.
averageCoveringIndex(self, choice, direction='out')
Renders the average covering index of a given choice in a set of objects,
ie the average number of choice members that cover each
non selected object.
bestRanks(self)
renders best possible ranks from indegrees account
bipolarKCorrelation(self, digraph, Debug=False)
Renders the bipolar Kendall correlation between two bipolar valued
digraphs computed from the average valuation of the
XORDigraph(self,digraph) instance.
 
.. warning::
 
     Obsolete! Is replaced by the self.computeBipolarCorrelation(other) Digraph method
bipolarKDistance(self, digraph, Debug=False)
Renders the bipolar crisp Kendall distance between two bipolar valued
digraphs.
 
.. warning::
 
     Obsolete! Is replaced by the self.computeBipolarCorrelation(other, MedianCut=True) Digraph method
chordlessPaths(self, Pk, n2, Odd=False, Comments=False, Debug=False)
New procedure from Agrum study April 2009
recursive chordless path extraction strating from path
Pk = [n2, ...., n1] and ending in node n2.
Optimized with marking of visited chordless P1s.
circuitAverageCredibility(self, circ)
Renders the average linking credibility of a COC.
circuitCredibilities(self, circuit, Debug=False)
Renders the average linking credibilities and the minimal link of a COC.
circuitMaxCredibility(self, circ)
Renders the minimal linking credibility of a COC.
circuitMinCredibility(self, circ)
Renders the minimal linking credibility of a COC.
closeSymmetric(self)
Produces the symmetric closure of self.relation.
closeTransitive(self, Irreflexive=True, Reverse=False)
Produces the transitive closure of self.relation.
collectcomps(self, x, A, ncomp)
Recursive subroutine of the components method.
components(self)
Renders the list of connected components.
computeAllDensities(self, choice=None)
parameter: choice in self
renders six densitiy parameters:
arc density, double arc density,
single arc density, strict single arc density,
absence arc density, strict absence arc densitiy.
computeArrowRaynaudOrder(self)
Renders a linear ordering from worst to best of the actions following Arrow&Raynaud's rule.
computeAverageValuation(self)
Computes the bipolar average correlation between
self and the crisp complete digraph of same order
of the irreflexive and determined arcs of the digraph
computeBadChoices(self, Comments=False)
Computes characteristic values for potentially bad choices.
 
.. note::
 
     Returns a tuple with following content:
 
     [(0)-determ,(1)degirred,(2)degi,(3)degd,(4)dega,(5)str(choice),(6)absvec]
computeBadPirlotChoices(self, Comments=False)
Characteristic values for potentially bad choices
using the Pirlot's fixpoint algorithm.
computeBipolarCorrelation(self, other, MedianCut=False, filterRelation=None, Debug=False)
obsolete: dummy replacement for Digraph.computeOrdinalCorrelation method
computeChordlessCircuits(self, Odd=False, Comments=False, Debug=False)
Renders the set of all chordless odd circuits detected in a digraph.
Result (possible empty list) stored in <self.circuitsList>
holding a possibly empty list tuples with at position 0 the
list of adjacent actions of the circuit and at position 1
the set of actions in the stored circuit.
computeChordlessCircuitsMP(self, Odd=False, Threading=False, nbrOfCPUs=None, Comments=False, Debug=False)
Multiprocessing version of computeChordlessCircuits().
 
Renders the set of all chordless odd circuits detected in a digraph.
Result (possible empty list) stored in <self.circuitsList>
holding a possibly empty list tuples with at position 0 the
list of adjacent actions of the circuit and at position 1
the set of actions in the stored circuit.
Inspired by Dias, Castonguay, Longo, Jradi, Algorithmica (2015).
 
Returns a possibly empty list of tuples (circuit,frozenset(circuit)).
 
If Odd == True, only circuits of odd length are retained in the result.
computeCoSize(self)
Renders the number of non validated non reflexive arcs
computeConcentrationIndex(self, X, N)
Renders the Gini concentration index of the X serie.
N contains the partial frequencies.
Based on the triangle summation formula.
computeConcentrationIndexTrapez(self, X, N)
Renders the Gini concentration index of the X serie.
N contains the partial frequencies.
Based on the triangles summation formula.
computeCondorcetWinners(self)
Wrapper for condorcetWinners().
computeCopelandRanking(self)
Renders a linear ranking from best to worst of the actions
following Copelands's rule.
computeCppChordlessCircuits(self, Odd=False, Debug=False)
python wrapper for the C++/Agrum based chordless circuits enumeration
exchange arguments with external temporary files
computeCppInOutPipingChordlessCircuits(self, Odd=False, Debug=False)
python wrapper for the C++/Agrum based chordless circuits enumeration
exchange arguments with external temporary files
computeCutLevelDensities(self, choice, level)
parameter: choice in self, robustness level
renders three robust densitiy parameters:
robust double arc density,
robust single arc density,
robust absence arc densitiy.
computeDensities(self, choice)
parameter: choice in self
renders the four densitiy parameters:
arc density, double arc density, single arc density, absence arc density.
computeDeterminateness(self)
Computes the Kendalll distance in % of self
with the all median valued (indeterminate) digraph.
computeGoodChoiceVector(self, ker, Comments=False)
| Characteristic values for potentially good choices.
| [(0)-determ,(1)degirred,(2)degi,(3)degd,(4)dega,(5)str(choice),(6)domvec]
computeGoodChoices(self, Comments=False)
Computes characteristic values for potentially good choices.
 
..note::
 
     Return a tuple with following content:
 
     [(0)-determ,(1)degirred,(2)degi,(3)degd,(4)dega,(5)str(choice),(6)domvec,(7)cover]
computeGoodPirlotChoices(self, Comments=False)
Characteristic values for potentially good choices
using the Pirlot fixpoint algorithm.
computeKemenyIndex(self, otherRelation)
renders the Kemeny index of the self.relation
compared with a given crisp valued relation of a compatible
other digraph (same nodes or actions).
computeKemenyOrder(self, orderLimit=7, Debug=False)
Renders a ordering from worst to best of the actions with maximal Kemeny index.
Return a tuple: kemenyOrder (from worst to best), kemenyIndex
computeKemenyRanking(self, isProbabilistic=False, orderLimit=7, seed=None, sampleSize=1000, Debug=False)
Renders a ordering from worst to best of the actions with maximal Kemeny index.
 
.. note::
 
     Returns a tuple: kemenyRanking (from best to worst), kemenyIndex.
computeKohlerOrder(self)
computeMeanInDegree(self)
Renders the mean indegree of self.
!!! self.size must be set previously !!!
computeMeanOutDegree(self)
Renders the mean degree of self.
!!! self.size must be set previously !!!
computeMeanSymDegree(self)
Renders the mean degree of self.
!!! self.size must be set previously !!!
computeMedianOutDegree(self)
Renders the median outdegree of self.
!!! self.size must be set previously !!!
computeMedianSymDegree(self)
Renders the median symmetric degree of self.
!!! self.size must be set previously !!!
computeMoreOrLessUnrelatedPairs(self)
Renders a list of more or less unrelated pairs.
computeNetFlowsOrder(self)
Renders an ordered list (from worst to best) of the actions
following the net flows ranking rule.
computeNetFlowsRanking(self)
Renders an ordered list (from best to worst) of the actions
following the net flows ranking rule.
computeODistance(self, op2, comments=False)
renders the squared normalized distance of
two digraph valuations.
 
.. note::
 
     op2 = digraphs of same order as self.
computeOrbit(self, choice, withListing=False)
renders the set of isomorph copies of a choice following
the automorphism of the digraph self
computeOrderCorrelation(self, order, Debug=False)
Renders the ordinal correlation K of a digraph instance
when compared with a given linear order (from worst to best) of its actions
 
K = sum_{x != y} [ min( max(-self.relation(x,y)),other.relation(x,y), max(self.relation(x,y),-other.relation(x,y)) ]
 
K /= sum_{x!=y} [ min(abs(self.relation(x,y),abs(other.relation(x,y)) ]
 
.. note::
 
     Renders a dictionary with the key 'correlation' containing the actual bipolar correlation index and the key 'determination' containing the minimal determination level D of self and the other relation.
 
     D = sum_{x != y} min(abs(self.relation(x,y)),abs(other.relation(x,y)) / n(n-1)
 
     where n is the number of actions considered.
 
     The correlation index with a completely indeterminate relation
     is by convention 0.0 at determination level 0.0 .
 
.. warning::
 
     self must be a normalized outranking digraph instance !
computeOrdinalCorrelation(self, other, MedianCut=False, filterRelation=None, Debug=False)
Renders the bipolar correlation K of a
self.relation when compared
with a given compatible (same actions set)) digraph or
a [-1,1] valued compatible relation (same actions set).
 
If MedianCut=True, the correlation is computed on the median polarized relations.
 
If filterRelation != None, the correlation is computed on the partial domain corresponding to the determined part of the filter relation.
 
.. warning::
 
     Notice that the 'other' relation and/or the 'filterRelation',
     the case given, must both be normalized, ie [-1,1]-valued !
 
K = sum_{x != y} [ min( max(-self.relation[x][y]),other.relation[x][y]), max(self.relation[x][y],-other.relation[x][y]) ]
 
K /= sum_{x!=y} [ min(abs(self.relation[x][y]),abs(other.relation[x][y])) ]
 
.. note::
 
     Renders a tuple with at position 0 the actual bipolar correlation index
     and in position 1 the minimal determination level D of self and
     the other relation.
 
     D = sum_{x != y} min(abs(self.relation[x][y]),abs(other.relation[x][y])) / n(n-1)
 
     where n is the number of actions considered.
 
     The correlation index with a completely indeterminate relation
     is by convention 0.0 at determination level 0.0 .
computeOrdinalCorrelationMP(self, other, MedianCut=False, Threading=True, nbrOfCPUs=None, Comments=False, Debug=False)
Multi processing version of the digraphs.computeOrdinalCorrelation() method.
 
.. note::
     The relation filtering and the MedinaCut option are not implemented in the MP version.
computePairwiseClusterComparison(self, K1, K2, Debug=False)
Computes the pairwise cluster comparison credibility vector
from bipolar-valued digraph g. with K1 and K2 disjoint
lists of action keys from g actions disctionary.
Returns the dictionary
{'I': Decimal(),'P+':Decimal(),'P-':Decimal(),'R' :Decimal()}
where one and only one item is strictly positive.
computePreKernels(self)
computing dominant and absorbent preKernels:
    Result in self.dompreKernels and self.abspreKernels
computePreRankingRelation(self, preRanking, Normalized=True, Debug=False)
Renders the bipolar-valued relation obtained from
a given preRanking in decreasing levels (list of lists) result.
computePreorderRelation(self, preorder, Normalized=True, Debug=False)
Renders the bipolar-valued relation obtained from
a given preordering in increasing levels (list of lists) result.
computePrincipalOrder(self, plotFileName=None, Colwise=False, imageType=None, TempDir=None, Comments=False, Debug=False)
Renders a ordered list of self.actions using the decreasing scores from the
first rincipal eigenvector of the covariance of the valued outdegrees of self.
 
.. note::
 
   The method, relying on writing and reading temporary files by default in a temporary directory is threading and multiprocessing safe !
   (see Digraph.exportPrincipalImage method)
computePrudentBetaLevel(self, Debug=False)
computes alpha, ie the lowest valuation level, for which the
bipolarly polarised digraph doesn't contain a chordless circuit.
computeRankedPairsOrder(self, Cpp=False, Debug=False)
Renders an actions ordering from the worst to the best obtained from the
ranked pairs rule.
computeRankedPairsRanking(self)
Renders an actions ordering from the best to the worst obtained from the
ranked pairs rule.
computeRankingByBestChoosing(self, CoDual=False, CppAgrum=False, Debug=False)
Computes a weak preordering of the self.actions by recursive
best choice elagations.
 
Stores in self.rankingByBestChoosing['result'] a list of (P+,bestChoice) tuples
where P+ gives the best choice complement outranking
average valuation via the computePairwiseClusterComparison
method.
 
If self.rankingByBestChoosing['CoDual'] is True, 
the ranking-by-choosing was computed on the codual of self.
computeRankingByBestChoosingRelation(self, rankingByBestChoosing=None, Debug=False)
Renders the bipolar-valued relation obtained from
the self.rankingByBestChoosing result.
computeRankingByChoosing(self, actionsSubset=None, CppAgrum=False, Debug=False, CoDual=False)
Computes a weak preordring of the self.actions by iterating
jointly best and worst choice elagations.
 
Stores in self.rankingByChoosing['result'] a list of ((P+,bestChoice),(P-,worstChoice)) pairs
where P+ (resp. P-) gives the best (resp. worst) choice complement outranking
(resp. outranked) average valuation via the computePairwiseClusterComparison
method.
 
If self.rankingByChoosing['CoDual'] is True, the ranking-by-choosing was computed on the codual of self.
computeRankingByChoosingRelation(self, rankingByChoosing=None, actionsSubset=None, Debug=False)
Renders the bipolar-valued relation obtained from
the self.rankingByChoosing result.
computeRankingByLastChoosing(self, CoDual=False, CppAgrum=False, Debug=False)
Computes a weak preordring of the self.actions by iterating
worst choice elagations.
 
Stores in self.rankingByLastChoosing['result'] a list of (P-,worstChoice) pairs
where P- gives the worst choice complement outranked
average valuation via the computePairwiseClusterComparison
method.
 
If self.rankingByChoosing['CoDual'] is True, the ranking-by-last-chossing 
was computed on the codual of self.
computeRankingByLastChoosingRelation(self, rankingByLastChoosing=None, Debug=False)
Renders the bipolar-valued relation obtained from
the self.rankingByLastChoosing result.
computeRankingCorrelation(self, ranking, Debug=False)
Renders the ordinal correlation K of a digraph instance
when compared with a given linear ranking of its actions
 
K = sum_{x != y} [ min( max(-self.relation(x,y)),other.relation(x,y), max(self.relation(x,y),-other.relation(x,y)) ]
 
K /= sum_{x!=y} [ min(abs(self.relation(x,y),abs(other.relation(x,y)) ]
 
.. note::
 
     Renders a tuple with at position 0 the actual bipolar correlation index
     and in position 1 the minimal determination level D of self and
     the other relation.
 
     D = sum_{x != y} min(abs(self.relation(x,y)),abs(other.relation(x,y)) / n(n-1)
 
     where n is the number of actions considered.
 
     The correlation index with a completely indeterminate relation
     is by convention 0.0 at determination level 0.0 .
computeRelationalStructure(self, Debug=False)
Renders the counted decomposition of the valued relations into
the following type of links:
gt '>', eq '=', lt '<', incomp '<>',
leq '<=', geq '>=', indeterm '?'
computeRubisChoice(self, CppAgrum=False, Comments=False, _OldCoca=False, BrokenCocs=True, Threading=False, nbrOfCPUs=1)
Renders self.strictGoodChoices, self.nullChoices
self.strictBadChoices, self.nonRobustChoices.
 
CppgArum = False (default | true : use C++/Agrum digraph library
for computing chordless circuits in self.
 
.. warning::
    Changes in site the outranking digraph by
    adding or braking chordless odd outranking circuits.
computeRubyChoice(self, CppAgrum=False, Comments=False, _OldCoca=False)
dummy for computeRubisChoice()
old versions compatibility.
computeSingletonRanking(self, Comments=False, Debug=False)
Renders the sorted bipolar net determinatation of outrankingness
minus outrankedness credibilities of all singleton choices.
 
res = ((netdet,singleton,dom,absorb)+)
computeSize(self)
Renders the number of validated non reflexive arcs
computeSizeTransitiveClosure(self)
Renders the size of the transitive closure of a digraph.
computeSlaterOrder(self, isProbabilistic=False, seed=None, sampleSize=1000, Debug=False)
Reversed return from computeSlaterRanking method.
computeSlaterRanking(self, isProbabilistic=False, seed=None, sampleSize=1000, Debug=False)
Renders a ranking of the actions with minimal Slater index.
Return a tuple: slaterOrder, slaterIndex
computeTransitivityDegree(self)
Renders the transitivity degree of a digraph.
computeUnrelatedPairs(self)
Renders a list of more or less unrelated pairs.
computeValuationLevels(self, choice=None, Debug=False)
renders the symmetric closure of the
apparent valuations levels of self
in an increasingly ordered list.
If parameter choice is given, the
computation is limited to the actions
of the choice.
computeValuationPercentages(self, choice, percentiles, withValues=False)
Parameters: choice and list of percentages.
renders a series of quantiles of the characteristics valuation of
the arcs in the digraph.
computeValuationPercentiles(self, choice, percentages, withValues=False)
Parameters: choice and list of percentages.
renders a series of quantiles of the characteristics valuation of
the arcs in the digraph.
computeValuationStatistics(self, Sampling=False, Comments=False)
Renders the mean and variance of the valuation
of the non reflexive pairs.
computeWeakCondorcetWinners(self)
Wrapper for weakCondorcetWinners().
computeupdown1(self, s, S)
Help method for show_MIS_HB2 method.
fills self.newmisset, self.upmis, self.downmis.
computeupdown2(self, s, S)
Help method for show_MIS_HB1 method.
Fills self.newmisset, self.upmis, self.downmis.
computeupdown2irred(self, s, S)
Help method for show_MIS_HB1 method.
Fills self.newmisset, self.upmis, self.downmis.
condorcetWinners(self)
Renders the set of decision actions x such that
self.relation[x][y] > self.valuationdomain['med']
for all y != x.
contra(self, v)
Parameter: choice.
Renders the negation of a choice v characteristic's vector.
convertRelationToDecimal(self)
Converts the float valued self.relation in a decimal valued one.
convertValuationToDecimal(self)
Convert the float valuation limits to Decimals.
coveringIndex(self, choice, direction='out')
Renders the covering index of a given choice in a set of objects,
ie the minimum number of choice members that cover each
non selected object.
crispKDistance(self, digraph, Debug=False)
Renders the crisp Kendall distance between two bipolar valued
digraphs.
 
.. warning::
 
     Obsolete! Is replaced by the self.computeBipolarCorrelation(other, MedianCut=True) Digraph method
detectChordlessCircuits(self, Comments=False, Debug=False)
Detects a chordless circuit in a digraph.
Returns a Boolean
detectChordlessPath(self, Pk, n2, Comments=False, Debug=False)
New procedure from Agrum study April 2009
recursive chordless path extraction starting from path
Pk = [n2, ...., n1] and ending in node n2.
Optimized with marking of visited chordless P1s.
detectCppChordlessCircuits(self, Debug=False)
python wrapper for the C++/Agrum based chordless circuits detection
exchange arguments with external temporary files.
Returns a boolean value
determinateness(self, vec, inPercent=True)
Renders the determinateness of a bipolar characteristic vector
[(r(x),x),(r(y),y), ...] of length *n* in valuationdomain [Min,Max]:
 
result = sum_x abs(r(x))/(n*(Max-Min)
 
If inPercent, result shifted (+1) and reduced (/2) to [0,1] range.
diameter(self, Oriented=False)
Renders the (by default non-oriented) diameter of the digraph instance
digraph2Graph(self, valuationDomain={'max': 1, 'min': -1, 'med': 0}, Debug=False, conjunctiveConversion=True)
Convert a Digraph instance to a Graph instance.
dneighbors(self, node)
Renders the set of dominated out-neighbors of a node.
domin(self, choice)
Renders the dominance degree of a choice.
dominantChoices(self, S)
Generates all minimal dominant choices of a bipolar valued digraph.
 
.. note::
 
     Initiate with S = self.actions,copy().
domirred(self, choice)
Renders the crips +irredundance degree of a choice.
domirredval(self, choice, relation)
Renders the valued +irredundance degree of a choice.
domirredx(self, choice, x)
Renders the crips +irredundance degree of node x in a choice.
domkernelrestrict(self, choice)
Parameter: prekernel
Renders dominant prekernel restricted relation.
exportD3(self, fileName='index', Comments=True)
This function was designed and implemented by Gary Cornelius, 2014 for his bachelor thesis at the University of Luxembourg. 
The thesis document with more explanations can be found
`here <http://leopold-loewenheim.uni.lu/Digraph3/literature/>`_ .
 
*Parameters*:
    * fileName, name of the generated html file, default = None (graph name as defined in python);
    * Comments, True = default;
 
The idea of the project was to find a way that allows you to easily get details about certain nodes or edges of a directed graph in a dynamic format. 
Therefore this function allows you to export a html file together with all the needed libraries, including the 
D3 Library which we use for graph generation and the physics between nodes, which attracts or pushes nodes away from each other.
 
Features of our graph include i.e. : 
    * A way to only inspect a node and it's neighbours 
    * Dynamic draging and freezing of the graph
    * Export of a newly created general graph
 
You can find the list of fututres in the Section below which is arranged according to the graph type.
 
*If the graph is an outrankingdigraphs*:
    * Nodes can be dragged and only the name and comment can be edited. 
    * Edges can be inspected but not edited for this purpose a special json array containing all possible pairwiseComparisions is generated.
 
*If the graph is a general graph*:
    * Nodes can be dragged, added, removed and edited.
    * Edges can be added, removed, inverted and edited. But edges cannot be inspected.
    * The pairwiseComparisions key leads to an empty array {}.
 
In both cases, undefined edges can be hidden and reappear after a simple reload.(right click - reload)
 
*The generated files*:
    * d3.v3.js, contains the D3 Data-driven Documents source code, containing one small addition that we made in order to be able to easyly import links with a different formatself.
    * digraph3lib.js, contains our library. This file contains everything that we need from import of an XMCDA2 file, visualization of the graph to export of the changed graph.
    * d3export.json, usually named after the python graph name followed by a ticket number if the file is already present. It is the JSON file that is exported with the format "{"xmcda2": "some xml","pairwiseComparisions":"{"a01": "some html",...}"}.
 
*Example 1*:
    #. python3 session:
        >>> from digraphs import RandomValuationDigraph
        >>> dg = RandomValuationDigraph(order=5,Normalized=True)
        >>> dg.exportD3()
        or
        >> dg.showInteractiveGraph()
 
    #. index.html:   
        * Main Screen:
            .. image:: randomvaluation_d3_main.png
        * Inspect function:
            .. image:: randomvaluation_d3_inspect.png
 
.. note::
 
        If you want to use the automatic load in Chrome, try using the command: "python -m SimpleHTTPServer"
        and then access the index.html via "http://0.0.0.0:8000/index.html".
        In order to load the CSS an active internet connection is needed!
exportGraphViz(self, fileName=None, actionsSubset=None, bestChoice=set(), worstChoice=set(), noSilent=True, graphType='png', graphSize='7,7', relation=None)
export GraphViz dot file  for graph drawing filtering.
exportPrincipalImage(self, Reduced=False, Colwise=False, plotFileName=None, Type='png', TempDir='.', Comments=False)
Export as PNG (default) or PDF the principal projection of
the valued relation using the three principal eigen vectors.
 
.. warning::
 
    The method, writing and reading temporary files: 
    tempCol.r and rotationCol.csv, resp. tempRow.r and rotationRow.csv,
    by default in the working directory (./),
    is hence not safe for multiprocessing programs, unless a
    temporary dirctory is provided
flatChoice(self, ch, Debug=False)
Converts set or list ch recursively to a flat list of items.
forcedBestSingleChoice(self)
Renders the set of most determined outranking singletons in self.
gammaSets(self)
Renders the dictionary of neighborhoods {node: (dx,ax)}
with set *dx* gathering the dominated, and set *ax* gathering
the absorbed neighborhood.
generateAbsPreKernels(self)
Generate all absorbent prekernels from independent choices generator.
generateDomPreKernels(self)
Generate all dominant prekernels from independent choices generator.
graphDetermination(self, Normalized=True)
Output: average normalized (by default) arc determination:
 
averageDeterm = ( sum_(x,y) [ abs( relf-relation[x][y] - Med )] / n ) / [( Max-Med ) if Normalized],
 
where Med = self.valuationdomain['med'] and Max = self.valuationdomain['max'].
htmlRelationMap(self, tableTitle='Relation Map', relationName='r(x R y)', actionsSubset=None, rankingRule='Copeland', symbols=['+', '&middot;', '&nbsp;', '-', '_'], Colored=True, ContentCentered=True)
renders the relation map in actions X actions html table format.
htmlRelationTable(self, tableTitle='Valued Relation Table', relationName='r(x R y)', hasIntegerValues=False, actionsSubset=None, isColored=False)
renders the relation valuation in actions X actions html table format.
inDegrees(self)
renders the median cut indegrees
inDegreesDistribution(self)
Renders the distribution of indegrees.
independentChoices(self, U)
Generator for all independent choices with neighborhoods of a bipolar valued digraph:
 
.. note::
 
       * Initiate with U = self.singletons().
       * Yields [(independent choice, domnb, absnb, indnb)].
inner_prod(self, v1, v2)
Parameters: two choice characteristic vectors
Renders the inner product of two characteristic vetors.
intstab(self, choice)
Computes the independence degree of a choice.
irreflex(self, mat)
Puts diagonal entries of mat to valuationdomain['min']
isComplete(self, Debug=False)
checks the completeness property of self.relation by checking
for the absence of a link between two actions!!
 
.. warning::
 
    The reflexive links are ignored !!
isCyclic(self, Debug=False)
checks the cyclicity of self.relation by checking
for a reflexive loop in its transitive closure-
 
.. warning::
 
     self.relation is supposed to be irreflexive !
isWeaklyComplete(self, Debug=False)
checks the weakly completeness property of self.relation by checking
for the absence of a link between two actions!!
 
.. warning::
 
    The reflexive links are ignored !!
iterateRankingByChoosing(self, Odd=False, CoDual=False, Comments=True, Debug=False, Limited=None)
Renders a ranking by choosing result when progressively eliminating
all chordless (odd only) circuits with rising valuation cut levels.
 
Parameters
    CoDual = False (default)/True
    Limited = proportion (in [0,1]) * (max - med) valuationdomain
kChoices(self, A, k)
Renders all choices of length k from set A
matmult2(self, m, v)
Parameters: digraph relation and choice characteristic vector
matrix multiply vector by inner production
meanDegree(self)
Renders the mean degree of self.
!!! self.size must be set previously !!!
meanLength(self, Oriented=False)
Renders the (by default non-oriented) mean neighbourhoor depth of self.
!!! self.order must be set previously !!!
minimalChoices(self, S)
Generates all dominant or absorbent choices of a bipolar
valued digraph.
 
.. note:
 
   * Initiate with S = (actions, dict of dominant or absorbent closed neighborhoods)
   * See showMinDom and showMinAbs methods.
minimalValuationLevelForCircuitsElimination(self, Odd=True, Debug=False, Comments=False)
renders the minimal valuation level <lambda> that eliminates all
self.circuitsList stored odd chordless circuits from self.
 
.. warning::
 
    The <lambda> level polarised may still contain newly appearing chordless odd circuits !
neighbourhoodCollection(self, Oriented=False, Potential=False)
Renders the neighbourhood.
neighbourhoodDepthDistribution(self, Oriented=False)
Renders the distribtion of neighbourhood depths.
notGammaSets(self)
Renders the dictionary of neighborhoods {node: (dx,ax)}
with set *dx* gathering the not dominated, and set *ax* gathering
the not absorbed neighborhood.
notaneighbors(self, node)
Renders the set of absorbed not in-neighbors of a node.
notdneighbors(self, node)
Renders the set of not dominated out-neighbors of a node.
omax(self, L, Debug=False)
Epistemic disjunction for bipolar outranking characteristics
computation.
omin(self, L, Debug=False)
Epistemic conjunction for bipolar outranking characteristics
computation.
outDegrees(self)
renders the median cut outdegrees
outDegreesDistribution(self)
Renders the distribution of outdegrees.
plusirredundant(self, U)
Generates all +irredundant choices of a digraph.
powerset(self, U)
Generates all subsets of a set.
readPerrinMisset(self, file)
read method for 0-1-char-coded MISs from perrinMIS.c curd.dat file.
readPerrinMissetOpt(self, file)
read method for 0-1-char-coded MISs from perrinMIS.c curd.dat file.
readabsvector(self, x, relation)
Parameter: action x
absorbent in vector.
readdomvector(self, x, relation)
Parameter: action x
dominant out vector.
recodeValuation(self, newMin=-1.0, newMax=1.0, Debug=False)
Recodes the characteristic valuation domain according
to the parameters given.
 
.. note::
 
    Default values gives a normalized valuation domain
relationFct(self, x, y)
wrapper for self.relation dictionary access to ensure interoperability
with the sparse and big outranking digraph implementation model.
save(self, fileName='tempdigraph', option=None, DecimalValuation=True, decDigits=2)
Persistent storage of a Digraph class instance in the form of
a python source code file
saveCSV(self, fileName='tempdigraph', Normalized=False, Dual=False, Converse=False, Diagonal=False, Debug=False)
Persistent storage of a Digraph class instance in the form of
a csv file.
saveXMCDA(self, fileName='temp', relationName='R', category='random', subcategory='valued', author='digraphs Module (RB)', reference='saved from Python', valuationType='standard', servingD3=False)
save digraph in XMCDA format.
saveXMCDA2(self, fileName='temp', fileExt='xmcda2', Comments=True, relationName='R', relationType='binary', category='random', subcategory='valued', author='digraphs Module (RB)', reference='saved from Python', valuationType='standard', digits=2, servingD3=False)
save digraph in XMCDA format.
saveXML(self, name='temp', category='general', subcategory='general', author='digraphs Module (RB)', reference='saved from Python')
save digraph in XML format.
savedre(self, name='temp')
save digraph in nauty format.
sharp(self, x, y)
Paramaters: choice characteristic values.
Renders the sharpest of two characteristic values x and y.
sharpvec(self, v, w)
Paramaters: choice characteristic vectors.
Renders the sharpest of two characteristic vectors v and w.
showActions(self)
presentation methods for digraphs actions
showAll(self)
Detailed show method for genuine digraphs.
showAutomorphismGenerators(self)
Renders the generators of the automorphism group.
showBadChoices(self, Recompute=True)
Characteristic values for potentially bad choices.
showChoiceVector(self, ch, ChoiceVector=True)
Show procedure for annotated bipolar choices.
showChordlessCircuits(self)
show methods for (chordless) circuits in a Digraph.
Dummy for showCircuits().
showCircuits(self)
show methods for circuits observed in a Digraph instance.
showComponents(self)
Shows the list of connected components of the digraph instance.
showGoodChoices(self, Recompute=True)
Characteristic values for potentially good choices.
showHTMLRelationMap(self, actionsList=None, rankingRule='Copeland', Colored=True, tableTitle='Relation Map', relationName='r(x S y)', symbols=['+', '&middot;', '&nbsp;', '&#150;', '&#151'])
Launches a browser window with the colored relation map of self.
See corresponding Digraph.showRelationMap() method.
 
Example::
 
    >>> from outrankingDigraphs import *
    >>> t = RandomCBPerformanceTableau(numberOfActions=25,seed=1)
    >>> g = BipolarOutrankingDigraph(t,Normalized=True)
    >>> gcd = ~(-g)  # strict outranking relation
    >>> gcd.showHTMLRelationMap(rankingRule="netFlows")
    
.. image:: relationMap.png
   :alt: Browser view of a relation map
   :width: 600 px
   :align: center
showHTMLRelationTable(self, actionsList=None, IntegerValues=False, Colored=True, tableTitle='Valued Adjacency Matrix', relationName='r(x S y)')
Launches a browser window with the colored relation table of self.
showInteractiveGraph(self)
Save the graph and all needed files for the visualization of an interactive graph generated by the exportD3() function.
For best experience make sure to use Firefox, because other browser restrict the loading of local files.
showMIS(self, withListing=True)
Prints all maximal independent choices:
    Result in self.misset.
showMIS_AH(self, withListing=True)
Prints all MIS using the Hertz method.
 
Result saved in self.hertzmisset.
showMIS_HB2(self, withListing=True)
Prints all MIS using the Hertz-Bisdorff method.
 
Result saved in self.newmisset.
showMIS_RB(self, withListing=True)
Prints all MIS using the Bisdorff method.
 
Result saved in self.newmisset.
showMIS_UD(self, withListing=True)
Prints all MIS using the Hertz-Bisdorff method.
 
Result saved in self.newmisset.
showMaxAbsIrred(self, withListing=True)
Computing maximal -irredundant choices:
    Result in self.absirset.
showMaxDomIrred(self, withListing=True)
Computing maximal +irredundant choices:
   Result in self.domirset.
showMinAbs(self, withListing=True)
Prints minimal absorbent choices:
    Result in self.absset.
showMinDom(self, withListing=True)
Prints all minimal dominant choices:
    Result in self.domset.
showNeighborhoods(self)
Lists the gamma and the notGamma function of self.
showOrbits(self, InChoices, withListing=True)
Prints the orbits of Choices along the automorphisms of
the digraph instance.
showOrbitsFromFile(self, InFile, withListing=True)
Prints the orbits of Choices along the automorphisms of
the digraph self by reading in the 0-1 misset file format.
See the digraphs.Digraph.readPerrinMisset() method.
showPreKernels(self, withListing=True)
Printing dominant and absorbent preKernels:
    Result in self.dompreKernels and self.abspreKernels
showRankingByBestChoosing(self, rankingByBestChoosing=None)
A show method for self.rankinByBestChoosing result.
 
.. warning::
 
     The self.computeRankingByBestChoosing(CoDual=False/True) method instantiating the self.rankingByBestChoosing slot is pre-required !
showRankingByChoosing(self, rankingByChoosing=None)
A show method for self.rankinByChoosing result.
 
.. warning::
 
     The self.computeRankingByChoosing(CoDual=False/True) method instantiating the self.rankingByChoosing slot is pre-required !
showRankingByLastChoosing(self, rankingByLastChoosing=None, Debug=None)
A show method for self.rankinByChoosing result.
 
.. warning::
 
     The self.computeRankingByLastChoosing(CoDual=False/True) method instantiating the self.rankingByChoosing slot is pre-required !
showRelation(self)
prints the relation valuation in ##.## format.
showRelationMap(self, symbols=None, rankingRule='Copeland')
Prints on the console, in text map format, the location of
certainly validated and certainly invalidated outranking situations.
 
By default, symbols = {'max':'┬','positive': '+', 'median': ' ',
                       'negative': '-', 'min': '┴'}
 
The default ordering of the output is following the Copeland ranking rule
from best to worst actions. Further available ranking rules are net flows (rankingRule="netFlows"),
Kohler's (rankingRule="kohler"), and Tideman's ranked pairs rule (rankingRule="rankedPairs").
 
Example::
 
    >>> from outrankingDigraphs import *
    >>> t = RandomCBPerformanceTableau(numberOfActions=25,seed=1)
    >>> g = BipolarOutrankingDigraph(t,Normalized=True)
    >>> gcd = ~(-g)  # strict outranking relation
    >>> gcd.showRelationMap(rankingRule="netFlows")
     -   ++++++++  +++++┬+┬┬+
    - -   + +++++ ++┬+┬+++┬++
    ┴+  ┴ + ++  ++++┬+┬┬++┬++
    -   ++ - ++++-++++++┬++┬+
       - - - ++- ┬- + -+┬+-┬┬
    -----  -      -┬┬┬-+  -┬┬
    ----    --+-+++++++++++++
    -- --+- --++ ++ +++-┬+-┬┬
    ----  -  -+-- ++--+++++ +
    ----- ++- --- +---++++┬ +
    -- -- ---+ -++-+++-+ +-++
    -- --┴---+  + +-++-+ -  +
    ---- ┴---+-- ++--++++ - +
      --┴┴--  --- -  --+ --┬┬
     ---------+--+ ----- +-┬┬
    -┴---┴- ---+- + ---+++┬ +
    -┴┴--┴---+--- ++ -++--+++
    -----┴--- ---+-+- ++---+ 
    -┴┴--------------- --++┬ 
    --┴---------------- --+┬ 
    ┴--┴┴ -┴--┴┴-┴ --++  ++-+
    ----┴┴--------------- -  
    ┴┴┴----+-┴+┴---┴-+---+ ┴+
    ┴┴-┴┴┴-┴- - -┴┴---┴┴+ ┬ -
    ----┴┴-┴-----┴┴---  - -- 
    Ranking rule: netFlows
    >>>
showRelationTable(self, Sorted=True, IntegerValues=False, actionsSubset=None, relation=None, ndigits=2, ReflexiveTerms=True)
prints the relation valuation in actions X actions table format.
showRubisBestChoiceRecommendation(self, Comments=False, ChoiceVector=False, CoDual=True, Debug=False, _OldCoca=False, BrokenCocs=True, Cpp=False)
Renders the RuBis best choice recommendation.
 
.. note::
 
    Computes by default the Rubis best choice recommendation on the corresponding strict (codual) outranking digraph.
 
    In case of chordless circuits, if supporting arcs are more credible
    than the reversed negating arcs, we collapse the circuits into hyper nodes.
    Inversely,  if supporting arcs are not more credible than the reversed negating arcs,
    we brake the circuits on their weakest arc.
 
Usage example:
 
>>> from outrankingDigraphs import *
>>> t = Random3ObjectivesPerformanceTableau(seed=5)
>>> g = BipolarOutrankingDigraph(t)
>>> g.showRubisBestChoiceRecommendation()
***********************
RuBis Best Choice Recommendation (BCR)
(in decreasing order of determinateness)   
Credibility domain:  [-100.0, 100.0]
=== >> potential vest choices
* choice              : ['a04', 'a14', 'a19', 'a20']
   +-irredundancy      : 1.19
   independence        : 1.19
   dominance           : 4.76
   absorbency          : -59.52
   covering (%)        : 75.00
   determinateness (%) : 57.86
   - most credible action(s) = { 'a14': 23.81, 'a19': 11.90, 'a04': 2.38, 'a20': 1.19, }  
=== >> potential worst choices 
* choice              : ['a03', 'a12', 'a17']
   +-irredundancy      : 4.76
  independence        : 4.76
  dominance           : -76.19
  absorbency          : 4.76
  covering (%)        : 0.00
  determinateness (%) : 65.39
  - most credible action(s) = { 'a03': 38.10, 'a12': 13.10, 'a17': 4.76, }
Execution time: 0.024 seconds
*****************************
showRubyChoice(self, Comments=False, _OldCoca=True)
dummy for showRubisBestChoiceRecommendation()
older versions compatibility
showShort(self)
concise presentation method for genuine digraphs.
showSingletonRanking(self, Comments=True, Debug=False)
Calls self.computeSingletonRanking(comments=True,Debug = False).
Renders and prints the sorted bipolar net determinatation of outrankingness
minus outrankedness credibilities of all singleton choices.
 
res = ((netdet,sigleton,dom,absorb)+)
showStatistics(self)
Computes digraph statistics like order, size and arc-density.
showdre(self)
Shows relation in nauty format.
singletons(self)
list of singletons and neighborhoods
[(singx1, +nx1, -nx1, not(+nx1 or -nx1)),.... ]
sizeSubGraph(self, choice)
Output: (size, undeterm,arcDensity).
Renders the arc density of the induced subgraph.
strongComponents(self, setPotential=False)
Renders the set of strong components of self.
symDegreesDistribution(self)
Renders the distribution of symmetric degrees.
topologicalSort(self, Debug=False)
If self is acyclic, adds topological sort number to each node of self
and renders ordered list of nodes. Otherwise renders None.
Source: M. Golumbic Algorithmic Graph heory and Perfect Graphs,
Annals Of Discrete Mathematics 57 2nd Ed. , Elsevier 2004, Algorithm 2.4 p.44.
weakAneighbors(self, node)
Renders the set of absorbed in-neighbors of a node.
weakCondorcetWinners(self)
Renders the set of decision actions x such that
self.relation[x][y] >= self.valuationdomain['med']
for all y != x.
weakDneighbors(self, node)
Renders the set of dominated out-neighbors of a node.
weakGammaSets(self)
Renders the dictionary of neighborhoods {node: (dx,ax)}
worstRanks(self)
renders worst possible ranks from outdegrees account
zoomValuation(self, zoomFactor=1.0)
Zooms in or out, depending on the value of the zoomFactor provided,
the bipolar valuation of a digraph.

Data descriptors inherited from digraphs.Digraph:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class LinearVotingProfile(VotingProfile)
    A specialised class for linear voting profiles
 
Structure::
 
    candidates = OrderedDict([('a', ...) ,('b', ...),('c', ...), ...])
    voters = OrderedDict([('1',{'weight':1.0}), ('2',{'weight':1.0}), ...])
    ## each specifies a a ranked list of candidates
    ## from the best to the worst
    linearBallot = {
        '1' : ['b','c','a', ...],
        '2' : ['a','b','c', ...],
        ...
        }
 
Sample Python3 session
 
>>> from votingDigraphs import *
>>> v = RandomLinearVotingProfile(numberOfVoters=5,numberOfCandidates=3)
>>> v.showLinearBallots()
voters(weight)       candidates rankings
v4(1.0):     ['a1', 'a2', 'a3']
v5(1.0):     ['a1', 'a2', 'a3']
v1(1.0):     ['a2', 'a1', 'a3']
v2(1.0):     ['a1', 'a2', 'a3']
v3(1.0):     ['a1', 'a3', 'a2']
>>> v.computeRankAnalysis()
{'a1': [4.0, 1.0, 0],
 'a2': [1.0, 3.0, 1.0],
 'a3': [0, 1.0, 4.0]}
>>> v.showRankAnalysisTable()
*----  Rank analysis tableau -----*
  ranks |  1    2    3    | Borda score
 -------|------------------------------
   'a1' |  4    1    0    |   6
   'a2' |  1    3    1    |   10
   'a3' |  0    1    4    |   14
>>> v.computeUninominalVotes()
{'a1': 4.0, 'a3': 0, 'a2': 1.0}
>>> v.computeSimpleMajorityWinner()
['a1']
>>> v.computeBordaScores()
{'a1': 6.0, 'a3': 14.0, 'a2': 10.0}
>>> v.computeBordaWinners()
['a1']
>>> v.computeInstantRunoffWinner()
['a1']
 
 
Method resolution order:
LinearVotingProfile
VotingProfile
builtins.object

Methods defined here:
__init__(self, fileVotingProfile=None, numberOfCandidates=5, numberOfVoters=9, seed=None)
Initialize self.  See help(type(self)) for accurate signature.
computeBallot(self)
Computes a complete ballot from the linear Ballot.
computeBordaScores(self)
compute Borda scores from the rank analysis
computeBordaWinners(self)
compute the Borda winner from the Borda scores, ie the list of
candidates with the minimal Borda score.
computeInstantRunoffWinner(self, Comments=False)
compute the instant runoff winner from a linear voting ballot
computeRankAnalysis(self)
compute the number of ranks each candidate obtains
computeSimpleMajorityWinner(self, Comments=False)
compute the winner in a uninominal Election from a linear ballot
computeUninominalVotes(self, candidates=None, linearBallot=None)
compute uninominal votes for each candidate in candidates sublist
and restricted linear ballots
save(self, name='templinearprofile')
Persistant storage of a linear voting profile.
 
Parameter:
    name of file (without <.py> extension!).
save2PerfTab(self, fileName='votingPerfTab', isDecimal=True, valueDigits=2)
Persistant storage of a linear voting profile in the format of a rank performance Tableau.
For each voter *v*, the rank performance of candidate *x* corresponds to:
 
number of candidates - linearProfile[v].index(x)
showHTMLVotingHeatmap(self, criteriaList=None, actionsList=None, SparseModel=False, minimalComponentSize=1, RankingRule='Copeland', quantiles=None, strategy='average', ndigits=0, colorLevels=None, pageTitle='Voting Heatmap', Correlations=True, Threading=False, nbrOfCPUs=1, Debug=False)
Show the linear voting profile as a rank performance heatmap.
The linear voting profile is previously saved to a stored Performance Tableau.
 
(see perfTabs.PerformanceTableau.showHTMLPerformanceHeatmap() )
showLinearBallots(self)
show the linear ballots
showRankAnalysisTable(self, Sorted=True, ndigits=0, Debug=False)
Print the rank analysis tableau.
 
If Sorted (True by default), the candidates
are ordered by increasing Borda Scores.
 
In case of decimal voters weights, ndigits allows
to format the decimal precision of the numerical output.

Methods inherited from VotingProfile:
showAll(self, WithBallots=True)
Show method for <VotingProfile> instances.
showVoterBallot(self, voter, hasIntegerValuation=False)
Show the actual voting of a voter.

Data descriptors inherited from VotingProfile:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class RandomApprovalVotingProfile(ApprovalVotingProfile)
    A specialized class for approval voting profiles.
 
 
Method resolution order:
RandomApprovalVotingProfile
ApprovalVotingProfile
VotingProfile
builtins.object

Methods defined here:
__init__(self, numberOfVoters=9, numberOfCandidates=5, minSizeOfBallot=1, maxSizeOfBallot=2, seed=None)
Random profile creation parameters:
    | numberOfVoters=9, numberOfCandidates=5,
    | minSizeOfBallot=1, maxSizeOfBallot=2.
generateRandomApprovalBallot(self, minSizeOfBallot, maxSizeOfBallot, seed=None)
Renders a randomly generated approval ballot.
generateRandomDisApprovalBallot(self, minSizeOfBallot, maxSizeOfBallot, seed=None)
Renders a randomly generated approval ballot.

Methods inherited from ApprovalVotingProfile:
computeBallot(self)
Computes a complete ballot from the approval Ballot.
 
Parameters:
    approvalEquivalence=False, disapprovalEquivalence=False.
save(self, name='tempAVprofile')
Persistant storage of an approval voting profile.
 
Parameter:
    name of file (without <.py> extension!).
save2PerfTab(self, fileName='votingPerfTab', isDecimal=True, valueDigits=2)
Persistant storage of an approval voting profile in the format of a standard performance tableau.
For each voter *v*, the performance of candidate *x* corresponds to:
 
      1, if approved;
      0, if disapproved;
      -999, miising evalaution otherwise,
showApprovalResults(self)
Renders the approval obtained by each candidates.
showDisApprovalResults(self)
Renders the disapprovals obtained by each candidates.
showResults(self)

Methods inherited from VotingProfile:
showAll(self, WithBallots=True)
Show method for <VotingProfile> instances.
showVoterBallot(self, voter, hasIntegerValuation=False)
Show the actual voting of a voter.

Data descriptors inherited from VotingProfile:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class RandomLinearVotingProfile(LinearVotingProfile)
    A specialized class for random linwear voting profiles.
 
 
Method resolution order:
RandomLinearVotingProfile
LinearVotingProfile
VotingProfile
builtins.object

Methods defined here:
__init__(self, numberOfVoters=9, numberOfCandidates=5, seed=None)
Random profile creation parameters:
    | numberOfVoters=9, numberOfCandidates=5,
generateRandomLinearBallot(self, seed)
Renders a randomly generated linear ballot.

Methods inherited from LinearVotingProfile:
computeBallot(self)
Computes a complete ballot from the linear Ballot.
computeBordaScores(self)
compute Borda scores from the rank analysis
computeBordaWinners(self)
compute the Borda winner from the Borda scores, ie the list of
candidates with the minimal Borda score.
computeInstantRunoffWinner(self, Comments=False)
compute the instant runoff winner from a linear voting ballot
computeRankAnalysis(self)
compute the number of ranks each candidate obtains
computeSimpleMajorityWinner(self, Comments=False)
compute the winner in a uninominal Election from a linear ballot
computeUninominalVotes(self, candidates=None, linearBallot=None)
compute uninominal votes for each candidate in candidates sublist
and restricted linear ballots
save(self, name='templinearprofile')
Persistant storage of a linear voting profile.
 
Parameter:
    name of file (without <.py> extension!).
save2PerfTab(self, fileName='votingPerfTab', isDecimal=True, valueDigits=2)
Persistant storage of a linear voting profile in the format of a rank performance Tableau.
For each voter *v*, the rank performance of candidate *x* corresponds to:
 
number of candidates - linearProfile[v].index(x)
showHTMLVotingHeatmap(self, criteriaList=None, actionsList=None, SparseModel=False, minimalComponentSize=1, RankingRule='Copeland', quantiles=None, strategy='average', ndigits=0, colorLevels=None, pageTitle='Voting Heatmap', Correlations=True, Threading=False, nbrOfCPUs=1, Debug=False)
Show the linear voting profile as a rank performance heatmap.
The linear voting profile is previously saved to a stored Performance Tableau.
 
(see perfTabs.PerformanceTableau.showHTMLPerformanceHeatmap() )
showLinearBallots(self)
show the linear ballots
showRankAnalysisTable(self, Sorted=True, ndigits=0, Debug=False)
Print the rank analysis tableau.
 
If Sorted (True by default), the candidates
are ordered by increasing Borda Scores.
 
In case of decimal voters weights, ndigits allows
to format the decimal precision of the numerical output.

Methods inherited from VotingProfile:
showAll(self, WithBallots=True)
Show method for <VotingProfile> instances.
showVoterBallot(self, voter, hasIntegerValuation=False)
Show the actual voting of a voter.

Data descriptors inherited from VotingProfile:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class RandomVotingProfile(VotingProfile)
    A subclass for generating random voting profiles.
 
 
Method resolution order:
RandomVotingProfile
VotingProfile
builtins.object

Methods defined here:
__init__(self, numberOfVoters=9, numberOfCandidates=5, hasRandomWeights=False, maxWeight=10, seed=None, Debug=False)
Random profile creation parameters:
 
    | numberOfVoters=9,
    | numberOfCandidates=5
generateRandomBallot(self, seed, Debug=False)
Renders a randomly generated approval ballot
from a shuffled list of candidates for each voter.

Methods inherited from VotingProfile:
save(self, name='tempVprofile')
Persistant storage of an approval voting profile.
showAll(self, WithBallots=True)
Show method for <VotingProfile> instances.
showVoterBallot(self, voter, hasIntegerValuation=False)
Show the actual voting of a voter.

Data descriptors inherited from VotingProfile:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class VotingProfile(builtins.object)
    A general class for storing voting profiles.
 
General structure::
 
    candidates = OrderedDict([('a', ...),('b', ...),('c', ...), ( ... ) ])
    voters = OrderedDict([
    ('1', {'weight':1.0}),
    ('2', {'weight':1.0}),
    ...,
    ])
    ballot = {     # voters x candidates x candidates
        '1': {     # bipolar characteristic {-1,0,1} of each voter's
              'a': { 'a':0,'b':-1,'c':0, ...},   # pairwise preferences
              'b': { 'a':1,'b':0, 'c':1, ...},
              'c': { 'a':0,'b':-1,'c':0, ...},
              ...,
        },
        '2': { 'a': { 'a':0, 'b':0, 'c':1, ...},
               'b': { 'a':0, 'b':0, 'c':1, ...},
               'c': { 'a':-1,'b':-1,'c':0, ...},
               ...,
        },
        ...,
    }
 
  Methods defined here:
__init__(self, fileVotingProfile=None, seed=None)
Initialize self.  See help(type(self)) for accurate signature.
save(self, name='tempVprofile')
Persistant storage of an approval voting profile.
showAll(self, WithBallots=True)
Show method for <VotingProfile> instances.
showVoterBallot(self, voter, hasIntegerValuation=False)
Show the actual voting of a voter.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
time(...)
time() -> floating point number
 
Return the current time in seconds since the Epoch.
Fractions of a second may be present if the system clock provides them.

 
Data
        default_parser_list = ['xml.sax.expatreader']