コード例 #1
0
ファイル: GesSearchEditor.java プロジェクト: jdramsey/tetrad
  /**
   * Factory to return the correct param editor for independence test params. This will go in a
   * little box in the search editor.
   */
  private JComponent getIndTestParamBox(IndTestParams indTestParams) {
    if (indTestParams == null) {
      throw new NullPointerException();
    }

    if (indTestParams instanceof GesIndTestParams) {
      if (getAlgorithmRunner() instanceof IGesRunner) {
        IGesRunner gesRunner = ((IGesRunner) getAlgorithmRunner());
        GesIndTestParams params = (GesIndTestParams) indTestParams;
        DataModel dataModel = gesRunner.getDataModel();
        boolean discreteData = dataModel instanceof DataSet && ((DataSet) dataModel).isDiscrete();
        return new GesIndTestParamsEditor(params, discreteData);
      }

      if (getAlgorithmRunner() instanceof ImagesRunner) {
        ImagesRunner gesRunner = ((ImagesRunner) getAlgorithmRunner());
        GesIndTestParams params = (GesIndTestParams) indTestParams;
        DataSet dataSet = (DataSet) gesRunner.getDataModel();
        boolean discreteData = dataSet.isDiscrete();
        return new GesIndTestParamsEditor(params, discreteData);
      }
    }

    return new IndTestParamsEditor(indTestParams);
  }
コード例 #2
0
ファイル: GesSearchEditor.java プロジェクト: jdramsey/tetrad
  // TODO Fix this.
  private List<ScoredGraph> arrangeGraphs() {
    IGesRunner runner = (IGesRunner) getAlgorithmRunner();
    Graph resultGraph = runner.getResultGraph();

    List<ScoredGraph> topGraphs = runner.getTopGraphs();

    if (topGraphs == null) topGraphs = new ArrayList<ScoredGraph>();

    Graph latestWorkbenchGraph = runner.getParams().getSourceGraph();
    Graph sourceGraph = runner.getSourceGraph();

    boolean arrangedAll = false;

    for (ScoredGraph topGraph1 : topGraphs) {
      arrangedAll = GraphUtils.arrangeBySourceGraph(topGraph1.getGraph(), latestWorkbenchGraph);
    }

    if (!arrangedAll) {
      arrangedAll = GraphUtils.arrangeBySourceGraph(resultGraph, sourceGraph);
    }

    if (!arrangedAll) {
      for (ScoredGraph topGraph : topGraphs) {
        GraphUtils.circleLayout(topGraph.getGraph(), 200, 200, 150);
        GraphUtils.circleLayout(resultGraph, 200, 200, 150);
      }
    }

    return topGraphs;
  }
コード例 #3
0
ファイル: GesSearchEditor.java プロジェクト: jdramsey/tetrad
  private void calcStats() {
    //        Graph resultGraph = getAlgorithmRunner().getResultGraph();
    IGesRunner runner = (IGesRunner) getAlgorithmRunner();

    if (runner.getTopGraphs().isEmpty()) {
      throw new IllegalArgumentException(
          "No patterns were recorded. Please adjust the number of " + "patterns to store.");
    }

    Graph resultGraph = runner.getTopGraphs().get(runner.getIndex()).getGraph();

    if (getAlgorithmRunner().getDataModel() instanceof DataSet) {

      // resultGraph may be the output of a PC search.
      // Such graphs sometimes contain doubly directed edges.

      // /We converte such edges to directed edges here.
      // For the time being an orientation is arbitrarily selected.
      Set<Edge> allEdges = resultGraph.getEdges();

      for (Edge edge : allEdges) {
        if (edge.getEndpoint1() == Endpoint.ARROW && edge.getEndpoint2() == Endpoint.ARROW) {
          // Option 1 orient it from node1 to node2
          resultGraph.setEndpoint(edge.getNode1(), edge.getNode2(), Endpoint.ARROW);

          // Option 2 remove such edges:
          resultGraph.removeEdge(edge);
        }
      }

      Pattern pattern = new Pattern(resultGraph);
      PatternToDag ptd = new PatternToDag(pattern);
      Graph dag = ptd.patternToDagMeekRules();

      DataSet dataSet = (DataSet) getAlgorithmRunner().getDataModel();
      String report;

      if (dataSet.isContinuous()) {
        report = reportIfContinuous(dag, dataSet);
      } else if (dataSet.isDiscrete()) {
        report = reportIfDiscrete(dag, dataSet);
      } else {
        throw new IllegalArgumentException("");
      }

      JScrollPane dagWorkbenchScroll = dagWorkbenchScroll(dag);
      modelStatsText.setLineWrap(true);
      modelStatsText.setWrapStyleWord(true);
      modelStatsText.setText(report);

      removeStatsTabs();
      tabbedPane.addTab("DAG in pattern", dagWorkbenchScroll);
      tabbedPane.addTab("DAG Model Statistics", modelStatsText);
    }
  }