Search in sources :

Example 1 with IndependenceFactsModel

use of edu.cmu.tetradapp.model.IndependenceFactsModel in project tetrad by cmu-phil.

the class TestIndependenceFacts method test1.

@Test
public void test1() {
    IndependenceFactsModel facts = new IndependenceFactsModel();
    Node x1 = new GraphNode("X1");
    Node x2 = new GraphNode("X2");
    Node x3 = new GraphNode("X3");
    Node x4 = new GraphNode("X4");
    Node x5 = new GraphNode("X5");
    Node x6 = new GraphNode("X6");
    facts.add(new IndependenceFact(x1, x2, x3));
    facts.add(new IndependenceFact(x2, x3));
    facts.add(new IndependenceFact(x2, x4, x1, x2));
    facts.add(new IndependenceFact(x2, x4, x1, x3, x5));
    facts.add(new IndependenceFact(x2, x4, x3));
    facts.add(new IndependenceFact(x2, x4, x3, x6));
    facts.remove(new IndependenceFact(x1, x2, x3));
    IndependenceFacts _facts = new IndependenceFacts(facts.getFacts());
    assertTrue(_facts.isIndependent(x4, x2, x1, x2));
    assertTrue(_facts.isIndependent(x4, x2, x5, x3, x1));
    List<Node> l = new ArrayList<>();
    l.add(x1);
    l.add(x2);
    assertTrue(_facts.isIndependent(x4, x2, l));
}
Also used : IndependenceFacts(edu.cmu.tetrad.data.IndependenceFacts) IndependenceFactsModel(edu.cmu.tetradapp.model.IndependenceFactsModel) GraphNode(edu.cmu.tetrad.graph.GraphNode) Node(edu.cmu.tetrad.graph.Node) ArrayList(java.util.ArrayList) GraphNode(edu.cmu.tetrad.graph.GraphNode) IndependenceFact(edu.cmu.tetrad.graph.IndependenceFact) Test(org.junit.Test)

Example 2 with IndependenceFactsModel

use of edu.cmu.tetradapp.model.IndependenceFactsModel in project tetrad by cmu-phil.

the class MbSearchParamEditor method getVarsFromData.

private List<String> getVarsFromData(Object[] parentModels) {
    DataModel dataModel = null;
    for (Object parentModel : parentModels) {
        if (parentModel instanceof DataWrapper) {
            DataWrapper dataWrapper = (DataWrapper) parentModel;
            dataModel = dataWrapper.getSelectedDataModel();
        } else if (parentModel instanceof IndependenceFactsModel) {
            dataModel = ((IndependenceFactsModel) parentModel).getFacts();
        }
    }
    if (dataModel == null) {
        return null;
    } else {
        return new ArrayList<>(dataModel.getVariableNames());
    }
}
Also used : DataWrapper(edu.cmu.tetradapp.model.DataWrapper) DataModel(edu.cmu.tetrad.data.DataModel) IndependenceFactsModel(edu.cmu.tetradapp.model.IndependenceFactsModel) ArrayList(java.util.ArrayList)

Aggregations

IndependenceFactsModel (edu.cmu.tetradapp.model.IndependenceFactsModel)2 ArrayList (java.util.ArrayList)2 DataModel (edu.cmu.tetrad.data.DataModel)1 IndependenceFacts (edu.cmu.tetrad.data.IndependenceFacts)1 GraphNode (edu.cmu.tetrad.graph.GraphNode)1 IndependenceFact (edu.cmu.tetrad.graph.IndependenceFact)1 Node (edu.cmu.tetrad.graph.Node)1 DataWrapper (edu.cmu.tetradapp.model.DataWrapper)1 Test (org.junit.Test)1