use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.
the class VcpcFastRunner method execute.
// ===================PUBLIC METHODS OVERRIDING ABSTRACT================//
public void execute() {
IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
Parameters searchParams = getParams();
Parameters params = searchParams;
VcpcFast fvcpc = new VcpcFast(getIndependenceTest());
fvcpc.setKnowledge(knowledge);
fvcpc.setAggressivelyPreventCycles(this.isAggressivelyPreventCycles());
fvcpc.setDepth(params.getInt("depth", -1));
if (independenceFactsModel != null) {
fvcpc.setFacts(independenceFactsModel.getFacts());
}
Graph graph = fvcpc.search();
if (getSourceGraph() != null) {
GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
} else if (knowledge.isDefaultToKnowledgeLayout()) {
SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
} else {
GraphUtils.circleLayout(graph, 200, 200, 150);
}
setResultGraph(graph);
setVcpcFastFields(fvcpc);
}
use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.
the class WFgesRunner method getParamSettings.
@Override
public Map<String, String> getParamSettings() {
super.getParamSettings();
Parameters params = getParams();
paramSettings.put("Penalty Discount", new DecimalFormat("0.0").format(params.getDouble("penaltyDiscount", 4)));
return paramSettings;
}
use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.
the class WFgesRunner method execute.
// ============================PUBLIC METHODS==========================//
/**
* Executes the algorithm, producing (at least) a result workbench. Must be
* implemented in the extending class.
*/
public void execute() {
System.out.println("A");
DataSet dataSet = (DataSet) getDataModel();
Parameters params = getParams();
double penaltyDiscount = params.getDouble("penaltyDiscount", 4);
WFges fges = new WFges(dataSet);
fges.setPenaltyDiscount(penaltyDiscount);
Graph graph = fges.search();
if (getSourceGraph() != null) {
GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
} else if (((IKnowledge) getParams().get("knowledge", new Knowledge2())).isDefaultToKnowledgeLayout()) {
SearchGraphUtils.arrangeByKnowledgeTiers(graph, (IKnowledge) getParams().get("knowledge", new Knowledge2()));
} else {
GraphUtils.circleLayout(graph, 200, 200, 150);
}
setResultGraph(graph);
this.topGraphs = new ArrayList<>();
topGraphs.add(new ScoredGraph(getResultGraph(), Double.NaN));
setIndex(topGraphs.size() - 1);
}
use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.
the class RequiredGraphModel method createKnowledge.
private void createKnowledge(Parameters params) {
IKnowledge knwl = getKnowledge();
if (knwl == null) {
return;
}
knwl.clear();
List<String> varNames = getVarNames();
getKnowledgeBoxInput().getVariableNames().stream().filter(e -> !e.startsWith("E_")).forEach(e -> {
varNames.add(e);
knwl.addVariable(e);
});
if (resultGraph == null) {
throw new NullPointerException("I couldn't find a parent graph.");
}
List<Node> nodes = resultGraph.getNodes();
int numOfNodes = nodes.size();
for (int i = 0; i < numOfNodes; i++) {
for (int j = i + 1; j < numOfNodes; j++) {
Node n1 = nodes.get(i);
Node n2 = nodes.get(j);
if (n1.getName().startsWith("E_") || n2.getName().startsWith("E_")) {
continue;
}
Edge edge = resultGraph.getEdge(n1, n2);
if (edge == null) {
continue;
} else if (edge.isDirected()) {
knwl.setRequired(edge.getNode1().getName(), edge.getNode2().getName());
} else if (Edges.isUndirectedEdge(edge)) {
knwl.setRequired(n1.getName(), n2.getName());
knwl.setRequired(n2.getName(), n1.getName());
}
}
}
}
use of edu.cmu.tetrad.util.Parameters in project tetrad by cmu-phil.
the class SampleVcpcRunner method execute.
// ===================PUBLIC METHODS OVERRIDING ABSTRACT================//
public void execute() {
IKnowledge knowledge = (IKnowledge) getParams().get("knowledge", new Knowledge2());
Parameters searchParams = getParams();
Parameters params = searchParams;
SampleVcpc svcpc = new SampleVcpc(getIndependenceTest());
svcpc.setKnowledge(knowledge);
svcpc.setAggressivelyPreventCycles(this.isAggressivelyPreventCycles());
svcpc.setDepth(params.getInt("depth", -1));
if (independenceFactsModel != null) {
svcpc.setFacts(independenceFactsModel.getFacts());
}
// vcpc.setSemPm(semPm);
//
// if (semPm != null) {
// vcpc.setSemPm(getSemPm());
// }
svcpc.setSemIm(semIm);
if (semIm != null) {
svcpc.setSemIm(this.semIm);
}
Graph graph = svcpc.search();
if (getSourceGraph() != null) {
GraphUtils.arrangeBySourceGraph(graph, getSourceGraph());
} else if (knowledge.isDefaultToKnowledgeLayout()) {
SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
} else {
GraphUtils.circleLayout(graph, 200, 200, 150);
}
setResultGraph(graph);
setSvcpcFields(svcpc);
}
Aggregations