Parcourir la source

deprectated HUTN

Cláudio Gomes il y a 10 ans
Parent
commit
c8baf241cd

+ 127 - 0
fsa_cbd_composition/cbdsimulator/DEPRECATED_cbdsim.sccd

@@ -0,0 +1,127 @@
+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')

+ 114 - 0
fsa_cbd_composition/cbdsimulator/DEPRECATED_cbdsim_hierarchical.sccd

@@ -0,0 +1,114 @@
+Diagram(name = 'CBDSimulator',
+        author = 'Sadaf Mustafiz and Bruno Barroca 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) < len(self.strongComponentList)
+        }
+		
+		Method computeBlock(){
+			if self->currentComponentIsCycle():
+				self.cbdController->computeNextAlgebraicLoop(self.strongComponentList[self.currentCompIdx], self.iteration)
+			else:
+				self.cbdController->computeNextBlock(self.strongComponentList[self.currentCompIdx], self.iteration)
+			end
+		}
+		
+        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 = 'Started'
+			final = 'End'
+			State('Started'):
+				Transition(target='../Initialized'):
+					Actions {
+						print('Going to Initialized... ')
+						print('Performing initialization...')
+						self.iteration = 0
+						self.clock = 0
+						self.cbdController = CBDController(self.model,self.delta)
+						self.cbdController->initSimulation()
+						print('Performing initialization... DONE')
+					}
+			State('Initialized'):
+				Transition(target='../CheckTermination'):
+					Actions {
+						print('Going to CheckTermination... ')
+					}
+			State('CheckTermination'):
+				initial = 'MacroStepProcessed'
+				State('MacroStepProcessed'):
+					Transition(target='../../DoSimulation'):
+						guard = { not self->maxIterationsReached() }
+						Actions {
+							print('Going to DoSimulation... ')
+							self.currentCompIdx = 0
+							self.depGraph = self.cbdController->createDepGraph(self.iteration)
+							self.strongComponentList = self.cbdController->createStrongComponents(self.depGraph, self.iteration)
+						}
+					Transition(target='../../End'):
+						guard = { self->maxIterationsReached() }
+						Actions {
+							print('Going to End... ')
+						}
+			State('DoSimulation'):
+				initial = 'MacroStepPrepared'
+				State('MacroStepPrepared'):
+					Transition(target='../MicroStepProcessed'):
+						Actions {
+							print('Going to MicroStepProcessed... ')
+						}
+				State('MicroStepProcessed'):
+					Transition(target='../../CheckTermination'):
+						guard = { not self->hasNextStrongComponent() }
+						Actions {
+							print('Going to CheckTermination and advancing time... ')
+							self->advanceTime()
+							print(self.clock)
+							print(self.iteration)
+						}
+					Transition(target='../MicroStepPrepared'):
+						guard = { self->hasNextStrongComponent() }
+						Actions {
+							print('Going to MicroStepPrepared')
+						}
+				State('MicroStepPrepared'):
+					Transition(target='../MicroStepProcessed'):
+						Actions {
+							print('Going to MicroStepProcessed...')
+							self->computeBlock()
+							self.currentCompIdx = self.currentCompIdx + 1
+						}
+			State('End')

+ 110 - 0
fsa_cbd_composition/cbdsimulator/DEPRECATED_cbdsim_normal_form.sccd

@@ -0,0 +1,110 @@
+Diagram(name = 'CBDSimulator',
+        author = 'Sadaf Mustafiz and Bruno Barroca 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) < len(self.strongComponentList)
+        }
+		
+		Method computeBlock(){
+			if self->currentComponentIsCycle():
+				self.cbdController->computeNextAlgebraicLoop(self.strongComponentList[self.currentCompIdx], self.iteration)
+			else:
+				self.cbdController->computeNextBlock(self.strongComponentList[self.currentCompIdx], self.iteration)
+			end
+		}
+		
+        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 = 'Started'
+			final = 'End'
+			State('Started'):
+				Transition(target='../Initialized'):
+					Actions {
+						print('Going to Initialized... ')
+						print('Performing initialization...')
+						self.iteration = 0
+						self.clock = 0
+						self.cbdController = CBDController(self.model,self.delta)
+						self.cbdController->initSimulation()
+						print('Performing initialization... DONE')
+					}
+			State('Initialized'):
+				Transition(target='../MacroStepProcessed'):
+					Actions {
+						print('Going to MacroStepProcessed... ')
+					}
+			State('MacroStepProcessed'):
+				Transition(target='../MacroStepPrepared'):
+					guard = { not self->maxIterationsReached() }
+					Actions {
+						print('Going to MacroStepPrepared... ')
+						self.currentCompIdx = 0
+						self.depGraph = self.cbdController->createDepGraph(self.iteration)
+						self.strongComponentList = self.cbdController->createStrongComponents(self.depGraph, self.iteration)
+					}
+				Transition(target='../End'):
+					guard = { self->maxIterationsReached() }
+					Actions {
+						print('Going to End... ')
+					}
+			State('MacroStepPrepared'):
+				Transition(target='../MicroStepProcessed'):
+					Actions {
+						print('Going to MicroStepProcessed... ')
+					}
+			State('MicroStepProcessed'):
+				Transition(target='../MacroStepProcessed'):
+					guard = { not self->hasNextStrongComponent() }
+					Actions {
+						print('Going to MacroStepProcessed and advancing time... ')
+						self->advanceTime()
+						print(self.clock)
+						print(self.iteration)
+					}
+				Transition(target='../MicroStepPrepared'):
+					guard = { self->hasNextStrongComponent() }
+					Actions {
+						print('Going to MicroStepPrepared')
+					}
+			State('MicroStepPrepared'):
+				Transition(target='../MicroStepProcessed'):
+					Actions {
+						print('Going to MicroStepProcessed...')
+						self->computeBlock()
+						self.currentCompIdx = self.currentCompIdx + 1
+					}
+			State('End')

+ 6 - 0
fsa_cbd_composition/cbdsimulator/DEPRECATED_generateSCCD.bat

@@ -0,0 +1,6 @@
+@ECHO OFF
+setlocal
+set PYTHONPATH=C:\Users\clagms\Source Control\Git_SCCD\src\build\lib;C:\Users\clagms\Source Control\SVN_MvK
+python "C:\Users\clagms\Source Control\Git_SCCD\textualnotations\sccdtnc.py" "C:\Users\clagms\Source Control\Git_MLE\fsa_cbd_composition\cbdsimulator\cbdsim_hierarchical.sccd" -o "C:\Users\clagms\Source Control\Git_MLE\fsa_cbd_composition\cbdsimulator\cbdsim.py"
+endlocal
+pause