/// <summary> /// Extract a snapshot from the constraint network. /// </summary> /// <param name="constraintNetwork">Constraint network.</param> /// <param name="solutionSnapshot">Solution snapshot.</param> /// <returns>True if a snapshot was extracted, False if the snapshot could not be extracted.</returns> internal bool ExtractFrom(ConstraintNetwork constraintNetwork, out SolutionSnapshot solutionSnapshot) { _constraintNetwork = constraintNetwork; var solverVariables = constraintNetwork.GetSolverVariables(); var assignment = new SnapshotLabelAssignment(solverVariables); _variables = new List <VariableBase>(constraintNetwork.GetVariables()); var status = Backtrack(0, assignment, constraintNetwork); solutionSnapshot = status ? ConvertSnapshotFrom(assignment, constraintNetwork) : SolutionSnapshot.Empty; return(status); }
private bool AllVariablesTested(int variableIndex) { return(variableIndex + 1 >= _constraintNetwork.GetVariables().Count); }