You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: solver/src/main/java/org/chocosolver/solver/constraints/nary/alldifferent/algo/AlgoAllDiffBimodal.java
+69-97Lines changed: 69 additions & 97 deletions
Original file line number
Diff line number
Diff line change
@@ -43,47 +43,51 @@ public class AlgoAllDiffBimodal implements IAlldifferentAlgorithm {
43
43
publicstaticfinalStringPARTIAL = "AC_PARTIAL";
44
44
publicstaticfinalStringTUNED = "AC_TUNED";
45
45
46
+
publicstaticfinalintBFS = 0;
47
+
publicstaticfinalintDFS = 1;
48
+
publicstaticfinalintPRUNE = 2;
49
+
46
50
Propagator<IntVar> aCause;
47
51
Modelmodel;
48
52
protectedIntVar[] vars;
49
53
privatefinalintR; // Total number of variables
50
-
privateTrackingListvariablesDynamic; // The dynamic list of uninstantiated variables
54
+
privatefinalTrackingListvariablesDynamic; // The dynamic list of uninstantiated variables
51
55
privatefinalintminValue;
52
56
privatefinalintmaxValue;
53
57
privatefinalintD; // Total number of values
54
-
privateTrackingListvaluesDynamic; // The dynamic list of values present in the domain of at least one variable and not matched to an instantiated variable
58
+
privatefinalTrackingListvaluesDynamic; // The dynamic list of values present in the domain of at least one variable and not matched to an instantiated variable
55
59
privatefinalintfail; // Symbol signifying we couldn't find an augmenting path
56
-
privateBipartiteMatchingmatching; // The matching used dynamically
57
-
privateint[] parentBFS; // Array storing the parent of each value-node in the BFS tree
58
-
privateint[] queueBFS; // Queue of the variables to explore during the BFS
60
+
privatefinalBipartiteMatchingmatching; // The matching used dynamically
61
+
privatefinalint[] parentBFS; // Array storing the parent of each value-node in the BFS tree
62
+
privatefinalint[] queueBFS; // Queue of the variables to explore during the BFS
59
63
privateintheadBFS;
60
64
privateinttailBFS;
61
65
privateintminValSearchedNodes; // For failure explanation
62
66
privateintmaxValSearchedNodes; // For failure explanation
63
67
privatefinalintt_node; // Symbol representing the artificial sink node of the Residual Graph
64
-
privateTrackingListcomplementSCC; // List of the values that are not in the discovered SCC
65
-
privateint[] tarjanStack; // The stack used in Tarjan's algorithm to find the SCCs
68
+
privatefinalTrackingListcomplementSCC; // List of the values that are not in the discovered SCC
69
+
privatefinalint[] tarjanStack; // The stack used in Tarjan's algorithm to find the SCCs
66
70
privateinttopTarjan;
67
-
privateboolean[] inStack; // Boolean array informing the presence of a value in the stack
68
-
privateint[] pre; // Pre visit order of the values
69
-
privateint[] low; // Low point of the values
71
+
privatefinalboolean[] inStack; // Boolean array informing the presence of a value in the stack
72
+
privatefinalint[] pre; // Pre visit order of the values
73
+
privatefinalint[] low; // Low point of the values
70
74
privateintnumVisit; // Current visit number of the DFS in Tarjan's algorithm
71
75
privatebooleanfirstSCC; // Indicates if the discovered SCC is the first discovered one in the current propagation
72
76
privatefinalStringmode; // Indicating the mode in which we are using the procedure (Classic, Complement, Hybrid or Tuned)
73
77
privatebooleanpruned; // True if some variable-value pairs were pruned
74
78
75
-
privateint[] SCCpartition; // Partition of the values relative to the SCCs
76
-
privateint[] SCCindices; // End point of each SCC in the partition
79
+
privatefinalint[] sccPartition; // Partition of the values relative to the SCCs
80
+
privatefinalint[] sccIndices; // End point of each SCC in the partition
77
81
privateintnumberOfSCCs;
78
-
privateint[] SCCbelonging; // index of the SCC each value belongs to
79
-
privateint[] upToDateSCC; // indicating for each value if its SCC has been updated in this call
82
+
privatefinalint[] sccBelonging; // index of the SCC each value belongs to
83
+
privatefinalint[] upToDateSCC; // indicating for each value if its SCC has been updated in this call
80
84
privateintupdateKey; // This key is incremented at each call, to reset the upToDate information
intpointerVar = valuesDynamic.getPrevious(vars[var].getLB()); //Optimisation: start iterating from the lower bound instead of the beginning of the list (the list is sorted in ascending order)
333
327
intvar_ub = vars[var].getUB(); //Optimisation
334
328
while (valuesDynamic.hasNext(pointerVar) && pointerVar < var_ub) { // Explore all the branches going out of var in the DFS tree
335
-
pointerVar = valuesDynamic.trackLeft(pointerVar); // Go back in the list of unvisited values
329
+
pointerVar = valuesDynamic.trackPrev(pointerVar); // Go back in the list of unvisited values
336
330
337
331
while(valuesDynamic.hasNext(pointerVar) && pointerVar < var_ub && !vars[var].contains(valuesDynamic.getNext(pointerVar))) { // Go to the last consecutive non-domain value
338
332
pointerVar = valuesDynamic.getNext(pointerVar);
@@ -377,7 +371,7 @@ private void process(int var, int val) throws ContradictionException {
377
371
378
372
379
373
/**
380
-
* In this function we prune all the arcs coming from the variables of the discovered SCC and pointing toward valyes outside the discovered SCC
374
+
* In this function we prune all the arcs coming from the variables of the discovered SCC and pointing toward values outside the discovered SCC
0 commit comments