Esempio n. 1
0
 public void layoutByKnowledge() {
   GraphWorkbench resultWorkbench = getWorkbench();
   Graph graph = resultWorkbench.getGraph();
   IKnowledge knowledge = getAlgorithmRunner().getParams().getKnowledge();
   SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
   //        resultWorkbench.setGraph(graph);
 }
Esempio n. 2
0
 protected void doDefaultArrangement(Graph resultGraph) {
   if (getLatestWorkbenchGraph() != null) { // (alreadyLaidOut) {
     GraphUtils.arrangeBySourceGraph(resultGraph, getLatestWorkbenchGraph());
   } else if (getKnowledge().isDefaultToKnowledgeLayout()) {
     SearchGraphUtils.arrangeByKnowledgeTiers(resultGraph, getKnowledge());
     //            alreadyLaidOut = true;
   } else {
     GraphUtils.circleLayout(resultGraph, 200, 200, 150);
     //            alreadyLaidOut = true;
   }
 }
Esempio n. 3
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);
  }
Esempio n. 4
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);
  }
Esempio n. 5
0
  /**
   * Executes the algorithm, producing (at least) a result workbench. Must be implemented in the
   * extending class.
   */
  public void execute() {
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    Parameters searchParams = getParams();

    Parameters params = searchParams;

    Graph graph;

    IndependenceTest independenceTest = getIndependenceTest();
    Score score = new ScoredIndTest(independenceTest);

    if (independenceTest instanceof IndTestDSep) {
      final DagToPag dagToPag = new DagToPag(((IndTestDSep) independenceTest).getGraph());
      dagToPag.setCompleteRuleSetUsed(params.getBoolean("completeRuleSetUsed", false));
      graph = dagToPag.convert();
    } else {
      GFci fci = new GFci(independenceTest, score);
      fci.setKnowledge(knowledge);
      fci.setCompleteRuleSetUsed(params.getBoolean("completeRuleSetUsed", false));
      fci.setMaxPathLength(params.getInt("maxReachablePathLength", -1));
      fci.setMaxDegree(params.getInt("maxIndegree"));
      fci.setCompleteRuleSetUsed(false);
      fci.setFaithfulnessAssumed(params.getBoolean("faithfulnessAssumed", true));
      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);
  }
Esempio n. 6
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));
  }