/** Test Trinks7 GBase, min pair list. */
  @SuppressWarnings("cast")
  public void testTrinks7GBaseMin() {
    bb =
        new GroebnerBaseSeqIter<BigRational>(
            new ReductionSeq<BigRational>(), new OrderedMinPairlist<BigRational>());

    String exam =
        "(B,S,T,Z,P,W) L "
            + "( "
            + "( 45 P + 35 S - 165 B - 36 ), "
            + "( 35 P + 40 Z + 25 T - 27 S ), "
            + "( 15 W + 25 S P + 30 Z - 18 T - 165 B**2 ), "
            + "( - 9 W + 15 T P + 20 S Z ), "
            + "( P W + 2 T Z - 11 B**3 ), "
            + "( 99 W - 11 B S + 3 B**2 ), "
            + "( B**2 + 33/50 B + 2673/10000 ) "
            + ") ";
    Reader source = new StringReader(exam);
    GenPolynomialTokenizer parser = new GenPolynomialTokenizer(source);
    try {
      F = (PolynomialList<BigRational>) parser.nextPolynomialSet();
    } catch (ClassCastException e) {
      fail("" + e);
    } catch (IOException e) {
      fail("" + e);
    }
    // System.out.println("F = " + F);

    G = bb.GB(F.list);
    assertTrue("isGB( GB(Trinks7) )", bb.isGB(G));
    assertEquals("#GB(Trinks7) == 6", 6, G.size());
    // PolynomialList<BigRational> trinks = new PolynomialList<BigRational>(F.ring,G);
    // System.out.println("G = " + trinks);
  }
  /** Test Trinks7 GBase, syz pair list. */
  @SuppressWarnings("cast")
  public void testTrinks7GBaseSyz() {
    GroebnerBase<BigRational> bbs;
    bbs =
        new GroebnerBaseSeqIter<BigRational>(
            new ReductionSeq<BigRational>(), new OrderedSyzPairlist<BigRational>());

    String exam =
        "(B,S,T,Z,P,W) L "
            + "( "
            + "( 45 P + 35 S - 165 B - 36 ), "
            + "( 35 P + 40 Z + 25 T - 27 S ), "
            + "( 15 W + 25 S P + 30 Z - 18 T - 165 B**2 ), "
            + "( - 9 W + 15 T P + 20 S Z ), "
            + "( P W + 2 T Z - 11 B**3 ), "
            + "( 99 W - 11 B S + 3 B**2 ), "
            + "( B**2 + 33/50 B + 2673/10000 ) "
            + ") ";
    @SuppressWarnings("unused")
    String exam2 =
        "(x,y,z) L "
            + "( "
            + "( z y**2 + 2 x + 1/2 )"
            + "( z x**2 - y**2 - 1/2 x )"
            + "( -z + y**2 x + 4 x**2 + 1/4 )"
            + " )";

    Reader source = new StringReader(exam);
    GenPolynomialTokenizer parser = new GenPolynomialTokenizer(source);
    try {
      F = (PolynomialList<BigRational>) parser.nextPolynomialSet();
    } catch (ClassCastException e) {
      fail("" + e);
    } catch (IOException e) {
      fail("" + e);
    }
    // System.out.println("F = " + F);

    G = bbs.GB(F.list);
    assertTrue("isGB( GB(Trinks7) )", bbs.isGB(G));
    assertEquals("#GB(Trinks7) == 6", 6, G.size());
    // PolynomialList<BigRational> trinks = new PolynomialList<BigRational>(F.ring,G);
    // System.out.println("G = " + trinks);
    assertTrue("isGB( GB(Trinks7) )", bb.isGB(G));

    // Reduction<BigRational> rd = new ReductionSeq<BigRational>();
    // System.out.println("G.contains(F) = " + rd.normalform(G,F.list) );
  }
示例#3
0
  /**
   * main method to be called from commandline <br>
   * Usage: RunSGB [seq|seq+|par|par+] [irr|left|right|two] &lt;file&gt; #procs
   */
  @SuppressWarnings("unchecked")
  public static void main(String[] args) {

    String[] allkinds =
        new String[] {
          "seq", "seq+",
          "par", "par+",
          // "dist", "dist+", ,
          // "disthyb", "disthyb+",
          // "cli"
        }; // must be last
    String[] allmeth = new String[] {"irr", "left", "right", "two"};

    String usage =
        "Usage: RunGB [ "
            + join(allkinds, " | ")
            // + "[port] ] "
            + " ] ["
            + join(allmeth, " | ")
            + "] <file> "
            + "#threads "
            // + "#procs/#threadsPerNode "
            // + "[machinefile] ";
            + "[check] [nolog]";

    if (args.length < 3) {
      System.out.println("args: " + Arrays.toString(args));
      System.out.println(usage);
      return;
    }

    boolean plusextra = false;
    String kind = args[0];
    boolean sup = false;
    int k = -1;
    for (int i = 0; i < args.length; i++) {
      int j = indexOf(allkinds, args[i]);
      if (j < 0) {
        continue;
      }
      sup = true;
      k = i;
      kind = args[k];
      break;
    }
    if (!sup) {
      System.out.println("args(sup): " + Arrays.toString(args));
      System.out.println(usage);
      return;
    }
    if (kind.indexOf("+") >= 0) {
      plusextra = true;
    }
    System.out.println("kind: " + kind + ", k = " + k);

    String action = args[k + 1];
    sup = false;
    int j = indexOf(allmeth, action);
    if (j < 0) {
      System.out.println(usage);
      return;
    }

    String filename = args[k + 2];

    int threads = 0;
    if (kind.startsWith("par")) {
      if (args.length < 4) {
        System.out.println("args(par): " + Arrays.toString(args));
        System.out.println(usage);
        return;
      }
      String tup = args[k + 3];
      String t = tup;
      try {
        threads = Integer.parseInt(t);
      } catch (NumberFormatException e) {
        e.printStackTrace();
        System.out.println("args(threads): " + Arrays.toString(args));
        System.out.println(usage);
        return;
      }
      if (threads < 1) {
        threads = 1;
      }
    }
    j = indexOf(args, "check");
    if (j >= 0) {
      doCheck = true;
    }
    j = indexOf(args, "nolog");
    if (j >= 0) {
      doLog = false;
    }

    Reader problem = RunGB.getReader(filename);
    if (problem == null) {
      System.out.println("args(file): " + filename);
      System.out.println("args(file): examples.jar(" + filename + ")");
      System.out.println("args(file): " + Arrays.toString(args));
      System.out.println(usage);
      return;
    }
    RingFactoryTokenizer rftok = new RingFactoryTokenizer(problem);
    GenSolvablePolynomialRing spfac = null;
    try {
      spfac = rftok.nextSolvablePolynomialRing();
      rftok = null;
    } catch (IOException e) {
      e.printStackTrace();
      return;
    }
    Reader polyreader = new CatReader(new StringReader("("), problem); // ( has gone
    // Reader polyreader = problem;
    GenPolynomialTokenizer tok = new GenPolynomialTokenizer(spfac, polyreader);
    PolynomialList S = null;
    try {
      S = new PolynomialList(spfac, tok.nextSolvablePolynomialList());
    } catch (IOException e) {
      e.printStackTrace();
      return;
    }
    System.out.println("S =\n" + S);

    if (doLog) {
      BasicConfigurator.configure();
    }

    if (kind.startsWith("seq")) {
      runSequential(S, action, plusextra);
    } else if (kind.startsWith("par")) {
      runParallel(S, threads, action, plusextra);
    }
    ComputerThreads.terminate();
  }
示例#4
0
  /**
   * main method to be called from commandline <br>
   * Usage: RunSGB [seq|par|par+] [irr|left|right|two] &lt;file&gt; #procs
   */
  public static void main(java.lang.String[] args) {

    BasicConfigurator.configure();

    String usage =
        "Usage: RunSGB "
            + "[ seq | par | par+ ] "
            //        + "[ seq | par | dist | cli [port] ] "
            + "[ irr | left | right | two ] "
            + "<file> "
            + "#procs ";
    //  + "[machinefile]";
    if (args.length < 3) {
      System.out.println(usage);
      return;
    }

    boolean pairseq = false;
    String kind = args[0];
    String[] allkinds = new String[] {"seq", "par", "par+"};
    // String[] allkinds = new String[] { "seq", "par", "dist", "cli"  };
    boolean sup = false;
    for (int i = 0; i < allkinds.length; i++) {
      if (kind.equals(allkinds[i])) {
        sup = true;
        if (kind.indexOf("+") >= 0) {
          pairseq = true;
        }
      }
    }
    if (!sup) {
      System.out.println(usage);
      return;
    }
    String[] allmeth = new String[] {"irr", "left", "right", "two"};
    String action = args[1];
    sup = false;
    for (int i = 0; i < allmeth.length; i++) {
      if (action.equals(allmeth[i])) {
        sup = true;
      }
    }
    if (!sup) {
      System.out.println(usage);
      return;
    }

    String filename = args[2];

    int threads = 0;
    if (kind.startsWith("par")) {
      if (args.length < 4) {
        System.out.println(usage);
        return;
      }
      String tup = args[3];
      String t = tup;
      try {
        threads = Integer.parseInt(t);
      } catch (NumberFormatException e) {
        e.printStackTrace();
        System.out.println(usage);
        return;
      }
      if (threads < 1) {
        threads = 1;
      }
    }

    Reader problem = null;
    try {
      problem = new FileReader(filename);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      System.out.println(usage);
      return;
    }

    RingFactoryTokenizer rftok = new RingFactoryTokenizer(problem);
    GenSolvablePolynomialRing spfac = null;
    try {
      spfac = rftok.nextSolvablePolynomialRing();
      rftok = null;
    } catch (IOException e) {
      e.printStackTrace();
      return;
    }
    Reader polyreader = new CatReader(new StringReader("("), problem); // ( has gone
    GenPolynomialTokenizer tok = new GenPolynomialTokenizer(spfac, polyreader);
    PolynomialList S = null;
    try {
      S = new PolynomialList(spfac, tok.nextSolvablePolynomialList());
    } catch (IOException e) {
      e.printStackTrace();
      return;
    }
    System.out.println("S =\n" + S);

    if (kind.startsWith("seq")) {
      runSequential(S, action, pairseq);
    }

    if (kind.startsWith("par")) {
      runParallel(S, threads, action, pairseq);
    }
  }