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

javax.constraints.impl.search.selectors.VarSelectorImpl 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
package javax.constraints.impl.search.selectors;

import javax.constraints.SearchStrategy;
import javax.constraints.Var;
import javax.constraints.VarSelector;

/**
 * This abstract defines an interface for the selection of the constrained
 * variable from a given array of variables. 
 */

abstract public class VarSelectorImpl implements VarSelector {
	
	SearchStrategy strategy;

	/**
	 * Constructor from SearchStrategy
	 */
	public VarSelectorImpl(SearchStrategy strategy) {
		this.strategy = strategy;
	}
	
	/**
	 * Return a search strategy with which this selector is associated
	 * @return
	 */
	public final SearchStrategy getSearchStrategy() {
		return strategy;
	}

	final public Var[] getVars() {
		return strategy.getVars();
	}

	/**
	 * Returns the index of the selected variable in the array of constrained
	 * variables passed to the selector as a constructor parameter. If no
	 * variables to select, it returns -1;
	 */
	abstract public int select();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy