use of edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.SingleGraphAlg in project tetrad by cmu-phil.
the class GeneralAlgorithmEditor method getAlgorithmFromInterface.
/**
* Initialize algorithm
*
* @param algoModel
* @param indTestModel
* @param scoreModel
* @return Algorithm
*/
public Algorithm getAlgorithmFromInterface(AlgorithmModel algoModel, IndependenceTestModel indTestModel, ScoreModel scoreModel) {
Class algoClass = algoModel.getAlgorithm().getClazz();
Class indTestClass = (indTestModel == null) ? null : indTestModel.getIndependenceTest().getClazz();
Class scoreClass = (scoreModel == null) ? null : scoreModel.getScore().getClazz();
Algorithm algorithm = null;
try {
algorithm = AlgorithmFactory.create(algoClass, indTestClass, scoreClass);
} catch (IllegalAccessException | InstantiationException exception) {
LOGGER.error("", exception);
}
// Those pairwise algos (R1, R2,..) require source graph to initialize - Zhou
if (algorithm != null && algorithm instanceof TakesInitialGraph && runner.getSourceGraph() != null && !runner.getDataModelList().isEmpty()) {
Algorithm initialGraph = new SingleGraphAlg(runner.getSourceGraph());
((TakesInitialGraph) algorithm).setInitialGraph(initialGraph);
}
return algorithm;
}
Aggregations