Search in sources :

Example 51 with IKnowledge

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

the class TsFciRunner2 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() {
    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);
}
Also used : IKnowledge(edu.cmu.tetrad.data.IKnowledge) Parameters(edu.cmu.tetrad.util.Parameters) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 52 with IKnowledge

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

the class SampleVcpcFastRunner method execute.

// ===================PUBLIC METHODS OVERRIDING ABSTRACT================//
public void execute() {
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    Parameters searchParams = getParams();
    Parameters params = searchParams;
    SampleVcpcFast sfvcpc = new SampleVcpcFast(getIndependenceTest());
    sfvcpc.setKnowledge(knowledge);
    sfvcpc.setAggressivelyPreventCycles(this.isAggressivelyPreventCycles());
    sfvcpc.setDepth(params.getInt("depth", -1));
    if (independenceFactsModel != null) {
        sfvcpc.setFacts(independenceFactsModel.getFacts());
    }
    // vcpc.setSemPm(semPm);
    // 
    // if (semPm != null) {
    // vcpc.setSemPm(getSemPm());
    // }
    sfvcpc.setSemIm(semIm);
    // if (semIm != null) {
    // vcpc.setSemIm(getEstIm());
    // }
    Graph graph = sfvcpc.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);
    setSfvcpcFields(sfvcpc);
}
Also used : IKnowledge(edu.cmu.tetrad.data.IKnowledge) Parameters(edu.cmu.tetrad.util.Parameters) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 53 with IKnowledge

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

the class PcdRunner method execute.

// ===================PUBLIC METHODS OVERRIDING ABSTRACT================//
public void execute() {
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    Parameters searchParams = getParams();
    Parameters params = searchParams;
    Pcd pc = new Pcd(getIndependenceTest());
    pc.setKnowledge(knowledge);
    pc.setDepth(params.getInt("depth", -1));
    Graph graph;
    try {
        graph = pc.search();
    } catch (UnsupportedOperationException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "There was an error, probably because the " + "independence test doesn't support determinististic checks.");
        return;
    }
    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 54 with IKnowledge

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

the class MbfsPatternRunner method execute.

// ===================PUBLIC METHODS OVERRIDING ABSTRACT================//
public void execute() {
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    Mbfs search = new Mbfs(getIndependenceTest(), -1);
    search.setDepth(getParams().getInt("depth", -1));
    // search.setTrueGraph(trueGraph);
    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) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 55 with IKnowledge

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

the class PcLocalRunner method execute.

// ===================PUBLIC METHODS OVERRIDING ABSTRACT================//
public void execute() {
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    IndependenceTest independenceTest = getIndependenceTest();
    Parameters testParams = getParams();
    PcLocal search = new PcLocal(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)

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