@woosh/meep-engine 2.138.20 → 2.139.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/collection/PairUint32Map.d.ts +100 -0
- package/src/core/collection/PairUint32Map.d.ts.map +1 -0
- package/src/core/collection/PairUint32Map.js +321 -0
- package/src/core/collection/Uint32Map.d.ts +119 -0
- package/src/core/collection/Uint32Map.d.ts.map +1 -0
- package/src/core/collection/Uint32Map.js +345 -0
- package/src/core/collection/array/array_shuffle.d.ts +10 -3
- package/src/core/collection/array/array_shuffle.d.ts.map +1 -1
- package/src/core/collection/array/array_shuffle.js +27 -22
- package/src/core/collection/heap/FibonacciHeap.d.ts +195 -0
- package/src/core/collection/heap/FibonacciHeap.d.ts.map +1 -0
- package/src/core/collection/heap/FibonacciHeap.js +586 -0
- package/src/core/collection/heap/Uint32Heap.js +1 -1
- package/src/core/collection/heap/Uint32Heap4.d.ts +169 -0
- package/src/core/collection/heap/Uint32Heap4.d.ts.map +1 -0
- package/src/core/collection/heap/Uint32Heap4.js +490 -0
- package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts +27 -0
- package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts.map +1 -0
- package/src/core/geom/3d/line/line3_closest_points_segment_segment.js +88 -0
- package/src/core/geom/3d/shape/BoxShape3D.d.ts +61 -0
- package/src/core/geom/3d/shape/BoxShape3D.d.ts.map +1 -0
- package/src/core/geom/3d/shape/BoxShape3D.js +158 -0
- package/src/core/geom/3d/shape/CapsuleShape3D.d.ts +11 -0
- package/src/core/geom/3d/shape/CapsuleShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/CapsuleShape3D.js +12 -0
- package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts +37 -9
- package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/UnitCubeShape3D.js +45 -98
- package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts +10 -0
- package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/UnitSphereShape3D.js +11 -0
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts +61 -0
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts.map +1 -0
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.js +148 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts +39 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.js +147 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts +15 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.js +22 -0
- package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts +2 -0
- package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.js +673 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts +26 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.js +222 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts +34 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.js +146 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts +36 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.js +232 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts +33 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.js +255 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts +68 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.js +365 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts +31 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.js +112 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts +22 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.js +55 -0
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts +32 -0
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.js +66 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts +22 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.js +49 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts +134 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +276 -3
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts +17 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.js +135 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts +14 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.js +177 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.js +20 -4
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +5 -3
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.js +9 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.js +21 -45
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.js +7 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts +8 -6
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.js +8 -6
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts +22 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.js +73 -0
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.js +51 -1
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts +10 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.js +42 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts +28 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.js +227 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts +13 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.js +108 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts +11 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.js +20 -0
- package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts +20 -0
- package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts.map +1 -0
- package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.js +38 -0
- package/src/core/graph/csr/CSRGraph.d.ts +168 -0
- package/src/core/graph/csr/CSRGraph.d.ts.map +1 -0
- package/src/core/graph/csr/CSRGraph.js +319 -0
- package/src/core/graph/metis/cluster_mesh_metis.d.ts +12 -0
- package/src/core/graph/metis/cluster_mesh_metis.d.ts.map +1 -1
- package/src/core/graph/metis/cluster_mesh_metis.js +12 -0
- package/src/core/graph/metis/metis.d.ts +19 -0
- package/src/core/graph/metis/metis.d.ts.map +1 -1
- package/src/core/graph/metis/metis.js +20 -0
- package/src/core/graph/metis/metis_cluster_bs.d.ts +11 -0
- package/src/core/graph/metis/metis_cluster_bs.d.ts.map +1 -1
- package/src/core/graph/metis/metis_cluster_bs.js +11 -0
- package/src/core/graph/metis/metis_options.d.ts +17 -2
- package/src/core/graph/metis/metis_options.d.ts.map +1 -1
- package/src/core/graph/metis/metis_options.js +17 -2
- package/src/core/graph/metis/native/MetisGraph.d.ts +144 -0
- package/src/core/graph/metis/native/MetisGraph.d.ts.map +1 -0
- package/src/core/graph/metis/native/MetisGraph.js +212 -0
- package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts +72 -0
- package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/BisectionScratch.js +101 -0
- package/src/core/graph/metis/native/bisection/bisect_graph.d.ts +37 -0
- package/src/core/graph/metis/native/bisection/bisect_graph.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/bisect_graph.js +100 -0
- package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts +15 -0
- package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/compute_2way_params.js +84 -0
- package/src/core/graph/metis/native/bisection/fm_2way.d.ts +30 -0
- package/src/core/graph/metis/native/bisection/fm_2way.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/fm_2way.js +290 -0
- package/src/core/graph/metis/native/bisection/grow_bisection.d.ts +23 -0
- package/src/core/graph/metis/native/bisection/grow_bisection.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/grow_bisection.js +137 -0
- package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts +28 -0
- package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/split_graph_two_way.js +119 -0
- package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts +20 -0
- package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts.map +1 -0
- package/src/core/graph/metis/native/coarsen/coarsen_graph.js +94 -0
- package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts +24 -0
- package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts.map +1 -0
- package/src/core/graph/metis/native/coarsen/create_coarse_graph.js +158 -0
- package/src/core/graph/metis/native/coarsen/match_shem.d.ts +41 -0
- package/src/core/graph/metis/native/coarsen/match_shem.d.ts.map +1 -0
- package/src/core/graph/metis/native/coarsen/match_shem.js +175 -0
- package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts +24 -0
- package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts.map +1 -0
- package/src/core/graph/metis/native/initial/initial_kway_bfs.js +122 -0
- package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts +29 -0
- package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts.map +1 -0
- package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.js +170 -0
- package/src/core/graph/metis/native/metis_partition_kway.d.ts +41 -0
- package/src/core/graph/metis/native/metis_partition_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/metis_partition_kway.js +126 -0
- package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts +62 -0
- package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.js +261 -0
- package/src/core/graph/metis/native/refine/RefinementScratch.d.ts +45 -0
- package/src/core/graph/metis/native/refine/RefinementScratch.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/RefinementScratch.js +53 -0
- package/src/core/graph/metis/native/refine/compute_kway_params.d.ts +18 -0
- package/src/core/graph/metis/native/refine/compute_kway_params.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/compute_kway_params.js +138 -0
- package/src/core/graph/metis/native/refine/fm_kway.d.ts +63 -0
- package/src/core/graph/metis/native/refine/fm_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/fm_kway.js +462 -0
- package/src/core/graph/metis/native/refine/project_kway.d.ts +22 -0
- package/src/core/graph/metis/native/refine/project_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/project_kway.js +43 -0
- package/src/core/graph/metis/native/refine/refine_kway.d.ts +34 -0
- package/src/core/graph/metis/native/refine/refine_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/refine_kway.js +43 -0
- package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts +2 -2
- package/src/core/math/linalg/eigen/matrix_householder_in_place.js +2 -2
- package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +6 -4
- package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -1
- package/src/core/math/linalg/eigen/matrix_qr_in_place.js +69 -23
- package/src/engine/EngineHarness.d.ts +3 -1
- package/src/engine/EngineHarness.d.ts.map +1 -1
- package/src/engine/EngineHarness.js +3 -0
- package/src/engine/control/first-person/DESIGN.md +30 -6
- package/src/engine/control/first-person/DESIGN_EXTENSIONS.md +563 -0
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +102 -9
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerController.js +38 -3
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +533 -4
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +315 -6
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +220 -22
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +858 -241
- package/src/engine/control/first-person/TODO.md +127 -0
- package/src/engine/control/first-person/abilities/Ability.d.ts +101 -0
- package/src/engine/control/first-person/abilities/Ability.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/Ability.js +119 -0
- package/src/engine/control/first-person/abilities/AbilitySet.d.ts +86 -0
- package/src/engine/control/first-person/abilities/AbilitySet.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/AbilitySet.js +185 -0
- package/src/engine/control/first-person/abilities/LedgeGrab.d.ts +62 -0
- package/src/engine/control/first-person/abilities/LedgeGrab.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/LedgeGrab.js +199 -0
- package/src/engine/control/first-person/abilities/Mantle.d.ts +45 -0
- package/src/engine/control/first-person/abilities/Mantle.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/Mantle.js +188 -0
- package/src/engine/control/first-person/abilities/Slide.d.ts +33 -0
- package/src/engine/control/first-person/abilities/Slide.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/Slide.js +158 -0
- package/src/engine/control/first-person/abilities/WallJump.d.ts +45 -0
- package/src/engine/control/first-person/abilities/WallJump.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/WallJump.js +131 -0
- package/src/engine/control/first-person/abilities/WallRun.d.ts +44 -0
- package/src/engine/control/first-person/abilities/WallRun.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/WallRun.js +180 -0
- package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts +49 -0
- package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts.map +1 -0
- package/src/engine/control/first-person/composer/EyeOffsetStack.js +60 -0
- package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts +100 -0
- package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.js +133 -0
- package/src/engine/control/first-person/mastery/DecisionPoint.d.ts +10 -0
- package/src/engine/control/first-person/mastery/DecisionPoint.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/DecisionPoint.js +30 -0
- package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts +61 -0
- package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.js +109 -0
- package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts +40 -0
- package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/MasteryEvaluator.js +45 -0
- package/src/engine/control/first-person/mastery/MasteryScore.d.ts +68 -0
- package/src/engine/control/first-person/mastery/MasteryScore.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/MasteryScore.js +100 -0
- package/src/engine/control/first-person/mastery/MasterySet.d.ts +60 -0
- package/src/engine/control/first-person/mastery/MasterySet.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/MasterySet.js +86 -0
- package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts +58 -0
- package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.js +83 -0
- package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts +69 -0
- package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.js +109 -0
- package/src/engine/control/first-person/math/Spring.d.ts +56 -0
- package/src/engine/control/first-person/math/Spring.d.ts.map +1 -0
- package/src/engine/control/first-person/math/Spring.js +71 -0
- package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts +26 -0
- package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts.map +1 -0
- package/src/engine/control/first-person/math/computeLRCBreathRate.js +41 -0
- package/src/engine/control/first-person/math/computeMassRatios.d.ts +35 -0
- package/src/engine/control/first-person/math/computeMassRatios.d.ts.map +1 -0
- package/src/engine/control/first-person/math/computeMassRatios.js +44 -0
- package/src/engine/control/first-person/pose/FirstPersonPose.d.ts +31 -1
- package/src/engine/control/first-person/pose/FirstPersonPose.d.ts.map +1 -1
- package/src/engine/control/first-person/pose/FirstPersonPose.js +49 -3
- package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts +7 -0
- package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts.map +1 -0
- package/src/engine/control/first-person/pose/FirstPersonPosture.js +27 -0
- package/src/engine/control/first-person/prototype_first_person_controller.js +550 -119
- package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts +58 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts.map +1 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensors.js +77 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts +80 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts.map +1 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.js +196 -0
- package/src/engine/control/first-person/test/buildTestPlayer.d.ts +20 -0
- package/src/engine/control/first-person/test/buildTestPlayer.d.ts.map +1 -0
- package/src/engine/control/first-person/test/buildTestPlayer.js +28 -0
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -2
- package/src/engine/graphics/ecs/light/Light.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/Light.js +27 -0
- package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
- package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +0 -2
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +0 -2
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
- package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
- package/src/engine/navigation/grid/find_path_on_grid_astar.js +11 -2
- package/src/engine/navigation/mesh/bt_mesh_face_find_path.d.ts.map +1 -1
- package/src/engine/navigation/mesh/bt_mesh_face_find_path.js +11 -1
- package/src/engine/physics/PLAN.md +236 -0
- package/src/engine/physics/body/BodyStorage.d.ts +187 -0
- package/src/engine/physics/body/BodyStorage.d.ts.map +1 -0
- package/src/engine/physics/body/BodyStorage.js +427 -0
- package/src/engine/physics/broadphase/PairList.d.ts +62 -0
- package/src/engine/physics/broadphase/PairList.d.ts.map +1 -0
- package/src/engine/physics/broadphase/PairList.js +97 -0
- package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts +30 -0
- package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts.map +1 -0
- package/src/engine/physics/broadphase/aabb_transform_oriented.js +93 -0
- package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts +16 -0
- package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts.map +1 -0
- package/src/engine/physics/broadphase/compute_fat_world_aabb.js +61 -0
- package/src/engine/physics/broadphase/generate_pairs.d.ts +38 -0
- package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -0
- package/src/engine/physics/broadphase/generate_pairs.js +101 -0
- package/src/engine/physics/contact/ManifoldStore.d.ts +226 -0
- package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -0
- package/src/engine/physics/contact/ManifoldStore.js +499 -0
- package/src/engine/physics/ecs/BodyKind.d.ts +23 -0
- package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -0
- package/src/engine/physics/ecs/BodyKind.js +24 -0
- package/src/engine/physics/ecs/Collider.d.ts +98 -0
- package/src/engine/physics/ecs/Collider.d.ts.map +1 -0
- package/src/engine/physics/ecs/Collider.js +136 -0
- package/src/engine/physics/ecs/ColliderFlags.d.ts +14 -0
- package/src/engine/physics/ecs/ColliderFlags.d.ts.map +1 -0
- package/src/engine/physics/ecs/ColliderFlags.js +15 -0
- package/src/engine/physics/ecs/ColliderObserverSystem.d.ts +58 -0
- package/src/engine/physics/ecs/ColliderObserverSystem.d.ts.map +1 -0
- package/src/engine/physics/ecs/ColliderObserverSystem.js +103 -0
- package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts +25 -0
- package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts.map +1 -0
- package/src/engine/physics/ecs/ColliderSerializationAdapter.js +37 -0
- package/src/engine/physics/ecs/PhysicsEvents.d.ts +15 -0
- package/src/engine/physics/ecs/PhysicsEvents.d.ts.map +1 -0
- package/src/engine/physics/ecs/PhysicsEvents.js +16 -0
- package/src/engine/physics/ecs/PhysicsSystem.d.ts +520 -0
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -0
- package/src/engine/physics/ecs/PhysicsSystem.js +1159 -0
- package/src/engine/physics/ecs/RigidBody.d.ts +197 -0
- package/src/engine/physics/ecs/RigidBody.d.ts.map +1 -0
- package/src/engine/physics/ecs/RigidBody.js +240 -0
- package/src/engine/physics/ecs/RigidBodyFlags.d.ts +21 -0
- package/src/engine/physics/ecs/RigidBodyFlags.d.ts.map +1 -0
- package/src/engine/physics/ecs/RigidBodyFlags.js +22 -0
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts +28 -0
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -0
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.js +81 -0
- package/src/engine/physics/ecs/SleepState.d.ts +11 -0
- package/src/engine/physics/ecs/SleepState.d.ts.map +1 -0
- package/src/engine/physics/ecs/SleepState.js +12 -0
- package/src/engine/physics/events/ContactEventBuffer.d.ts +46 -0
- package/src/engine/physics/events/ContactEventBuffer.d.ts.map +1 -0
- package/src/engine/physics/events/ContactEventBuffer.js +83 -0
- package/src/engine/physics/events/diff_manifolds.d.ts +25 -0
- package/src/engine/physics/events/diff_manifolds.d.ts.map +1 -0
- package/src/engine/physics/events/diff_manifolds.js +50 -0
- package/src/engine/physics/fluid/FluidField.d.ts +294 -16
- package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
- package/src/engine/physics/fluid/FluidField.js +510 -66
- package/src/engine/physics/fluid/FluidSimulator.d.ts +188 -5
- package/src/engine/physics/fluid/FluidSimulator.d.ts.map +1 -1
- package/src/engine/physics/fluid/FluidSimulator.js +455 -95
- package/src/engine/physics/fluid/SliceVisualiser.d.ts +29 -6
- package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
- package/src/engine/physics/fluid/SliceVisualiser.js +190 -165
- package/src/engine/physics/fluid/ecs/FluidComponent.d.ts +154 -0
- package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -0
- package/src/engine/physics/fluid/ecs/FluidComponent.js +238 -0
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts +45 -0
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts.map +1 -0
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.js +89 -0
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +107 -0
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts.map +1 -0
- package/src/engine/physics/fluid/ecs/FluidSystem.js +278 -0
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +62 -1
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +81 -6
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts +17 -4
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +105 -12
- package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts +43 -0
- package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -0
- package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +210 -0
- package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts +62 -1
- package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/WakeFluidEffector.js +302 -8
- package/src/engine/physics/fluid/prototype.js +102 -91
- package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts +33 -0
- package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/optimal_sor_omega.js +41 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts +20 -5
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts.map +1 -1
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.js +60 -38
- package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts +25 -4
- package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts.map +1 -1
- package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.js +93 -73
- package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts +23 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.js +60 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts +23 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.js +68 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts +30 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.js +66 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts +26 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.js +113 -0
- package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts +30 -0
- package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.js +107 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts +49 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.js +126 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts +93 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.js +424 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts +20 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.js +83 -0
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts +26 -0
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.js +70 -0
- package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -1
- package/src/engine/physics/gjk/expanding_polytope_algorithm.js +8 -10
- package/src/engine/physics/inertia/world_inverse_inertia.d.ts +29 -0
- package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -0
- package/src/engine/physics/inertia/world_inverse_inertia.js +79 -0
- package/src/engine/physics/integration/integrate_position.d.ts +16 -0
- package/src/engine/physics/integration/integrate_position.d.ts.map +1 -0
- package/src/engine/physics/integration/integrate_position.js +48 -0
- package/src/engine/physics/integration/integrate_velocity.d.ts +25 -0
- package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -0
- package/src/engine/physics/integration/integrate_velocity.js +79 -0
- package/src/engine/physics/integration/quat_integrate.d.ts +27 -0
- package/src/engine/physics/integration/quat_integrate.d.ts.map +1 -0
- package/src/engine/physics/integration/quat_integrate.js +62 -0
- package/src/engine/physics/island/IslandBuilder.d.ts +167 -0
- package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -0
- package/src/engine/physics/island/IslandBuilder.js +411 -0
- package/src/engine/physics/island/union_find.d.ts +51 -0
- package/src/engine/physics/island/union_find.d.ts.map +1 -0
- package/src/engine/physics/island/union_find.js +76 -0
- package/src/engine/physics/narrowphase/PosedShape.d.ts +59 -0
- package/src/engine/physics/narrowphase/PosedShape.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/PosedShape.js +110 -0
- package/src/engine/physics/narrowphase/box_box_manifold.d.ts +32 -0
- package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/box_box_manifold.js +543 -0
- package/src/engine/physics/narrowphase/capsule_contacts.d.ts +122 -0
- package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/capsule_contacts.js +508 -0
- package/src/engine/physics/narrowphase/narrowphase_step.d.ts +11 -0
- package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/narrowphase_step.js +382 -0
- package/src/engine/physics/narrowphase/sphere_box_contact.d.ts +38 -0
- package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/sphere_box_contact.js +130 -0
- package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts +26 -0
- package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/sphere_sphere_contact.js +51 -0
- package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts +83 -0
- package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts.map +1 -0
- package/src/engine/physics/queries/PhysicsSurfacePoint.js +100 -0
- package/src/engine/physics/queries/raycast.d.ts +20 -0
- package/src/engine/physics/queries/raycast.d.ts.map +1 -0
- package/src/engine/physics/queries/raycast.js +249 -0
- package/src/engine/physics/solver/friction_cone.d.ts +16 -0
- package/src/engine/physics/solver/friction_cone.d.ts.map +1 -0
- package/src/engine/physics/solver/friction_cone.js +37 -0
- package/src/engine/physics/solver/solve_contacts.d.ts +36 -0
- package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -0
- package/src/engine/physics/solver/solve_contacts.js +598 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts +0 -34
- package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts.map +0 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.js +0 -66
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts +0 -2
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts.map +0 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.js +0 -54
- package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts +0 -2
- package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts.map +0 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.js +0 -26
- package/src/engine/ecs/components/Motion.d.ts +0 -21
- package/src/engine/ecs/components/Motion.d.ts.map +0 -1
- package/src/engine/ecs/components/Motion.js +0 -27
- package/src/engine/ecs/components/MotionSerializationAdapter.d.ts +0 -20
- package/src/engine/ecs/components/MotionSerializationAdapter.d.ts.map +0 -1
- package/src/engine/ecs/components/MotionSerializationAdapter.js +0 -26
- package/src/engine/ecs/systems/MotionSystem.d.ts +0 -9
- package/src/engine/ecs/systems/MotionSystem.d.ts.map +0 -1
- package/src/engine/ecs/systems/MotionSystem.js +0 -29
- package/src/engine/physics/fluid/Fluid.d.ts +0 -26
- package/src/engine/physics/fluid/Fluid.d.ts.map +0 -1
- package/src/engine/physics/fluid/Fluid.js +0 -221
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts +0 -7
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts.map +0 -1
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.js +0 -8
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { assert } from "../../../../assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Max-heap of (uint32 id, float32 score) entries with an external id→slot index
|
|
5
|
+
* for O(log n) `update` and `remove` by id (rather than O(n) linear scan).
|
|
6
|
+
*
|
|
7
|
+
* Used by the k-way Fiduccia–Mattheyses refinement, where each vertex move
|
|
8
|
+
* requires updating the gain entries of every neighbour's boundary vertex.
|
|
9
|
+
* Without the index, that's O(degree · |boundary|) per move; with it,
|
|
10
|
+
* O(degree · log |boundary|).
|
|
11
|
+
*
|
|
12
|
+
* Behaviour notes:
|
|
13
|
+
* - This is a MAX-heap (`pop_max` returns the entry with the largest score).
|
|
14
|
+
* - Ids must be in `[0, id_capacity)`; the index table is sized at construction.
|
|
15
|
+
* - Duplicate ids are not allowed. Calling `insert` with an existing id throws.
|
|
16
|
+
*
|
|
17
|
+
* Storage layout mirrors meep's `Uint32Heap`: each heap slot is 8 bytes packed
|
|
18
|
+
* as `(float32 score, uint32 id)`. The id→slot map is a separate
|
|
19
|
+
* `Uint32Array(id_capacity)` where `SLOT_NOT_PRESENT` means "not in heap".
|
|
20
|
+
*
|
|
21
|
+
* We measured a JS `Map<number, number>` as the index instead — it removes the
|
|
22
|
+
* eager `id_capacity` allocation but added 35-60% to FM-dominated benchmarks
|
|
23
|
+
* because `Map.get/set/delete` per `__swap_slots` call (O(log n) per pop) is
|
|
24
|
+
* meaningfully slower than typed-array indexing. Kept the typed-array form.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const SLOT_NOT_PRESENT = 0xFFFFFFFF;
|
|
28
|
+
const BYTES_PER_SLOT = 8;
|
|
29
|
+
|
|
30
|
+
export class IndexedFloatMaxHeap {
|
|
31
|
+
/**
|
|
32
|
+
* @param {number} id_capacity ids must be in [0, id_capacity)
|
|
33
|
+
* @param {number} [initial_slot_capacity] initial heap slot count (grows on demand)
|
|
34
|
+
*/
|
|
35
|
+
constructor(
|
|
36
|
+
id_capacity,
|
|
37
|
+
initial_slot_capacity = Math.min(64, id_capacity)
|
|
38
|
+
) {
|
|
39
|
+
assert.isNonNegativeInteger(id_capacity, 'id_capacity');
|
|
40
|
+
assert.isNonNegativeInteger(initial_slot_capacity, 'initial_slot_capacity');
|
|
41
|
+
|
|
42
|
+
this.__slot_capacity = initial_slot_capacity;
|
|
43
|
+
this.__size = 0;
|
|
44
|
+
|
|
45
|
+
this.__data_buffer = new ArrayBuffer(initial_slot_capacity * BYTES_PER_SLOT);
|
|
46
|
+
this.__data_uint32 = new Uint32Array(this.__data_buffer);
|
|
47
|
+
this.__data_float32 = new Float32Array(this.__data_buffer);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Maps id → slot index in [0, size), or SLOT_NOT_PRESENT.
|
|
51
|
+
* @type {Uint32Array}
|
|
52
|
+
*/
|
|
53
|
+
this.__slot_of_id = new Uint32Array(id_capacity);
|
|
54
|
+
this.__slot_of_id.fill(SLOT_NOT_PRESENT);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get size() {
|
|
58
|
+
return this.__size;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Empty the heap. Only resets the index entries that are actually populated,
|
|
63
|
+
* so this is O(size), not O(id_capacity).
|
|
64
|
+
*/
|
|
65
|
+
clear() {
|
|
66
|
+
const data_uint32 = this.__data_uint32;
|
|
67
|
+
const size = this.__size;
|
|
68
|
+
const slot_of_id = this.__slot_of_id;
|
|
69
|
+
for (let slot = 0; slot < size; slot++) {
|
|
70
|
+
slot_of_id[data_uint32[slot * 2 + 1]] = SLOT_NOT_PRESENT;
|
|
71
|
+
}
|
|
72
|
+
this.__size = 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
contains(id) {
|
|
76
|
+
return this.__slot_of_id[id] !== SLOT_NOT_PRESENT;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Swap the entries at two slot indices, keeping the id→slot index in sync.
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
__swap_slots(slot_a, slot_b) {
|
|
84
|
+
const data_uint32 = this.__data_uint32;
|
|
85
|
+
const word_a = slot_a << 1;
|
|
86
|
+
const word_b = slot_b << 1;
|
|
87
|
+
|
|
88
|
+
const score_a = data_uint32[word_a];
|
|
89
|
+
const id_a = data_uint32[word_a + 1];
|
|
90
|
+
const score_b = data_uint32[word_b];
|
|
91
|
+
const id_b = data_uint32[word_b + 1];
|
|
92
|
+
|
|
93
|
+
data_uint32[word_a] = score_b;
|
|
94
|
+
data_uint32[word_a + 1] = id_b;
|
|
95
|
+
data_uint32[word_b] = score_a;
|
|
96
|
+
data_uint32[word_b + 1] = id_a;
|
|
97
|
+
|
|
98
|
+
const slot_of_id = this.__slot_of_id;
|
|
99
|
+
slot_of_id[id_a] = slot_b;
|
|
100
|
+
slot_of_id[id_b] = slot_a;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Restore heap order downward starting at `start_slot`. Used when an entry's
|
|
105
|
+
* score has just decreased.
|
|
106
|
+
* @private
|
|
107
|
+
*/
|
|
108
|
+
__sift_down(start_slot) {
|
|
109
|
+
const size = this.__size;
|
|
110
|
+
const data_float32 = this.__data_float32;
|
|
111
|
+
let slot = start_slot;
|
|
112
|
+
|
|
113
|
+
for (;;) {
|
|
114
|
+
const left_child = (slot << 1) + 1;
|
|
115
|
+
const right_child = left_child + 1;
|
|
116
|
+
let largest_slot = slot;
|
|
117
|
+
|
|
118
|
+
if (left_child < size && data_float32[left_child * 2] > data_float32[largest_slot * 2]) {
|
|
119
|
+
largest_slot = left_child;
|
|
120
|
+
}
|
|
121
|
+
if (right_child < size && data_float32[right_child * 2] > data_float32[largest_slot * 2]) {
|
|
122
|
+
largest_slot = right_child;
|
|
123
|
+
}
|
|
124
|
+
if (largest_slot === slot) {
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
this.__swap_slots(slot, largest_slot);
|
|
128
|
+
slot = largest_slot;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Restore heap order upward starting at `start_slot`. Used when an entry's
|
|
134
|
+
* score has just increased.
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
__sift_up(start_slot) {
|
|
138
|
+
const data_float32 = this.__data_float32;
|
|
139
|
+
let slot = start_slot;
|
|
140
|
+
|
|
141
|
+
while (slot > 0) {
|
|
142
|
+
const parent_slot = (slot - 1) >> 1;
|
|
143
|
+
if (data_float32[parent_slot * 2] >= data_float32[slot * 2]) {
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
this.__swap_slots(parent_slot, slot);
|
|
147
|
+
slot = parent_slot;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
__grow_capacity() {
|
|
152
|
+
const old_capacity = this.__slot_capacity;
|
|
153
|
+
const new_capacity = Math.max(old_capacity + 16, Math.ceil(old_capacity * 1.5));
|
|
154
|
+
const new_buffer = new ArrayBuffer(new_capacity * BYTES_PER_SLOT);
|
|
155
|
+
const new_uint32 = new Uint32Array(new_buffer);
|
|
156
|
+
new_uint32.set(this.__data_uint32);
|
|
157
|
+
this.__data_buffer = new_buffer;
|
|
158
|
+
this.__data_uint32 = new_uint32;
|
|
159
|
+
this.__data_float32 = new Float32Array(new_buffer);
|
|
160
|
+
this.__slot_capacity = new_capacity;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @param {number} id
|
|
165
|
+
* @param {number} score
|
|
166
|
+
*/
|
|
167
|
+
insert(id, score) {
|
|
168
|
+
if (this.__slot_of_id[id] !== SLOT_NOT_PRESENT) {
|
|
169
|
+
throw new Error(`id ${id} already in heap`);
|
|
170
|
+
}
|
|
171
|
+
if (this.__size >= this.__slot_capacity) {
|
|
172
|
+
this.__grow_capacity();
|
|
173
|
+
}
|
|
174
|
+
const new_slot = this.__size;
|
|
175
|
+
this.__data_float32[new_slot * 2] = score;
|
|
176
|
+
this.__data_uint32[new_slot * 2 + 1] = id;
|
|
177
|
+
this.__slot_of_id[id] = new_slot;
|
|
178
|
+
this.__size = new_slot + 1;
|
|
179
|
+
this.__sift_up(new_slot);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @returns {number} id of the entry with the largest score, or -1 if empty
|
|
184
|
+
*/
|
|
185
|
+
pop_max() {
|
|
186
|
+
if (this.__size === 0) {
|
|
187
|
+
return -1;
|
|
188
|
+
}
|
|
189
|
+
const data_uint32 = this.__data_uint32;
|
|
190
|
+
const top_id = data_uint32[1];
|
|
191
|
+
const new_size = this.__size - 1;
|
|
192
|
+
this.__size = new_size;
|
|
193
|
+
this.__slot_of_id[top_id] = SLOT_NOT_PRESENT;
|
|
194
|
+
|
|
195
|
+
if (new_size > 0) {
|
|
196
|
+
const last_slot_word = new_size << 1;
|
|
197
|
+
const moved_score = this.__data_float32[last_slot_word];
|
|
198
|
+
const moved_id = data_uint32[last_slot_word + 1];
|
|
199
|
+
this.__data_float32[0] = moved_score;
|
|
200
|
+
data_uint32[1] = moved_id;
|
|
201
|
+
this.__slot_of_id[moved_id] = 0;
|
|
202
|
+
this.__sift_down(0);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return top_id;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @param {number} id
|
|
210
|
+
* @param {number} new_score
|
|
211
|
+
*/
|
|
212
|
+
update(id, new_score) {
|
|
213
|
+
const slot = this.__slot_of_id[id];
|
|
214
|
+
if (slot === SLOT_NOT_PRESENT) {
|
|
215
|
+
throw new Error(`id ${id} not in heap`);
|
|
216
|
+
}
|
|
217
|
+
const slot_score_address = slot * 2;
|
|
218
|
+
const old_score = this.__data_float32[slot_score_address];
|
|
219
|
+
this.__data_float32[slot_score_address] = new_score;
|
|
220
|
+
if (new_score > old_score) {
|
|
221
|
+
this.__sift_up(slot);
|
|
222
|
+
} else if (new_score < old_score) {
|
|
223
|
+
this.__sift_down(slot);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @param {number} id
|
|
229
|
+
* @returns {boolean} true if the id was present and removed
|
|
230
|
+
*/
|
|
231
|
+
remove(id) {
|
|
232
|
+
const slot = this.__slot_of_id[id];
|
|
233
|
+
if (slot === SLOT_NOT_PRESENT) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
this.__slot_of_id[id] = SLOT_NOT_PRESENT;
|
|
237
|
+
const new_size = this.__size - 1;
|
|
238
|
+
this.__size = new_size;
|
|
239
|
+
|
|
240
|
+
if (slot === new_size) {
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Move the last entry into the vacated slot, then restore heap order.
|
|
245
|
+
const last_slot_word = new_size << 1;
|
|
246
|
+
const moved_score = this.__data_float32[last_slot_word];
|
|
247
|
+
const moved_id = this.__data_uint32[last_slot_word + 1];
|
|
248
|
+
const slot_word = slot * 2;
|
|
249
|
+
const old_slot_score = this.__data_float32[slot_word];
|
|
250
|
+
this.__data_float32[slot_word] = moved_score;
|
|
251
|
+
this.__data_uint32[slot_word + 1] = moved_id;
|
|
252
|
+
this.__slot_of_id[moved_id] = slot;
|
|
253
|
+
|
|
254
|
+
if (moved_score > old_slot_score) {
|
|
255
|
+
this.__sift_up(slot);
|
|
256
|
+
} else {
|
|
257
|
+
this.__sift_down(slot);
|
|
258
|
+
}
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-allocated scratch reused across every `fm_kway` call during the
|
|
3
|
+
* uncoarsening / refinement phase.
|
|
4
|
+
*
|
|
5
|
+
* `refine_kway` invokes `fm_kway` once per multilevel level (typically 3-15
|
|
6
|
+
* times per partition run). Each call previously allocated:
|
|
7
|
+
* - one `IndexedFloatMaxHeap` (with a `Uint32Array(vertex_count)` index table —
|
|
8
|
+
* 4 MB at 1M vertices)
|
|
9
|
+
* - three vertex-sized typed arrays for queue status and touched bookkeeping
|
|
10
|
+
* - two partition-count-sized arrays for the weight bounds
|
|
11
|
+
*
|
|
12
|
+
* Sharing one set of arrays scoped to the original (finest) graph's vertex
|
|
13
|
+
* count means the heap's index table is sized once and the rest of the state
|
|
14
|
+
* is reused across all levels.
|
|
15
|
+
*
|
|
16
|
+
* The arrays' invariants are preserved across calls without explicit clears:
|
|
17
|
+
*
|
|
18
|
+
* - `queue_status` starts all-0 (NOT_PRESENT). Each fm_kway pass resets
|
|
19
|
+
* touched entries back to 0 in its cleanup, so subsequent calls see a
|
|
20
|
+
* clean slate without needing a fresh `.fill(0)`.
|
|
21
|
+
*
|
|
22
|
+
* - `touched_position_of_vertex` starts all -1. Same per-pass cleanup
|
|
23
|
+
* restores -1 for every touched entry.
|
|
24
|
+
*
|
|
25
|
+
* - The heap uses `.clear()` at the start of each pass — that's O(size),
|
|
26
|
+
* not O(capacity), and resets `__slot_of_id` only for the entries actually
|
|
27
|
+
* in the heap.
|
|
28
|
+
*/
|
|
29
|
+
export class RefinementScratch {
|
|
30
|
+
/**
|
|
31
|
+
* @param {number} max_vertex_count typically the original (finest) graph's vertex count
|
|
32
|
+
* @param {number} partition_count
|
|
33
|
+
*/
|
|
34
|
+
constructor(max_vertex_count: number, partition_count: number);
|
|
35
|
+
max_vertex_count: number;
|
|
36
|
+
partition_count: number;
|
|
37
|
+
move_queue: IndexedFloatMaxHeap;
|
|
38
|
+
queue_status: Uint8Array;
|
|
39
|
+
touched_vertices: Uint32Array;
|
|
40
|
+
touched_position_of_vertex: Int32Array;
|
|
41
|
+
partition_weight_min: Uint32Array;
|
|
42
|
+
partition_weight_max: Uint32Array;
|
|
43
|
+
}
|
|
44
|
+
import { IndexedFloatMaxHeap } from "./IndexedFloatMaxHeap.js";
|
|
45
|
+
//# sourceMappingURL=RefinementScratch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefinementScratch.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/graph/metis/native/refine/RefinementScratch.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IACI;;;OAGG;IACH,8BAHW,MAAM,mBACN,MAAM,EAkBhB;IAfG,yBAAwC;IACxC,wBAAsC;IAEtC,gCAGC;IAED,yBAAoD;IACpD,8BAAyD;IACzD,uCAAkE;IAGlE,kCAA4D;IAC5D,kCAA4D;CAEnE;oCApDmC,0BAA0B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IndexedFloatMaxHeap } from "./IndexedFloatMaxHeap.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre-allocated scratch reused across every `fm_kway` call during the
|
|
5
|
+
* uncoarsening / refinement phase.
|
|
6
|
+
*
|
|
7
|
+
* `refine_kway` invokes `fm_kway` once per multilevel level (typically 3-15
|
|
8
|
+
* times per partition run). Each call previously allocated:
|
|
9
|
+
* - one `IndexedFloatMaxHeap` (with a `Uint32Array(vertex_count)` index table —
|
|
10
|
+
* 4 MB at 1M vertices)
|
|
11
|
+
* - three vertex-sized typed arrays for queue status and touched bookkeeping
|
|
12
|
+
* - two partition-count-sized arrays for the weight bounds
|
|
13
|
+
*
|
|
14
|
+
* Sharing one set of arrays scoped to the original (finest) graph's vertex
|
|
15
|
+
* count means the heap's index table is sized once and the rest of the state
|
|
16
|
+
* is reused across all levels.
|
|
17
|
+
*
|
|
18
|
+
* The arrays' invariants are preserved across calls without explicit clears:
|
|
19
|
+
*
|
|
20
|
+
* - `queue_status` starts all-0 (NOT_PRESENT). Each fm_kway pass resets
|
|
21
|
+
* touched entries back to 0 in its cleanup, so subsequent calls see a
|
|
22
|
+
* clean slate without needing a fresh `.fill(0)`.
|
|
23
|
+
*
|
|
24
|
+
* - `touched_position_of_vertex` starts all -1. Same per-pass cleanup
|
|
25
|
+
* restores -1 for every touched entry.
|
|
26
|
+
*
|
|
27
|
+
* - The heap uses `.clear()` at the start of each pass — that's O(size),
|
|
28
|
+
* not O(capacity), and resets `__slot_of_id` only for the entries actually
|
|
29
|
+
* in the heap.
|
|
30
|
+
*/
|
|
31
|
+
export class RefinementScratch {
|
|
32
|
+
/**
|
|
33
|
+
* @param {number} max_vertex_count typically the original (finest) graph's vertex count
|
|
34
|
+
* @param {number} partition_count
|
|
35
|
+
*/
|
|
36
|
+
constructor(max_vertex_count, partition_count) {
|
|
37
|
+
this.max_vertex_count = max_vertex_count;
|
|
38
|
+
this.partition_count = partition_count;
|
|
39
|
+
|
|
40
|
+
this.move_queue = new IndexedFloatMaxHeap(
|
|
41
|
+
max_vertex_count,
|
|
42
|
+
Math.min(max_vertex_count, 1024)
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
this.queue_status = new Uint8Array(max_vertex_count);
|
|
46
|
+
this.touched_vertices = new Uint32Array(max_vertex_count);
|
|
47
|
+
this.touched_position_of_vertex = new Int32Array(max_vertex_count);
|
|
48
|
+
this.touched_position_of_vertex.fill(-1);
|
|
49
|
+
|
|
50
|
+
this.partition_weight_min = new Uint32Array(partition_count);
|
|
51
|
+
this.partition_weight_max = new Uint32Array(partition_count);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* From a freshly-assigned `vertex_partition[]`, populate the rest of the k-way
|
|
3
|
+
* refinement state: per-partition weights, per-vertex internal/external degree,
|
|
4
|
+
* the neighbour-partition list (via `neighbor_partition_pool`), the boundary
|
|
5
|
+
* list, and the total edge cut.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `ComputeKWayPartitionParams` from libmetis/kwayrefine.c, cut-objective
|
|
8
|
+
* branch only.
|
|
9
|
+
*
|
|
10
|
+
* Boundary insertion rule (refinement-type boundary): a vertex is added to the
|
|
11
|
+
* boundary when `external_degree >= internal_degree`. That captures "worth
|
|
12
|
+
* considering for a move" — vertices with no external pull aren't candidates.
|
|
13
|
+
*
|
|
14
|
+
* @param {import('../MetisGraph.js').MetisGraph} graph
|
|
15
|
+
* @param {number} partition_count
|
|
16
|
+
*/
|
|
17
|
+
export function compute_kway_params(graph: import('../MetisGraph.js').MetisGraph, partition_count: number): void;
|
|
18
|
+
//# sourceMappingURL=compute_kway_params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute_kway_params.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/graph/metis/native/refine/compute_kway_params.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,2CAHW,OAAO,kBAAkB,EAAE,UAAU,mBACrC,MAAM,QAyHhB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { assert } from "../../../../assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* From a freshly-assigned `vertex_partition[]`, populate the rest of the k-way
|
|
5
|
+
* refinement state: per-partition weights, per-vertex internal/external degree,
|
|
6
|
+
* the neighbour-partition list (via `neighbor_partition_pool`), the boundary
|
|
7
|
+
* list, and the total edge cut.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors `ComputeKWayPartitionParams` from libmetis/kwayrefine.c, cut-objective
|
|
10
|
+
* branch only.
|
|
11
|
+
*
|
|
12
|
+
* Boundary insertion rule (refinement-type boundary): a vertex is added to the
|
|
13
|
+
* boundary when `external_degree >= internal_degree`. That captures "worth
|
|
14
|
+
* considering for a move" — vertices with no external pull aren't candidates.
|
|
15
|
+
*
|
|
16
|
+
* @param {import('../MetisGraph.js').MetisGraph} graph
|
|
17
|
+
* @param {number} partition_count
|
|
18
|
+
*/
|
|
19
|
+
export function compute_kway_params(graph, partition_count) {
|
|
20
|
+
const vertex_count = graph.vertex_count;
|
|
21
|
+
const edge_addresses = graph.edge_addresses;
|
|
22
|
+
const adjacency = graph.adjacency;
|
|
23
|
+
const edge_weights = graph.edge_weights;
|
|
24
|
+
const vertex_weights = graph.vertex_weights;
|
|
25
|
+
const vertex_partition = graph.vertex_partition;
|
|
26
|
+
const partition_weights = graph.partition_weights;
|
|
27
|
+
const internal_degree = graph.internal_degree;
|
|
28
|
+
const external_degree = graph.external_degree;
|
|
29
|
+
const neighbor_partition_count = graph.neighbor_partition_count;
|
|
30
|
+
const neighbor_partition_offset = graph.neighbor_partition_offset;
|
|
31
|
+
const boundary_vertices = graph.boundary_vertices;
|
|
32
|
+
const boundary_position_of_vertex = graph.boundary_position_of_vertex;
|
|
33
|
+
const neighbor_partition_pool = graph.neighbor_partition_pool;
|
|
34
|
+
|
|
35
|
+
assert.equal(vertex_partition !== null, true, 'graph.vertex_partition must be allocated');
|
|
36
|
+
assert.equal(neighbor_partition_pool !== null, true, 'graph.neighbor_partition_pool must be allocated');
|
|
37
|
+
|
|
38
|
+
partition_weights.fill(0);
|
|
39
|
+
internal_degree.fill(0);
|
|
40
|
+
external_degree.fill(0);
|
|
41
|
+
neighbor_partition_count.fill(0);
|
|
42
|
+
neighbor_partition_offset.fill(-1);
|
|
43
|
+
boundary_position_of_vertex.fill(-1);
|
|
44
|
+
neighbor_partition_pool.clear();
|
|
45
|
+
|
|
46
|
+
// Recompute partition weights from `vertex_partition`. initial_kway_bfs
|
|
47
|
+
// already produces these, but refinement passes invalidate the count, so
|
|
48
|
+
// recompute unconditionally to keep this routine self-contained.
|
|
49
|
+
for (let v = 0; v < vertex_count; v++) {
|
|
50
|
+
partition_weights[vertex_partition[v]] += vertex_weights[v];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Scratch arrays for per-vertex neighbour-partition deduplication:
|
|
54
|
+
// `scratch_partition_position[p]` = where in `scratch_partition_id` /
|
|
55
|
+
// `scratch_partition_edge_weight` we've stored partition p for the current
|
|
56
|
+
// vertex, or -1 if p hasn't been seen yet for this vertex.
|
|
57
|
+
const scratch_partition_position = new Int32Array(partition_count);
|
|
58
|
+
scratch_partition_position.fill(-1);
|
|
59
|
+
|
|
60
|
+
// A vertex's distinct neighbour-partition count never exceeds its degree
|
|
61
|
+
// nor `partition_count`; `partition_count` is the safe upper bound on
|
|
62
|
+
// scratch size.
|
|
63
|
+
const scratch_partition_id = new Uint32Array(partition_count);
|
|
64
|
+
const scratch_partition_edge_weight = new Uint32Array(partition_count);
|
|
65
|
+
|
|
66
|
+
let boundary_count = 0;
|
|
67
|
+
let cut_doubled = 0;
|
|
68
|
+
|
|
69
|
+
const pool_data = neighbor_partition_pool.data_uint32;
|
|
70
|
+
|
|
71
|
+
for (let vertex = 0; vertex < vertex_count; vertex++) {
|
|
72
|
+
const my_partition = vertex_partition[vertex];
|
|
73
|
+
|
|
74
|
+
let v_internal_degree = 0;
|
|
75
|
+
let v_external_degree = 0;
|
|
76
|
+
let distinct_neighbor_partitions = 0;
|
|
77
|
+
|
|
78
|
+
const edge_start = edge_addresses[vertex];
|
|
79
|
+
const edge_end = edge_addresses[vertex + 1];
|
|
80
|
+
for (let edge_offset = edge_start; edge_offset < edge_end; edge_offset++) {
|
|
81
|
+
const neighbor_partition = vertex_partition[adjacency[edge_offset]];
|
|
82
|
+
const edge_weight = edge_weights[edge_offset];
|
|
83
|
+
if (neighbor_partition === my_partition) {
|
|
84
|
+
v_internal_degree += edge_weight;
|
|
85
|
+
} else {
|
|
86
|
+
v_external_degree += edge_weight;
|
|
87
|
+
const existing_position = scratch_partition_position[neighbor_partition];
|
|
88
|
+
if (existing_position === -1) {
|
|
89
|
+
scratch_partition_position[neighbor_partition] = distinct_neighbor_partitions;
|
|
90
|
+
scratch_partition_id[distinct_neighbor_partitions] = neighbor_partition;
|
|
91
|
+
scratch_partition_edge_weight[distinct_neighbor_partitions] = edge_weight;
|
|
92
|
+
distinct_neighbor_partitions++;
|
|
93
|
+
} else {
|
|
94
|
+
scratch_partition_edge_weight[existing_position] += edge_weight;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
internal_degree[vertex] = v_internal_degree;
|
|
100
|
+
external_degree[vertex] = v_external_degree;
|
|
101
|
+
|
|
102
|
+
if (v_external_degree > 0) {
|
|
103
|
+
cut_doubled += v_external_degree;
|
|
104
|
+
|
|
105
|
+
// Reserve pool slots sized to the vertex's degree (not just the
|
|
106
|
+
// current distinct-neighbour-partition count). fm_kway can grow
|
|
107
|
+
// a vertex's neighbour-partition list when its neighbours move
|
|
108
|
+
// and introduce a new partition; we need room.
|
|
109
|
+
const degree = edge_end - edge_start;
|
|
110
|
+
const pool_record_offset = neighbor_partition_pool.allocate_continuous(degree);
|
|
111
|
+
neighbor_partition_offset[vertex] = pool_record_offset;
|
|
112
|
+
neighbor_partition_count[vertex] = distinct_neighbor_partitions;
|
|
113
|
+
|
|
114
|
+
// Each pool record is 8 bytes = 2 uint32 words: (partition_id, edge_weight).
|
|
115
|
+
const word_base = neighbor_partition_pool.element_word(pool_record_offset);
|
|
116
|
+
for (let nbr = 0; nbr < distinct_neighbor_partitions; nbr++) {
|
|
117
|
+
pool_data[word_base + nbr * 2] = scratch_partition_id[nbr];
|
|
118
|
+
pool_data[word_base + nbr * 2 + 1] = scratch_partition_edge_weight[nbr];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (v_external_degree >= v_internal_degree) {
|
|
122
|
+
boundary_vertices[boundary_count] = vertex;
|
|
123
|
+
boundary_position_of_vertex[vertex] = boundary_count;
|
|
124
|
+
boundary_count++;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Reset only the touched scratch entries.
|
|
129
|
+
for (let nbr = 0; nbr < distinct_neighbor_partitions; nbr++) {
|
|
130
|
+
scratch_partition_position[scratch_partition_id[nbr]] = -1;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Each crossing edge contributes to both endpoints' external_degree, so we
|
|
135
|
+
// counted it twice across the loop above.
|
|
136
|
+
graph.current_cut = cut_doubled >> 1;
|
|
137
|
+
graph.boundary_count = boundary_count;
|
|
138
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* K-way Fiduccia–Mattheyses cut refinement (single-constraint, cut objective).
|
|
3
|
+
*
|
|
4
|
+
* For each pass:
|
|
5
|
+
* 1. Insert all boundary vertices into a max-heap keyed by
|
|
6
|
+
* `gain = external_degree / sqrt(neighbor_partition_count) - internal_degree`.
|
|
7
|
+
* 2. Repeatedly pop the highest-gain vertex. Find the best target partition
|
|
8
|
+
* satisfying either the standard balance bounds OR a balance-improvement
|
|
9
|
+
* exception. Commit the move.
|
|
10
|
+
* 3. Each move incrementally updates id/ed/nbrs for the moved vertex and all
|
|
11
|
+
* its neighbours, including queue priorities and boundary membership.
|
|
12
|
+
*
|
|
13
|
+
* The pass terminates when the heap drains or no further moves help. Multiple
|
|
14
|
+
* passes are run (default 10) until cut stops improving.
|
|
15
|
+
*
|
|
16
|
+
* Mirrors `Greedy_KWayCutOptimize` from libmetis/kwayfm.c master (post-5.1.0),
|
|
17
|
+
* OMODE_REFINE branch. Three master-era refinements over the 5.1.0 baseline:
|
|
18
|
+
*
|
|
19
|
+
* - **Adaptive ub_factor**: at start, expand `ub_factor` to match the current
|
|
20
|
+
* load imbalance if the graph is already worse than the configured bound.
|
|
21
|
+
* Without this, refinement starting from an imbalanced state can't legally
|
|
22
|
+
* act on it and gets stuck.
|
|
23
|
+
* - **No `fudge_factor` slack** on the max-weight check (master forces this to
|
|
24
|
+
* 0 internally). The looser balance comes from the adaptive ub_factor instead.
|
|
25
|
+
* - **Balance-improvement exception**: a move that violates the strict balance
|
|
26
|
+
* bound is still allowed if it improves the proportional balance ratio
|
|
27
|
+
* between `from` and `to`. Lets refinement pull weight back toward the
|
|
28
|
+
* target over time.
|
|
29
|
+
*
|
|
30
|
+
* Skipped:
|
|
31
|
+
* - minconn (sub-domain connectivity minimisation)
|
|
32
|
+
* - contig (contiguous-partition articulation-point checks)
|
|
33
|
+
* - ncon > 1 (multi-constraint balance)
|
|
34
|
+
* - OMODE_BALANCE (we run REFINE only; the adaptive ub_factor recovers most
|
|
35
|
+
* of what an explicit BALANCE pass would have done)
|
|
36
|
+
*
|
|
37
|
+
* Assumes `compute_kway_params` (or `project_kway`) has populated the refinement
|
|
38
|
+
* state on the graph.
|
|
39
|
+
*
|
|
40
|
+
* @param {import('../MetisGraph.js').MetisGraph} graph
|
|
41
|
+
* @param {number} partition_count
|
|
42
|
+
* @param {{
|
|
43
|
+
* random: function():number,
|
|
44
|
+
* pass_count?: number,
|
|
45
|
+
* ub_factor?: number,
|
|
46
|
+
* fudge_factor?: number,
|
|
47
|
+
* }} opts
|
|
48
|
+
* `ub_factor` (default 1.03) caps `partition_weight` at `target × ub_factor`.
|
|
49
|
+
* Will be expanded automatically if the input is already more imbalanced.
|
|
50
|
+
* `fudge_factor` (default 0; master sets this to 0). Set non-zero to allow
|
|
51
|
+
* positive-gain moves to overshoot the max bound by `fudge_factor × gain`.
|
|
52
|
+
* @param {import('./RefinementScratch.js').RefinementScratch} scratch shared
|
|
53
|
+
* scratch sized to the original (finest) graph's vertex_count and the same
|
|
54
|
+
* partition_count used here
|
|
55
|
+
* @returns {number} total moves committed across all passes
|
|
56
|
+
*/
|
|
57
|
+
export function fm_kway(graph: import('../MetisGraph.js').MetisGraph, partition_count: number, opts: {
|
|
58
|
+
random: () => number;
|
|
59
|
+
pass_count?: number;
|
|
60
|
+
ub_factor?: number;
|
|
61
|
+
fudge_factor?: number;
|
|
62
|
+
}, scratch: import('./RefinementScratch.js').RefinementScratch): number;
|
|
63
|
+
//# sourceMappingURL=fm_kway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fm_kway.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/graph/metis/native/refine/fm_kway.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,+BAjBW,OAAO,kBAAkB,EAAE,UAAU,mBACrC,MAAM;kBAEO,MAAM;iBACZ,MAAM;gBACP,MAAM;mBACH,MAAM;YAMf,OAAO,wBAAwB,EAAE,iBAAiB,GAGhD,MAAM,CAgZlB"}
|