From 05ec70830f168bb62c463692388c805bd5baefcf Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sun, 27 Jun 2021 22:36:50 +1000 Subject: [PATCH] Fix bug with constraints Also initialise constraint matrix with total number of seats --- src/election.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/election.rs b/src/election.rs index 6d62914..d4e1e70 100644 --- a/src/election.rs +++ b/src/election.rs @@ -236,6 +236,11 @@ impl<'a, N: Number> CountState<'a, N> { cm.init(); //println!("{}", cm); + // Require correct number of candidates to be elected + let idx = vec![0; constraints.0.len()]; + cm[&idx].min = election.seats; + cm[&idx].max = election.seats; + state.constraint_matrix = Some(cm); }