Package primitiveTests

Source Code of primitiveTests.XorFitnessTest

package primitiveTests;

import org.junit.Before;
import org.junit.Test;

import primitives.cluster.ClusterHead;
import primitives.cluster.IClusterLevel;
import primitives.graph.Graph;
import primitives.graph.Node;
import search.fitnessfunctions.SimpleXorFitnessFunction;

public class XorFitnessTest {
  Node a, b, c, d, e, f;
  Graph g;

  ClusterHead ch;

  @Before
  public void setup() {
    g = new Graph();
    a = new Node("a");
    b = new Node("b");
    c = new Node("c");
    d = new Node("d");
    e = new Node("e");
    f = new Node("f");

    g.addNode(a);
    g.addNode(b);
    g.addNode(c);
    g.addNode(d);
    g.addNode(e);
    g.addNode(f);
    ch = new ClusterHead(g);
    IClusterLevel c1, c2;
    try {
      // c1 = ClusterUtils.lookup(ch, 0);
      // c2 = ClusterUtils.lookup(ch, 1);
      // ClusterUtils.merge(ch, c1, c2);
    } catch (Exception e) {
      System.exit(-1);
    }

  }

  @Test
  public void testUnconnectedGraph() {
    SimpleXorFitnessFunction ft = new SimpleXorFitnessFunction();
    ft.setTree(ch);
    System.out.println(ft.evaluate(ch));

  }

  @Test
  public void testConnectedXorTrue() {
    for (IClusterLevel c : ch.getChildren()) {
      if (c.contains(a))
        System.out.println(c.getIDs() + " has a");
      for (Node n : c.getNodes()) {
        System.out.println(c.getIDs() + " has " + n.getLabel());
      }

    }
    g.connect(a, c);
    g.connect(a, f);
    SimpleXorFitnessFunction ft = new SimpleXorFitnessFunction();
    ft.setTree(ch);
    System.out.println(ft.evaluate(ch));

  }

}
TOP

Related Classes of primitiveTests.XorFitnessTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.