/* * CSP Project * Authors: * Jay Bernardo * Matt Rancourt * * File: FailState.java * * Contains the FailState class. This transition determines if, given the variables in * M, the formula F is unsatisfiable. * */ class FailState extends Transition{ public FailState(TransitionAssignment M, CSP F){ super(M, F); } /** * Determines if the assignment given in M cannot satisfy F * * @return 1 on failstate is true * undefined otherwise * */ public int doTransition() throws InvalidVariableValueException, RelationNumberOutOfBoundsException, RankOutOfBoundsException, InvalidVariableNamesLengthException, VariablePositionOutOfBoundsException{ // Iterate over all variables in M -- but only if it // has a decided variable (this is the only case we can fail) if(M.containsADecidedVariable == false){ int i = 0; for(; i < F.numberOfRelations(); i ++){ Relation thisRelation = F.getRelationAt(i); // If there are no unassigned variables, and the relation is not // satisfied, then we have a failure if(thisRelation.findUnassignedVariableName() == null){ if(thisRelation.isSatisfied() == false){ return 1; } } } } return -1; } }