Package org.kigalisim
Class KigaliSimFacade
java.lang.Object
org.kigalisim.KigaliSimFacade
Entry point into the Kigali platform when used as a library.
Facade which helps facilitate common operations within the Kigali simulation platform when used as a library. It also provides a unified interface for WASM and the command-line tool.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertResultsToCsv(List<EngineResult> results) Convert a list of EngineResult objects to a CSV string.static StringgetDetailedErrorMessage(ParseResult parseResult) Get a formatted error message from a ParseResult.static intgetNumberTotalTrials(ParsedProgram program) Calculate the total number of trials across all scenarios in a program.static ParsedPrograminterpret(ParseResult parseResult) Interpret a parsed QubecTalk script to Java objects which can run the simulation.static ParseResultParse a QubecTalk script.static ParsedProgramparseAndInterpret(String filePath) Parse and interpret a QubecTalk script from a file.static Stream<EngineResult> runScenario(ParsedProgram program, String scenarioName, ProgressReportCallback progressCallback) Run a scenario from the provided program and return results.static booleanValidate a QubecTalk script.
-
Constructor Details
-
KigaliSimFacade
public KigaliSimFacade()Constructs a new KigaliSimFacade.
-
-
Method Details
-
parse
Parse a QubecTalk script.- Parameters:
code- String code to parse as a QubecTalk source.- Returns:
- The parse result containing either the parse tree or errors.
-
interpret
Interpret a parsed QubecTalk script to Java objects which can run the simulation.- Parameters:
parseResult- The parse result from parsing the QubecTalk source.- Returns:
- The parsed program which can be used to run a specific simulation.
-
parseAndInterpret
Parse and interpret a QubecTalk script from a file.- Parameters:
filePath- The path to the QubecTalk script file.- Returns:
- The parsed program which can be used to run a specific simulation.
- Throws:
IOException- If there is an error reading the file.
-
getNumberTotalTrials
Calculate the total number of trials across all scenarios in a program.- Parameters:
program- The parsed program containing scenarios.- Returns:
- The total number of trials across all scenarios.
-
runScenario
public static Stream<EngineResult> runScenario(ParsedProgram program, String scenarioName, ProgressReportCallback progressCallback) Run a scenario from the provided program and return results.Creates and executes a simulation using the provided program and simulation name where this name refers to a scenario indicating the set of policies to be stacked. The simulation will iterate through all years from the scenario's start year to end year and collect results for all applications and substances for each year.
- Parameters:
program- The parsed program containing the simulation to run.scenarioName- The name of the simulation to execute from the program.progressCallback- Callback for reporting progress, called after each trial completes.- Returns:
- Stream of EngineResult objects containing the simulation results
-
getDetailedErrorMessage
Get a formatted error message from a ParseResult.Extracts detailed error information from a ParseResult and formats it for display to the user, including line numbers and error messages.
- Parameters:
parseResult- The ParseResult containing errors.- Returns:
- A formatted string with detailed error information, or null if no errors.
-
validate
Validate a QubecTalk script.Parse and interpret a QubecTalk script to check for syntax errors.
- Parameters:
filePath- The path to the QubecTalk script file.- Returns:
- True if the script is valid, false otherwise.
-
convertResultsToCsv
Convert a list of EngineResult objects to a CSV string.- Parameters:
results- The list of EngineResult objects to convert.- Returns:
- A CSV string representation of the results.
-