diff --git a/brush-strokes/src/cusps/bench/Main.hs b/brush-strokes/src/cusps/bench/Main.hs index 17eb870..06a3a34 100644 --- a/brush-strokes/src/cusps/bench/Main.hs +++ b/brush-strokes/src/cusps/bench/Main.hs @@ -92,14 +92,15 @@ benchGroups :: [ ( String, NE.NonEmpty TestCase ) ] benchGroups = [ ( "ellipse" , NE.fromList - [ ellipseTestCase opts ("ε=" ++ show narrowAbs) + [ ellipseTestCase opts ("ε_bis=" ++ show ε_bis ++ if doBox1 then "box(1)" else "") ( 0, 1 ) pi ( defaultStartBoxes [ 0 .. 3 ] ) - | narrowAbs <- [ 5e-2, 1e-6 ] + | ε_bis <- [ 1e-6, 5e-6, 1e-5, 5e-5, 1e-4, 5e-4, 1e-4, 5e-4, 1e-3, 5e-3, 1e-2, 5e-2, 0.1, 0.2, 0.3 ] + , doBox1 <- [ False, True ] , let opts = RootIsolationOptions { rootIsolationAlgorithms = - defaultRootIsolationAlgorithms minWidth narrowAbs + defaultRootIsolationAlgorithms minWidth ε_bis doBox1 } ] ) diff --git a/brush-strokes/src/lib/Math/Root/Isolation.hs b/brush-strokes/src/lib/Math/Root/Isolation.hs index 2decabc..e568a39 100644 --- a/brush-strokes/src/lib/Math/Root/Isolation.hs +++ b/brush-strokes/src/lib/Math/Root/Isolation.hs @@ -102,7 +102,7 @@ newtype RootIsolationOptions n d defaultRootIsolationOptions :: BoxCt n d => RootIsolationOptions n d defaultRootIsolationOptions = RootIsolationOptions - { rootIsolationAlgorithms = defaultRootIsolationAlgorithms minWidth ε_eq + { rootIsolationAlgorithms = defaultRootIsolationAlgorithms minWidth ε_eq True } where minWidth = 1e-5 @@ -114,10 +114,11 @@ defaultRootIsolationAlgorithms . BoxCt n d => Double -- ^ minimum width of boxes (don't bisect further) -> Double -- ^ threshold for progress + -> Bool -- ^ do box1 -> BoxHistory n -> Box n -> Either String ( NE.NonEmpty ( RootIsolationAlgorithmWithOptions n d ) ) -defaultRootIsolationAlgorithms minWidth ε_eq history box = +defaultRootIsolationAlgorithms minWidth ε_eq doBox1 history box = case history of lastRoundBoxes : _ -- If, in the last round of strategies, we didn't try bisection... @@ -133,7 +134,8 @@ defaultRootIsolationAlgorithms minWidth ε_eq history box = -- Otherwise, do a normal round. -- Currently: we try an interval Gauss–Seidel step followed by box(1)-consistency. _ -> Right $ AlgoWithOptions @GaussSeidel _gsOptions - NE.:| [ AlgoWithOptions @Box1 _box1Options | not verySmall ] + NE.:| [ AlgoWithOptions @Box1 _box1Options + | doBox1 && not verySmall ] where verySmall = and $ ( \ cd -> width cd <= minWidth ) <$> coordinates box