Class RealVarImpl

    • Constructor Detail

      • RealVarImpl

        public RealVarImpl​(String name,
                           double lb,
                           double ub,
                           double precision,
                           Model model)
    • Method Detail

      • getPrecision

        public double getPrecision()
        Specified by:
        getPrecision in interface RealVar
      • 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
      • 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