kopia lustrzana https://github.com/drastus/sejm-calculator
Use better past support equivalence
rodzic
872e06d3fa
commit
7746c7ac70
10
src/data.ts
10
src/data.ts
|
@ -21,35 +21,35 @@ export const committees: Committee[] = [
|
|||
name: 'Prawo i Sprawiedliwość',
|
||||
shortName: 'PiS',
|
||||
threshold: 5,
|
||||
pastSupportEquivalence: ['pis'],
|
||||
pastSupportEquivalence: [['pis', 1]],
|
||||
},
|
||||
{
|
||||
id: 'ko',
|
||||
name: 'Koalicja Obywatelska',
|
||||
shortName: 'KO',
|
||||
threshold: 8,
|
||||
pastSupportEquivalence: ['po', 'nowoczesna'],
|
||||
pastSupportEquivalence: [['po', 1], ['nowoczesna', 1]],
|
||||
},
|
||||
{
|
||||
id: 'lewica',
|
||||
name: 'SLD – Lewica',
|
||||
shortName: 'Lew.',
|
||||
threshold: 5,
|
||||
pastSupportEquivalence: ['zl', 'razem'],
|
||||
pastSupportEquivalence: [['zl', 1], ['razem', 1]],
|
||||
},
|
||||
{
|
||||
id: 'psl',
|
||||
name: 'PSL – Koalicja Polska',
|
||||
shortName: 'PSL',
|
||||
threshold: 5,
|
||||
pastSupportEquivalence: ['psl', 'k15'],
|
||||
pastSupportEquivalence: [['psl', 1], ['k15', 0.5]],
|
||||
},
|
||||
{
|
||||
id: 'konfederacja',
|
||||
name: 'Konfederacja',
|
||||
shortName: 'Konf.',
|
||||
threshold: 5,
|
||||
pastSupportEquivalence: ['korwin'],
|
||||
pastSupportEquivalence: [['korwin', 1], ['k15', 0.5]],
|
||||
},
|
||||
{
|
||||
id: 'mn',
|
||||
|
|
|
@ -9,7 +9,7 @@ const calculateLocalSupport = (
|
|||
const localPastSupport = constituency.pastSupport;
|
||||
const localPastSupportProjection = support.map((committeeSupport, index) => (
|
||||
committees[index].pastSupportEquivalence
|
||||
.map(pastCommitteeId => localPastSupport[pastCommitteeId])
|
||||
.map(pastCommittee => localPastSupport[pastCommittee[0]] * pastCommittee[1])
|
||||
.reduce((a, b) => a + b, 0)
|
||||
));
|
||||
const localSupportDeviation = pastSupportProjection
|
||||
|
@ -29,7 +29,7 @@ const calculateLocalSupport = (
|
|||
export const calculateMandates = (support: number[]): number[] => {
|
||||
const pastSupportProjection = support.map((committeeSupport, index) => (
|
||||
committees[index].pastSupportEquivalence
|
||||
.map(pastCommitteeId => pastSupport[pastCommitteeId])
|
||||
.map(pastCommittee => pastSupport[pastCommittee[0]] * pastCommittee[1])
|
||||
.reduce((a, b) => a + b, 0)
|
||||
));
|
||||
const mandates: number[] = new Array(support.length + 1).fill(0);
|
||||
|
|
|
@ -9,7 +9,7 @@ export type Committee = {
|
|||
name: string;
|
||||
shortName: string;
|
||||
threshold: number;
|
||||
pastSupportEquivalence: PastCommiteeId[];
|
||||
pastSupportEquivalence: [PastCommiteeId, number][];
|
||||
}
|
||||
|
||||
export type Constituency = {
|
||||
|
|
Ładowanie…
Reference in New Issue