|
|
@@ -1,127 +0,0 @@
|
|
|
-Diagram(name = 'CBDSimulator',
|
|
|
- author = 'Sadaf Mustafiz and Claudio Gomes',
|
|
|
- description = 'SCCD HUTN model of a CBD simulator'):
|
|
|
- Top {
|
|
|
- from CBD_Controller import CBDController
|
|
|
- import Options
|
|
|
- }
|
|
|
-
|
|
|
- Class(name = 'CBDSimulator', default = True):
|
|
|
- Attribute(name='iteration')
|
|
|
- Attribute(name='strongComponentList')
|
|
|
- Attribute(name='currentCompIdx')
|
|
|
- Attribute(name='clock')
|
|
|
- Attribute(name='delta')
|
|
|
- Attribute(name='cbdController')
|
|
|
- Attribute(name='model')
|
|
|
- Attribute(name='depGraph')
|
|
|
-
|
|
|
- Constructor(options, model) {
|
|
|
- self.options = options
|
|
|
- self.delta = self.options->getDeltaT()
|
|
|
- self.model = model
|
|
|
- }
|
|
|
-
|
|
|
- Method currentComponentIsCycle() {
|
|
|
- return self.cbdController->componentIsCycle(self.strongComponentList[self.currentCompIdx], self.depGraph)
|
|
|
- }
|
|
|
-
|
|
|
- Method hasNextStrongComponent() {
|
|
|
- return (self.currentCompIdx + 1) < len(self.strongComponentList)
|
|
|
- }
|
|
|
-
|
|
|
- Method advanceTime() {
|
|
|
- self.iteration = self.iteration + 1
|
|
|
- self.clock = self.clock + self.delta
|
|
|
- self.cbdController->advanceTimeStep()
|
|
|
- }
|
|
|
-
|
|
|
- Method maxIterationsReached() {
|
|
|
- return self.iteration >= self.options->getMaxIterations()
|
|
|
- }
|
|
|
-
|
|
|
- StateMachine:
|
|
|
- initial = 'Initialize'
|
|
|
- State('Initialize'):
|
|
|
- Transition(target='../CheckTerminationCondition'):
|
|
|
- Actions {
|
|
|
- print('Transition to CheckTerminationCondition')
|
|
|
- }
|
|
|
- OnEnter {
|
|
|
- print('Performing initialization...')
|
|
|
- self.iteration = 0
|
|
|
- self.clock = 0
|
|
|
- self.cbdController = CBDController(self.model,self.delta)
|
|
|
- self.cbdController->initSimulation()
|
|
|
- print('Performing initialization... DONE')
|
|
|
- }
|
|
|
- State('CheckTerminationCondition'):
|
|
|
- Transition(target='../CreateDependencyGraph'):
|
|
|
- guard = {not self->maxIterationsReached()}
|
|
|
- Actions {
|
|
|
- print('Transition to CreateDependencyGraph')
|
|
|
- }
|
|
|
- Transition(target='../SimulationComplete'):
|
|
|
- guard = {self->maxIterationsReached()}
|
|
|
- Actions {
|
|
|
- print('Transition to SimulationComplete')
|
|
|
- }
|
|
|
- State('CreateDependencyGraph'):
|
|
|
- Transition(target='../IsolateStrongComponents'):
|
|
|
- Actions {
|
|
|
- print('Transition to IsolateStrongComponents')
|
|
|
- }
|
|
|
- OnEnter {
|
|
|
- print('Performing dependency graph creation...')
|
|
|
- self.depGraph = self.cbdController->createDepGraph(self.iteration)
|
|
|
- print('Performing dependency graph creation... DONE')
|
|
|
- }
|
|
|
- State('IsolateStrongComponents'):
|
|
|
- Transition(target='../ExecuteSimulationStep'):
|
|
|
- Actions {
|
|
|
- print('Transition to ExecuteSimulationStep')
|
|
|
- self.currentCompIdx = -1
|
|
|
- }
|
|
|
- OnEnter {
|
|
|
- print('Performing strong components isolation...')
|
|
|
- self.strongComponentList = self.cbdController->createStrongComponents(self.depGraph, self.iteration)
|
|
|
- print('Performing strong components isolation... DONE')
|
|
|
- }
|
|
|
-
|
|
|
- State('ExecuteSimulationStep'):
|
|
|
- initial = 'CheckNextComponent'
|
|
|
- State('CheckNextComponent'):
|
|
|
- Transition(target='../CheckCycle'):
|
|
|
- guard = {self->hasNextStrongComponent()}
|
|
|
- Actions {
|
|
|
- print('Transition to CheckCycle')
|
|
|
- self.currentCompIdx = self.currentCompIdx + 1
|
|
|
- }
|
|
|
- Transition(target='../../CheckTerminationCondition'):
|
|
|
- guard = {not self->hasNextStrongComponent()}
|
|
|
- Actions {
|
|
|
- print('Transition to CheckTerminationCondition')
|
|
|
- self->advanceTime()
|
|
|
- }
|
|
|
- OnEnter {
|
|
|
- print('Performing CheckNextComponent...')
|
|
|
- print('Performing CheckNextComponent... DONE')
|
|
|
- }
|
|
|
- State('CheckCycle'):
|
|
|
- Transition(target='../CheckNextComponent'):
|
|
|
- guard = {self->currentComponentIsCycle()}
|
|
|
- Actions {
|
|
|
- print('Transition to CheckNextComponent')
|
|
|
- self.cbdController->computeNextAlgebraicLoop(self.strongComponentList[self.currentCompIdx], self.iteration)
|
|
|
- }
|
|
|
- Transition(target='../CheckNextComponent'):
|
|
|
- guard = {not self->currentComponentIsCycle()}
|
|
|
- Actions {
|
|
|
- print('Transition to CheckNextComponent')
|
|
|
- self.cbdController->computeNextBlock(self.strongComponentList[self.currentCompIdx], self.iteration)
|
|
|
- }
|
|
|
- OnEnter {
|
|
|
- print('Performing CheckCycle...')
|
|
|
- print('Performing CheckCycle... DONE')
|
|
|
- }
|
|
|
- State('SimulationComplete')
|