Class PropMultiCostRegular

  • All Implemented Interfaces:
    Comparable<Propagator>, ICause, Identity

    public final class PropMultiCostRegular
    extends Propagator<IntVar>
    Created by IntelliJ IDEA. User: julien S Date: Jul 16, 2008 Time: 5:56:50 PM

    Multi-Cost-Regular is a propagator for the constraint ensuring that, given : an automaton Pi; a sequence of domain variables X; a set of bound variables Z; a assignment cost matrix for each bound variable C;

    The word formed by the sequence of assigned variables is accepted by Pi; for each z^k in Z, sum_i(C_i(x_k)k) = z^k

    AC is NP hard for such a constraint. The propagation is based on a Lagrangian Relaxation approach of the underlying Resource constrained shortest/longest path problems

    • Field Detail

      • MAXBOUNDITER

        public static final int MAXBOUNDITER
        Maximum number of iteration during a bound computation
        See Also:
        Constant Field Values
      • MAXNONIMPROVEITER

        public static final int MAXNONIMPROVEITER
        Maximum number of non improving iteration while computing a bound
        See Also:
        Constant Field Values
      • U0

        public static final double U0
        Constant coefficient of the lagrangian relaxation
        See Also:
        Constant Field Values
      • RO

        public static final double RO
        Lagrangian multiplier decreasing factor
        See Also:
        Constant Field Values
      • map

        public final gnu.trove.map.hash.TObjectIntHashMap<IntVar> map
        Map to retrieve rapidly the index of a given variable.
      • _MCR_DECIMAL_PREC

        public final double _MCR_DECIMAL_PREC
    • Constructor Detail

      • PropMultiCostRegular

        public PropMultiCostRegular​(IntVar[] variables,
                                    IntVar[] costvariables,
                                    ICostAutomaton cauto,
                                    double precision)
        Constructs a multi-cost-regular propagator
        Parameters:
        variables - decision variables
        costvariables - cost variables
        cauto - finite automaton with costs
    • Method Detail

      • getPropagationConditions

        public int getPropagationConditions​(int vIdx)
        Description copied from class: Propagator
        Returns the specific mask indicating the variable events on which this Propagator object can react.
        A mask is a bitwise OR operations over IEventType this can react on. For example, consider a propagator that can deduce filtering based on the lower bound of the integer variable X. Then, for this variable, the mask should be equal to :
             int mask = IntEventType.INCLOW.getMask() | IntEventType.INSTANTIATE.getMask();
         
        or, in a more convenient way:
             int mask = IntEvtType.combine(IntEventType.INCLOW,IntEventType.INSTANTIATE);
         
        That indicates the following behavior:
        1. if X is instantiated, this propagator will be executed,
        2. if the lower bound of X is modified, this propagator will be executed,
        3. if the lower bound of X is removed, the event is promoted from REMOVE to INCLOW and this propagator will NOT be executed,
        4. otherwise, this propagator will NOT be executed
        Some combinations are valid. For example, a propagator which reacts on REMOVE and INSTANTIATE should also declare INCLOW and DECUPP as conditions. Indeed INCLOW (resp. DECUPP), for efficiency purpose, removing the lower bound (resp. upper bound) of an integer variable will automatically be promoted into INCLOW (resp. DECUPP). So, ignoring INCLOW and/or DECUPP in that case may result in a lack of filtering. The same goes with events of other variable types, but most of the time, there are only few combinations. Reacts to any kind of event by default. Alternatively, this method can return IntEventType.VOID which states that this propagator should not be aware of modifications applied to the variable in position vIdx.
        Overrides:
        getPropagationConditions in class Propagator<IntVar>
        Parameters:
        vIdx - index of the variable within the propagator
        Returns:
        an int composed of REMOVE and/or INSTANTIATE and/or DECUPP and/or INCLOW
      • propagate

        public void propagate​(int evtmask)
                       throws ContradictionException
        Description copied from class: Propagator
        Call the main filtering algorithm to apply to the Domain of the Variable objects. It considers the current state of this objects to remove some values from domains and/or instantiate some variables. Calling this method is done from 2 (and only 2) steps:
        - at the initial propagation step,
        - when involved in a reified constraint.
        It should initialized the internal data structure and apply filtering algorithm from scratch.
        Specified by:
        propagate in class Propagator<IntVar>
        Parameters:
        evtmask - type of propagation event this must consider.
        Throws:
        ContradictionException - when a contradiction occurs, like domain wipe out or other incoherencies.
      • propagate

        public void propagate​(int varIdx,
                              int mask)
                       throws ContradictionException
        Description copied from class: Propagator
        Incremental filtering algorithm defined within the Propagator, called whenever the variable of index idxVarInProp has changed. This method calls a CUSTOM_PROPAGATION (coarse-grained) by default.

        This method should be overridden if the argument reactToFineEvt is set to true in the constructor. Otherwise, it executes propagate(PropagatorEventType.CUSTOM_PROPAGATION.getStrengthenedMask());

        Overrides:
        propagate in class Propagator<IntVar>
        Parameters:
        varIdx - index of the variable var in this
        mask - type of event
        Throws:
        ContradictionException - if a contradiction occurs
      • updateUpperBound

        protected void updateUpperBound()
                                 throws ContradictionException
        Performs a lagrangian relaxation to compute a new Upper bound of the underlying RCSPP problem Each built subproblem is a longest path one can use to perform cost based filtering
        Throws:
        ContradictionException - if a domain becomes empty
      • updateLowerBound

        protected void updateLowerBound()
                                 throws ContradictionException
        Performs a lagrangian relaxation to compute a new Lower bound of the underlying RCSPP problem Each built subproblem is a shortest path one can use to perform cost based filtering
        Throws:
        ContradictionException - if a domain becomes empty
      • filterDown

        protected void filterDown​(double realsp)
                           throws ContradictionException
        Filters w.r.t. a given lower bound.
        Parameters:
        realsp - a given lower bound
        Throws:
        ContradictionException - if the cost variable domain is emptied
      • filterUp

        protected void filterUp​(double reallp)
                         throws ContradictionException
        Filters w.r.t. a given upper bound.
        Parameters:
        reallp - a given upper bound
        Throws:
        ContradictionException - if the cost variable domain is emptied
      • delayedGraphUpdate

        protected void delayedGraphUpdate()
                                   throws ContradictionException
        Updates the graphs w.r.t. the caught event during event-based propagation
        Throws:
        ContradictionException - if removing an edge causes a domain to be emptied
      • needPropagation

        public final boolean needPropagation()
      • isGraphConsistent

        public boolean isGraphConsistent()
      • getRegret

        public final int getRegret​(int layer,
                                   int value,
                                   int... resources)
      • isEntailed

        public ESat isEntailed()
        Description copied from class: Propagator
        Check wether this is entailed according to the current state of its internal structure. At least, should check the satisfaction of this (when all is instantiated).
        Specified by:
        isEntailed in class Propagator<IntVar>
        Returns:
        ESat.TRUE if entailed, ESat.FALSE if not entailed, ESat.UNDEFINED if unknown
      • isSatisfied

        public boolean isSatisfied()
      • check

        public boolean check​(int[] word)
      • check

        public boolean check()
        Necessary condition : checks whether the constraint is violted or not
        Returns:
        true if the constraint is not violated
      • getMinPathCostForAssignment

        public int getMinPathCostForAssignment​(int col,
                                               int val,
                                               int... resources)
      • getMinMaxPathCostForAssignment

        public int[] getMinMaxPathCostForAssignment​(int col,
                                                    int val,
                                                    int... resources)
      • getMinPathCost

        public int getMinPathCost​(int... resources)
      • getInstantiatedLayerCosts

        public double[] getInstantiatedLayerCosts​(int layer)