Skip to content

Commit

Permalink
feat(textile): update number of references index thresholds. (#839)
Browse files Browse the repository at this point in the history
Update number of refs thresholds for durability:
- 100% when the number of references is less than 1,000
- 80% for 6,000 references ⇒ this threshold is deleted
- 50% for 7,000 references
- 0% when the number of references is greater than 16,000
  • Loading branch information
n1k0 authored Nov 21, 2024
1 parent 464d978 commit ef6287d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
22 changes: 9 additions & 13 deletions src/Data/Textile/Economics.elm
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,20 @@ computeNumberOfReferencesIndex n =
(low - toFloat n) / (low - high)
in
Unit.ratio <|
if n <= 3000 then
-- From 0 to 3000: 100%
if n <= 1000 then
-- From 0 to 1000: 100%
1

else if n <= 6000 then
-- From 3000 to 6000: decreasing from 100% to 80%
0.8 + (fromThreshold 3000 6000 * 0.2)
else if n <= 7000 then
-- From 1000 to 7000: decreasing from 100% to 50%
0.5 + (fromThreshold 1000 7000 * (1 - 0.5))

else if n <= 10000 then
-- From 6000 to 10000: decreasing from 80% to 50%
0.5 + (fromThreshold 6000 10000 * (0.8 - 0.5))

else if n <= 50000 then
-- From 10000 to 50000: decreasing from 50% to 0%
fromThreshold 10000 50000 * 0.5
else if n <= 16000 then
-- From 7000 to 16000: decreasing from 50% to 0%
fromThreshold 7000 16000 * 0.5

else
-- Over 50000: 0%
-- Over 16000: 0%
0


Expand Down
19 changes: 10 additions & 9 deletions tests/Data/Textile/EconomicsTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ suite =
, traceability = False
}
|> Unit.nonPhysicalDurabilityToFloat
|> Expect.within (Expect.Absolute 0.01) 1.1
|> Expect.within (Expect.Absolute 0.01) 0.98
|> asTest "should compute durability index"
]
, describe "computeNumberOfReferencesIndex"
([ ( 1, 1 )
, ( 3000, 1 )
, ( 3750, 0.95 )
, ( 4500, 0.9 )
, ( 5250, 0.85 )
, ( 6000, 0.8 )
, ( 8000, 0.65 )
, ( 10000, 0.5 )
, ( 30000, 0.25 )
, ( 500, 1 )
, ( 750, 1 )
, ( 1000, 1 )
, ( 2000, 0.91 )
, ( 3000, 0.83 )
, ( 4500, 0.7 )
, ( 7000, 0.5 )
, ( 11500, 0.25 )
, ( 16000, 0 )
, ( 50000, 0 )
, ( 100000, 0 )
]
Expand Down

0 comments on commit ef6287d

Please sign in to comment.