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

org.xcsp.modeler.problems.MagicSequence Maven / Gradle / Ivy

Go to download

Java Tools for parsing XCSP3 instances, compiling JvCSP3 models, and checking solutions. For more information about XCSP3, follow www.xcsp.org

The newest version!
/**
 * AbsCon - Copyright (c) 2017, CRIL-CNRS - [email protected]
 * 
 * All rights reserved.
 * 
 * This program and the accompanying materials are made available under the terms of the CONTRAT DE LICENCE DE LOGICIEL LIBRE CeCILL which accompanies this
 * distribution, and is available at http://www.cecill.info
 */
package org.xcsp.modeler.problems;

import org.xcsp.common.IVar.Var;
import org.xcsp.modeler.api.ProblemAPI;

public class MagicSequence implements ProblemAPI {
	int n;

	@Override
	public void model() {
		Var[] x = array("x", size(n), dom(range(n)), "x[i] is the ith value of the sequence");

		cardinality(x, range(n), occurExactly(x)).note("each value i occurs exactly x[i] times in the sequence");

		block(() -> {
			sum(x, EQ, n);
			sum(x, range(-1, n - 1), EQ, 0);
		}).tag(REDUNDANT_CONSTRAINTS);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy