Skip to content

Idea: Optimize operations on bools #97

@pvdz

Description

@pvdz

When inspecting the configuration of a large case (20k+ constraints) the vars are often boolean bound (or at otherwise have an upper bound of about 5). We have a lot of code intended to be generic, but maybe it would pay off to handle boolean cases explicitly.

We already have "small" domains, represented as bitwise flags, this already helps considerably. We could simply compare domain === ONE and act accordingly. For example, the eq([0, 1], [1, 1]) could be handled with a table. Now this is a bad example because eq on small domains is dealt with through binary AND-ing. But the point is that not all propagators can get away with bitwise shortcuts. For them a simply solution table for booleans could make a lot of difference.

  • It also may not if it turns out the small domains already save most of this
  • Any boolean bound domain should be a number, which can be compared to constants (EMPTY ZERO ONE BOOL) which is much faster than what arrays used to do. Simple lookup tables can lead to O(1) solutions for propagation steps, for insofar they aren't already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions