Class RealView

    • Field Detail

      • var

        protected final IntVar var
      • precision

        protected final double precision
    • Constructor Detail

      • RealView

        public RealView​(IntVar var,
                        double precision)
    • Method Detail

      • getVariable

        public IntVar getVariable()
        Description copied from interface: IView
        Return the basis variable
        Specified by:
        getVariable in interface IView
        Returns:
        variable observed
      • justifyEvent

        public void justifyEvent​(IntEventType mask,
                                 int one,
                                 int two,
                                 int three)
        Description copied from interface: IView
        This methods is related to explanations, it binds an event occurring on the observed variable to the view.
        Specified by:
        justifyEvent in interface IView
        Parameters:
        mask - type of modification
        one - an int
        two - an int
        three - an int
      • explain

        public void explain​(ExplanationForSignedClause clause,
                            ValueSortedMap<IntVar> front,
                            Implications ig,
                            int p)
        Description copied from interface: ICause
        Clausal explanation for this cause.

        This method must filled explanations with inferred literals. These literals are inferred from the analysis of (a subset of) conflicting nodes stored in front, the implication graph ig and the current node in conflict, not yet contained in front.

        Optionally, this method can update front by looking for a predecessor of any node that seems more relevant than the declared one.

        Specified by:
        explain in interface ICause
        Specified by:
        explain in interface IView
        Parameters:
        clause - explanation to compute
        front - ordered map of (variable,node> in the conflict frontier of the implication graph.
        ig - an implication graph
        p - the pivot node out of front
      • getLB

        public double getLB()
        Description copied from interface: RealVar
        Retrieves the lower bound of the variable
        Specified by:
        getLB in interface RealVar
        Returns:
        the lower bound
      • getUB

        public double getUB()
        Description copied from interface: RealVar
        Retrieves the upper bound of the variable
        Specified by:
        getUB in interface RealVar
        Returns:
        the upper bound
      • updateLowerBound

        public boolean updateLowerBound​(double value,
                                        ICause cause)
                                 throws ContradictionException
        Description copied from interface: RealVar
        Updates the lower bound of the domain of this to value. The instruction comes from propagator.
        • If value is smaller than the lower bound of the domain, nothing is done and the return value is false,
        • if updating the lower bound to value leads to a dead-end (domain wipe-out), a ContradictionException is thrown,
        • otherwise, if updating the lower bound to value can be done safely, the event type is created (the original event can be promoted) and observers are notified and the return value is true
        Specified by:
        updateLowerBound in interface RealVar
        Parameters:
        value - new lower bound (included)
        cause - updating releaser
        Returns:
        true if the lower bound has been updated, false otherwise
        Throws:
        ContradictionException - if the domain become empty due to this action
      • updateUpperBound

        public boolean updateUpperBound​(double value,
                                        ICause cause)
                                 throws ContradictionException
        Description copied from interface: RealVar
        Updates the upper bound of the domain of this to value. The instruction comes from propagator.
        • If value is greater than the upper bound of the domain, nothing is done and the return value is false,
        • if updating the upper bound to value leads to a dead-end (domain wipe-out), a ContradictionException is thrown,
        • otherwise, if updating the upper bound to value can be done safely, the event type is created (the original event can be promoted) and observers are notified and the return value is true
        Specified by:
        updateUpperBound in interface RealVar
        Parameters:
        value - new upper bound (included)
        cause - update releaser
        Returns:
        true if the upper bound has been updated, false otherwise
        Throws:
        ContradictionException - if the domain become empty due to this action
      • updateBounds

        public boolean updateBounds​(double lowerbound,
                                    double upperbound,
                                    ICause cause)
                             throws ContradictionException
        Description copied from interface: RealVar
        Updates the bounds of the domain of this to value. The instruction comes from propagator.
        • If the interval defined by [lowerbound,upperbound] includes the domain of this, nothing is done and the return value is false,
        • if updating the domain leads to a dead-end (domain wipe-out), a ContradictionException is thrown,
        • otherwise, if updating the domain be done safely, the event type is created (the original event can be promoted) and observers are notified and the return value is true
        Specified by:
        updateBounds in interface RealVar
        Parameters:
        lowerbound - new lower bound (included)
        upperbound - new upper bound (included)
        cause - update releaser
        Returns:
        true if the upper bound has been updated, false otherwise
        Throws:
        ContradictionException - if the domain become empty due to this action
      • getPrecision

        public double getPrecision()
        Specified by:
        getPrecision in interface RealVar
      • isInstantiated

        public boolean isInstantiated()
        Description copied from interface: Variable
        Indicates whether this is instantiated (see implemtations to know what instantiation means).
        Specified by:
        isInstantiated in interface Variable
        Returns:
        true if this is instantiated
      • getDelta

        public NoDelta getDelta()
        Description copied from interface: Variable
        Return the delta domain of this
        Specified by:
        getDelta in interface Variable
        Returns:
        the delta domain of the variable
      • createDelta

        public void createDelta()
        Description copied from interface: Variable
        Create a delta, if necessary, in order to observe removed values of a this. If the delta already exists, has no effect.
        Specified by:
        createDelta in interface Variable
      • getTypeAndKind

        public int getTypeAndKind()
        Description copied from interface: Variable
        Return a MASK composed of 2 main information: TYPE and KIND.
        TYPE is defined in the 3 first bits : VAR ( 1 << 0), CSTE (1 << 1) or VIEW (1 << 2)
        KIND is defined on the other bits : INT (1 << 3), BOOL (INT + 1 << 4), GRAPH (1 << 5) or META (1 << 6)

        To get the TYPE of a variable:

         int type = var.getTypeAndKind() & Variable.TYPE;
         

        To get the KIND of a variable:

         int kind = var.getTypeAndKind() & Variable.KIND;
         

        To check a specific type or kind of a variable:

             boolean isVar = (var.getTypeAndKind() & Variable.VAR) !=0;
             boolean isInt = (var.getTypeAndKind() & Variable.INT) !=0;
         
        Specified by:
        getTypeAndKind in interface Variable
        Returns:
        an int representing the type and kind of the variable