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.7
-
-
Field Summary
Fields Modifier and Type Field Description IntVar
costVariable
The cost variableboolean
disableQueueVariable
Disables the queue variable function during consistencyprivate static boolean
DO_INSTRUMENTATION
(package private) static java.util.concurrent.atomic.AtomicInteger
idNumber
Instance counterjava.util.Map<IntVar,VarHandler>
map
The variables and their handlersPruning
network
The networkint
previousLevel
java.util.Set<IntVar>
queue
The set of queued variablesprivate static int
QUEUE_INDEX
private static boolean
SHOW_LEVEL
(package private) Statistics
statistics
-
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 private
NetworkFlow(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 void
consistency(Store store)
It is a (most probably incomplete) consistency function which removes the values from variables domains.int
getConsistencyPruningEvent(Var var)
It retrieves the pruning event which causes reevaluation of the constraint.int
getDefaultConsistencyPruningEvent()
void
impose(Store store)
It imposes the constraint in a given store.void
queueVariable(int level, Var variable)
Search & Backtrackingvoid
removeLevel(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.void
removeLevelLate(int level)
This function is called in case of the backtrack.java.lang.String
toString()
Identifiersprivate void
updateGraph()
-
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:Constraint
It retrieves the pruning event which causes reevaluation of the constraint.- Overrides:
getConsistencyPruningEvent
in 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:
getDefaultConsistencyPruningEvent
in classConstraint
-
impose
public void impose(Store store)
Description copied from class:Constraint
It imposes the constraint in a given store.- Overrides:
impose
in classConstraint
- Parameters:
store
- the constraint store to which the constraint is imposed to.
-
queueVariable
public void queueVariable(int level, Var variable)
Search & Backtracking- Overrides:
queueVariable
in 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:Constraint
It 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:
consistency
in classConstraint
- Parameters:
store
- constraint store within which the constraint consistency is being checked.
-
removeLevel
public void removeLevel(int level)
Description copied from interface:Stateful
This 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:
removeLevel
in interfaceStateful
- Parameters:
level
- the level which is being removed.
-
removeLevelLate
public void removeLevelLate(int level)
Description copied from interface:RemoveLevelLate
This 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:
removeLevelLate
in interfaceRemoveLevelLate
- Parameters:
level
- the level which is being removed.
-
toString
public java.lang.String toString()
Identifiers- Overrides:
toString
in classConstraint
-
-