gt:         e = d; //fac.random(kl, ll, el, q );
context: /*
   * $Id$
   */
  
  package edu.jas.gb;
  
  
  // import edu.jas.poly.GroebnerBase;
  
  import java.io.IOException;
  import java.io.Reader;
  import java.io.StringReader;
  import java.util.ArrayList;
  import java.util.List;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  import org.apache.log4j.BasicConfigurator; // import org.apache.log4j.Logger;
  
  import edu.jas.arith.BigRational;
  import edu.jas.kern.ComputerThreads;
  import edu.jas.poly.GenPolynomial;
  import edu.jas.poly.GenPolynomialRing;
  import edu.jas.poly.GenPolynomialTokenizer;
  import edu.jas.poly.PolynomialList;
  import edu.jas.util.ExecutableServer;
  
  
  /**
   * Distributed GroebnerBase tests with JUnit.
   * @author Heinz Kredel
   */
  
  public class GroebnerBaseDistECTest extends TestCase {
  
  
      //private static final Logger logger = Logger.getLogger(GroebnerBaseDistECTest.class);
  
      /**
       * main
       */
      public static void main(String[] args) {
          BasicConfigurator.configure();
          junit.textui.TestRunner.run(suite());
          //ComputerThreads.terminate();
      }
  
  
      /**
       * Constructs a <CODE>GroebnerBaseDistECTest</CODE> object.
       * @param name String.
       */
      public GroebnerBaseDistECTest(String name) {
          super(name);
      }
  
  
      /**
       * suite.
       */
      public static Test suite() {
          TestSuite suite = new TestSuite(GroebnerBaseDistECTest.class);
          return suite;
      }
  
  
      int port = 55711;
  
  
      String host = "localhost";
  
  
      String mfile = "examples/machines.localhost"; // contains localhost
  
  
      GenPolynomialRing<BigRational> fac;
  
  
      List<GenPolynomial<BigRational>> L;
  
  
      PolynomialList<BigRational> F;
  
  
      List<GenPolynomial<BigRational>> G;
  
  
      GroebnerBase<BigRational> bbseq;
  
  
      GroebnerBaseAbstract<BigRational> bbdist;
  
  
      GroebnerBaseAbstract<BigRational> bbdists;
  
  
      GenPolynomial<BigRational> a;
  
  
      GenPolynomial<BigRational> b;
  
  
      GenPolynomial<BigRational> c;
  
  
      GenPolynomial<BigRational> d;
  
  
      GenPolynomial<BigRational> e;
  
  
      int rl = 3; //4; //3; 
  
  
      int kl = 4;
  
  
      int ll = 7;
  
  
      int el = 3;
  
  
      float q = 0.2f; //0.4f
  
  
      int threads = 2;
  
  
      ExecutableServer es1;
  
  
      ExecutableServer es2;
  
  
      @Override
      protected void setUp() {
          es1 = new ExecutableServer(4712); // == machines.localhost:4712
          es1.init();
          es2 = new ExecutableServer(4711); // == machines.localhost:4711
          es2.init();
          //System.out.println("es1 = " + es1);
          //System.out.println("es2 = " + es2);
          BigRational coeff = new BigRational(9);
          fac = new GenPolynomialRing<BigRational>(coeff, rl);
          a = b = c = d = e = null;
          bbseq = new GroebnerBaseSeq<BigRational>();
          bbdist = new GroebnerBaseDistributedEC<BigRational>(mfile, threads, port);
          //bbdists = new GroebnerBaseDistributedEC<BigRational>(mfile, threads, new OrderedSyzPairlist<BigRational>(), port);
      }
  
  
      @Override
      protected void tearDown() {
          a = b = c = d = e = null;
          fac = null;
          bbseq = null;
          bbdist.terminate();
          bbdist = null;
          //bbdists.terminate();
          //bbdists = null;
          es1.terminate();
          es2.terminate();
          es1 = null;
          es2 = null;
          ComputerThreads.terminate();
      }
  
  
      /**
       * Test distributed GBase corner cases.
       */
      public void testDistributedGBaseCorner() {
          L = new ArrayList<GenPolynomial<BigRational>>();
  
          a = fac.getZERO();
  
          L.add(a);
          L = bbdist.GB(L);
          assertTrue("isGB( { a } ): " + L, bbseq.isGB(L));
          assertTrue("L == {}: " + L, L.isEmpty());
  
          b = fac.getONE();
  
          L.add(b);
          L = bbdist.GB(L);
          assertTrue("isGB( { a } ): " + L, bbseq.isGB(L));
          assertTrue("L == {1}: " + L, L.size() == 1);
      }
  
  
      /**
       * Test distributed GBase.
       */
      public void testDistributedGBase() {
          L = new ArrayList<GenPolynomial<BigRational>>();
  
          a = fac.random(kl, ll, el, q);
          b = fac.random(kl, ll, el, q);
          c = fac.random(kl, ll, el, q);
          d = fac.random(kl, ll, el, q);
  