/* * CSP Project * Authors: * Jay Bernardo * Matt Rancourt * * File: Main.java * * Contains the Main class. This is the starting * point of the entire application * * TODO: Update description once this actually * starts doing things */ // TODO: Remove when testing using ArrayLists is removed import java.util.*; class Main{ public static void main(String args[]) throws Exception{ // TODO: Remove this testing material when finished // Home test /*String r[] = {"a", "b"}; String r1[] = {"!a", "!b"}; String r2[] = {"!b", "d"}; String r3[] = {"!a", "!b", "f"}; String r4[] = {"!f", "z"}; String r5[] = {"!g", "g"}; String r6[] = {"!a", "v"}; ArrayList relations = new ArrayList(); relations.add(new Relation(14, 2, r)); relations.add(new Relation(14, 2, r1)); relations.add(new Relation(14, 2, r2)); relations.add(new Relation(254, 3, r3)); relations.add(new Relation(14, 2, r4)); relations.add(new Relation(14, 2, r5)); relations.add(new Relation(14, 2, r6));*/ // Midterm test /*String r[] = {"a", "b", "c"}; String r1[] = {"a", "b", "!c"}; String r2[] = {"!a", "d"}; String r3[] = {"a", "!b", "c"}; String r4[] = {"!a", "!d"}; String r5[] = {"a", "!b", "!c"}; //String r6[] = {"!a"}; ArrayList relations = new ArrayList(); relations.add(new Relation(254, 3, r)); relations.add(new Relation(254, 3, r1)); relations.add(new Relation(14, 2, r2)); relations.add(new Relation(254, 3, r3)); relations.add(new Relation(14, 2, r4)); relations.add(new Relation(254, 3, r5)); //relations.add(new Relation(2, 1, r6));*/ /*String r[] = {"a", "b"}; String r1[] = {"a", "d", "e"}; String r2[] = {"a", "f", "g"}; String r3[] = {"a", "!d", "f"}; String r4[] = {"a", "!b"}; String r5[] = {"!e", "b", "d"}; ArrayList relations = new ArrayList(); relations.add(new Relation(14, 2, r)); relations.add(new Relation(254, 3, r1)); relations.add(new Relation(16, 3, r2)); relations.add(new Relation(200, 3, r3)); relations.add(new Relation(8, 2, r4)); relations.add(new Relation(100, 3, r5));*/ // Relation 0 test ArrayList relations = new ArrayList(); String r[] = {"a", "b", "c"}; relations.add(new Relation(0, 3, r)); CSP c = new CSP(relations); // Preprocess the CSP to use ONLY positives (no negs) c.preprocess(); TransitionManager t = new TransitionManager(c); t.run(); // Various testing below -- disregard. /* // Satisfaction checker System.out.println("Testing satisfaction checker."); String testBlah[] = {"!x", "y"}; Relation test = new Relation(14, 2, testBlah); test.setVariable("x", 0); test.setVariable("y", 0); test.print(); System.out.println(); System.out.println(test.isSatisfied()); System.out.println("=================="); String testBlah2[] = {"x"}; Relation test2 = new Relation(2, 1, testBlah2); test2.setVariable("x", 0); test2.print(); System.out.println(); System.out.println(test2.isSatisfied()); */ /* // Copy testing System.out.println("\nTesting copying.\nThe original...."); Relation relationToCopy = new Relation(23, 3, r3); relationToCopy.print(); System.out.println("\nCopy..."); Relation newRelation = relationToCopy.duplicate(); newRelation.print(); System.out.println("\nSetting A to 1.\nThe original..."); newRelation.setVariable("a", 1); relationToCopy.print(); System.out.println("\nThe copy...."); newRelation.print(); System.out.println("\nDone doing copy testing"); */ /* // Testing reduce System.out.println("Reduction test"); String reduceVars[] = {"x", "y", "!z"}; Relation testReduce = new Relation(254, 3, reduceVars); testReduce.setVariable("z", 1); testReduce.setVariable("x", 1); testReduce.print(); System.out.println(); testReduce.print(); System.out.println("\nREDUCED: =>"); Relation reduced = testReduce.reduce(); reduced.print(); */ /* // Translation test from lower to rank 3 String lowRankVariables[] = {"a"}; Relation lowRank = new Relation(2, 1, lowRankVariables); Relation highRank = lowRank.translateToRankThree(); highRank.print(); System.out.println(); */ /* // Parse testing System.out.println("Testing Parser"); CSP a = CSP.parse("R12( _s !a b \n )R1(a)R1(\nR1A\nB\n)"); a.setVariable("a", 0); a.print(); */ /* String munge[] = {"a", "!b", "c", "!d", "e", "f", "!g"}; String mungeStringTest[] = SSRelation.mungeVariableNamesIn(munge); System.out.println(mungeStringTest[0]); System.out.println(mungeStringTest[1]); System.out.println(mungeStringTest[2]); //int i = 0; //for(; i < mungeStringTest.length; i ++){ // System.out.print //} System.out.println("ASHASDJOAIWEJFWEOI"); ArrayListmungeVars = SSRelation.mungedVariablesList(munge); Iteratorit = mungeVars.iterator(); while(it.hasNext()){ it.next().print(); System.out.println(); } */ /* // SSR testing String munge[] = {"a", "!b", "c", "!d", "e", "f", "!g"}; SSRelation ssr = new SSRelation(254, 3, SSRelation.mungeVariableNamesIn(munge), SSRelation.mungedVariablesList(munge)); ssr.print(); ssr.setVariable("a", 0); ssr.setVariable("b", 1); ssr.setVariable("c", 0); //ssr.setVariable("d", 1); Relation b = ssr.reduce(); System.out.println(); b.print(); System.out.println(); b.setVariable("e", 0); Relation e = b.reduce(); e.print(); e.setVariable("f", 1); Relation g = e.reduce(); System.out.println(); g.print(); */ } }