copy() 공개 메소드

public copy ( ) : Assignment
리턴 Assignment
예제 #1
0
        private Object getMinConflictValueFor(Variable var, Assignment assignment,
                                              CSP csp)
        {
            List <Constraint> constraints  = csp.getConstraints(var);
            Assignment        duplicate    = assignment.copy();
            int           minConflict      = int.MAX_VALUE;
            List <Object> resultCandidates = new List <Object>();

            foreach (Object value in csp.getDomain(var))
            {
                duplicate.setAssignment(var, value);
                int currConflict = countConflicts(duplicate, constraints);
                if (currConflict <= minConflict)
                {
                    if (currConflict < minConflict)
                    {
                        resultCandidates.clear();
                        minConflict = currConflict;
                    }
                    resultCandidates.Add(value);
                }
            }
            if (!resultCandidates.isEmpty())
            {
                return(Util.selectRandomlyFromList(resultCandidates));
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
 protected void fireStateChanged(Assignment assignment, CSP csp)
 {
     foreach (CSPStateListener listener in listeners)
     {
         listener.stateChanged(assignment.copy(), csp.copyDomains());
     }
 }
예제 #3
0
        private Object getMinConflictValueFor(Variable var, Assignment assignment,
                CSP csp) {
		List<Constraint> constraints = csp.getConstraints(var);
		Assignment duplicate = assignment.copy();
		int minConflict = int.MAX_VALUE;
		List<Object> resultCandidates = new List<Object>();
        foreach (Object value in csp.getDomain(var))
        {
			duplicate.setAssignment(var, value);
			int currConflict = countConflicts(duplicate, constraints);
			if (currConflict <= minConflict) {
				if (currConflict < minConflict) {
					resultCandidates.clear();
					minConflict = currConflict;
				}
				resultCandidates.Add(value);
			}
		}
		if (!resultCandidates.isEmpty())
			return Util.selectRandomlyFromList(resultCandidates);
		else
			return null;
	}
예제 #4
0
 protected void fireStateChanged(Assignment assignment, CSP csp)
 {
     foreach (CSPStateListener listener in listeners)
         listener.stateChanged(assignment.copy(), csp.copyDomains());
 }