org.chocosolver.solver.constraints.nary.alldifferent.PropAllDiffAC Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of choco-solver Show documentation
Show all versions of choco-solver Show documentation
Open-source constraint solver.
The newest version!
/*
* This file is part of choco-solver, http://choco-solver.org/
*
* Copyright (c) 2024, IMT Atlantique. All rights reserved.
*
* Licensed under the BSD 4-clause license.
*
* See LICENSE file in the project root for full license information.
*/
package org.chocosolver.solver.constraints.nary.alldifferent;
import org.chocosolver.solver.constraints.Propagator;
import org.chocosolver.solver.constraints.PropagatorPriority;
import org.chocosolver.solver.constraints.nary.alldifferent.algo.AlgoAllDiffAC;
import org.chocosolver.solver.constraints.nary.alldifferent.algo.AlgoAllDiffACFast;
import org.chocosolver.solver.exception.ContradictionException;
import org.chocosolver.solver.variables.IntVar;
import org.chocosolver.util.ESat;
/**
* Propagator for AllDifferent AC constraint for integer variables
*
* Uses Regin algorithm
* Runs in O(m.n) worst case time for the initial propagation
* but has a good average behavior in practice
*
* Runs incrementally for maintaining a matching
*
*
* @author Jean-Guillaume Fages
*/
public class PropAllDiffAC extends Propagator {
//***********************************************************************************
// VARIABLES
//***********************************************************************************
protected AlgoAllDiffAC filter;
//***********************************************************************************
// CONSTRUCTORS
//***********************************************************************************
/**
* AllDifferent constraint for integer variables
* enables to control the cardinality of the matching
*
* @param variables array of integer variables
*/
public PropAllDiffAC(IntVar[] variables, boolean fast) {
super(variables, PropagatorPriority.QUADRATIC, false);
this.filter = fast ?
new AlgoAllDiffACFast(variables, this):
new AlgoAllDiffAC(variables, this);
}
//***********************************************************************************
// PROPAGATION
//***********************************************************************************
@Override
public void propagate(int evtmask) throws ContradictionException {
filter.propagate();
}
@Override
public ESat isEntailed() {
return ESat.TRUE; // redundant propagator (used with PropAllDiffInst)
}
}