pub fn compute_dataset<CommonTally:PartialEq+Clone+FromStr+Display,R1,R2,R3,R4>(&self,data:&ElectionData) -> anyhow::Result<(Vec<RuleComparisonDefinition>,CompareRulesOneDataset)>
    where
        R1: PreferenceDistributionRules<Tally=CommonTally>,
        R2: PreferenceDistributionRules<Tally=CommonTally>,
        R3: PreferenceDistributionRules<Tally=CommonTally>,
        R4: PreferenceDistributionRules<Tally=CommonTally>,
    {
        let mut comparisons : Vec<RuleComparisonDefinition> = vec![];
        let mut results = vec![];
        let transcripts : Vec<Transcript<CommonTally>> = vec![
            self.compute::<R1>(data)?,
            self.compute::<R2>(data)?,
            self.compute::<R3>(data)?,
            self.compute::<R4>(data)?,
        ];
        self.compare_alternate_rules::<R1>(&transcripts[0],data,&mut comparisons,&mut results)?;
        self.compare_alternate_rules::<R2>(&transcripts[1],data,&mut comparisons,&mut results)?;
        self.compare_alternate_rules::<R3>(&transcripts[2],data,&mut comparisons,&mut results)?;
        self.compare_alternate_rules::<R4>(&transcripts[3],data,&mut comparisons,&mut results)?;
        for i in 0..transcripts.len() {
            for j in 0..i {
                let diff = compare_transcripts(&transcripts[i],&transcripts[j]);
                comparisons.push(RuleComparisonDefinition{ rule1: transcripts[i].rules.clone(), rule2: transcripts[j].rules.clone() });
                println!("{} vs {} : {}",transcripts[i].rules,transcripts[j].rules,diff);
                results.push(diff);
            }
        }
        Ok((comparisons,CompareRulesOneDataset{ dataset: data.metadata.clone(), results }))
    }
/// This should be more general, rather than restricted to 4 rules.
This should be more general, rather than restricted to 4 rules.
This should be more general rather than restricted to 4 rules .
pub fn compute_dataset<CommonTally:PartialEq+Clone+FromStr+Display,R1,R2,R3,R4>(&self,data:&ElectionData) -> anyhow::Result<(Vec<RuleComparisonDefinition>,CompareRulesOneDataset)>
    where
        R1: PreferenceDistributionRules<Tally=CommonTally>,
        R2: PreferenceDistributionRules<Tally=CommonTally>,
        R3: PreferenceDistributionRules<Tally=CommonTally>,
        R4: PreferenceDistributionRules<Tally=CommonTally>,
    {
        let mut comparisons : Vec<RuleComparisonDefinition> = vec![];
        let mut results = vec![];
        let transcripts : Vec<Transcript<CommonTally>> = vec![
            self.compute::<R1>(data)?,
            self.compute::<R2>(data)?,
            self.compute::<R3>(data)?,
            self.compute::<R4>(data)?,
        ];
        self.compare_alternate_rules::<R1>(&transcripts[0],data,&mut comparisons,&mut results)?;
        self.compare_alternate_rules::<R2>(&transcripts[1],data,&mut comparisons,&mut results)?;
        self.compare_alternate_rules::<R3>(&transcripts[2],data,&mut comparisons,&mut results)?;
        self.compare_alternate_rules::<R4>(&transcripts[3],data,&mut comparisons,&mut results)?;
        for i in 0..transcripts.len() {
            for j in 0..i {
                let diff = compare_transcripts(&transcripts[i],&transcripts[j]);
                comparisons.push(RuleComparisonDefinition{ rule1: transcripts[i].rules.clone(), rule2: transcripts[j].rules.clone() });
                println!("{} vs {} : {}",transcripts[i].rules,transcripts[j].rules,diff);
                results.push(diff);
            }
        }
        Ok((comparisons,CompareRulesOneDataset{ dataset: data.metadata.clone(), results }))
    }
pub fn compute_dataset < CommonTally : PartialEq + Clone + FromStr + Display , R1 , R2 , R3 , R4 > ( & self , data : & ElectionData ) -> anyhow :: Result < ( Vec < RuleComparisonDefinition > , CompareRulesOneDataset ) > where R1 : PreferenceDistributionRules < Tally = CommonTally > , R2 : PreferenceDistributionRules < Tally = CommonTally > , R3 : PreferenceDistributionRules < Tally = CommonTally > , R4 : PreferenceDistributionRules < Tally = CommonTally > , { let mut comparisons : Vec < RuleComparisonDefinition > = vec ! [ ] ; let mut results = vec ! [ ] ; let transcripts : Vec < Transcript < CommonTally > > = vec ! [ self compute R1 ( data ) self compute R2 ( data ) self compute R3 ( data ) self compute R4 ( data ) ] ; self . compare_alternate_rules :: < R1 > ( & transcripts [ 0 ] , data , & mut comparisons , & mut results ) ? ; self . compare_alternate_rules :: < R2 > ( & transcripts [ 1 ] , data , & mut comparisons , & mut results ) ? ; self . compare_alternate_rules :: < R3 > ( & transcripts [ 2 ] , data , & mut comparisons , & mut results ) ? ; self . compare_alternate_rules :: < R4 > ( & transcripts [ 3 ] , data , & mut comparisons , & mut results ) ? ; for i in 0 .. transcripts . len ( ) { for j in 0 .. i { let diff = compare_transcripts ( & transcripts [ i ] , & transcripts [ j ] ) ; comparisons . push ( RuleComparisonDefinition { rule1 : transcripts [ i ] . rules . clone ( ) , rule2 : transcripts [ j ] . rules . clone ( ) } ) ; println ! ( " " transcripts [ i ] rules transcripts [ j ] rules diff ) ; results . push ( diff ) ; } } Ok ( ( comparisons , CompareRulesOneDataset { dataset : data . metadata . clone ( ) , results } ) ) }
This should be more general, rather than restricted to 4 rules.
This should be more general rather than restricted to 4 rules .
&self
data
&ElectionData
&self
data
&ElectionData