Esempio n. 1
0
  public void rtestDSeparation4() {
    Graph graph = new Dag(GraphUtils.randomGraph(100, 20, 100, 5, 5, 5, false));

    long start, stop;
    int depth = -1;

    IndependenceTest test = new IndTestDSep(graph);

    Rfci fci = new Rfci(test);
    Fas fas = new Fas(test);
    start = System.currentTimeMillis();
    fci.setDepth(depth);
    fci.setVerbose(true);
    fci.search(fas, fas.getNodes());
    stop = System.currentTimeMillis();

    System.out.println("DSEP RFCI");
    System.out.println("# dsep checks = " + fas.getNumIndependenceTests());
    System.out.println("Elapsed " + (stop - start));
    System.out.println("Per " + fas.getNumIndependenceTests() / (double) (stop - start));

    SemPm pm = new SemPm(graph);
    SemIm im = new SemIm(pm);
    DataSet data = im.simulateData(1000, false);
    IndependenceTest test2 = new IndTestFisherZ(data, 0.001);

    Rfci fci3 = new Rfci(test2);
    Fas fas2 = new Fas(test2);
    start = System.currentTimeMillis();
    fci3.setDepth(depth);
    fci3.search(fas2, fas2.getNodes());
    stop = System.currentTimeMillis();

    System.out.println("FISHER Z RFCI");
    System.out.println("# indep checks = " + fas.getNumIndependenceTests());
    System.out.println("Elapsed " + (stop - start));
    System.out.println("Per " + fas.getNumIndependenceTests() / (double) (stop - start));
  }
Esempio n. 2
0
  /**
   * Executes the algorithm, producing (at least) a result workbench. Must be implemented in the
   * extending class.
   */
  public void execute() {
    IKnowledge knowledge = getParams().getKnowledge();
    SearchParams searchParams = getParams();

    FciIndTestParams indTestParams = (FciIndTestParams) searchParams.getIndTestParams();

    //            Cfci fciSearch =
    //                    new Cfci(getIndependenceTest(), knowledge);
    //            fciSearch.setMaxIndegree(indTestParams.depth());
    //            Graph graph = fciSearch.search();
    //
    //            if (knowledge.isDefaultToKnowledgeLayout()) {
    //                SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
    //            }
    //
    //            setResultGraph(graph);
    Graph graph;

    if (indTestParams.isRFCI_Used()) {
      Rfci fci = new Rfci(getIndependenceTest());
      fci.setKnowledge(knowledge);
      fci.setCompleteRuleSetUsed(indTestParams.isCompleteRuleSetUsed());
      fci.setMaxPathLength(indTestParams.getMaxReachablePathLength());
      fci.setDepth(indTestParams.getDepth());
      graph = fci.search();
    } else {
      Fci fci = new Fci(getIndependenceTest());
      fci.setKnowledge(knowledge);
      fci.setCompleteRuleSetUsed(indTestParams.isCompleteRuleSetUsed());
      fci.setPossibleDsepSearchDone(indTestParams.isPossibleDsepDone());
      fci.setMaxPathLength(indTestParams.getMaxReachablePathLength());
      fci.setDepth(indTestParams.getDepth());
      graph = fci.search();
    }

    if (getSourceGraph() != null) {
      GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
    } else if (knowledge.isDefaultToKnowledgeLayout()) {
      SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
    } else {
      GraphUtils.circleLayout(graph, 200, 200, 150);
    }

    setResultGraph(graph);
  }