Search in sources :

Example 6 with IKnowledge

use of edu.cmu.tetrad.data.IKnowledge in project tetrad by cmu-phil.

the class KnowledgeEditorToolbar method setWorkbenchMode.

/**
 * Sets the state of the workbench in response to a button press.
 *
 * @param button the JToggleButton whose workbench state is to be set.
 */
private void setWorkbenchMode(JToggleButton button) {
    String nodeType = this.nodeTypes.get(button);
    if ("Select".equals(nodeType)) {
        workbench.setWorkbenchMode(KnowledgeWorkbench.SELECT_MOVE);
    } else if ("Forbidden".equals(nodeType)) {
        workbench.setWorkbenchMode(KnowledgeWorkbench.ADD_EDGE);
        workbench.setEdgeMode(KnowledgeWorkbench.FORBIDDEN_EDGE);
    } else if ("Required".equals(nodeType)) {
        workbench.setWorkbenchMode(KnowledgeWorkbench.ADD_EDGE);
        workbench.setEdgeMode(KnowledgeWorkbench.REQUIRED_EDGE);
    } else if ("Source Layout".equals(nodeType)) {
        KnowledgeGraph graph = (KnowledgeGraph) workbench.getGraph();
        GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
        workbench.setGraph(graph);
    } else if ("Knowledge Layout".equals(nodeType)) {
        KnowledgeGraph graph = (KnowledgeGraph) workbench.getGraph();
        IKnowledge knowledge = graph.getKnowledge();
        try {
            SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
            workbench.setGraph(graph);
        } catch (IllegalArgumentException ex) {
            System.out.print(ex.getMessage());
            JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), ex.getMessage());
        }
    }
}
Also used : IKnowledge(edu.cmu.tetrad.data.IKnowledge)

Example 7 with IKnowledge

use of edu.cmu.tetrad.data.IKnowledge in project tetrad by cmu-phil.

the class FasRunner method execute.

// ===================PUBLIC METHODS OVERRIDING ABSTRACT================//
public void execute() {
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    int depth = getParams().getInt("depth", -1);
    Graph graph = new EdgeListGraph(getIndependenceTest().getVariables());
    Fas fas = new Fas(graph, getIndependenceTest());
    fas.setKnowledge(knowledge);
    fas.setDepth(depth);
    graph = fas.search();
    System.out.println(graph);
    for (Node node : graph.getNodes()) {
        System.out.println(node + " " + graph.getAdjacentNodes(node).size());
    }
    if (getSourceGraph() != null) {
        GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
    } else if (knowledge.isDefaultToKnowledgeLayout()) {
        SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
    } else {
        GraphUtils.circleLayout(graph, 200, 200, 150);
    }
    setResultGraph(graph);
}
Also used : IKnowledge(edu.cmu.tetrad.data.IKnowledge) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 8 with IKnowledge

use of edu.cmu.tetrad.data.IKnowledge in project tetrad by cmu-phil.

the class PcPatternRunner method execute.

// ===================PUBLIC METHODS OVERRIDING ABSTRACT================//
public void execute() {
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    int depth = getParams().getInt("depth", -1);
    PcPattern pcSearch = new PcPattern(getIndependenceTest());
    pcSearch.setKnowledge(knowledge);
    pcSearch.setAggressivelyPreventCycles(isAggressivelyPreventCycles());
    pcSearch.setDepth(depth);
    Graph graph = pcSearch.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);
}
Also used : IKnowledge(edu.cmu.tetrad.data.IKnowledge) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 9 with IKnowledge

use of edu.cmu.tetrad.data.IKnowledge in project tetrad by cmu-phil.

the class PcStableMaxLocalRunner method execute.

// ===================PUBLIC METHODS OVERRIDING ABSTRACT================//
public void execute() {
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    IndependenceTest independenceTest = getIndependenceTest();
    Parameters testParams = getParams();
    PcStableMaxLocal search = new PcStableMaxLocal(independenceTest);
    search.setAggressivelyPreventCycles(isAggressivelyPreventCycles());
    search.setKnowledge(knowledge);
    Graph graph = search.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);
}
Also used : IKnowledge(edu.cmu.tetrad.data.IKnowledge) Parameters(edu.cmu.tetrad.util.Parameters) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 10 with IKnowledge

use of edu.cmu.tetrad.data.IKnowledge in project tetrad by cmu-phil.

the class CeFanSearchRunner method execute.

// =================PUBLIC METHODS OVERRIDING ABSTRACT=================//
/**
 * Executes the algorithm, producing (at least) a result workbench. Must be
 * implemented in the extending class.
 */
public void execute() {
    int pcDepth = getParams().getInt("depth", -1);
    Cefs search = new Cefs(getIndependenceTest(), pcDepth);
    Parameters params = getParams();
    if (params instanceof Parameters) {
        search.setAggressivelyPreventCycles(params.getBoolean("aggressivelyPreventCycles", false));
    }
    String targetName = getParams().getString("targetName", null);
    Graph graph = search.search(targetName);
    setResultGraph(graph);
    if (getSourceGraph() != null) {
        GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
    } else if (((IKnowledge) getParams().get("knowledge", new Knowledge2())).isDefaultToKnowledgeLayout()) {
        SearchGraphUtils.arrangeByKnowledgeTiers(graph, (IKnowledge) getParams().get("knowledge", new Knowledge2()));
    } else {
        GraphUtils.circleLayout(graph, 200, 200, 150);
    }
}
Also used : Cefs(edu.cmu.tetrad.search.Cefs) IKnowledge(edu.cmu.tetrad.data.IKnowledge) Parameters(edu.cmu.tetrad.util.Parameters) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Aggregations

IKnowledge (edu.cmu.tetrad.data.IKnowledge)58 Knowledge2 (edu.cmu.tetrad.data.Knowledge2)46 Parameters (edu.cmu.tetrad.util.Parameters)18 Graph (edu.cmu.tetrad.graph.Graph)12 ArrayList (java.util.ArrayList)10 GraphWorkbench (edu.cmu.tetradapp.workbench.GraphWorkbench)8 IOException (java.io.IOException)7 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)5 CharArrayWriter (java.io.CharArrayWriter)5 DataReader (edu.cmu.tetrad.data.DataReader)4 DataSet (edu.cmu.tetrad.data.DataSet)4 Node (edu.cmu.tetrad.graph.Node)4 WatchedProcess (edu.cmu.tetradapp.util.WatchedProcess)4 File (java.io.File)4 PrintWriter (java.io.PrintWriter)4 List (java.util.List)4 KnowledgeBoxInput (edu.cmu.tetrad.data.KnowledgeBoxInput)3 KnowledgeEdge (edu.cmu.tetrad.data.KnowledgeEdge)3 Test (org.junit.Test)3 BdeuScore (edu.cmu.tetrad.algcomparison.score.BdeuScore)2