Search in sources :

Example 1 with SolverEvaluatorConfiguration

use of com.sri.ai.praise.evaluate.solver.SolverEvaluatorConfiguration in project aic-praise by aic-sri-international.

the class Evaluation method instantiateSolvers.

@SuppressWarnings("unchecked")
private List<SolverEvaluator> instantiateSolvers(List<SolverEvaluatorConfiguration> solverConfigurations, File workingDirectory) {
    List<SolverEvaluator> result = new ArrayList<>(solverConfigurations.size());
    for (SolverEvaluatorConfiguration configuration : solverConfigurations) {
        Class<? extends SolverEvaluator> clazz;
        try {
            clazz = (Class<? extends SolverEvaluator>) Class.forName(configuration.getImplementationClassName());
        } catch (ClassNotFoundException cnfe) {
            throw new IllegalArgumentException("Unable to find " + SolverEvaluator.class.getName() + " implementation class: " + configuration.getImplementationClassName(), cnfe);
        }
        try {
            SolverEvaluator solver = clazz.newInstance();
            configuration.setWorkingDirectory(workingDirectory);
            solver.setConfiguration(configuration);
            result.add(solver);
        } catch (Throwable t) {
            throw new IllegalStateException("Unable to instantiate instance of " + clazz.getName(), t);
        }
    }
    return result;
}
Also used : SolverEvaluator(com.sri.ai.praise.evaluate.solver.SolverEvaluator) SolverEvaluatorConfiguration(com.sri.ai.praise.evaluate.solver.SolverEvaluatorConfiguration) ArrayList(java.util.ArrayList)

Example 2 with SolverEvaluatorConfiguration

use of com.sri.ai.praise.evaluate.solver.SolverEvaluatorConfiguration in project aic-praise by aic-sri-international.

the class AbstractEvaluateCLI method run.

public void run(String[] args) throws Exception {
    try (EvaluationArgs evaluationArgs = getArgs(args)) {
        PagedModelContainer modelsContainer = makeModelsContainer(evaluationArgs);
        Evaluation.Configuration configuration = new Evaluation.Configuration(Evaluation.Type.PR, evaluationArgs.workingDirectory, evaluationArgs.numberRunsToAverageOver);
        List<SolverEvaluatorConfiguration> solverConfigurations = new ArrayList<>();
        for (String solverImplementationClassName : evaluationArgs.solverImplementationClassNames) {
            solverConfigurations.add(new SolverEvaluatorConfiguration(solverImplementationClassName, evaluationArgs.totalCPURuntimeLimitSecondsPerSolveAttempt, evaluationArgs.totalMemoryLimitInMegabytesPerSolveAttempt, !evaluationArgs.translateAlways, Collections.emptyMap()));
        }
        PrintStream notificationOut = evaluationArgs.notificationOut;
        PrintStream resultOut = evaluationArgs.resultOut;
        evaluate(configuration, modelsContainer, solverConfigurations, notificationOut, resultOut);
    }
}
Also used : Evaluation(com.sri.ai.praise.evaluate.run.Evaluation) PrintStream(java.io.PrintStream) SolverEvaluatorConfiguration(com.sri.ai.praise.evaluate.solver.SolverEvaluatorConfiguration) SolverEvaluatorConfiguration(com.sri.ai.praise.evaluate.solver.SolverEvaluatorConfiguration) ArrayList(java.util.ArrayList) PagedModelContainer(com.sri.ai.praise.model.common.io.PagedModelContainer)

Aggregations

SolverEvaluatorConfiguration (com.sri.ai.praise.evaluate.solver.SolverEvaluatorConfiguration)2 ArrayList (java.util.ArrayList)2 Evaluation (com.sri.ai.praise.evaluate.run.Evaluation)1 SolverEvaluator (com.sri.ai.praise.evaluate.solver.SolverEvaluator)1 PagedModelContainer (com.sri.ai.praise.model.common.io.PagedModelContainer)1 PrintStream (java.io.PrintStream)1