Package org.jacop.constraints.netflow
Class NetworkFlow
- java.lang.Object
-
- org.jacop.constraints.DecomposedConstraint<Constraint>
-
- org.jacop.constraints.Constraint
-
- org.jacop.constraints.netflow.NetworkFlow
-
- All Implemented Interfaces:
RemoveLevelLate,Stateful,UsesQueueVariable
public class NetworkFlow extends Constraint implements UsesQueueVariable, Stateful, RemoveLevelLate
The network flow constraint. Use the NetworkBuilder to create a network and instantiate the network.- Version:
- 4.8
-
-
Field Summary
Fields Modifier and Type Field Description IntVarcostVariableThe cost variablebooleandisableQueueVariableDisables the queue variable function during consistencyprivate static booleanDO_INSTRUMENTATION(package private) static java.util.concurrent.atomic.AtomicIntegeridNumberInstance counterjava.util.Map<IntVar,VarHandler>mapThe variables and their handlersPruningnetworkThe networkintpreviousLeveljava.util.Set<IntVar>queueThe set of queued variablesprivate static intQUEUE_INDEXprivate static booleanSHOW_LEVEL(package private) Statisticsstatistics-
Fields inherited from class org.jacop.constraints.Constraint
atomicExecution, consistencyPruningEvents, constraintScope, earlyTerminationOK, increaseWeight, numberId, scope, trace
-
Fields inherited from class org.jacop.constraints.DecomposedConstraint
queueIndex
-
-
Constructor Summary
Constructors Modifier Constructor Description privateNetworkFlow(java.util.List<Node> nodes, java.util.List<Arc> arcs, java.util.List<VarHandler> flowVariables, IntVar costVariable)InitializationNetworkFlow(NetworkBuilder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconsistency(Store store)It is a (most probably incomplete) consistency function which removes the values from variables domains.intgetConsistencyPruningEvent(Var var)It retrieves the pruning event which causes reevaluation of the constraint.intgetDefaultConsistencyPruningEvent()voidimpose(Store store)It imposes the constraint in a given store.voidqueueVariable(int level, Var variable)Search & BacktrackingvoidremoveLevel(int level)This function is called in case of the backtrack, so a constraint can clear the queue of changed variables which is no longer valid.voidremoveLevelLate(int level)This function is called in case of the backtrack.java.lang.StringtoString()Identifiersprivate voidupdateGraph()-
Methods inherited from class org.jacop.constraints.Constraint
afc, arguments, cleanAfterFailure, decompose, getGuideConstraint, getGuideValue, getGuideVariable, grounded, grounded, id, impose, imposeDecomposition, increaseWeight, intArrayToString, numberArgs, removeConstraint, requiresMonotonicity, setConsistencyPruningEvent, setConstraintScope, setScope, setScope, setScope, setScope, setScope, setWatchedVariableGrounded, supplyGuideFeedback, updateAFC, watchedVariableGrounded
-
Methods inherited from class org.jacop.constraints.DecomposedConstraint
auxiliaryVariables, checkInput, checkInput, checkInputForDuplication, checkInputForDuplicationSkipSingletons, checkInputForNullness, checkInputForNullness, checkInputForNullness, derivative, getDubletonsSkipSingletons, imposeDecomposition
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jacop.api.Stateful
isStateful
-
-
-
-
Field Detail
-
QUEUE_INDEX
private static final int QUEUE_INDEX
- See Also:
- Constant Field Values
-
DO_INSTRUMENTATION
private static final boolean DO_INSTRUMENTATION
- See Also:
- Constant Field Values
-
SHOW_LEVEL
private static final boolean SHOW_LEVEL
- See Also:
- Constant Field Values
-
statistics
Statistics statistics
-
idNumber
static java.util.concurrent.atomic.AtomicInteger idNumber
Instance counter
-
network
public final Pruning network
The network
-
costVariable
public IntVar costVariable
The cost variable
-
map
public final java.util.Map<IntVar,VarHandler> map
The variables and their handlers
-
queue
public final java.util.Set<IntVar> queue
The set of queued variables
-
disableQueueVariable
public boolean disableQueueVariable
Disables the queue variable function during consistency
-
previousLevel
public int previousLevel
-
-
Constructor Detail
-
NetworkFlow
private NetworkFlow(java.util.List<Node> nodes, java.util.List<Arc> arcs, java.util.List<VarHandler> flowVariables, IntVar costVariable)
Initialization
-
NetworkFlow
public NetworkFlow(NetworkBuilder builder)
-
-
Method Detail
-
getConsistencyPruningEvent
public int getConsistencyPruningEvent(Var var)
Description copied from class:ConstraintIt retrieves the pruning event which causes reevaluation of the constraint.- Overrides:
getConsistencyPruningEventin classConstraint- Parameters:
var- variable for which pruning event is retrieved- Returns:
- it returns the int code of the pruning event (GROUND, BOUND, ANY, NONE)
-
getDefaultConsistencyPruningEvent
public int getDefaultConsistencyPruningEvent()
- Specified by:
getDefaultConsistencyPruningEventin classConstraint
-
impose
public void impose(Store store)
Description copied from class:ConstraintIt imposes the constraint in a given store.- Overrides:
imposein classConstraint- Parameters:
store- the constraint store to which the constraint is imposed to.
-
queueVariable
public void queueVariable(int level, Var variable)Search & Backtracking- Overrides:
queueVariablein classConstraint- Parameters:
level- the level of the store at which the change has occurred.variable- variable which has changed.
-
updateGraph
private void updateGraph()
-
consistency
public void consistency(Store store)
Description copied from class:ConstraintIt is a (most probably incomplete) consistency function which removes the values from variables domains. Only values which do not have any support in a solution space are removed.- Specified by:
consistencyin classConstraint- Parameters:
store- constraint store within which the constraint consistency is being checked.
-
removeLevel
public void removeLevel(int level)
Description copied from interface:StatefulThis function is called in case of the backtrack, so a constraint can clear the queue of changed variables which is no longer valid. This function is called *before* all timestamps, variables, mutablevariables have reverted to their previous value.- Specified by:
removeLevelin interfaceStateful- Parameters:
level- the level which is being removed.
-
removeLevelLate
public void removeLevelLate(int level)
Description copied from interface:RemoveLevelLateThis function is called in case of the backtrack. It is called after all timestamps, variables, mutablevariables have reverted to their values *after* removing the level.- Specified by:
removeLevelLatein interfaceRemoveLevelLate- Parameters:
level- the level which is being removed.
-
toString
public java.lang.String toString()
Identifiers- Overrides:
toStringin classConstraint
-
-