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

org.chocosolver.solver.constraints.extension.nary.PropLargeCSP 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) 2020, 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.extension.nary;

import org.chocosolver.solver.constraints.Propagator;
import org.chocosolver.solver.constraints.PropagatorPriority;
import org.chocosolver.solver.constraints.extension.Tuples;
import org.chocosolver.solver.variables.IntVar;
import org.chocosolver.util.ESat;

/**
 * 
* * @author Charles Prud'homme * @since 08/06/11 */ public abstract class PropLargeCSP extends Propagator { protected final R relation; protected PropLargeCSP(IntVar[] vars, R relation) { super(vars, PropagatorPriority.QUADRATIC, true); this.relation = relation; } public final R getRelation() { return relation; } @Override public ESat isEntailed() { if (isCompletelyInstantiated()) { int[] tuple = new int[vars.length]; for (int i = 0; i < vars.length; i++) { tuple[i] = vars[i].getValue(); } return ESat.eval(relation.isConsistent(tuple)); } return ESat.UNDEFINED; } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("CSPLarge({"); for (int i = 0; i < vars.length; i++) { if (i > 0) { sb.append(", "); } sb.append(vars[i]).append(", "); } sb.append("})"); return sb.toString(); } /** * Extract the tuples from this internal data structure * @return a tuples object */ public Tuples extractTuples(){ return relation.convert(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy