Exemplo n.º 1
0
  public void execute() {
    IKnowledge knowledge = getParams().getKnowledge();
    PcSearchParams searchParams = (PcSearchParams) getParams();

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

    VcpcAlt VcpcAlt = new VcpcAlt(getIndependenceTest());
    VcpcAlt.setKnowledge(knowledge);
    VcpcAlt.setAggressivelyPreventCycles(this.isAggressivelyPreventCycles());
    VcpcAlt.setDepth(indTestParams.getDepth());
    Graph graph = VcpcAlt.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);
  }
Exemplo n.º 2
0
  /**
   * Executes the algorithm, producing (at least) a result workbench. Must be implemented in the
   * extending class.
   */
  public void execute() {
    Object source = dataWrapper.getSelectedDataModel();

    DataModel dataModel = (DataModel) source;

    IKnowledge knowledge = params2.getKnowledge();

    if (initialGraph == null) {
      initialGraph = new EdgeListGraph(dataModel.getVariables());
    }

    Graph graph2 = new EdgeListGraph(initialGraph);
    graph2 = GraphUtils.replaceNodes(graph2, dataModel.getVariables());

    Bff search;

    if (dataModel instanceof DataSet) {
      DataSet dataSet = (DataSet) dataModel;

      if (getAlgorithmType() == AlgorithmType.BEAM) {
        search = new BffBeam(graph2, dataSet, knowledge);
      } else if (getAlgorithmType() == AlgorithmType.GES) {
        search = new BffGes(graph2, dataSet);
        search.setKnowledge(knowledge);
      } else {
        throw new IllegalStateException();
      }
    } else if (dataModel instanceof CovarianceMatrix) {
      CovarianceMatrix covarianceMatrix = (CovarianceMatrix) dataModel;

      if (getAlgorithmType() == AlgorithmType.BEAM) {
        search = new BffBeam(graph2, covarianceMatrix, knowledge);
      } else if (getAlgorithmType() == AlgorithmType.GES) {
        throw new IllegalArgumentException(
            "GES method requires a dataset; a covariance matrix was provided.");
        //                search = new BffGes(graph2, covarianceMatrix);
        //                search.setKnowledge(knowledge);
      } else {
        throw new IllegalStateException();
      }
    } else {
      throw new IllegalStateException();
    }

    PcIndTestParams indTestParams = (PcIndTestParams) getParams().getIndTestParams();

    search.setAlpha(indTestParams.getAlpha());
    search.setBeamWidth(indTestParams.getBeamWidth());
    search.setHighPValueAlpha(indTestParams.getZeroEdgeP());
    this.graph = search.search();

    //        this.graph = search.getNewSemIm().getSemPm().getGraph();

    setOriginalSemIm(search.getOriginalSemIm());
    this.newSemIm = search.getNewSemIm();
    fireGraphChange(graph);

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

    setResultGraph(SearchGraphUtils.patternForDag(graph, knowledge));
  }