-
Notifications
You must be signed in to change notification settings - Fork 1
Using the Simulator
thomas-vogel edited this page Jan 28, 2018
·
3 revisions
The following code snippet illustrates the use of the simulator. See also the example solutions we provide for the self-healing and self-optimization cases of mRUBiS, which use the simulator in the very same fashion.
// Load the CompArch model; Architecture is the root element of the model.
Architecture architecture = ...
// Instantiate the utility function and scenario
UtilityFunction utilityFunction = ...
Scenario scenario = ...
// Parameters for the simulator
// Number of simulation rounds
int rounds = ...
/* Delay im ms before the issues are injected in one round.
* A delay avoids overlapping of the points in time when a
* feedback loop has finished and when new issues are injected. */
long injectionDelayMS = ...
/* Whether the simulator should track and provide events
* notifying about changes of the CompArch model. */
boolean eventTrackingEnabled = ...
// Whether the simulator should log to the console in addition to a file.
boolean logToConsole = ...
// Get an instance of the simulator
Simulator simulator = Simulator.FACTORY.createSimulator(architecture,
utilityFunction, scenario, runs, injectionDelayMS, eventTrackingEnabled,
Level.CONFIG, logToConsole);
// Add the validators to the simulator
simulator.addValidator(new ComponentLifeCycleAdaptationValidator());
simulator.addValidator(new ComponentStateValidator());
...
// Run the simulation
do {
// Trigger the simulator to inject issues
simulator.injectIssues();
// Run feedback loop and repair the issues
// TODO
// Trigger the simulator to validate the model
simulator.validateModel();
// Optionally, snapshot the model (see folder "results" of the project)
// simulator.snapshotModel();
// Repeat until the simulation is completed
} while (!simulator.isSimulationCompleted());
// Create and show final results (see folder "results" of the project)
simulator.showResults();
mRUBiS Exemplar by Thomas Vogel (2018)