Search in sources :

Example 1 with LoadDataAndGraphs

use of edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs in project tetrad by cmu-phil.

the class TimeoutComparison method generateReportFromExternalAlgorithms.

public void generateReportFromExternalAlgorithms(String dataPath, String resultsPath, String outputFileName, Algorithms algorithms, Statistics statistics, Parameters parameters, long timeout, TimeUnit unit) {
    this.saveGraphs = false;
    this.dataPath = dataPath;
    this.resultsPath = resultsPath;
    for (Algorithm algorithm : algorithms.getAlgorithms()) {
        if (!(algorithm instanceof ExternalAlgorithm)) {
            throw new IllegalArgumentException("Expecting all algorithms to implement ExternalAlgorithm.");
        }
    }
    Simulations simulations = new Simulations();
    File file = new File(this.dataPath, "save");
    File[] dirs = file.listFiles();
    if (dirs == null) {
        throw new NullPointerException("No files in " + file.getAbsolutePath());
    }
    this.dirs = new ArrayList<String>();
    int count = 0;
    for (File dir : dirs) {
        if (dir.getName().contains("DS_Store")) {
            continue;
        }
        count++;
    }
    for (int i = 1; i <= count; i++) {
        File _dir = new File(dataPath, "save/" + i);
        simulations.add(new LoadDataAndGraphs(_dir.getAbsolutePath()));
        this.dirs.add(_dir.getAbsolutePath());
    }
    compareFromSimulations(this.resultsPath, simulations, outputFileName, algorithms, statistics, parameters, timeout, unit);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) MultiDataSetAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) File(java.io.File) LoadDataAndGraphs(edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs)

Example 2 with LoadDataAndGraphs

use of edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs in project tetrad by cmu-phil.

the class TimeoutComparison method compareFromFiles.

/**
 * Compares algorithms.
 *
 * @param dataPath Path to the directory where data and graph files have
 * been saved.
 * @param resultsPath Path to the file where the results should be stored.
 * @param algorithms The list of algorithms to be compared.
 * @param statistics The list of statistics on which to compare the
 * algorithm, and their utility weights.
 * @param parameters The list of parameters and their values.
 */
public void compareFromFiles(String dataPath, String resultsPath, Algorithms algorithms, Statistics statistics, Parameters parameters, long timeout, TimeUnit unit) {
    for (Algorithm algorithm : algorithms.getAlgorithms()) {
        if (algorithm instanceof ExternalAlgorithm) {
            throw new IllegalArgumentException("Not expecting any implementations of ExternalAlgorithm here.");
        }
    }
    this.dataPath = dataPath;
    this.resultsPath = resultsPath;
    Simulations simulations = new Simulations();
    File file = new File(this.dataPath, "save");
    File[] dirs = file.listFiles();
    if (dirs == null) {
        throw new NullPointerException("No files in " + file.getAbsolutePath());
    }
    this.dirs = new ArrayList<String>();
    int count = 0;
    for (File dir : dirs) {
        if (dir.getName().contains("DS_Store")) {
            continue;
        }
        count++;
    }
    for (int i = 1; i <= count; i++) {
        File _dir = new File(dataPath, "save/" + i);
        simulations.add(new LoadDataAndGraphs(_dir.getAbsolutePath()));
        this.dirs.add(_dir.getAbsolutePath());
    }
    compareFromSimulations(this.resultsPath, simulations, algorithms, statistics, parameters, timeout, unit);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) MultiDataSetAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) File(java.io.File) LoadDataAndGraphs(edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs)

Example 3 with LoadDataAndGraphs

use of edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs in project tetrad by cmu-phil.

the class Comparison method generateReportFromExternalAlgorithms.

public void generateReportFromExternalAlgorithms(String dataPath, String resultsPath, String outputFileName, Algorithms algorithms, Statistics statistics, Parameters parameters) {
    this.saveGraphs = false;
    this.dataPath = dataPath;
    this.resultsPath = resultsPath;
    for (Algorithm algorithm : algorithms.getAlgorithms()) {
        if (!(algorithm instanceof ExternalAlgorithm))
            throw new IllegalArgumentException("Expecting all algorithms to implement ExternalAlgorithm.");
    }
    Simulations simulations = new Simulations();
    File file = new File(this.dataPath, "save");
    File[] dirs = file.listFiles();
    if (dirs == null) {
        throw new NullPointerException("No files in " + file.getAbsolutePath());
    }
    this.dirs = new ArrayList<String>();
    int count = 0;
    for (File dir : dirs) {
        if (dir.getName().contains("DS_Store"))
            continue;
        count++;
    }
    for (int i = 1; i <= count; i++) {
        File _dir = new File(dataPath, "save/" + i);
        simulations.add(new LoadDataAndGraphs(_dir.getAbsolutePath()));
        this.dirs.add(_dir.getAbsolutePath());
    }
    compareFromSimulations(this.resultsPath, simulations, outputFileName, algorithms, statistics, parameters);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) MultiDataSetAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) LoadDataAndGraphs(edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs)

Example 4 with LoadDataAndGraphs

use of edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs in project tetrad by cmu-phil.

the class Comparison method compareFromFiles.

/**
 * Compares algorithms.
 *
 * @param dataPath    Path to the directory where data and graph files have been saved.
 * @param resultsPath Path to the file where the results should be stored.
 * @param algorithms  The list of algorithms to be compared.
 * @param statistics  The list of statistics on which to compare the algorithm, and their utility weights.
 * @param parameters  The list of parameters and their values.
 */
public void compareFromFiles(String dataPath, String resultsPath, Algorithms algorithms, Statistics statistics, Parameters parameters) {
    for (Algorithm algorithm : algorithms.getAlgorithms()) {
        if (algorithm instanceof ExternalAlgorithm) {
            throw new IllegalArgumentException("Not expecting any implementations of ExternalAlgorithm here.");
        }
    }
    this.dataPath = dataPath;
    this.resultsPath = resultsPath;
    Simulations simulations = new Simulations();
    File file = new File(this.dataPath, "save");
    File[] dirs = file.listFiles();
    if (dirs == null) {
        throw new NullPointerException("No files in " + file.getAbsolutePath());
    }
    this.dirs = new ArrayList<String>();
    int count = 0;
    for (File dir : dirs) {
        if (dir.getName().contains("DS_Store"))
            continue;
        count++;
    }
    for (int i = 1; i <= count; i++) {
        File _dir = new File(dataPath, "save/" + i);
        simulations.add(new LoadDataAndGraphs(_dir.getAbsolutePath()));
        this.dirs.add(_dir.getAbsolutePath());
    }
    compareFromSimulations(this.resultsPath, simulations, algorithms, statistics, parameters);
}
Also used : Simulations(edu.cmu.tetrad.algcomparison.simulation.Simulations) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) Algorithm(edu.cmu.tetrad.algcomparison.algorithm.Algorithm) MultiDataSetAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm) ExternalAlgorithm(edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm) LoadDataAndGraphs(edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs)

Aggregations

Algorithm (edu.cmu.tetrad.algcomparison.algorithm.Algorithm)4 ExternalAlgorithm (edu.cmu.tetrad.algcomparison.algorithm.ExternalAlgorithm)4 MultiDataSetAlgorithm (edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm)4 LoadDataAndGraphs (edu.cmu.tetrad.algcomparison.simulation.LoadDataAndGraphs)4 Simulations (edu.cmu.tetrad.algcomparison.simulation.Simulations)4 File (java.io.File)2