Skip to content

Commit

Permalink
endoExoLinkstests #23
Browse files Browse the repository at this point in the history
  • Loading branch information
rcabanasdepaz committed Jun 18, 2021
1 parent 1d313b2 commit 3fb30f4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
23 changes: 23 additions & 0 deletions models/synthetic/chain_twExo2_nEndo5_0.uai
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CAUSAL
9
2 2 2 2 2 9 9 3 5
9
2 7 0
3 6 0 1
4 6 5 1 2
3 5 2 3
3 8 3 4
1 5
1 6
1 7
1 8

3 1 0 0
18 0 0 0 0 0 0 0 1 0 1 1 0 1 1 0 1 0 0
162 0 0 0 1 0 0 0 1 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 0 1 0 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 0 1 1 0 0 1 0 1 1 1 0 1 1 1 0 0 1 0 0 1 0 0 1 1 0 1 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 1 0 1 1 0 0 0 1 0 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 0 1 0 1 0 0 0 1 0 0 0 1 1 1 1 0 0 1 1 1 0 1
18 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 0 0 0
10 0 1 1 1 1 0 0 1 0 0
9 0.001 0.291 0.002 0.014 0.061 0.002 0.001 0.069 0.559
9 0.008 0.002 0.175 0.001 0.006 0.72 0.003 0.081 0.004
3 0.006 0.032 0.962
5 0.097 0.053 0.294 0.242 0.314
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package ch.idsia.credici.model;

import ch.idsia.credici.IO;
import ch.idsia.credici.model.StructuralCausalModel;
import ch.idsia.crema.utility.ArraysUtil;
import org.junit.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import java.io.IOException;
import java.nio.file.Path;
import java.util.stream.Stream;

import static org.junit.Assert.*;
Expand Down Expand Up @@ -47,6 +51,12 @@ private static StructuralCausalModel modelSingleU(){
return m;
}

private static StructuralCausalModel syntheticModel() throws IOException {
Path wdir = Path.of("");
Path modelfile = wdir.resolve("./models/synthetic/chain_twExo2_nEndo5_0.uai");
return (StructuralCausalModel) IO.readUAI(modelfile.toString());
}


@ParameterizedTest
@MethodSource("copyParams")
Expand Down Expand Up @@ -163,5 +173,23 @@ private static Stream<Arguments> mergeParams() {

);
}

@Test
public void endoExoLinks() throws IOException {

StructuralCausalModel model = syntheticModel();

// Exogenous parents
assertArrayEquals(model.getExogenousParents(2), new int[]{5, 6});

//Edgogenous parents
assertArrayEquals(model.getEndegenousParents(2), new int[]{1});

// Endogenous children
assertArrayEquals(model.getEndogenousChildren(5), new int[]{2, 3});
assertArrayEquals(model.getEndogenousChildren(2), new int[]{3});


}

}

0 comments on commit 3fb30f4

Please sign in to comment.