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

Test suite failure for /multiplicative (positive weights).QuickCheck/ #5

Open
runeksvendsen opened this issue Sep 15, 2023 · 5 comments
Assignees

Comments

@runeksvendsen
Copy link
Owner

runeksvendsen commented Sep 15, 2023

multiplicative (positive weights)
        SmallCheck: OK
          190 tests completed
        QuickCheck: FAIL (0.10s)
          *** Failed! (after 50 tests and 2 shrinks):
          Exception:
            distTo source /= zero
            CallStack (from HasCallStack):
              error, called at src/Data/Graph/BellmanFord.hs:316:13 in bellman-ford-0.1.0.0-inplace:Data.Graph.BellmanFord
          [TestEdge {getFrom = "=d7oh\92566\ETBt\DC3k\992320\ACKN*[\1003745r\38120y\NAKIty\ACKY\SO", getTo = "eTme t\rpR[x\NAK\USD", getWeight = 16.8},TestEdge {getFrom = "cA8\FSvY{G\GSIC4G=\ENQs\994057n\50237QUIdijT\832[72](https://github.com/runeksvendsen/bellman-ford/actions/runs/6182991083/job/16783808837#step:9:73)\DEL\SOH]2\50735#l6!?\111150", getTo = "\n@l\169580gl9\63647\CANn!\DLE\r\NULwhX\175293Y9 \SO\4698\69383\&3RS\1016403t\1066628L\15537U\v47\v\28100\ETX\158902\FSQ", getWeight = 21.678571428571427},TestEdge {getFrom = "\140430\1046479\ESC\1088417\"\v\FS\SO", getTo = "RZ[\DC4", getWeight = 5.0},TestEdge {getFrom = "\SUB\1069004g\197646\DC1\DLE\FSr$\189369)% (\151881\SUBQn1\ENQ\118903M\4407\t\EM\18918\RS}", getTo = "C6H\60800\33337h@Gk\1107295_\EOTuO/!}\1086438", getWeight = 0.45454545454545453},TestEdge {getFrom = "lYY]\42616~\GS\146858ad-8ZK\198542C7gZ7jJ\1066915\1045393Q\SYNA!\135837u>\US(\DC4\1018793I\170049DK\1101109\DC3L", getTo = "3\ETX\95887#m\70516=\142433qA\123641\153829\126256u\1036397\141588QK\54604\SI{\60299\194856\&1(-\SOu", getWeight = 10.0},TestEdge {getFrom = "\83494\1008691\DC3\1035230AM\1106845F-\DC2Fk,#8y\154046f;G\b\1093513'sel\120017o=\123620s=pn\998647V\NUL9Q\160559:RF*\26576\1021151s", getTo = "~\NAK\154013>\ETX)\61352\"\NULR", getWeight = 14.0},TestEdge {getFrom = "\NAK\n\CANb\190898\SO\ETB\1017546}lE*\1028491o^\1111972@\36147&\151571f\ESC^b0\1050735\148218\RSP{\US\SID\1113109k\f\1055319\998304\r\1063893\ACK\999031,`9", getTo = "X9\145154FC5!", getWeight = 19.0},TestEdge {getFrom = "\97569\DC3 \DC4\1013772Vq\ACKi\1080353EC\US%\18662\"", getTo = "rZ|)}hh\42943\ESCm1\GS\96087\154457V\a\1031509ef,5\SOH", getWeight = 0.5714285714285714},TestEdge {getFrom = "-M\nO[\STX\176838D\FSZ\CAN)\ACK\10636z", getTo = "!bp\STX\RS\SO\EOT\US\DC2\1048366\4187\SO\158140\f\1094977xJpgJ\1047955\1001192zU\127247\160928\1110610 9w\1050367\&7O\DC3h\94503P\DLE+B {1", getWeight = 28.53846153846154},TestEdge {getFrom = "\987433vP\GS\21725\60515\&5\1065815T\1015508w`.%\1037161\&8\n\164271\1061566\&7t\EOTJ\1099883\STX;\"\999016\64724D\SUB\USMj\5878t\DEL\1055129Ew(\b\ESC\NAKHX\150114", getTo = "\1086145WY!\991635[r\1064496P\61101v\NAKmG\26827\21230c\DC3\1099423\1018267B\b[$}\23124\b\1044557\176571\EOT\ACK", getWeight = 44.27906976744186},TestEdge {getFrom = "\DC1rD\1021885\24430\SO#\1091437\177623Q\1111098\1036701dZR\EM\DC4-\983599U]bt\n\fx0", getTo = "x", getWeight = 0.7214833819108236},TestEdge {getFrom = "", getTo = "", getWeight = 0.5},TestEdge {getFrom = "\1000130@(\STX\1080701\r\ETX\83128\\l\r;\SOH%:\168514T\DC3vT\ACK\SYN\99702\1037838\62955\111353~\1007298\FS\186647\153605\DC4/d\FSJ=", getTo = "Y[\60683\51052`p\GS|\1100093y\1011467\27440\1022686u]\144103\1016317\a\12526", getWeight = 22.56},TestEdge {getFrom = "JwY]", getTo = "\1034193]\SO\DLEB;\EOTj\8145<\v\NUL\NAK+\CANj\CANWi$\25386\n'`7\28526\DC4\152864V\NUL\169634\1054096\SI\CAN\176301\1006606K5\SO\25699\\\"_\ETB/", getWeight = 0.7590380331428749},TestEdge {getFrom = "3\175752qv\USwc\6924\72121\992029\1072781\99085\1085011t9\STX\1077127\1075153Y\1094458\66624o;\96187\r\FS-n@\nzG\DEL\ESC\135614\&8S", getTo = "i\DC18;;W\171033uBS\1077794VK\138735~>_n$\1016917Jbk\DC2\\{|\STX\1111390", getWeight = 31.72972972972973},TestEdge {getFrom = "\990124U\998830JM2T\RS\EML\1107111.\DEL\ETB\tHbf\67410[Wa\SOev\989435\986330\2130{1%2{4$\tY3Zr", getTo = "\EOT~\EOT+<G\144690\1072418]\v\SUByn-\1016612\15628s>Q", getWeight = 16.0},TestEdge {getFrom = "&Q\1081159\f\170586q5:Y", getTo = "\1079595", getWeight = 32.56},TestEdge {getFrom = "\DLE\1012529b~2M\120625\fS\1054110j\131476\186875\173348zA&\1027764bdV\996038\a)I\1010726\\\146558\FS6\DEL\ETB\39348rO;\nSsI", getTo = "\DC1Q", getWeight = 0.7147901925189171},TestEdge {getFrom = "\187748\148581\STXz<')", getTo = "UcbB9\ESC\1051043n\FS(\1110727\rQ|\"\997276\178363\1030605y\NAKGk\1006338E]o\NUL\1110275\GS\STXPnK\25319um8\fb\97123j\1032757z\US", getWeight = 47.21052631578947},TestEdge {getFrom = "b\FS\14186!", getTo = "er\23736!$\1009042Zae\65769 \FSzQ[s\DC3lo\DLE{\120482=\DEL6\ENQC#)", getWeight = 0.375},TestEdge {getFrom = "\153\1025345\fq\vD\1021597\DC2\97290j\DELgst\1043200\FSC7\GS`\t", getTo = "\FSb\171787\ACK)e\SYN\22512\12723}U\SI\177485gCwn\FS\38761J~\145876y\1078037\1026845$\SOHDR3r", getWeight = 0.3333333333333333},TestEdge {getFrom = "Q\ETX\FS\DEL<\DC38FWK\9496=\CAN\994436)\SYN\f_B\137633\FS\1107859$\37757Rd,\\69&\EM", getTo = "3~=n\DC4+K\ETBK7\1035437\33429\1019306D:)T0\987443?H\SO\\\164330\DEL0Qk{\1000227R\1039402\SUBY", getWeight = 29.0},TestEdge {getFrom = "\ENQ\\\984437\34820b01b_\STX+r|\DC4%q\991836\1743GtXF\1061330b\171088\DC4I\33601\134831\&4s\\\994610\a\DC42I", getTo = "Q\"PN\127524\32933-\NAK;\1004068yGT;\1000436a\1008622", getWeight = 26.413793103448278},TestEdge {getFrom = "\SI\150160\GS\STX\29195c\DC4`\24044,\ETBJ&[;DM1\ESC*\37183\59721;\30910\STXY\fuLj\14234rt\1094712\tc\62713\&7N\t.Kd<-1\1043501Fn", getTo = "\59368\FSNx\vK\FS\761\987318\184744F\STX\ESC\DC3\RSOW7\1010068\96526\b,wtufT\57973", getWeight = 42.0},TestEdge {getFrom = "\ENQ]Z\29417\&6(p%\EOT#\\\r4\136734$<\175090\CANE\74059i6\182722\&0yTII\149399fdf\996398\1070583:t\SI\DC3\1112748\SOZ\CANS", getTo = "\990310\187689\32868G\49721\&4\42308O\998956s\1042630\\\132500ONk1>%\987894TLJkP", getWeight = 0.43231868809891094}]
          Use --quickcheck-replay=130492 to reproduce.
          Use -p '/multiplicative (positive weights).QuickCheck/' to rerun this test only.

Input test data (list of edges):

[ TestEdge {getFrom = "=d7oh\92566\ETBt\DC3k\992320\ACKN*[\1003745r\38120y\NAKIty\ACKY\SO", getTo = "eTme t\rpR[x\NAK\USD", getWeight = 16.8}
, TestEdge {getFrom = "cA8\FSvY{G\GSIC4G=\ENQs\994057n\50237QUIdijT\832[72](https://github.com/runeksvendsen/bellman-ford/actions/runs/6182991083/job/16783808837#step:9:73)\DEL\SOH]2\50735#l6!?\111150", getTo = "\n@l\169580gl9\63647\CANn!\DLE\r\NULwhX\175293Y9 \SO\4698\69383\&3RS\1016403t\1066628L\15537U\v47\v\28100\ETX\158902\FSQ", getWeight = 21.678571428571427}
, TestEdge {getFrom = "\140430\1046479\ESC\1088417\"\v\FS\SO", getTo = "RZ[\DC4", getWeight = 5.0}
, TestEdge {getFrom = "\SUB\1069004g\197646\DC1\DLE\FSr$\189369)% (\151881\SUBQn1\ENQ\118903M\4407\t\EM\18918\RS}", getTo = "C6H\60800\33337h@Gk\1107295_\EOTuO/!}\1086438", getWeight = 0.45454545454545453}
, TestEdge {getFrom = "lYY]\42616~\GS\146858ad-8ZK\198542C7gZ7jJ\1066915\1045393Q\SYNA!\135837u>\US(\DC4\1018793I\170049DK\1101109\DC3L", getTo = "3\ETX\95887#m\70516=\142433qA\123641\153829\126256u\1036397\141588QK\54604\SI{\60299\194856\&1(-\SOu", getWeight = 10.0}
, TestEdge {getFrom = "\83494\1008691\DC3\1035230AM\1106845F-\DC2Fk,#8y\154046f;G\b\1093513'sel\120017o=\123620s=pn\998647V\NUL9Q\160559:RF*\26576\1021151s", getTo = "~\NAK\154013>\ETX)\61352\"\NULR", getWeight = 14.0}
, TestEdge {getFrom = "\NAK\n\CANb\190898\SO\ETB\1017546}lE*\1028491o^\1111972@\36147&\151571f\ESC^b0\1050735\148218\RSP{\US\SID\1113109k\f\1055319\998304\r\1063893\ACK\999031,`9", getTo = "X9\145154FC5!", getWeight = 19.0}
, TestEdge {getFrom = "\97569\DC3 \DC4\1013772Vq\ACKi\1080353EC\US%\18662\"", getTo = "rZ|)}hh\42943\ESCm1\GS\96087\154457V\a\1031509ef,5\SOH", getWeight = 0.5714285714285714}
, TestEdge {getFrom = "-M\nO[\STX\176838D\FSZ\CAN)\ACK\10636z", getTo = "!bp\STX\RS\SO\EOT\US\DC2\1048366\4187\SO\158140\f\1094977xJpgJ\1047955\1001192zU\127247\160928\1110610 9w\1050367\&7O\DC3h\94503P\DLE+B {1", getWeight = 28.53846153846154}
, TestEdge {getFrom = "\987433vP\GS\21725\60515\&5\1065815T\1015508w`.%\1037161\&8\n\164271\1061566\&7t\EOTJ\1099883\STX;\"\999016\64724D\SUB\USMj\5878t\DEL\1055129Ew(\b\ESC\NAKHX\150114", getTo = "\1086145WY!\991635[r\1064496P\61101v\NAKmG\26827\21230c\DC3\1099423\1018267B\b[$}\23124\b\1044557\176571\EOT\ACK", getWeight = 44.27906976744186}
, TestEdge {getFrom = "\DC1rD\1021885\24430\SO#\1091437\177623Q\1111098\1036701dZR\EM\DC4-\983599U]bt\n\fx0", getTo = "x", getWeight = 0.7214833819108236}
, TestEdge {getFrom = "", getTo = "", getWeight = 0.5}
, TestEdge {getFrom = "\1000130@(\STX\1080701\r\ETX\83128\\l\r;\SOH%:\168514T\DC3vT\ACK\SYN\99702\1037838\62955\111353~\1007298\FS\186647\153605\DC4/d\FSJ=", getTo = "Y[\60683\51052`p\GS|\1100093y\1011467\27440\1022686u]\144103\1016317\a\12526", getWeight = 22.56}
, TestEdge {getFrom = "JwY]", getTo = "\1034193]\SO\DLEB;\EOTj\8145<\v\NUL\NAK+\CANj\CANWi$\25386\n'`7\28526\DC4\152864V\NUL\169634\1054096\SI\CAN\176301\1006606K5\SO\25699\\\"_\ETB/", getWeight = 0.7590380331428749}
, TestEdge {getFrom = "3\175752qv\USwc\6924\72121\992029\1072781\99085\1085011t9\STX\1077127\1075153Y\1094458\66624o;\96187\r\FS-n@\nzG\DEL\ESC\135614\&8S", getTo = "i\DC18;;W\171033uBS\1077794VK\138735~>_n$\1016917Jbk\DC2\\{|\STX\1111390", getWeight = 31.72972972972973}
, TestEdge {getFrom = "\990124U\998830JM2T\RS\EML\1107111.\DEL\ETB\tHbf\67410[Wa\SOev\989435\986330\2130{1%2{4$\tY3Zr", getTo = "\EOT~\EOT+<G\144690\1072418]\v\SUByn-\1016612\15628s>Q", getWeight = 16.0}
, TestEdge {getFrom = "&Q\1081159\f\170586q5:Y", getTo = "\1079595", getWeight = 32.56}
, TestEdge {getFrom = "\DLE\1012529b~2M\120625\fS\1054110j\131476\186875\173348zA&\1027764bdV\996038\a)I\1010726\\\146558\FS6\DEL\ETB\39348rO;\nSsI", getTo = "\DC1Q", getWeight = 0.7147901925189171}
, TestEdge {getFrom = "\187748\148581\STXz<')", getTo = "UcbB9\ESC\1051043n\FS(\1110727\rQ|\"\997276\178363\1030605y\NAKGk\1006338E]o\NUL\1110275\GS\STXPnK\25319um8\fb\97123j\1032757z\US", getWeight = 47.21052631578947}
, TestEdge {getFrom = "b\FS\14186!", getTo = "er\23736!$\1009042Zae\65769 \FSzQ[s\DC3lo\DLE{\120482=\DEL6\ENQC#)", getWeight = 0.375}
, TestEdge {getFrom = "\153\1025345\fq\vD\1021597\DC2\97290j\DELgst\1043200\FSC7\GS`\t", getTo = "\FSb\171787\ACK)e\SYN\22512\12723}U\SI\177485gCwn\FS\38761J~\145876y\1078037\1026845$\SOHDR3r", getWeight = 0.3333333333333333}
, TestEdge {getFrom = "Q\ETX\FS\DEL<\DC38FWK\9496=\CAN\994436)\SYN\f_B\137633\FS\1107859$\37757Rd,\\69&\EM", getTo = "3~=n\DC4+K\ETBK7\1035437\33429\1019306D:)T0\987443?H\SO\\\164330\DEL0Qk{\1000227R\1039402\SUBY", getWeight = 29.0}
, TestEdge {getFrom = "\ENQ\\\984437\34820b01b_\STX+r|\DC4%q\991836\1743GtXF\1061330b\171088\DC4I\33601\134831\&4s\\\994610\a\DC42I", getTo = "Q\"PN\127524\32933-\NAK;\1004068yGT;\1000436a\1008622", getWeight = 26.413793103448278}
, TestEdge {getFrom = "\SI\150160\GS\STX\29195c\DC4`\24044,\ETBJ&[;DM1\ESC*\37183\59721;\30910\STXY\fuLj\14234rt\1094712\tc\62713\&7N\t.Kd<-1\1043501Fn", getTo = "\59368\FSNx\vK\FS\761\987318\184744F\STX\ESC\DC3\RSOW7\1010068\96526\b,wtufT\57973", getWeight = 42.0}
, TestEdge {getFrom = "\ENQ]Z\29417\&6(p%\EOT#\\\r4\136734$<\175090\CANE\74059i6\182722\&0yTII\149399fdf\996398\1070583:t\SI\DC3\1112748\SOZ\CANS", getTo = "\990310\187689\32868G\49721\&4\42308O\998956s\1042630\\\132500ONk1>%\987894TLJkP", getWeight = 0.43231868809891094}]

CI run: https://github.com/runeksvendsen/bellman-ford/actions/runs/6182991083/job/16783808837

Not reproducible locally (on M1 MacBook):

$ git checkout 40f8754

HEAD is now at 40f8754 Update README.md (spelling)
$ cabal run test-suite:bellman-ford-test -- --quickcheck-replay=130492 -p '/multiplicative (positive weights).QuickCheck/'
Properties
  BellmanFord
    passes 'check'
      multiplicative (positive weights)
        QuickCheck: OK (0.71s)
          +++ OK, passed 200 tests.

All 1 tests passed (0.71s)
@runeksvendsen runeksvendsen self-assigned this Sep 15, 2023
@runeksvendsen
Copy link
Owner Author

runeksvendsen commented Sep 15, 2023

Looks like there's a bug in the QuickCheck seed/generation logic. Passing --quickcheck-replay=130492 seemingly doesn't reproduce the given input data, since manually running it on the generated list of edges reproduces the bug. Diff:

diff --git a/test/BellmanFord/Spec.hs b/test/BellmanFord/Spec.hs
index 5c4bfb1..1d23328 100644
--- a/test/BellmanFord/Spec.hs
+++ b/test/BellmanFord/Spec.hs
@@ -3,6 +3,7 @@
 {-# LANGUAGE FlexibleContexts #-}
 module BellmanFord.Spec
 ( spec
+, tmpTest
 )
 where

@@ -26,6 +27,8 @@ import qualified Data.List.NonEmpty                 as NE
 import qualified System.Random.Shuffle              as Shuffle
 import           Text.Printf                        (printf)

+tmpTest :: [TestEdge] -> IO ()
+tmpTest = bellmanFord (*) 1

 spec :: Tasty.TestTree
 spec = Tasty.testGroup "BellmanFord"
diff --git a/test/Spec.hs b/test/Spec.hs
index d27fe5a..557b4f5 100644
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -8,10 +8,15 @@ import qualified Util.Spec                          as Util
 import qualified Test.Tasty                         as Tasty
 import           Test.Tasty.SmallCheck              as SC
 import qualified Test.Tasty.QuickCheck              as QC
+import Types.Edge

+testEdges =
+    [TestEdge {getFrom = "=d7oh\92566\ETBt\DC3k\992320\ACKN*[\1003745r\38120y\NAKIty\ACKY\SO", getTo = "eTme t\rpR[x\NAK\USD", getWeight = 16.8},TestEdge {getFrom = "cA8\FSvY{G\GSIC4G=\ENQs\994057n\50237QUIdijT\832[72](https://github.com/runeksvendsen/bellman-ford/actions/runs/6182991083/job/16783808837#step:9:73)\DEL\SOH]2\50735#l6!?\111150", getTo = "\n@l\169580gl9\63647\CANn!\DLE\r\NULwhX\175293Y9 \SO\4698\69383\&3RS\1016403t\1066628L\15537U\v47\v\28100\ETX\158902\FSQ", getWeight = 21.678571428571427},TestEdge {getFrom = "\140430\1046479\ESC\1088417\"\v\FS\SO", getTo = "RZ[\DC4", getWeight = 5.0},TestEdge {getFrom = "\SUB\1069004g\197646\DC1\DLE\FSr$\189369)% (\151881\SUBQn1\ENQ\118903M\4407\t\EM\18918\RS}", getTo = "C6H\60800\33337h@Gk\1107295_\EOTuO/!}\1086438", getWeight = 0.45454545454545453},TestEdge {getFrom = "lYY]\42616~\GS\146858ad-8ZK\198542C7gZ7jJ\1066915\1045393Q\SYNA!\135837u>\US(\DC4\1018793I\170049DK\1101109\DC3L", getTo = "3\ETX\95887#m\70516=\142433qA\123641\153829\126256u\1036397\141588QK\54604\SI{\60299\194856\&1(-\SOu", getWeight = 10.0},TestEdge {getFrom = "\83494\1008691\DC3\1035230AM\1106845F-\DC2Fk,#8y\154046f;G\b\1093513'sel\120017o=\123620s=pn\998647V\NUL9Q\160559:RF*\26576\1021151s", getTo = "~\NAK\154013>\ETX)\61352\"\NULR", getWeight = 14.0},TestEdge {getFrom = "\NAK\n\CANb\190898\SO\ETB\1017546}lE*\1028491o^\1111972@\36147&\151571f\ESC^b0\1050735\148218\RSP{\US\SID\1113109k\f\1055319\998304\r\1063893\ACK\999031,`9", getTo = "X9\145154FC5!", getWeight = 19.0},TestEdge {getFrom = "\97569\DC3 \DC4\1013772Vq\ACKi\1080353EC\US%\18662\"", getTo = "rZ|)}hh\42943\ESCm1\GS\96087\154457V\a\1031509ef,5\SOH", getWeight = 0.5714285714285714},TestEdge {getFrom = "-M\nO[\STX\176838D\FSZ\CAN)\ACK\10636z", getTo = "!bp\STX\RS\SO\EOT\US\DC2\1048366\4187\SO\158140\f\1094977xJpgJ\1047955\1001192zU\127247\160928\1110610 9w\1050367\&7O\DC3h\94503P\DLE+B {1", getWeight = 28.53846153846154},TestEdge {getFrom = "\987433vP\GS\21725\60515\&5\1065815T\1015508w`.%\1037161\&8\n\164271\1061566\&7t\EOTJ\1099883\STX;\"\999016\64724D\SUB\USMj\5878t\DEL\1055129Ew(\b\ESC\NAKHX\150114", getTo = "\1086145WY!\991635[r\1064496P\61101v\NAKmG\26827\21230c\DC3\1099423\1018267B\b[$}\23124\b\1044557\176571\EOT\ACK", getWeight = 44.27906976744186},TestEdge {getFrom = "\DC1rD\1021885\24430\SO#\1091437\177623Q\1111098\1036701dZR\EM\DC4-\983599U]bt\n\fx0", getTo = "x", getWeight = 0.7214833819108236},TestEdge {getFrom = "", getTo = "", getWeight = 0.5},TestEdge {getFrom = "\1000130@(\STX\1080701\r\ETX\83128\\l\r;\SOH%:\168514T\DC3vT\ACK\SYN\99702\1037838\62955\111353~\1007298\FS\186647\153605\DC4/d\FSJ=", getTo = "Y[\60683\51052`p\GS|\1100093y\1011467\27440\1022686u]\144103\1016317\a\12526", getWeight = 22.56},TestEdge {getFrom = "JwY]", getTo = "\1034193]\SO\DLEB;\EOTj\8145<\v\NUL\NAK+\CANj\CANWi$\25386\n'`7\28526\DC4\152864V\NUL\169634\1054096\SI\CAN\176301\1006606K5\SO\25699\\\"_\ETB/", getWeight = 0.7590380331428749},TestEdge {getFrom = "3\175752qv\USwc\6924\72121\992029\1072781\99085\1085011t9\STX\1077127\1075153Y\1094458\66624o;\96187\r\FS-n@\nzG\DEL\ESC\135614\&8S", getTo = "i\DC18;;W\171033uBS\1077794VK\138735~>_n$\1016917Jbk\DC2\\{|\STX\1111390", getWeight = 31.72972972972973},TestEdge {getFrom = "\990124U\998830JM2T\RS\EML\1107111.\DEL\ETB\tHbf\67410[Wa\SOev\989435\986330\2130{1%2{4$\tY3Zr", getTo = "\EOT~\EOT+<G\144690\1072418]\v\SUByn-\1016612\15628s>Q", getWeight = 16.0},TestEdge {getFrom = "&Q\1081159\f\170586q5:Y", getTo = "\1079595", getWeight = 32.56},TestEdge {getFrom = "\DLE\1012529b~2M\120625\fS\1054110j\131476\186875\173348zA&\1027764bdV\996038\a)I\1010726\\\146558\FS6\DEL\ETB\39348rO;\nSsI", getTo = "\DC1Q", getWeight = 0.7147901925189171},TestEdge {getFrom = "\187748\148581\STXz<')", getTo = "UcbB9\ESC\1051043n\FS(\1110727\rQ|\"\997276\178363\1030605y\NAKGk\1006338E]o\NUL\1110275\GS\STXPnK\25319um8\fb\97123j\1032757z\US", getWeight = 47.21052631578947},TestEdge {getFrom = "b\FS\14186!", getTo = "er\23736!$\1009042Zae\65769 \FSzQ[s\DC3lo\DLE{\120482=\DEL6\ENQC#)", getWeight = 0.375},TestEdge {getFrom = "\153\1025345\fq\vD\1021597\DC2\97290j\DELgst\1043200\FSC7\GS`\t", getTo = "\FSb\171787\ACK)e\SYN\22512\12723}U\SI\177485gCwn\FS\38761J~\145876y\1078037\1026845$\SOHDR3r", getWeight = 0.3333333333333333},TestEdge {getFrom = "Q\ETX\FS\DEL<\DC38FWK\9496=\CAN\994436)\SYN\f_B\137633\FS\1107859$\37757Rd,\\69&\EM", getTo = "3~=n\DC4+K\ETBK7\1035437\33429\1019306D:)T0\987443?H\SO\\\164330\DEL0Qk{\1000227R\1039402\SUBY", getWeight = 29.0},TestEdge {getFrom = "\ENQ\\\984437\34820b01b_\STX+r|\DC4%q\991836\1743GtXF\1061330b\171088\DC4I\33601\134831\&4s\\\994610\a\DC42I", getTo = "Q\"PN\127524\32933-\NAK;\1004068yGT;\1000436a\1008622", getWeight = 26.413793103448278},TestEdge {getFrom = "\SI\150160\GS\STX\29195c\DC4`\24044,\ETBJ&[;DM1\ESC*\37183\59721;\30910\STXY\fuLj\14234rt\1094712\tc\62713\&7N\t.Kd<-1\1043501Fn", getTo = "\59368\FSNx\vK\FS\761\987318\184744F\STX\ESC\DC3\RSOW7\1010068\96526\b,wtufT\57973", getWeight = 42.0},TestEdge {getFrom = "\ENQ]Z\29417\&6(p%\EOT#\\\r4\136734$<\175090\CANE\74059i6\182722\&0yTII\149399fdf\996398\1070583:t\SI\DC3\1112748\SOZ\CANS", getTo = "\990310\187689\32868G\49721\&4\42308O\998956s\1042630\\\132500ONk1>%\987894TLJkP", getWeight = 0.43231868809891094}]

-main :: IO ()
-main =
+main = BellmanFord.tmpTest testEdges
+
+main' :: IO ()
+main' =
     Tasty.defaultMain $
         Tasty.testGroup "Properties" $
             [ mkLocalOption 5 $ Util.spec
$ cabal run test-suite:bellman-ford-test -- --quickcheck-replay=130492 -p '/multiplicative (positive weights).QuickCheck/'
bellman-ford-test: distTo source /= zero
CallStack (from HasCallStack):
  error, called at src/Data/Graph/BellmanFord.hs:316:13 in bellman-ford-0.1.0.0-inplace:Data.Graph.BellmanFord

@runeksvendsen
Copy link
Owner Author

Looks like it might be caused by a floating point rounding error. With 2949549 I get:

$ cabal run test-suite:bellman-ford-test -- -p '/multiplicative (positive weights).QuickCheck/'
bellman-ford-test: distTo source /= zero: 1.4210854715202004e-14
CallStack (from HasCallStack):
  error, called at src/Data/Graph/BellmanFord.hs:317:13 in bellman-ford-0.1.0.0-inplace:Data.Graph.BellmanFord

@runeksvendsen
Copy link
Owner Author

Here's a trace (cf. 7d45b90) of every time the distTo array is updated until the error occurs:

$ cabal run test-suite:bellman-ford-test -- -p '/multiplicative (positive weights).QuickCheck/'
new distTo: 32.56, old distTo Infinity for IdxEdge {eMeta = 32.56, _eFrom = "&Q\1081159\f\170586q5:Y", _eTo = "\1079595", _eFromIdx = VertexId {_vidInt = 13}, _eToIdx = VertexId {_vidInt = 47}}
new distTo: 0.45454545454545453, old distTo Infinity for IdxEdge {eMeta = 0.45454545454545453, _eFrom = "\SUB\1069004g\197646\DC1\DLE\FSr$\189369)% (\151881\SUBQn1\ENQ\118903M\4407\t\EM\18918\RS}", _eTo = "C6H\60800\33337h@Gk\1107295_\EOTuO/!}\1086438", _eFromIdx = VertexId {_vidInt = 10}, _eToIdx = VertexId {_vidInt = 19}}
new distTo: 47.21052631578947, old distTo Infinity for IdxEdge {eMeta = 47.21052631578947, _eFrom = "\187748\148581\STXz<')", _eTo = "UcbB9\ESC\1051043n\FS(\1110727\rQ|\"\997276\178363\1030605y\NAKGk\1006338E]o\NUL\1110275\GS\STXPnK\25319um8\fb\97123j\1032757z\US", _eFromIdx = VertexId {_vidInt = 41}, _eToIdx = VertexId {_vidInt = 24}}
new distTo: 31.72972972972973, old distTo Infinity for IdxEdge {eMeta = 31.72972972972973, _eFrom = "3\175752qv\USwc\6924\72121\992029\1072781\99085\1085011t9\STX\1077127\1075153Y\1094458\66624o;\96187\r\FS-n@\nzG\DEL\ESC\135614\&8S", _eTo = "i\DC18;;W\171033uBS\1077794VK\138735~>_n$\1016917Jbk\DC2\\{|\STX\1111390", _eFromIdx = VertexId {_vidInt = 17}, _eToIdx = VertexId {_vidInt = 31}}
new distTo: 42.0, old distTo Infinity for IdxEdge {eMeta = 42.0, _eFrom = "\SI\150160\GS\STX\29195c\DC4`\24044,\ETBJ&[;DM1\ESC*\37183\59721;\30910\STXY\fuLj\14234rt\1094712\tc\62713\&7N\t.Kd<-1\1043501Fn", _eTo = "\59368\FSNx\vK\FS\761\987318\184744F\STX\ESC\DC3\RSOW7\1010068\96526\b,wtufT\57973", _eFromIdx = VertexId {_vidInt = 5}, _eToIdx = VertexId {_vidInt = 37}}
new distTo: 29.0, old distTo Infinity for IdxEdge {eMeta = 29.0, _eFrom = "Q\ETX\FS\DEL<\DC38FWK\9496=\CAN\994436)\SYN\f_B\137633\FS\1107859$\37757Rd,\\69&\EM", _eTo = "3~=n\DC4+K\ETBK7\1035437\33429\1019306D:)T0\987443?H\SO\\\164330\DEL0Qk{\1000227R\1039402\SUBY", _eFromIdx = VertexId {_vidInt = 21}, _eToIdx = VertexId {_vidInt = 16}}
new distTo: 21.678571428571427, old distTo Infinity for IdxEdge {eMeta = 21.678571428571427, _eFrom = "cA8\FSvY{G\GSIC4G=\ENQs\994057n\50237QUIdijT\832[72](https://github.com/runeksvendsen/bellman-ford/actions/runs/6182991083/job/16783808837#step:9:73)\DEL\SOH]2\50735#l6!?\111150", _eTo = "\n@l\169580gl9\63647\CANn!\DLE\r\NULwhX\175293Y9 \SO\4698\69383\&3RS\1016403t\1066628L\15537U\v47\v\28100\ETX\158902\FSQ", _eFromIdx = VertexId {_vidInt = 28}, _eToIdx = VertexId {_vidInt = 4}}
new distTo: 16.8, old distTo Infinity for IdxEdge {eMeta = 16.8, _eFrom = "=d7oh\92566\ETBt\DC3k\992320\ACKN*[\1003745r\38120y\NAKIty\ACKY\SO", _eTo = "eTme t\rpR[x\NAK\USD", _eFromIdx = VertexId {_vidInt = 18}, _eToIdx = VertexId {_vidInt = 29}}
new distTo: 0.5, old distTo 1.0 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 0.25, old distTo 0.5 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 0.125, old distTo 0.25 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 6.25e-2, old distTo 0.125 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 3.125e-2, old distTo 6.25e-2 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.5625e-2, old distTo 3.125e-2 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 7.8125e-3, old distTo 1.5625e-2 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 3.90625e-3, old distTo 7.8125e-3 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.953125e-3, old distTo 3.90625e-3 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 9.765625e-4, old distTo 1.953125e-3 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 4.8828125e-4, old distTo 9.765625e-4 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 2.44140625e-4, old distTo 4.8828125e-4 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.220703125e-4, old distTo 2.44140625e-4 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 6.103515625e-5, old distTo 1.220703125e-4 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 3.0517578125e-5, old distTo 6.103515625e-5 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.52587890625e-5, old distTo 3.0517578125e-5 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 7.62939453125e-6, old distTo 1.52587890625e-5 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 3.814697265625e-6, old distTo 7.62939453125e-6 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.9073486328125e-6, old distTo 3.814697265625e-6 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 9.5367431640625e-7, old distTo 1.9073486328125e-6 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 4.76837158203125e-7, old distTo 9.5367431640625e-7 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 2.384185791015625e-7, old distTo 4.76837158203125e-7 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.1920928955078125e-7, old distTo 2.384185791015625e-7 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 5.960464477539063e-8, old distTo 1.1920928955078125e-7 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 2.9802322387695313e-8, old distTo 5.960464477539063e-8 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.4901161193847656e-8, old distTo 2.9802322387695313e-8 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 7.450580596923828e-9, old distTo 1.4901161193847656e-8 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 3.725290298461914e-9, old distTo 7.450580596923828e-9 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.862645149230957e-9, old distTo 3.725290298461914e-9 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 9.313225746154785e-10, old distTo 1.862645149230957e-9 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 4.656612873077393e-10, old distTo 9.313225746154785e-10 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 2.3283064365386963e-10, old distTo 4.656612873077393e-10 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.1641532182693481e-10, old distTo 2.3283064365386963e-10 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 5.820766091346741e-11, old distTo 1.1641532182693481e-10 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 2.9103830456733704e-11, old distTo 5.820766091346741e-11 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.4551915228366852e-11, old distTo 2.9103830456733704e-11 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 7.275957614183426e-12, old distTo 1.4551915228366852e-11 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 3.637978807091713e-12, old distTo 7.275957614183426e-12 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.8189894035458565e-12, old distTo 3.637978807091713e-12 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 9.094947017729282e-13, old distTo 1.8189894035458565e-12 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 4.547473508864641e-13, old distTo 9.094947017729282e-13 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 2.2737367544323206e-13, old distTo 4.547473508864641e-13 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.1368683772161603e-13, old distTo 2.2737367544323206e-13 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 5.684341886080802e-14, old distTo 1.1368683772161603e-13 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 2.842170943040401e-14, old distTo 5.684341886080802e-14 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
new distTo: 1.4210854715202004e-14, old distTo 2.842170943040401e-14 for IdxEdge {eMeta = 0.5, _eFrom = "", _eTo = "", _eFromIdx = VertexId {_vidInt = 0}, _eToIdx = VertexId {_vidInt = 0}}
bellman-ford-test: distTo source /= zero: 1.4210854715202004e-14
CallStack (from HasCallStack):
  error, called at src/Data/Graph/BellmanFord.hs:319:13 in bellman-ford-0.1.0.0-inplace:Data.Graph.BellmanFord

@runeksvendsen
Copy link
Owner Author

Looks like there's a bug in the QuickCheck seed/generation logic. Passing --quickcheck-replay=130492 seemingly doesn't reproduce the given input data, since manually running it on the generated list of edges reproduces the bug.

Not so fast. The use of System.Random.Shuffle.shuffleM in IO in the test suite is non-deterministic.

runeksvendsen added a commit that referenced this issue Oct 19, 2023
TODO: re-enable once #5 and #6 are fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant