Created by sophie on 10.01.17.
More...
|
BitVector | applyRuleBV (final List< String > p_alternatives, final List< BitVector > p_votes, final int p_comSize) |
|
Map< Integer, Integer > | sortMapASC (final Map< Integer, Integer > p_valuesMap) |
| sort HashMap according to its values in ascending order More...
|
|
|
List< BitVector > | computeBitComittees (final int p_altNum, final int p_comSize) |
| compute possible committees More...
|
|
int | determineMaxHDBV (final List< BitVector > p_votes, final BitVector p_comVect, final int p_altNum) |
|
BitVector org.lightvoting.simulation.rule.CMinimaxApproval.applyRuleBV |
( |
final List< String > |
p_alternatives, |
|
|
final List< BitVector > |
p_votes, |
|
|
final int |
p_comSize |
|
) |
| |
Definition at line 54 of file CMinimaxApproval.java.
58 final List<BitVector> l_bitCommittees = this.computeBitComittees( p_alternatives.size(), p_comSize );
59 System.out.println( l_bitCommittees );
63 Map<Integer, Integer> l_maxMap =
new HashMap<Integer, Integer>();
65 for (
int i = 0; i < l_bitCommittees.size(); i++ )
68 l_maxMap.put( i, this.determineMaxHDBV( p_votes, l_bitCommittees.get( i ), p_alternatives.size() ) );
71 l_maxMap = this.sortMapASC( l_maxMap );
73 return l_bitCommittees.get( l_maxMap.entrySet().iterator().next().getKey() );
List<BitVector> org.lightvoting.simulation.rule.CMinimaxApproval.computeBitComittees |
( |
final int |
p_altNum, |
|
|
final int |
p_comSize |
|
) |
| |
|
private |
- Parameters
-
p_altNum | number of alternatives |
p_comSize | committee size |
- Returns
- possible committees
Definition at line 84 of file CMinimaxApproval.java.
86 final CCombination l_combination =
new CCombination();
87 final int[] l_arr =
new int[p_altNum];
89 for (
int i = 0; i < p_altNum; i++ )
92 l_combination.combinations( l_arr, p_comSize, 0,
new int[p_comSize] );
94 final List<int[]> l_resultList = l_combination.getResultList();
96 final List<BitVector> l_bitVectors =
new LinkedList<>();
98 for (
int i = 0; i < l_resultList.size(); i++ )
100 final BitVector l_bitVector =
new BitVector( p_altNum );
102 for (
int j = 0; j < p_comSize; j++ )
104 l_bitVector.put( l_resultList.get( i )[j],
true );
106 l_bitVectors.add( l_bitVector );
int org.lightvoting.simulation.rule.CMinimaxApproval.determineMaxHDBV |
( |
final List< BitVector > |
p_votes, |
|
|
final BitVector |
p_comVect, |
|
|
final int |
p_altNum |
|
) |
| |
|
private |
Definition at line 112 of file CMinimaxApproval.java.
118 for (
int i = 0; i < p_votes.size(); i++ )
120 final BitVector l_curBitCom = p_comVect.copy();
122 l_curBitCom.xor( p_votes.get( i ) );
124 final int l_curHD = l_curBitCom.cardinality();
126 if ( l_curHD > l_maxHD )
129 System.out.println(
" maximal HD for committee " + p_comVect +
": " + l_maxHD );
Map<Integer, Integer> org.lightvoting.simulation.rule.CMinimaxApproval.sortMapASC |
( |
final Map< Integer, Integer > |
p_valuesMap | ) |
|
- Parameters
-
p_valuesMap | HashMap with Approval scores |
- Returns
- sorted HashMap
Definition at line 141 of file CMinimaxApproval.java.
144 final List<Map.Entry<Integer, Integer>> l_list =
new LinkedList<>( p_valuesMap.entrySet() );
147 Collections.sort( l_list, Comparator.comparing( Map.Entry::getValue ) );
150 final Map<Integer, Integer> l_sortedMap =
new LinkedHashMap<Integer, Integer>();
151 for (
final Map.Entry<Integer, Integer> l_entry : l_list )
153 l_sortedMap.put( l_entry.getKey(), l_entry.getValue() );