Class SimpleCpVarDomain

  • All Implemented Interfaces:
    WrapperComponent

    public class SimpleCpVarDomain
    extends SatCPBridge
    A simple representation for small domains, not lazy. It allocates boolean variables to stand for propositions '[x=v]' and '[x<=v]' for each value v of the domain of x (even '[x<=max]', which is a tautology, for simplicity)
    Version:
    4.8
    • Field Detail

      • firstVar

        private int firstVar
      • width

        private int width
      • isTranslated

        public boolean isTranslated
    • Constructor Detail

      • SimpleCpVarDomain

        public SimpleCpVarDomain​(SatWrapper wrapper,
                                 IntVar variable)
      • SimpleCpVarDomain

        public SimpleCpVarDomain​(SatWrapper wrapper,
                                 IntVar variable,
                                 boolean translate)
    • Method Detail

      • cpValueToBoolVar

        public final int cpValueToBoolVar​(int value,
                                          boolean isEquality)
        Description copied from class: SatCPBridge
        return the literal that represents the assertion 'var = value'. For the proposition 'var<= value', set the isEquality flag to false
        Specified by:
        cpValueToBoolVar in class SatCPBridge
        Parameters:
        value - the value for the variable this range represents
        isEquality - true if we want the literal for 'x=d' kind of propositions, false for 'x<=d'
        Returns:
        the literal corresponding to 'var = this value'. If the value is out of the domain of the variable, returns 0.
      • boolVarToCpValue

        public final int boolVarToCpValue​(int literal)
        Description copied from class: SatCPBridge
        return the value corresponding to given literal (variable)
        Specified by:
        boolVarToCpValue in class SatCPBridge
        Parameters:
        literal - the literal standing for 'var = value'
        Returns:
        the value such that 'var = value' (or 'var<= value')
      • isEqualityBoolVar

        public final boolean isEqualityBoolVar​(int literal)
        Description copied from class: SatCPBridge
        checks if the literal stands for a 'x=d' proposition, or a 'x<=d' proposition
        Specified by:
        isEqualityBoolVar in class SatCPBridge
        Parameters:
        literal - the literal (among literals from this range)
        Returns:
        true if the literal stands for 'x=d', false otherwise
      • setDomain

        public void setDomain​(int minValue,
                              int maxValue)
        Description copied from class: SatCPBridge
        set the domain to be between minValue and maxValue. It only does something on the first call.
        Overrides:
        setDomain in class SatCPBridge
        Parameters:
        minValue - minimum value of the range
        maxValue - maximum value of the range
      • propagate

        public void propagate​(int literal)
        given some literal has a value, what other literals should be asserted ?
        Specified by:
        propagate in class SatCPBridge
        Parameters:
        literal - the literal that has been asserted
      • isTranslated

        public boolean isTranslated()
        Description copied from class: SatCPBridge
        predicate for whether this variable should be handled by the DomainClausesDatabase or not
        Specified by:
        isTranslated in class SatCPBridge
        Returns:
        true if the variable should be handled by the DomainClausesDatabase