amnh / PCG

𝙋𝙝𝙮𝙡𝙤𝙜𝙚𝙣𝙚𝙩𝙞𝙘 𝘾𝙤𝙢𝙥𝙤𝙣𝙚𝙣𝙩 𝙂𝙧𝙖𝙥𝙝 ⸺ Haskell program and libraries for general phylogenetic graph search
28 stars 1 forks source link

Add a Cost type #133

Open recursion-ninja opened 5 years ago

recursion-ninja commented 5 years ago

Currently, our "cost" type is a Double or a new-typed Double labeled ExtendedReal.

Our use-case for Cost does not overlap well with the Num and related "numeric" type-class instances.

Our Cost should have the following invariants:

We could represent Cost as a non-negative rational number and a Monoid under addition.

recursion-ninja commented 5 years ago

I added the module Numeric.Cost in the pcg-utility package along with an accompanying test suite. See this commit f6d0b1f .

We should consider using this Cost type for the weights of characters along with the resulting cost of our scored graph objects. This would be the next step for this issue. The result would be no rounding errors in our codebase. The only possible exception to this is for continuous character optimization, as they are still implemented using Double values.