(Translated by https://www.hiragana.jp/)
Add a Cost type · Issue #133 · amnh/PCG · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Cost type #133

Open
recursion-ninja opened this issue Apr 25, 2019 · 1 comment
Open

Add a Cost type #133

recursion-ninja opened this issue Apr 25, 2019 · 1 comment
Assignees
Labels
enhancement minor Likely to take less than 10 hours of work.

Comments

@recursion-ninja
Copy link
Collaborator

recursion-ninja commented Apr 25, 2019

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:

  • Non-negative
  • Monotonically non-decreasing "addition"
  • Equatable
  • Total ordering
  • An "infinite value" representation
  • Perfect precision for rational numbers
  • Reasonable efficiency

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

@recursion-ninja
Copy link
Collaborator Author

recursion-ninja commented May 31, 2019

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.

@recursion-ninja recursion-ninja added the minor Likely to take less than 10 hours of work. label Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement minor Likely to take less than 10 hours of work.
Projects
None yet
Development

No branches or pull requests

2 participants