Interface Variable

    • Method Detail

      • isInstantiated

        boolean isInstantiated()
        Indicates whether this is instantiated (see implemtations to know what instantiation means).
        Returns:
        true if this is instantiated
      • getName

        String getName()
        Returns the name of this
        Returns:
        a String representing the name of this
      • getPropagators

        Propagator[] getPropagators()
        Return the array of propagators this
        Returns:
        the array of proapgators of this
      • getPropagator

        Propagator getPropagator​(int idx)
        Return the "idx" th propagator of this
        Parameters:
        idx - position of the propagator
        Returns:
        a propagator
      • getNbProps

        int getNbProps()
        Return the number of propagators
        Returns:
        number of propagators of this
      • getPIndices

        int[] getPIndices()
        Returns:
        the array of indices of this variable in its propagators.
      • setPIndice

        void setPIndice​(int pos,
                        int val)
        Update the position of the variable in the propagator at position in getPropagators().
        Parameters:
        pos - position of the propagator
        val - position of this variable in the propagator
      • getDindex

        int getDindex​(int i)
        This variable's propagators are stored in specific way which ease iteration based on propagation conditions. Any event indicates, through the dependency list which propagators should be executed. Thus, an event indicates a list of is, passed as parameter, which help returning the right propagators.
        Parameters:
        i - dependency index
        Returns:
        index of the first propagator associated with that dependency.
      • getIndexInPropagator

        int getIndexInPropagator​(int pidx)
        Return the position of the variable in the propagator at position pidx
        Parameters:
        pidx - index of the propagator within the list of propagators of this
        Returns:
        position of this in the propagator pidx
      • addMonitor

        void addMonitor​(IVariableMonitor monitor)
        Build and add a monitor to the monitor list of this. The monitor is inactive at the creation and must be activated (by the engine propagation).
        Parameters:
        monitor - a variable monitor
      • removeMonitor

        void removeMonitor​(IVariableMonitor monitor)
        Removes monitor form the list of this variable's monitors.
        Parameters:
        monitor - the monitor to remove.
      • subscribeView

        void subscribeView​(IView view)
        Attaches a view to this variable.
        Parameters:
        view - a view to add to this variable.
      • getDelta

        IDelta getDelta()
        Return the delta domain of this
        Returns:
        the delta domain of the variable
      • createDelta

        void createDelta()
        Create a delta, if necessary, in order to observe removed values of a this. If the delta already exists, has no effect.
      • link

        int link​(Propagator propagator,
                 int idxInProp)
        Link the propagator to this
        Parameters:
        propagator - a newly added propagator
        idxInProp - index of the variable in the propagator
        Returns:
        return the index of the propagator within the variable
      • swapOnPassivate

        int swapOnPassivate​(Propagator propagator,
                            int idxInProp)
        The propagator will not be informed of any modification of this anymore.
        Parameters:
        propagator - the propagator to swap
        idxInProp - index of the variable in the propagator
        Returns:
        return the index of the propagator within the variable
      • swapOnActivate

        int swapOnActivate​(Propagator propagator,
                           int idxInProp)
        The propagator will be informed back of any modification of this.
        Parameters:
        propagator - the propagator to swap
        idxInProp - index of the variable in the propagator
        Returns:
        return the index of the propagator within the variable
      • unlink

        void unlink​(Propagator propagator,
                    int idxInProp)
        Remove a propagator from the list of propagator of this. SHOULD BE CONTAINED IN THIS.
        Parameters:
        propagator - the propagator to remove
        idxInProp - index of the variable in the propagator
      • notifyPropagators

        void notifyPropagators​(IEventType event,
                               ICause cause)
                        throws ContradictionException
        If this has changed, then notify all of its observers.
        Each observer has its update method.
        Parameters:
        event - event on this object
        cause - object which leads to the modification of this object
        Throws:
        ContradictionException - if a contradiction occurs during notification
      • notifyViews

        void notifyViews​(IEventType event,
                         ICause cause)
                  throws ContradictionException
        Notify views of observed variable modifications
        Parameters:
        event - the event which occurred on the variable
        cause - the cause of the notification
        Throws:
        ContradictionException - if the notification detects contradiction.
      • getNbViews

        int getNbViews()
        Returns:
        the number of views attached to the variable
      • getView

        IView getView​(int p)
        Get the view at position p in this variable views. The array is filled from position 0 to position getNbViews() excluded.
        Parameters:
        p - position of the view to return
        Returns:
        view observing this variable, at position p
      • notifyMonitors

        void notifyMonitors​(IEventType event)
                     throws ContradictionException
        Notify monitors of observed variable modifications
        Parameters:
        event - the event which occurred on the variable
        Throws:
        ContradictionException - if the monitor detects contradiction.
      • contradiction

        void contradiction​(ICause cause,
                           String message)
                    throws ContradictionException
        Throws a contradiction exception based on
        Parameters:
        cause - ICause causing the exception
        message - the detailed message @throws ContradictionException expected behavior
        Throws:
        ContradictionException - the build contradiction.
      • getModel

        Model getModel()
        Return the associated model
        Returns:
        a Model object
      • getEnvironment

        default IEnvironment getEnvironment()
        Returns:
        the backtracking environment used for this variable
      • getTypeAndKind

        int getTypeAndKind()
        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;
         
        Returns:
        an int representing the type and kind of the variable
      • isAConstant

        boolean isAConstant()
        Returns:
        true iff the variable is a constant (created with a singleton domain)
      • getEvtScheduler

        EvtScheduler getEvtScheduler()
        For scheduling purpose only
        Returns:
        the scheduler
      • storeEvents

        void storeEvents​(int mask,
                         ICause cause)
        Temporarily store modification events made on this. This is requiered by the propagation engine.
        Parameters:
        mask - event's mask
        cause - what causes the modification (cannot be null)