summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--notes.txt2
-rw-r--r--src/Election.hs8
2 files changed, 4 insertions, 6 deletions
diff --git a/notes.txt b/notes.txt
index 0601e5f..d80fd23 100644
--- a/notes.txt
+++ b/notes.txt
@@ -30,8 +30,6 @@ better commented code, because I'm going to have to maintain this later
util to list paper ids that fit specific criteria to doublecheck potential errors
-replace the use of floats for transfer values with rational fixed points for increased accuracy
-
add proper tiebreaker handling
more counters/parsers/options to handle state elections, general stv data
diff --git a/src/Election.hs b/src/Election.hs
index 5ffba0d..ea23a05 100644
--- a/src/Election.hs
+++ b/src/Election.hs
@@ -16,10 +16,10 @@ import Data.List ( (\\) )
import qualified Data.List as List
import qualified Data.Maybe as Maybe
import qualified Data.Either.Unwrap as Either
+import Data.Ratio ( (%) )
import qualified Counter as Sen
import qualified Candidate as Typ
import qualified CSV as CSV
-import Miscellaneous ( (.:) )
import qualified Miscellaneous as Misc
@@ -52,7 +52,7 @@ data Entry = Entry
data Trace = Trace
{ getCriteria :: Sen.Criteria
- , getTransferVal :: Float }
+ , getTransferVal :: Rational }
deriving (Eq)
data Status = Running | Elected | Eliminated
@@ -61,7 +61,7 @@ data Status = Running | Elected | Eliminated
data Transfer = Transfer
{ getWhoFrom :: Typ.CandidateID
, getVoteAmount :: Int
- , getNewValue :: Float
+ , getNewValue :: Rational
, getWhatToDist :: [Trace] }
@@ -210,7 +210,7 @@ doElectCandidate e = do
newTransfer = Transfer
{ getWhoFrom = getID electedEntry
, getVoteAmount = getTotalVotes electedEntry - getQuota e
- , getNewValue = (fromIntegral (getTotalVotes electedEntry - getQuota e)) /
+ , getNewValue = (fromIntegral (getTotalVotes electedEntry - getQuota e)) %
(fromIntegral (getTotalVotes electedEntry))
, getWhatToDist = getCritTrace electedEntry }