Search in sources :

Example 41 with Knowledge2

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

the class IonRunner 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() {
    System.out.println("Executing.");
    IonJoeModifications ion = new IonJoeModifications(getGraphs());
    ion.setAdjacencySearch(getParams().getBoolean("pruneByAdjacencies", true));
    ion.setPathLengthSearch(getParams().getBoolean("pruneByPathLength", true));
    ion.setKnowledge((IKnowledge) getParams().get("knowledge", new Knowledge2()));
    List<Graph> graphs = ion.search();
    Collections.sort(graphs, new Comparator<Graph>() {

        public int compare(Graph graph, Graph graph1) {
            return graph.getNumEdges() - graph1.getNumEdges();
        }
    });
    if (graphs == null) {
        throw new NullPointerException();
    }
    if (!graphs.isEmpty()) {
        setResultGraph(graphs.get(0));
    }
    System.out.println("graphs = " + graphs);
    getParams().set("graphIndex", 0);
    this.graphs = graphs;
}
Also used : EdgeListGraph(edu.cmu.tetrad.graph.EdgeListGraph) Graph(edu.cmu.tetrad.graph.Graph) IonJoeModifications(edu.cmu.tetrad.search.IonJoeModifications) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 42 with Knowledge2

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

the class KpcRunner method getMeekRules.

public ImpliedOrientation getMeekRules() {
    MeekRules rules = new MeekRules();
    rules.setAggressivelyPreventCycles(this.isAggressivelyPreventCycles());
    rules.setKnowledge((IKnowledge) getParams().get("knowledge", new Knowledge2()));
    return rules;
}
Also used : Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 43 with Knowledge2

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

the class MbFanSearchRunner 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);
    Mbfs mbfs = new Mbfs(getIndependenceTest(), pcDepth);
    Parameters params = getParams();
    if (params instanceof Parameters) {
        mbfs.setAggressivelyPreventCycles(params.getBoolean("aggressivelyPreventCycles", false));
    }
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    mbfs.setKnowledge(knowledge);
    String targetName = getParams().getString("targetName", null);
    Graph graph = mbfs.search(targetName);
    setResultGraph(graph);
    if (getSourceGraph() != null) {
        GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
    } else if (knowledge.isDefaultToKnowledgeLayout()) {
        SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
    } else {
        GraphUtils.circleLayout(graph, 200, 200, 150);
    }
    this.mbfs = mbfs;
}
Also used : IKnowledge(edu.cmu.tetrad.data.IKnowledge) Parameters(edu.cmu.tetrad.util.Parameters) Graph(edu.cmu.tetrad.graph.Graph) Mbfs(edu.cmu.tetrad.search.Mbfs) Knowledge2(edu.cmu.tetrad.data.Knowledge2)

Example 44 with Knowledge2

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

the class MbfsRunner 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 = ((Parameters) getParameters()).getMaxIndegree();
    // Mbfs mbfs = new Mbfs(getIndependenceTest(), pcDepth);
    // Parameters params = getParameters();
    // if (params instanceof Parameters) {
    // mbfs.setAggressivelyPreventCycles(((Parameters) params)
    // .isAggressivelyPreventCycles());
    // }
    IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
    // mbfs.setKnowledge(knowledge);
    String targetName = getParams().getString("targetName", null);
    // Graph searchGraph = mbfs.search(targetName);
    // setResultGraph(searchGraph);
    DataSet dataSet = (DataSet) getDataModelList().get(0);
    SemBicScore score = new SemBicScore(new CovarianceMatrixOnTheFly(dataSet));
    score.setPenaltyDiscount(getParams().getDouble("alpha", 0.001));
    FgesMb search = new FgesMb(score);
    search.setFaithfulnessAssumed(true);
    Graph searchGraph = search.search(dataSet.getVariable(targetName));
    if (getSourceGraph() != null) {
        GraphUtils.arrangeBySourceGraph(searchGraph, getSourceGraph());
    } else if (knowledge.isDefaultToKnowledgeLayout()) {
        SearchGraphUtils.arrangeByKnowledgeTiers(searchGraph, knowledge);
    } else {
        GraphUtils.circleLayout(searchGraph, 200, 200, 150);
    }
    // this.mbfs = mbfs;
    setResultGraph(searchGraph);
}
Also used : IKnowledge(edu.cmu.tetrad.data.IKnowledge) Graph(edu.cmu.tetrad.graph.Graph) DataSet(edu.cmu.tetrad.data.DataSet) Knowledge2(edu.cmu.tetrad.data.Knowledge2) CovarianceMatrixOnTheFly(edu.cmu.tetrad.data.CovarianceMatrixOnTheFly)

Example 45 with Knowledge2

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

the class MmhcRunner method getMeekRules.

public ImpliedOrientation getMeekRules() {
    MeekRules rules = new MeekRules();
    rules.setKnowledge((IKnowledge) getParams().get("knowledge", new Knowledge2()));
    return rules;
}
Also used : Knowledge2(edu.cmu.tetrad.data.Knowledge2) MeekRules(edu.cmu.tetrad.search.MeekRules)

Aggregations

Knowledge2 (edu.cmu.tetrad.data.Knowledge2)75 IKnowledge (edu.cmu.tetrad.data.IKnowledge)43 Parameters (edu.cmu.tetrad.util.Parameters)17 Graph (edu.cmu.tetrad.graph.Graph)13 GraphWorkbench (edu.cmu.tetradapp.workbench.GraphWorkbench)8 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)5 DataSet (edu.cmu.tetrad.data.DataSet)4 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)4 MeekRules (edu.cmu.tetrad.search.MeekRules)4 WatchedProcess (edu.cmu.tetradapp.util.WatchedProcess)4 CharArrayWriter (java.io.CharArrayWriter)4 PrintWriter (java.io.PrintWriter)4 ContinuousVariable (edu.cmu.tetrad.data.ContinuousVariable)3 Node (edu.cmu.tetrad.graph.Node)3 CovarianceMatrixOnTheFly (edu.cmu.tetrad.data.CovarianceMatrixOnTheFly)1 DataModel (edu.cmu.tetrad.data.DataModel)1 DataReader (edu.cmu.tetrad.data.DataReader)1 KnowledgeEdge (edu.cmu.tetrad.data.KnowledgeEdge)1 Edge (edu.cmu.tetrad.graph.Edge)1