All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.chocosolver.solver.constraints.nary.alldifferent.PropAllDiffAC Maven / Gradle / Ivy

There is a newer version: 4.10.17
Show newest version
/*
 * This file is part of choco-solver, http://choco-solver.org/
 *
 * Copyright (c) 2023, 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) } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy