Skip to content

Commit

Permalink
Merge branch 'master' of github.com:augustindelecluse/choco-solver
Browse files Browse the repository at this point in the history
  • Loading branch information
Augustin Delecluse committed Apr 11, 2024
2 parents daa0f65 + 5de47dd commit 15327da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public Model makeModel() {
IntVar capacity = model.intVar("capacity", 1);
for (int i = 0; i < jobShopInstance.nJobs; i++) {
for (int j = 0; j < jobShopInstance.nMachines; j++) {
start[i][j] = model.intVar("start_"+i+"_"+j, 0, jobShopInstance.horizon);
start[i][j] = model.intVar("start_"+i+"_"+j+"_M" + jobShopInstance.machine[i][j], 0, jobShopInstance.horizon);
end[i][j] = model.offset(start[i][j], jobShopInstance.duration[i][j]);
}
}
Expand All @@ -212,7 +212,7 @@ public Model makeModel() {

for (int a1 = 0; a1 < start_m.length; a1++) {
for (int a2 = a1+1; a2 < start_m.length ; a2++) {
BoolVar a1_before_a2 = model.boolVar();
BoolVar a1_before_a2 = model.boolVar(start_m[a1].getName().replace("start", "end") + " < " + start_m[a2].getName());
BoolVar a2_before_a1 = model.boolNotView(a1_before_a2);
Constraint end_a1_before_start_a2 = precedence(end_m[a1], start_m[a2]);
Constraint end_a2_before_start_a1 = precedence(end_m[a2], start_m[a1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class CompactConstraintNetwork {
private Map<Variable, VarNode> varNodes = new HashMap<>();
private Map<IView<?>, Variable> viewToClosestVariableToObjective = new HashMap<>();
private Variable objective;
protected Set<Variable> processedVariables = new HashSet<>(); // variables already processed
protected Set<Variable> processedVariables = new HashSet<>(); // variables already processed (all of them)
protected Set<Variable> variablesInScope = new HashSet<>(); // variables already processed in the scope of a constraint
protected Set<Propagator<?>> processedContraints = new HashSet<>(); // constraints already processed
protected Queue<Variable> parentVars = new ArrayDeque<>(); // variables to process at the current iteration
protected Set<Variable> childVars = new HashSet<>(); // new variables to process for the next iteration
Expand Down Expand Up @@ -67,6 +68,7 @@ private DirectedPropagatorEdge(Propagator<?> propagator, Variable goingTowardObj
public boolean isActive() {
return propagator.isActive() && !goingTowardObjective.isInstantiated();
}

}

private static boolean isConcreteVar(Variable variable) {
Expand Down Expand Up @@ -131,16 +133,18 @@ private void storeShortestPathToObjective() {
if (!processedContraints.contains(p)) {
// for each new discovered constraint
processedContraints.add(p);
variablesInScope.clear();
for (Variable variable : p.getVars()) {
for (Variable child : getConcreteVars(variable)) {
if (!processedVariables.contains(child) && !isConstant(child)) {
if (!processedVariables.contains(child) && !isConstant(child) && !variablesInScope.contains(child)) {
// stores the path for reaching this variable
childVars.add(child);
if (!varNodes.containsKey(child)) {
varNodes.put(child, new VarNode(child, distance));
}
varNodes.get(child).addParent(new DirectedPropagatorEdge(p, parent, child));
}
variablesInScope.add(child);
}
}
}
Expand Down

0 comments on commit 15327da

Please sign in to comment.