# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Simulater
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Storers.Controller"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class SimulaterClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'SimulatingStopTimeFloat',
'SimulatingStepTimeFloat'
]
#@Hooker.HookerClass(**{'HookingAfterVariablesList':[{'CallingVariable':BaseClass.__init__}]})
def default_init(self,
_SimulatingStopTimeFloat=100.,
_SimulatingStepTimeFloat=0.1,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
#@Hooker.HookerClass(**{'HookingAfterVariablesList':[{'CallingMethodStr':'hdformat'}]})
#@Argumenter.ArgumenterClass()
def do_simulate(
self,
**_KwargVariablesDict
):
#debug
'''
self.debug(('self.',self,[
]))
'''
#Return self
#return self
#</DefineClass>
View the Simulater sources on Github
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Runner
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Specials.Simulaters.Simulater"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class RunnerClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'RunningTimeFloat'
]
def default_init(self,
_RunningTimeFloat=0.,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_run(
self
):
pass
#Return self
#return self
#</DefineClass>
View the Runner sources on Github
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Moniter
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Specials.Simulaters.Runner"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Representer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
#</ImportSpecificModules>
#<DefineDoStrsList>
DoStrsList=["Moniter","Monit","Monitering","Monitered"]
#<DefineDoStrsList>
#<DefineClass>
@DecorationClass()
class MoniterClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'MonitoringTrackTuplesList'
]
def default_init(self,
_MoniteringTrackTuplesList=None,
**_KwargVariablesDict
):
#Call the parent init method
BaseClass.__init__(self,**_KwargVariablesDict)
#<DefineDoMethod>
def do_monit(self):
pass
#</DefineClass>
View the Moniter sources on Github
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Populater
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Specials.Simulaters.Moniter"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<DefineClass>
@DecorationClass()
class PopulaterClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'PopulatingUnitsInt',
'PopulatingEquationStr',
'PopulatingThresholdStr',
'PopulatingResetStr',
'PopulatingCommunicationDictsList'
]
def default_init(self,
_PopulatingUnitsInt=0,
_PopulatingEquationStr='''
dv/dt = (ge+gi-(v+49*mV))/(20*ms) : volt
dge/dt = -ge/(5*ms) : volt
dgi/dt = -gi/(10*ms) : volt
''',
_PopulatingThresholdStr='v>-50*mV',
_PopulatingResetStr='v=-60*mV',
_PopulatingCommunicationDictsList=None,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_populate(self):
#debug
'''
self.debug(('self.',self,[
]))
'''
#monit first
self.monit()
#Return self
#return self
#</DefineClass>
View the Populater sources on Github
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Dynamizer
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Specials.Simulaters.Populater"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass()
class DynamizerClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'DynamizingTraceStr',
'DynamizingExternalCurrentStr',
'DynamizingTraceDimensionStr',
'DynamizedParamStr',
'DynamizedParamStr',
'DynamizedPreStr',
'DynamizedPostStr'
]
def default_init(self,
_DynamizingTraceStr="v",
_DynamizingExternalCurrentStr='mu',
_DynamizingTraceDimensionStr='mV',
_DynamizingTimeDimensionStr='ms',
_DynamizingThresholdFunction=None,
_DynamizedParamStr="",
_DynamizedPreStr="",
_DynamizedPostStr="",
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_dynamize(
self,
):
#debug
'''
self.debug(('self.',self,[
]))
'''
#set
self.DynamizedPostStr='d'+self.DynamizingTraceStr+'/dt='
#init
self.DynamizedPreStr='('
#Check
if self.DynamizingExternalCurrentStr!="":
#Add in params declaration
self.DynamizedParamStr+=self.DynamizingExternalCurrentStr+' : '+self.DynamizingTraceDimensionStr+'\n'
#Add in DynamizedPostStr
self.DynamizedPreStr+=self.DynamizingExternalCurrentStr
def mimic_populate(self):
#dynamize first
self.dynamize()
#set
self.PopulatingEquationStr='\n'.join(
[
self.DynamizedParamStr,
self.DynamizedPostStr+self.DynamizedPreStr+' : '+self.DynamizingTraceDimensionStr
]
)
#parent
BaseClass.populate(self)
#</DefineClass>
View the Dynamizer sources on Github
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Lifer
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Specials.Simulaters.Dynamizer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<DefineClass>
@DecorationClass()
class LiferClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'RatingMatrixStr',
'RatedPreStr'
]
def default_init(self,
_LifingVoltage='J',
_RatingConstantTimeFloat='tau',
_RatedPreStr="",
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_rate(
self,
):
#debug
'''
self.debug(('self.',self,[
]))
'''
#add the connection variable
self.RatedPreStr+=self.RatingMatrixStr+self.DynamizingTraceStr
#add the constant time
#self.RatedPreStr+=')/('+self.RatingConstantTimeStr+'*'+self.DynamizingTimeDimensionStr+')'
self.RatedPreStr+=')/('+self.RatingConstantTimeStr+')'
def mimic_dynamize(self):
#parent method
BaseClass.dynamize(self)
#rate first
self.rate()
#add in the DynamizedPreStr
if self.DynamizedPreStr!='(':
self.DynamizedPreStr+=' + '
self.DynamizedPreStr+=self.RatedPreStr
#Check
if self.RatingMatrixStr!="":
self.DynamizedParamStr+=self.RatingMatrixStr+self.DynamizingTraceStr+' : '+self.DynamizingTraceDimensionStr+'\n'
#Check
if self.RatingConstantTimeStr!="":
self.DynamizedParamStr+=self.RatingConstantTimeStr+' : '+self.DynamizingTimeDimensionStr+'\n'
#set
self.DynamizingRateThresholdFunction=lambda _VariableFloat :(_VariableFloat<=0.)
#</DefineClass>
View the Lifer sources on Github
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Rater
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Specials.Simulaters.Dynamizer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<DefineClass>
@DecorationClass()
class RaterClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'RatingMatrixStr',
'RatedPreStr'
]
def default_init(self,
_RatingMatrixStr='J',
_RatingConstantTimeFloat='tau',
_RatedPreStr="",
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def do_rate(
self,
):
#debug
'''
self.debug(('self.',self,[
]))
'''
#add the connection variable
self.RatedPreStr+=self.RatingMatrixStr+self.DynamizingTraceStr
#add the constant time
#self.RatedPreStr+=')/('+self.RatingConstantTimeStr+'*'+self.DynamizingTimeDimensionStr+')'
self.RatedPreStr+=')/('+self.RatingConstantTimeStr+')'
def mimic_dynamize(self):
#parent method
BaseClass.dynamize(self)
#rate first
self.rate()
#add in the DynamizedPreStr
if self.DynamizedPreStr!='(':
self.DynamizedPreStr+=' + '
self.DynamizedPreStr+=self.RatedPreStr
#Check
if self.RatingMatrixStr!="":
self.DynamizedParamStr+=self.RatingMatrixStr+self.DynamizingTraceStr+' : '+self.DynamizingTraceDimensionStr+'\n'
#Check
if self.RatingConstantTimeStr!="":
self.DynamizedParamStr+=self.RatingConstantTimeStr+' : '+self.DynamizingTimeDimensionStr+'\n'
#set
self.DynamizingRateThresholdFunction=lambda _VariableFloat :(_VariableFloat<=0.)
#</DefineClass>
View the Rater sources on Github
# -*- coding: utf-8 -*-
"""
<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>
A Brianer
"""
#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Specials.Simulaters.Runner"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>
#<ImportSpecificModules>
from ShareYourSystem.Standards.Noders import Noder
from ShareYourSystem.Specials.Simulaters import Populater
import operator
#</ImportSpecificModules>
#<DefineClass>
@DecorationClass(**{
'ClassingSwitchMethodStrsList':['brian']
})
class BrianerClass(BaseClass):
#Definition
RepresentingKeyStrsList=[
'BrianedNetworkVariable',
'BrianedClocksList',
'BrianedNeuronGroupsList',
'BrianedConnectionsList'
]
def default_init(self,
_BrianingTimeDimensionVariable=None,
_BrianingPrintRunIsBool=True,
_BrianedNetworkVariable=None,
_BrianedClocksList=None,
_BrianedSimulationClock=None,
_BrianedNeuronGroupsList=None,
_BrianedConnectionsList=None,
**_KwargVariablesDict
):
#Call the parent __init__ method
BaseClass.__init__(self,**_KwargVariablesDict)
def mimic_run(self):
#brian first
self.brian()
#parent method
BaseClass.run(self)
#debug
self.debug('We start running in brian')
#run with the brian method
self.BrianedNetworkVariable.run(
self.RunningTimeFloat*self.BrianingTimeDimensionVariable
)
#debug
self.debug('We stop running in brian')
def do_brian(self):
#network first
self.network(
**{
'RecruitingConcludeConditionVariable':[
(
'__class__.__mro__',
operator.contains,Populater.PopulaterClass
)
]
}
)
"""
#populate
map(
lambda __NetworkedDeriveConnecter:
__NetworkedDeriveConnecter.populate(),
self.NetworkedDeriveConnectersList
)
#import
import brian
#Check
if self.BrianingTimeDimensionVariable==None:
self.BrianingTimeDimensionVariable=brian.ms
#init
self.BrianedNetworkVariable=brian.MagicNetwork()
#populate
map(
lambda __NetworkedDeriveConnecter:
__NetworkedDeriveConnecter.populate(),
self.NetworkedDeriveConnectersList
)
#set the different times
self.BrianedStepTimeFloatsList=list(
set(
SYS.flat(
map(
lambda __BrianingDerivePopulater:
SYS.unzip(
__BrianingDerivePopulater.MoniteringTrackTuplesList,
[3]
) if len(
__BrianingDerivePopulater.MoniteringTrackTuplesList
)>0 else [],
self.NetworkedDeriveConnectersList
)
)
)
)
#debug
'''
self.debug(('self.',self,['BrianedStepTimeFloatsList']))
'''
#set the clocks
self.BrianedSimulationClock=brian.Clock(
dt=self.SimulatingStepTimeFloat*self.BrianingTimeDimensionVariable
)
self.BrianedClocksDict=dict(
map(
lambda __BrianedStepTimeFloat:
(
str(__BrianedStepTimeFloat),
brian.Clock(
dt=__BrianedStepTimeFloat*self.BrianingTimeDimensionVariable
)
),
self.BrianedStepTimeFloatsList
)
,**{
str(
self.SimulatingStepTimeFloat
):self.BrianedSimulationClock
}
)
#debug
'''
self.debug(('self.',self,['BrianedClocksDict']))
'''
#set clock to the neuron groups
self.BrianedNeuronGroupsList=map(
lambda __BrianingDerivePopulater:
__BrianingDerivePopulater.__setitem__(
'NeuronGroup',
brian.NeuronGroup(
__BrianingDerivePopulater.PopulatingUnitsInt,
__BrianingDerivePopulater.PopulatingEquationStr,
clock=self.BrianedClocksDict[str(self.SimulatingStepTimeFloat)]
)
).NeuronGroup,
self.NetworkedDeriveConnectersList
)
#set the clocks and monitors
self.BrianedMonitorsList=SYS.flat(
map(
lambda __BrianingDerivePopulater:
map(
lambda __MoniteringTrackTuple:
__BrianingDerivePopulater.__setitem__(
str(__MoniteringTrackTuple)+'Monitor',
getattr(
brian,
__MoniteringTrackTuple[0]+'Monitor'
)(
__BrianingDerivePopulater.NeuronGroup,
__MoniteringTrackTuple[1],
record=__MoniteringTrackTuple[2],
clock=self.BrianedClocksDict[str(__MoniteringTrackTuple[3])]
)
).SettingValueVariable,
__BrianingDerivePopulater.MoniteringTrackTuplesList
),
self.NetworkedDeriveConnectersList
)
)
#debug
'''
self.debug(('self.',self,['NetworkedConnectionTuplesList']))
'''
#set connections
self.BrianedConnectionsList=map(
lambda __ConnectionTuple:
map(
lambda __ListedVariable:
__ConnectionTuple[0].__setitem__(
str(
(
__ConnectionTuple[0].NodeKeyStr,
__ListedVariable.NodeKeyStr
)
)+'Connection',
brian.Connection(
__ConnectionTuple[0].NeuronGroup,
__ListedVariable.NeuronGroup
)
).SettingValueVariable,
__ConnectionTuple[1][0]
)+map(
lambda __ListedVariable:
__ListedVariable.__setitem__(
str(
(
__ListedVariable.NodeKeyStr,
__ConnectionTuple[0].NodeKeyStr
)
)+'Connection',
brian.Connection(
__ListedVariable.NeuronGroup,
__ConnectionTuple[0].NeuronGroup
)
).SettingValueVariable,
__ConnectionTuple[1][1]
),
self.NetworkedConnectionTuplesList
)
#debug
'''
self.debug(('self.',self,['BrianedNeuronGroupsList']))
'''
#alias
BrianedNetworkVariable=self.BrianedNetworkVariable
#add
map(
lambda __BrianedVariable:
BrianedNetworkVariable.add(__BrianedVariable),
self.BrianedNeuronGroupsList+self.BrianedConnectionsList+self.BrianedMonitorsList
)
#Check
if self.BrianingPrintRunIsBool:
#debug
self.debug(('self.',self,[
'BrianedSimulationClock'
]))
#define
@brian.network_operation(
self.BrianedSimulationClock
)
def printControl():
#Print Time
print(
"time is "+str(
self.BrianedSimulationClock.t*self.BrianingTimeDimensionVariable
)
)
'''
#Print NeuronGroup
print(
"variables are"+str(
self.BrianedNeuronGroupsList[0]
)
)
'''
self.BrianedNetworkVariable.add(printControl);
"""
#</DefineClass>
View the Brianer sources on Github