- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Runnable[]Constant that should be returned to notify the solver that there are no branches to create any more and that the current state should be considered as a solution.static final SymbolicBranching[] -
Method Summary
Modifier and TypeMethodDescriptionSequential Search combinator that linearly considers a list of branching generator.static Function<IntExpression, Integer> boundImpactValueSelector(IntExpression objective) Bound-Impact value selector.static Runnable[]static SymbolicModel[]branch(SymbolicModel... branches) branchesInsertingNode(SeqVar[] seqVars, int[][] distMatrix) branchesInsertingNode(SeqVar[] seqVars, TriFunction<Integer, Integer, Integer, Integer> detourCost) Generates all branches inserting a node, sorted by a given detour cost.branchOnPresentStarts(IntervalVar... vars) static Runnable[]static Runnable[]branchOnStatus(CPIntervalVar... vars) branchOnStatusThenStarts(CPIntervalVar... vars) conflictOrderingSearch(Supplier<IntExpression> variableSelector, Function<IntExpression, Integer> valueSelector) Conflict Ordering SearchConflict Ordering Search with default variable selector (first-fail min dom) and value selector (min value).fds(CPIntervalVar[] intervals) fds(IntervalVar[] intervals) firstFailBinary(IntExpression... x) First-Fail Binary search strategy.firstFailBinary(SeqVar... seqVars) firstFailNary(IntExpression... x) First-Fail N-Ary search strategy.heuristicBinary(Supplier<IntExpression> variableSelector) Binary Branching with custom variable heuristic and natural value ordering.heuristicBinary(Supplier<IntExpression> variableSelector, Function<IntExpression, Integer> valueSelector) Binary Branching with custom variable and value heuristics.heuristicNary(Supplier<IntExpression> variableSelector) N-ary Branching with custom variable heuristic and natural value ordering.heuristicNary(Supplier<IntExpression> variableSelector, Function<Integer, Integer> valueHeuristic) N-ary Branching with custom variable and value heuristics.lastConflict(Supplier<IntExpression> variableSelector, Function<IntExpression, Integer> valueSelector) Last conflict heuristic Attempts to branch first on the last variable that caused an InconsistencylimitedDiscrepancy(Supplier<Runnable[]> branching, int maxDiscrepancy) Limited Discrepancy Search combinator that limits the number of right decisionsstatic Supplier<IntExpression> It selects the first not fixed variable with the smallest domain.static OptionalIntnodeSelector(SeqVar[] seqVars, int[] nodes, BiFunction<SeqVar, Integer, Integer> nodeCost) Generic node selector for sequence variables.static OptionalIntnodeSelector(SeqVar[] seqVars, int[] nodes, BiFunction<SeqVar, Integer, Integer> nodeCost, BiFunction<Integer, Integer, Integer> nodeCostAggr) Generic node selector for sequence variables.static <N extends Comparable<N>>
OptionalIntMinimum selector.static <T,N extends Comparable<N>>
TMinimum selector.static <T,N extends Comparable<N>>
TMinimum selector.static <T,N extends Comparable<N>>
TMinimum selector.setTimes(IntervalVar[] intervals) setTimes(IntervalVar[] intervals, IntFunction tieBreaker) The SetTimes branching search is a branching scheme for scheduling problems with "regular" constraints between the tasks (e.g., precedence constraints).staticOrderBinary(Function<IntExpression, Integer> valueSelector, IntExpression... xs) Binary Branching with static variable ordering and custom value heuristic.staticOrderBinary(IntExpression... xs) Binary Branching with static variable ordering and natural value ordering.staticOrderNary(IntExpression... xs) N-ary Branching with static variable ordering and natural value ordering.static Supplier<IntExpression>
-
Field Details
-
EMPTY
Constant that should be returned to notify the solver that there are no branches to create any more and that the current state should be considered as a solution.- See Also:
-
EMPTY_SYMB
-
-
Method Details
-
branch
- Parameters:
branches- the ordered closures for the child branches ordered from left to right in the depth first search.- Returns:
- an array with those branches
- See Also:
-
branch
-
selectMin
Minimum selector.Example of usage.
IntVar xs = selectMin(x,xi -> xi.size() > 1,xi -> xi.size());- Type Parameters:
T- the type of the elements in x, for instanceIntVarN- the type on which the minimum is computed, for instanceInteger- Parameters:
x- the array on which the minimum value is searchedp- the predicate that filters the element eligible for selectionf- the evaluation function that returns a comparable when applied on an element of x- Returns:
- the minimum element in x that satisfies the predicate p or null if no element satisfies the predicate.
-
selectMin
public static <T,N extends Comparable<N>> T selectMin(Iterable<T> items, Predicate<T> p, Function<T, N> f) Minimum selector.Example of usage.
int i = selectMin( IntStream.range(0, n).boxed().toList(), qi -> q[qi].size() > 1, qi -> q[qi].size() );- Type Parameters:
T-N-- Parameters:
items- the iterable on which the minimum value is searchedp- the predicate that filters the element eligible for selectionf- the evaluation function that returns a comparable when applied on an element of items- Returns:
- the minimum element in items that satisfies the predicate p
-
selectMin
public static <T,N extends Comparable<N>> T selectMin(T[] x, int n, Predicate<T> p, Function<T, N> f) Minimum selector.Example of usage.
IntVar xs = selectMin(x,n, xi -> xi.size() > 1,xi -> xi.size());- Type Parameters:
T- the type of the elements in x, for instanceIntVarN- the type on which the minimum is computed, for instanceInteger- Parameters:
x- the array on which the minimum value is searchedn- the n first elements from x that must be consideredp- the predicate that filters the element eligible for selectionf- the evaluation function that returns a comparable when applied on an element of x- Returns:
- the minimum element in x that satisfies the predicate p or null if no element satisfies the predicate.
-
selectMin
public static <N extends Comparable<N>> OptionalInt selectMin(int[] x, int n, Predicate<Integer> p, Function<Integer, N> f) Minimum selector.Example of usage.
OptionalInt i = selectMin(values,n, i -> x[i].isFixed() > 1, i -> x[i].size());- Parameters:
x- the array on which the minimum value is searchedn- the n first elements from x that must be consideredp- the predicate that filters the element eligible for selectionf- the evaluation function that returns a comparable when applied on an element of x- Returns:
- the minimum element in x that satisfies the predicate p or null if no element satisfies the predicate.
-
heuristicBinary
Binary Branching with custom variable heuristic and natural value ordering.- Parameters:
variableSelector- returns the next variable to bind, null if all variables are fixed- Returns:
- a static branching strategy, the minimum value of the variable domain is attempted on the left, and removed on the right
-
heuristicBinary
public static Supplier<Runnable[]> heuristicBinary(Supplier<IntExpression> variableSelector, Function<IntExpression, Integer> valueSelector) Binary Branching with custom variable and value heuristics.- Parameters:
variableSelector- the variable heuristic, returns the variable on which the branching is applied null if all variables are fixedvalueSelector- given the variable, returns the value assigned in the left branch, and removed fin the right branch
-
heuristicNary
N-ary Branching with custom variable heuristic and natural value ordering.- Parameters:
variableSelector- returns the variable on which the n-ary branching is applied null if all variables are fixed- Returns:
- an n-ary branching strategy with the variable heuristic and natural value ordering (increasing order).
-
heuristicNary
public static Supplier<Runnable[]> heuristicNary(Supplier<IntExpression> variableSelector, Function<Integer, Integer> valueHeuristic) N-ary Branching with custom variable and value heuristics.- Parameters:
variableSelector- returns the variable on which the n-ary branching is appliedvalueHeuristic- the branches for each value are ordered according to the value of this function (in increasing order). This function is called once for each value in the variable domain to sort them according to the heuristic before creating the branches in the sorted order.- Returns:
- an n-ary branching strategy
-
staticOrderNary
N-ary Branching with static variable ordering and natural value ordering.- Parameters:
xs- the variable array to fix- Returns:
- an n-ary branching strategy with static variable ordering and natural value ordering (increasing order).
-
staticOrderBinary
Binary Branching with static variable ordering and natural value ordering.- Parameters:
xs- the variable array to fix- Returns:
- a binary static branching strategy, min value on the left, remove it on the right
-
staticOrderBinary
public static Supplier<Runnable[]> staticOrderBinary(Function<IntExpression, Integer> valueSelector, IntExpression... xs) Binary Branching with static variable ordering and custom value heuristic.- Parameters:
valueSelector- the value heuristic, given a variable, returns the value to which it must be assigned on the left branch, and removed on the right branchxs- the variable array to fix,- Returns:
- a binary static branching strategy on the variable, but the value is selected by the heuristic on the left, removed on the right branches
-
firstFailBinary
First-Fail Binary search strategy. Selects the first not fixed variable with smallest domain. Then it creates two branches. The left branch assigning the variable to its minimum value. The right branch removing this minimum value from the domain.- Parameters:
x- the variable on which the first fail strategy is applied.- Returns:
- a first-fail branching strategy
-
firstFailNary
First-Fail N-Ary search strategy. It selects the first variable with a domain larger than one. Then it creates one branch for each value in increasing order.- Parameters:
x- the variable on which the first fail strategy is applied.- Returns:
- a first-fail n-ary branching strategy
-
and
Sequential Search combinator that linearly considers a list of branching generator. One branching of this list is executed when all the previous ones are exhausted (they return an empty array).- Parameters:
choices- the branching schemes considered sequentially in the sequential by path in the search tree- Returns:
- a branching scheme implementing the sequential search
- See Also:
-
limitedDiscrepancy
public static Supplier<Runnable[]> limitedDiscrepancy(Supplier<Runnable[]> branching, int maxDiscrepancy) Limited Discrepancy Search combinator that limits the number of right decisions- Parameters:
branching- a branching schememaxDiscrepancy- a discrepancy limit (non negative number)- Returns:
- a branching scheme that cuts off any path accumulating a discrepancy beyond the limit maxDiscrepancy
- See Also:
-
minDomVariableSelector
It selects the first not fixed variable with the smallest domain.- Parameters:
xs- the variable array to fix- Returns:
- a supplier that returns the first not fixed variable with the smallest domain, null if all variables are fixed
-
staticOrderVariableSelector
-
lastConflict
public static Supplier<Runnable[]> lastConflict(Supplier<IntExpression> variableSelector, Function<IntExpression, Integer> valueSelector) Last conflict heuristic Attempts to branch first on the last variable that caused an InconsistencyLecoutre, C., Saïs, L., Tabary, S., Vidal, V. (2009). Reasoning from last conflict (s) in constraint programming. Artificial Intelligence, 173(18), 1592-1614.
- Parameters:
variableSelector- returns the next variable to bindvalueSelector- given a variable, returns the value to which it must be assigned on the left branch (and excluded on the right)
-
conflictOrderingSearch
public static Supplier<Runnable[]> conflictOrderingSearch(Supplier<IntExpression> variableSelector, Function<IntExpression, Integer> valueSelector) Conflict Ordering SearchGay, S., Hartert, R., Lecoutre, C., Schaus, P. (2015). Conflict ordering search for scheduling problems. In International conference on principles and practice of constraint programming (pp. 140-148). Springer.
- Parameters:
variableSelector- returns the next variable to bind (fall back heuristic)valueSelector- given a variable, returns the value to which it must be assigned on the left branch (and excluded on the right)
-
conflictOrderingSearch
Conflict Ordering Search with default variable selector (first-fail min dom) and value selector (min value).Gay, S., Hartert, R., Lecoutre, C., Schaus, P. (2015). Conflict ordering search for scheduling problems. In International conference on principles and practice of constraint programming (pp. 140-148). Springer.
-
firstFailBinary
-
nodeSelector
public static OptionalInt nodeSelector(SeqVar[] seqVars, int[] nodes, BiFunction<SeqVar, Integer, Integer> nodeCost) Generic node selector for sequence variables.Example of usage.
OptionalInt node = nodeSelector(routes, nodes, (seqvar, node) -> seqvar.nInsert(node));- Parameters:
seqVars- sequences variables in the problemnodes- nodes over which the sequence variables are relatednodeCost- heuristic cost used to select the node, summed over all sequences- Returns:
- node with the minimum cost, summed over all sequence variables
-
nodeSelector
public static OptionalInt nodeSelector(SeqVar[] seqVars, int[] nodes, BiFunction<SeqVar, Integer, Integer> nodeCost, BiFunction<Integer, Integer, Integer> nodeCostAggr) Generic node selector for sequence variables.Example of usage.
OptionalInt node = nodeSelector(routes, nodes, (seqvar, node) -> seqvar.nInsert(node), (c1, c2) -> c1 + c2);- Parameters:
seqVars- sequences variables in the problemnodes- nodes over which the sequence variables are relatednodeCost- heuristic cost used to select the node, summed over all sequencesnodeCostAggr- aggregator to combine the heuristic cost of two sequence variables- Returns:
- node with the minimum cost, summed over all sequence variables
-
branchesInsertingNode
public static Supplier<Function<Integer,Runnable[]>> branchesInsertingNode(SeqVar[] seqVars, TriFunction<Integer, Integer, Integer, Integer> detourCost) Generates all branches inserting a node, sorted by a given detour cost.Example of usage.
int[][] d = ... // distance matrix between nodes Function<Integer, Runnable[]> branchGenerator = branchesInsertingNode(seqvar, (pred, node, succ) -> d[pred][node] + d[node][succ] - d[pred][succ]).get(); Runnable[] branches = branchGenerator.apply(node); // all branches inserting the given node- Parameters:
seqVars- sequence over which the node may be inserteddetourCost- detour cost for inserting a node between a predecessor and a successor; lower values are tried first. Arguments are(pred, node succ), wherepredis the node after which the insertion happen,nodeis the node to insert andsuccthe current node after pred- Returns:
-
branchesInsertingNode
-
boundImpactValueSelector
Bound-Impact value selector. Gives a value selector yielding the value leading to the smallest decrease on the objectiveThis value selection strategy was introduced in: Fages, J. G., Prud’Homme, C. Making the first solution good! In 2017 IEEE 29th International Conference on Tools with Artificial Intelligence (ICTAI). IEEE.
- Parameters:
objective- objective whose impact must be measured- Returns:
- value decreasing the less the objective lower bound. Null if no value is valid for the variable
-
setTimes
The SetTimes branching search is a branching scheme for scheduling problems with "regular" constraints between the tasks (e.g., precedence constraints). The branching scheme is based on the following principle: - Select the earliest start time among the non postponed tasks - Branch on the start time of the task (Le Pape, C., Couronne, P., Vergamini, D., and Gosselin, V. (1995). Time-versus-capacity compromises in project scheduling)- Parameters:
intervals- tasks that must be decidedtieBreaker- how to select the best task to branch on when several have the same earliest start time- Returns:
- set time branching
-
setTimes
-
fds
-
fds
-
branchOnStartMin
-
branchOnStatus
-
branchOnPresentStarts
-
branchOnStatus
-
branchOnStatusThenStarts
-