choco.kernel.solver.variables.scheduling
Class TaskVar<C extends AbstractSConstraint & TaskPropagator>

java.lang.Object
  extended by choco.kernel.solver.variables.scheduling.AbstractTask
      extended by choco.kernel.solver.variables.scheduling.TaskVar<C>
All Implemented Interfaces:
IExtensionnable, IPretty, IDotty, IIndex, ITaskVariable<IntDomainVar>, ITask, Var

public final class TaskVar<C extends AbstractSConstraint & TaskPropagator>
extends AbstractTask
implements Var, ITaskVariable<IntDomainVar>, IIndex

Since:
23 janv. 2009 version 2.0.3
Version:
2.0.3
Author:
Arnaud Malapert

Field Summary
protected  APartiallyStoredCstrList<C> constraints
          The list of constraints (listeners) observing the variable.
protected  IntDomainVar duration
           
protected  IntDomainVar end
           
protected  VarEvent<? extends Var> event
           
protected  IntDomainVar start
           
 
Fields inherited from interface choco.kernel.solver.variables.Var
LOGGER
 
Constructor Summary
TaskVar(Solver solver, int id, String name, IntDomainVar start, IntDomainVar end, IntDomainVar duration)
          Initializes a new variable.
 
Method Summary
 int addConstraint(SConstraint c, int varIdx, boolean dynamicAddition)
          Adds a new constraints on the stack of constraints the addition can be dynamic (undone upon backtracking) or not.
 void addExtension(int extensionNumber)
          Adds a new extension.
 boolean detectOrPostConsistencyConstraint(Solver solver)
           
 IntDomainVar duration()
           
 IntDomainVar end()
           
 void eraseConstraint(SConstraint<? extends Var> c)
          Removes (permanently) a constraint from the list of constraints connected to the variable.
 DisposableIterator<Couple<C>> getActiveConstraints(C cstrCause)
           
 SConstraint getConstraint(int i)
          Retrieve the constraint i involving the variable.
 DisposableIterator<SConstraint> getConstraintsIterator()
          This methods should be used if one want to access the different constraints currently posted on this variable.
 PartiallyStoredVector<C> getConstraintVector()
          Access the data structure storing constraints involving a given variable.
 int getECT()
          Gets the Earliest Completion Time (ECT).
 int getEST()
          Gets the Earliest Starting Time (EST).
 VarEvent<? extends Var> getEvent()
          Returns the variable event.
 Extension getExtension(int extensionNumber)
          Returns the queried extension
 int getID()
          Gets the ID of the task.
 long getIndex()
          Unique index of an object in the master object (Different from hashCode, can change from one execution to another one)
 PartiallyStoredIntVector getIndexVector()
          Access the data structure storing indices associated to constraints involving a given variable.
 int getLCT()
          Gets the Latest Completion Time (LCT).
 int getLST()
          Gets the Latest Starting Time (LST).
 int getMaxDuration()
          Gets the maximum duration.
 int getMinDuration()
          Gets the minimum duration.
 String getName()
          Gets the name of the task.
 int getNbConstraints()
          Returns the number of constraints involving the variable.
 int getPriority()
          Return the priority of this according to the related constraints (minimum over all constraints priority)
 int getVarIndex(int constraintIndex)
          Returns the index of the variable in its constraint i.
 boolean hasConstantDuration()
          Checks for if the duration is constant.
 boolean isInstantiated()
          Public user API: Domains : testing whether a variable is instantiated or not.
 boolean isPreemptionAllowed()
          Checks whether the preemption is allowed.
 boolean isScheduled()
          Checks if the task is scheduled.
 void postConsistencyConstraint(Solver solver)
           
 void postHorizonConstraint(Solver solver, int horizon)
           
 IntDomainVar start()
           
 void updateCompulsoryPart(SConstraint cause)
           
 void updateHypotheticalDomain(int idx, SConstraint constraint, boolean forceAwake)
          Call awake on TaskVar.
 
Methods inherited from class choco.kernel.solver.variables.scheduling.AbstractTask
getTimePeriodList, isInterrupted, isPartiallyScheduled, pretty, toDotty, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface choco.IPretty
pretty
 

Field Detail

start

protected final IntDomainVar start

end

protected final IntDomainVar end

duration

protected final IntDomainVar duration

constraints

protected APartiallyStoredCstrList<C extends AbstractSConstraint & TaskPropagator> constraints
The list of constraints (listeners) observing the variable.


event

protected final VarEvent<? extends Var> event
Constructor Detail

TaskVar

public TaskVar(Solver solver,
               int id,
               String name,
               IntDomainVar start,
               IntDomainVar end,
               IntDomainVar duration)
Initializes a new variable.

Parameters:
solver - The model this variable belongs to
name - The name of the variable
Method Detail

isPreemptionAllowed

public final boolean isPreemptionAllowed()
Description copied from interface: ITask
Checks whether the preemption is allowed.

Specified by:
isPreemptionAllowed in interface ITask
Returns:
true, if preemption is allowed

getID

public final int getID()
Description copied from interface: ITask
Gets the ID of the task.

Specified by:
getID in interface ITask
Returns:
the iD

getName

public final String getName()
Description copied from interface: ITask
Gets the name of the task.

Specified by:
getName in interface ITask
Specified by:
getName in interface Var
Overrides:
getName in class AbstractTask
Returns:
the name

getIndex

public long getIndex()
Unique index of an object in the master object (Different from hashCode, can change from one execution to another one)

Specified by:
getIndex in interface IIndex
Returns:

getPriority

public int getPriority()
Description copied from interface: Var
Return the priority of this according to the related constraints (minimum over all constraints priority)

Specified by:
getPriority in interface Var
Returns:

start

public final IntDomainVar start()
Specified by:
start in interface ITaskVariable<IntDomainVar>

end

public final IntDomainVar end()
Specified by:
end in interface ITaskVariable<IntDomainVar>

duration

public final IntDomainVar duration()
Specified by:
duration in interface ITaskVariable<IntDomainVar>

getECT

public int getECT()
Description copied from interface: ITask
Gets the Earliest Completion Time (ECT).

Specified by:
getECT in interface ITask
Overrides:
getECT in class AbstractTask
Returns:
the ECT

getEST

public int getEST()
Description copied from interface: ITask
Gets the Earliest Starting Time (EST).

Specified by:
getEST in interface ITask
Returns:
the EST

getLCT

public int getLCT()
Description copied from interface: ITask
Gets the Latest Completion Time (LCT).

Specified by:
getLCT in interface ITask
Returns:
the LCT

getLST

public int getLST()
Description copied from interface: ITask
Gets the Latest Starting Time (LST).

Specified by:
getLST in interface ITask
Overrides:
getLST in class AbstractTask
Returns:
the LST

getMaxDuration

public int getMaxDuration()
Description copied from interface: ITask
Gets the maximum duration.

Specified by:
getMaxDuration in interface ITask
Returns:
the max duration

getMinDuration

public int getMinDuration()
Description copied from interface: ITask
Gets the minimum duration.

Specified by:
getMinDuration in interface ITask
Returns:
the minimum duration the task

hasConstantDuration

public boolean hasConstantDuration()
Description copied from interface: ITask
Checks for if the duration is constant.

Specified by:
hasConstantDuration in interface ITask
Overrides:
hasConstantDuration in class AbstractTask
Returns:
true, if the duration is constant.

isScheduled

public boolean isScheduled()
Description copied from interface: ITask
Checks if the task is scheduled. The task is scheduled if its starting time and its duration are fixed.

Specified by:
isScheduled in interface ITask
Overrides:
isScheduled in class AbstractTask
Returns:
true, if the tasks is scheduled

getEvent

public VarEvent<? extends Var> getEvent()
Returns the variable event.

Specified by:
getEvent in interface Var
Returns:
the event responsible for propagating variable modifications

getConstraint

public SConstraint getConstraint(int i)
Retrieve the constraint i involving the variable. Be careful to use the correct constraint index (constraints are not numbered from 0 to number of constraints minus one, since an offset is used for some of the constraints).

Specified by:
getConstraint in interface Var
Parameters:
i - the number of the required constraint
Returns:
the constraint number i according to the variable

getNbConstraints

public int getNbConstraints()
Returns the number of constraints involving the variable.

Specified by:
getNbConstraints in interface Var
Returns:
the number of constraints containing this variable

getConstraintVector

public PartiallyStoredVector<C> getConstraintVector()
Access the data structure storing constraints involving a given variable.

Specified by:
getConstraintVector in interface Var
Returns:
the backtrackable structure containing the constraints

getIndexVector

public PartiallyStoredIntVector getIndexVector()
Access the data structure storing indices associated to constraints involving a given variable.

Specified by:
getIndexVector in interface Var
Returns:
the indices associated to this variable in each constraint

getVarIndex

public int getVarIndex(int constraintIndex)
Returns the index of the variable in its constraint i.

Specified by:
getVarIndex in interface Var
Parameters:
constraintIndex - the index of the constraint (among all constraints linked to the variable)
Returns:
the index of the variable

eraseConstraint

public void eraseConstraint(SConstraint<? extends Var> c)
Removes (permanently) a constraint from the list of constraints connected to the variable.

Parameters:
c - the constraint that should be removed from the list this variable maintains.

addConstraint

public int addConstraint(SConstraint c,
                         int varIdx,
                         boolean dynamicAddition)
Adds a new constraints on the stack of constraints the addition can be dynamic (undone upon backtracking) or not.

Specified by:
addConstraint in interface Var
Parameters:
c - the constraint to add
varIdx - the variable index accrding to the added constraint
dynamicAddition - states if the addition is definitic (cut) or subject to backtracking (standard constraint)
Returns:
the index affected to the constraint according to this variable

getConstraintsIterator

public DisposableIterator<SConstraint> getConstraintsIterator()
This methods should be used if one want to access the different constraints currently posted on this variable. Indeed, since indices are not always consecutive, it is the only simple way to achieve this. Warning ! this iterator should not be used to remove elements. The remove method throws an UnsupportedOperationException.

Specified by:
getConstraintsIterator in interface Var
Returns:
an iterator over all constraints involving this variable

getActiveConstraints

public final DisposableIterator<Couple<C>> getActiveConstraints(C cstrCause)

isInstantiated

public boolean isInstantiated()
Description copied from interface: Var
Public user API: Domains : testing whether a variable is instantiated or not.

Specified by:
isInstantiated in interface Var
Returns:
a boolean giving if a variable is instanciated or not

updateCompulsoryPart

public final void updateCompulsoryPart(SConstraint cause)
                                throws ContradictionException
Throws:
ContradictionException

updateHypotheticalDomain

public void updateHypotheticalDomain(int idx,
                                     SConstraint constraint,
                                     boolean forceAwake)
Call awake on TaskVar.

Parameters:
idx - index of the constraint calling #awake().
constraint -
forceAwake -

getExtension

public Extension getExtension(int extensionNumber)
Description copied from interface: IExtensionnable
Returns the queried extension

Specified by:
getExtension in interface IExtensionnable
Parameters:
extensionNumber - should use the number returned by getAbstractSConstraintExtensionNumber
Returns:
the queried extension

addExtension

public void addExtension(int extensionNumber)
Description copied from interface: IExtensionnable
Adds a new extension.

Specified by:
addExtension in interface IExtensionnable
Parameters:
extensionNumber - should use the number returned by getAbstractSConstraintExtensionNumber

detectOrPostConsistencyConstraint

public final boolean detectOrPostConsistencyConstraint(Solver solver)

postConsistencyConstraint

public final void postConsistencyConstraint(Solver solver)

postHorizonConstraint

public final void postHorizonConstraint(Solver solver,
                                        int horizon)


Copyright © 2012. All Rights Reserved.