Skip to content

Commit

Permalink
Fixing initial graph / bound graph problem for FGES throughout code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdramsey committed Feb 14, 2023
1 parent 075e2da commit 0bc6a1e
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void execute() {
}
}

this.fges.setExternalGraph(this.externalGraph);
this.fges.setBoundGraph(this.externalGraph);
this.fges.setKnowledge((Knowledge) getParams().get("knowledge", new Knowledge()));
this.fges.setVerbose(true);
Graph graph = this.fges.search();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Graph search(List<DataModel> dataModels, Parameters parameters) {
}

if (initial != null) {
search.setExternalGraph(initial);
search.setBoundGraph(initial);
}

return search.search();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public Graph search() {
g.removeEdge(edge);
g.addEdge(reversed);

fges.setExternalGraph(g);
fges.setInitialGraph(g);
Graph g1 = fges.search();
double s1 = fges.getModelScore();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Graph search() {

meeks.orientImplied(g);

ges.setExternalGraph(g);
ges.setInitialGraph(g);
Graph g1 = ges.search();
double s1 = ges.getModelScore();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1964,47 +1964,6 @@ public static int[][] graphComparison(Graph trueCpdag, Graph estCpdag, PrintStre
return counts;
}

public static Graph reorient(Graph graph, DataModel dataModel, Knowledge knowledge) {
if (dataModel instanceof DataModelList) {
DataModelList list = (DataModelList) dataModel;
List<DataModel> dataSets = new ArrayList<>(list);
Fges images = new Fges(new SemBicScoreImages(dataSets));

images.setBoundGraph(graph);
images.setKnowledge(knowledge);
return images.search();
} else if (dataModel instanceof DataSet) {
DataSet dataSet = (DataSet) dataModel;

Score score;

if (dataModel.isContinuous()) {
score = new SemBicScore(new CovarianceMatrix(dataSet));
} else if (dataSet.isDiscrete()) {
score = new BDeuScore(dataSet);
} else {
throw new NullPointerException();
}

Fges ges = new Fges(score);

ges.setBoundGraph(graph);
ges.setKnowledge(knowledge);
return ges.search();
} else if (dataModel instanceof CovarianceMatrix) {
ICovarianceMatrix cov = (CovarianceMatrix) dataModel;
Score score = new SemBicScore(cov);

Fges ges = new Fges(score);

ges.setBoundGraph(graph);
ges.setKnowledge(knowledge);
return ges.search();
}

throw new IllegalStateException("Can do that that reorientation.");
}

@NotNull
public static Graph dagToPag(Graph trueGraph) {
return new DagToPag(trueGraph).convert();
Expand Down

0 comments on commit 0bc6a1e

Please sign in to comment.