Class RealVarImpl

    • Constructor Detail

      • RealVarImpl

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

      • getPrecision

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

        public void silentlyAssign​(double lb,
                                   double ub)
        Specified by:
        silentlyAssign in interface RealVar
      • getLB

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

        public double getUB()
        Description copied from interface: RealInterval
        Retrieves the upper bound of the variable
        Specified by:
        getUB in interface RealInterval
        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 implementations 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
      • tighten

        public void tighten()
        Description copied from interface: CArExpression
        Computes the narrowest bounds with respect to sub terms.
        Specified by:
        tighten in interface CArExpression
      • collectVariables

        public void collectVariables​(java.util.TreeSet<RealVar> set)
        Description copied from interface: CArExpression
        Collects real variables involved in this expression and add them into 'set'.
        Specified by:
        collectVariables in interface CArExpression
        Parameters:
        set - an ordered set of involved real variables
      • subExps

        public void subExps​(java.util.List<CArExpression> list)
        Description copied from interface: CArExpression
        Collects sub-expressions composing this expression and add them to 'list'.
        Specified by:
        subExps in interface CArExpression
        Parameters:
        list - list of sub-expressions of this.
      • isolate

        public boolean isolate​(RealVar var,
                               java.util.List<CArExpression> wx,
                               java.util.List<CArExpression> wox)
        Description copied from interface: CArExpression
        Considering 'var' and this expression, fills 'wx' with sub-expressions involving 'var' and fills 'wox' with sub-expressions not involving 'var'.
        Specified by:
        isolate in interface CArExpression
        Parameters:
        var - a real variable
        wx - list of sub-expressions involving 'var'
        wox - list of sub-expressions not involving 'var'
        Returns:
        'true' if this expression involves 'var'.