Skip to content

Commit

Permalink
Updating version to 7.3.4 and fixing knowledge problem for PcMax. Als…
Browse files Browse the repository at this point in the history
…o fixing a null pointer problem for PcMb.
  • Loading branch information
jdramsey committed Apr 13, 2023
1 parent c94c7f2 commit e46656b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.List;

/**
* CPC.
* PC.
*
* @author jdramsey
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import java.util.List;

/**
* CPC.
* PC-Max.
*
* @author jdramsey
*/
@edu.cmu.tetrad.annotation.Algorithm(
name = "PC-Max",
command = "pcmax",
command = "pc-max",
algoType = AlgType.forbid_latent_common_causes
)
@Bootstrapping
Expand Down Expand Up @@ -68,9 +68,9 @@ public Graph search(DataModel dataModel, Parameters parameters) {
search.setDepth(parameters.getInt(Params.DEPTH));
search.setAggressivelyPreventCycles(true);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
dataModel.setKnowledge(this.knowledge);
search.setKnowledge(this.knowledge);
// search.setConcurrent(parameters.getBoolean(Params.CONCURRENT_FAS));
search.setUseHeuristic(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC));
search.setUseMaxP(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC));
search.setMaxPPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH));
return search.search();
} else {
Expand All @@ -95,7 +95,7 @@ public Graph getComparisonGraph(Graph graph) {

@Override
public String getDescription() {
return "PCMAX using " + this.test.getDescription();
return "PC-Max using " + this.test.getDescription();
}

@Override
Expand Down Expand Up @@ -127,7 +127,7 @@ public Knowledge getKnowledge() {

@Override
public void setKnowledge(Knowledge knowledge) {
this.knowledge = new Knowledge((Knowledge) knowledge);
this.knowledge = new Knowledge(knowledge);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ private void testColliderMaxP(Graph graph, Map<Triple, Double> scores, Node a, N
adja.remove(c);
adjc.remove(a);

if (!(PcAll.isArrowpointAllowed(a, b, knowledge)
&& (PcAll.isArrowpointAllowed(c, b, knowledge)))) {
return;
}

double p = 0;
List<Node> S = null;

Expand Down
1 change: 1 addition & 0 deletions tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ public Graph search(List<Node> nodes) {
orientCollidersMaxP.setUseHeuristic(this.useHeuristic);
orientCollidersMaxP.setMaxPathLength(this.maxPathLength);
orientCollidersMaxP.setDepth(this.depth);
orientCollidersMaxP.setKnowledge(this.knowledge);
orientCollidersMaxP.orient(this.graph);
} else if (this.colliderDiscovery == ColliderDiscovery.CONSERVATIVE) {
if (this.verbose) {
Expand Down
18 changes: 11 additions & 7 deletions tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMax.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public class PcMax implements GraphSearch {

private boolean verbose;
private boolean stable;
private boolean concurrent;
private boolean useHeuristic = false;
// private boolean concurrent;
private boolean useMaxP = false;
private int maxPPathLength = -1;
private PcAll.ConflictRule conflictRule = PcAll.ConflictRule.OVERWRITE;

Expand Down Expand Up @@ -233,7 +233,7 @@ public Graph search(IFas fas, List<Node> nodes) {
"be in the domain of the independence test provided.");
}

PcAll search = new PcAll(independenceTest);
edu.cmu.tetrad.search.PcAll search = new edu.cmu.tetrad.search.PcAll(independenceTest);
search.setDepth(depth);
search.setHeuristic(1);
search.setKnowledge(this.knowledge);
Expand All @@ -249,14 +249,18 @@ public Graph search(IFas fas, List<Node> nodes) {
// } else {
// search.setConcurrent(PcAll.Concurrent.NO);
// }
//

search.setColliderDiscovery(PcAll.ColliderDiscovery.MAX_P);
search.setConflictRule(conflictRule);
search.setUseHeuristic(useHeuristic);
search.setUseHeuristic(useMaxP);
search.setMaxPathLength(maxPPathLength);
// search.setExternalGraph(externalGraph);
search.setVerbose(verbose);

// fas.setKnowledge(getKnowledge());
// fas.setDepth(getDepth());
// fas.setVerbose(this.verbose);

this.graph = search.search();
this.sepsets = fas.getSepsets();

Expand Down Expand Up @@ -315,8 +319,8 @@ public void setStable(boolean stable) {
// this.concurrent = concurrent;
// }

public void setUseHeuristic(boolean useHeuristic) {
this.useHeuristic = useHeuristic;
public void setUseMaxP(boolean useMaxP) {
this.useMaxP = useMaxP;
}

public void setMaxPPathLength(int maxPPathLength) {
Expand Down
2 changes: 2 additions & 0 deletions tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMb.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ public Graph search(List<Node> targets) {
this.logger.log("info", "BEGINNING step 1 (prune targets).");

for (Node target : getTargets()) {
if (target == null) throw new NullPointerException("Target not specified");

graph.addNode(target);
constructFan(target, graph);

Expand Down

0 comments on commit e46656b

Please sign in to comment.