Exemple #1
0
		public CSP(ArrayList variables, Constraint constraints, Domain domains) 
		{
			this.variables = variables;
			//this.assignment = new Assignment(variables);
			this.domains = domains;
			this.constraints = constraints;
		}
Exemple #2
0
//		private MapCSP(ArrayList variables, Constraint constraints): this(variables, constraints)
//		{
//			//super(variables, constraints);
//			
//		}

		public static CSP getMap() 
		{
			ArrayList variables = new ArrayList();
			variables.Add(WA);
			variables.Add(NT);
			variables.Add(SA);
			variables.Add(Q);
			variables.Add(NSW);
			variables.Add(V);
			variables.Add(T);

			ArrayList colors = new ArrayList();
				colors.Add(RED);
			colors.Add(BLUE);
			colors.Add(GREEN);

			Domain domains = new Domain(variables);
			for (int i = 0; i < variables.Count; i++) 
			{
				string variable = variables[i].ToString();
				domains.addToDomain(variable, colors);
			}

			Hashtable neighbors = new Hashtable();
			addToNeighbors(neighbors, T);
			addToNeighbors(neighbors, WA, NT, SA);
			addToNeighbors(neighbors, NT, WA, SA, Q);
			addToNeighbors(neighbors, SA, WA, NT, Q, NSW, V);
			addToNeighbors(neighbors, Q, NT, SA, NSW);
			addToNeighbors(neighbors, NSW, SA, Q, V);
			addToNeighbors(neighbors, V, SA, NSW);
			Constraint mapConstraints = new MapColoringConstraint(neighbors);

			return new CSP(variables, mapConstraints, domains);
		}
Exemple #3
0
		public static CSP getMap() 
		{    
			if (instance != null) return instance;
            
			ArrayList variables = new ArrayList();
			variables.Add("blue");
			variables.Add("green");
			variables.Add("ivory");
			variables.Add("red");
			variables.Add("yellow");
			variables.Add("coffee");
			variables.Add("milk");
			variables.Add("juice");
			variables.Add("tea");
			variables.Add("water");
			variables.Add("englishman");
			variables.Add("japanese");
			variables.Add("norwegian");
			variables.Add("spaniard");
			variables.Add("ukrainian");
			variables.Add("dog");
			variables.Add("fox");
			variables.Add("horse");
			variables.Add("snails");
			variables.Add("zebra");
			variables.Add("chesterfield");
			variables.Add("kools");
			variables.Add("lucky-strike");
			variables.Add("old-gold");
			variables.Add("parliament");

            
            
			Domain domains = new Domain(variables);
			for (int i = 0; i < variables.Count; i++) 
			{
				string variable = variables[i].ToString();
				domains.addToDomain(variable, "1");
				domains.addToDomain(variable, "2");
				domains.addToDomain(variable, "3");
				domains.addToDomain(variable, "4");
				domains.addToDomain(variable, "5");
			}

            
             
			Constraint housesConstraints = new HousesConstraint();

			instance = new HousesCSP(variables, housesConstraints, domains); 
			return instance;
		}
Exemple #4
0
		private HousesCSP(ArrayList variables, Constraint constraints, Domain domains) : base(variables, constraints, domains)
		{
			//super ;
		}