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

javax.constraints.impl.constraint.ConstraintTrue Maven / Gradle / Ivy

Go to download

JCP Standard JSR331 “Java Constraint Programming API”. It is used for Modeling and Solving Constraint Satisfaction and Optimization Problems using Java and off-the-shelf Constraint/Linear Solvers

There is a newer version: 2.3.1
Show newest version
//=============================================
// J A V A  C O M M U N I T Y  P R O C E S S
// 
// J S R  3 3 1
// 
// Common Implementation
// 
//============================================= 
package javax.constraints.impl.constraint;


import javax.constraints.Problem;
import javax.constraints.VarBool;
import javax.constraints.impl.AbstractConstraint;


/**
 * This is a constant constraint that always will be successfully
 * posted and executed without changing anything in its environment.
 */

public class ConstraintTrue extends AbstractConstraint {

	public ConstraintTrue(Problem problem) {
		super(problem);
	}

	public void post() {
	}

	/**
	 * @return a VarBool variable that is equal to 1
	 */
	public VarBool asBool() {
		Problem p = getProblem();
		VarBool var = p.variableBool();
		p.post(var, "=", 1);
		return var;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy