Skip to content

Commit

Permalink
out of bounds error
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Webb committed Jan 18, 2016
1 parent 01fc1d5 commit 91cd212
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 46 deletions.
80 changes: 37 additions & 43 deletions src/Simulation/HSimSNN/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,29 @@ type DelayedSpikes = SpikeTrain
passThroughNetwork :: SpikeTrain -> Double -> State NetworkState DelayedSpikes
passThroughNetwork EmptySpikeTrain tsim = do
(network,spkout) <- get
let i =
firstSpikingNeuron
(population network) -- Check for any spikes
if (i == Nothing) -- No spikes
then return EmptySpikeTrain
else do
let indx =
fromJust i
let nextspktm =
nextSpikeTime $
((neurons . population) network) V.!
indx
if (nextspktm >
At tsim) -- next spike time after tsim
then return EmptySpikeTrain
else do
let tn =
getTime nextspktm
let newspk =
SpikeTrain
(VU.singleton
(Spike (indx, tn)))
_ <- resetNeuronNinNet indx tn
(newnet,_) <- get
put (newnet, concST spkout newspk)
passThroughNetwork
(SpikeTrain
(VU.singleton
(Spike (indx, tn + 1.0))))
tsim
case firstSpikingNeuron (population network) of
Nothing -> return EmptySpikeTrain
Just indx ->
do let nextspktm =
nextSpikeTime
(((neurons . population) network) V.! indx)
if (nextspktm > At tsim) -- next spike time after tsim
then return EmptySpikeTrain
else do
let tn =
getTime nextspktm
let newspk =
SpikeTrain
(VU.singleton
(Spike (indx, tn)))
resetNeuronNinNet indx tn
(newnet,_) <- get
put (newnet, concST spkout newspk)
passThroughNetwork
(SpikeTrain
(VU.singleton
(Spike (indx, tn + 1.0))))
tsim
where
delay = 1.0 -- Spike transmission delay hardcoded

Expand All @@ -105,19 +98,20 @@ passThroughNetwork (SpikeTrain spktrn) tsim = do
-- Process reminder spikes
let restspk =
VU.tail spktrn -- reminder of spikes
if isEmptySpikeTrain dspktrn
then if isEmptySpikeTrain
(SpikeTrain restspk)
then passThroughNetwork EmptySpikeTrain tsim
else passThroughNetwork
(SpikeTrain restspk)
tsim
else if isEmptySpikeTrain
(SpikeTrain restspk)
then passThroughNetwork dspktrn tsim -- >>= return
else passThroughNetwork
(mergeST dspktrn (SpikeTrain restspk))
tsim
passThroughNetwork (mergeST dspktrn (SpikeTrain restspk)) tsim
-- if isEmptySpikeTrain dspktrn
-- then if isEmptySpikeTrain
-- (SpikeTrain restspk)
-- then passThroughNetwork EmptySpikeTrain tsim
-- else passThroughNetwork
-- (SpikeTrain restspk)
-- tsim
-- else if isEmptySpikeTrain
-- (SpikeTrain restspk)
-- then passThroughNetwork dspktrn tsim -- >>= return
-- else passThroughNetwork
-- (mergeST dspktrn (SpikeTrain restspk))
-- tsim
else do
-- Input spikes arrive after simulation time so they don't matter
dspktrn <-
Expand Down
5 changes: 3 additions & 2 deletions src/Simulation/HSimSNN/Spikes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ concST (SpikeTrain v1) (SpikeTrain v2) = SpikeTrain (v1 V.++ v2)

-- | Merge two SORTED spike trians
mergeST :: SpikeTrain -> SpikeTrain -> SpikeTrain
mergeST EmptySpikeTrain st = st
mergeST st EmptySpikeTrain = st
mergeST EmptySpikeTrain EmptySpikeTrain = EmptySpikeTrain
mergeST EmptySpikeTrain (SpikeTrain st) = SpikeTrain st
mergeST (SpikeTrain st) EmptySpikeTrain = SpikeTrain st
mergeST (SpikeTrain v1) (SpikeTrain v2) = SpikeTrain (merge v1 v2)
{-# INLINE mergeST #-}

Expand Down
2 changes: 1 addition & 1 deletion src/bench/bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ network1 = Network mypop conn

spktrn = SpikeTrain $ VU.fromList $ map Spike $ zip nindx tindx
tsim = 100.0 -- Simulation time (ms)
npop = 300 -- Total population size
npop = 340 -- Total population size
ninp = 100 -- No. of neurons assigned only for input
-- Simulation time
tinp = 45.0 -- input time (ms)
Expand Down

0 comments on commit 91cd212

Please sign in to comment.