Esempio n. 1
0
  // 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;
  }
Esempio n. 2
0
  JScrollPane workbenchScroll(String resultLabel) {
    Graph resultGraph = resultGraph();

    Graph sourceGraph = algorithmRunner.getSourceGraph();
    SearchParams searchParams = algorithmRunner.getParams();
    Graph latestWorkbenchGraph = null;

    if (searchParams != null) {
      latestWorkbenchGraph = searchParams.getSourceGraph();
    }

    if (latestWorkbenchGraph == null) {
      GraphUtils.arrangeBySourceGraph(resultGraph, sourceGraph);
    } else {
      GraphUtils.arrangeBySourceGraph(resultGraph, latestWorkbenchGraph);
    }

    //        boolean arrangedAll = DataGraphUtils.arrangeBySourceGraph(resultGraph,
    //                latestWorkbenchGraph);
    //
    //        if (!arrangedAll) {
    //            arrangedAll =
    //                    DataGraphUtils.arrangeBySourceGraph(resultGraph, sourceGraph);
    //        }

    //        if (!arrangedAll) {
    //            DataGraphUtils.circleLayout(resultGraph, 200, 200, 150);
    //        }

    this.workbench = new GraphWorkbench(resultGraph);

    graphHistory.clear();
    graphHistory.add(resultGraph);

    this.workbench.setAllowDoubleClickActions(false);
    this.workbench.setAllowNodeEdgeSelection(true);
    this.workbenchScroll = new JScrollPane(workbench);
    //        workbenchScroll.setPreferredSize(new Dimension(450, 450));
    //        workbenchScroll.setBorder(new TitledBorder(resultLabel));

    this.workbench.addMouseListener(
        new MouseAdapter() {
          public void mouseExited(MouseEvent e) {
            storeLatestWorkbenchGraph();
          }
        });

    return workbenchScroll;
  }
Esempio n. 3
0
  /**
   * Executes the algorithm, producing (at least) a result workbench. Must be implemented in the
   * extending class.
   */
  public void execute() {
    DataModel source = getDataModel();

    if (!(source instanceof DataSet)) {
      throw new IllegalArgumentException("Expecting a rectangular data set.");
    }

    DataSet data = (DataSet) source;

    if (!data.isContinuous()) {
      throw new IllegalArgumentException("Expecting a continuous data set.");
    }

    //        Lingam_old lingam = new Lingam_old();
    //        lingam.setPruningDone(true);
    //        lingam.setAlpha(getParams().getIndTestParams().getAlpha());
    //        GraphWithParameters result = lingam.lingam(data);
    //        Graph graph = result.getGraph();

    Lingam lingam = new Lingam();
    LingamParams params = (LingamParams) getParams();
    lingam.setPruneFactor(params.getPruneFactor());
    Graph graph = lingam.search(data);

    setResultGraph(graph);

    if (getSourceGraph() != null) {
      GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
    } else {
      GraphUtils.circleLayout(graph, 200, 200, 150);
    }
  }
Esempio n. 4
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. 5
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. 6
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();

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

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

    TFciGes fci = new TFciGes(getIndependenceTest());
    fci.setKnowledge(knowledge);
    fci.setCompleteRuleSetUsed(indTestParams.isCompleteRuleSetUsed());
    fci.setPossibleDsepSearchDone(indTestParams.isPossibleDsepDone());
    fci.setMaxPathLength(indTestParams.getMaxReachablePathLength());
    fci.setDepth(indTestParams.getDepth());
    fci.setPenaltyDiscount(indTestParams.getPenaltyDiscount());
    fci.setSamplePrior(indTestParams.getSamplePrior());
    fci.setStructurePrior(indTestParams.getStructurePrior());
    fci.setCompleteRuleSetUsed(false);
    fci.setPenaltyDiscount(indTestParams.getPenaltyDiscount());
    fci.setFaithfulnessAssumed(indTestParams.isFaithfulnessAssumed());
    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);
  }
  /**
   * Executes the algorithm, producing (at least) a result workbench. Must be implemented in the
   * extending class.
   */
  public void execute() {
    DataModel source = getDataModel();

    if (!(source instanceof DataSet)) {
      throw new IllegalArgumentException("Expecting a rectangular data set.");
    }

    DataSet data = (DataSet) source;

    if (!data.isContinuous()) {
      throw new IllegalArgumentException("Expecting a continuous data set.");
    }

    Lingam lingam = new Lingam();
    lingam.setAlpha(getParams().getIndTestParams().getAlpha());
    lingam.setPruningDone(true);
    lingam.setAlpha(getParams().getIndTestParams().getAlpha());
    GraphWithParameters result = lingam.lingam(data);
    setResultGraph(result.getGraph());
    GraphUtils.arrangeBySourceGraph(getResultGraph(), getSourceGraph());
  }
Esempio n. 8
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. 9
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. 10
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));
  }