import pylab as pl
from sys import path
path.append('../')
from scipy.sparse import csr_matrix
from NetPop import NetPop
import cfunctions as cfn
from functions import simpleaxis, errorfill, init_fig

init_fig()

net = NetPop(1)
W = np.copy(net.W)
dt = 1

R0 = net.R4flatPi(net.pstart_state)
Rmax = np.dot(net.calc_Qvalue().max(axis=1), net.pstart_state)

ref = 20
step = .2
rate = 400

## offline ##
try:
    perf = np.load('results/performance.npy')
except IOError:
    try:
        S = np.load('results/spikes.npz')['S']
    except IOError:
        S = [
            csr_matrix(
                cfn.runpop_js(net.W, step, 1, rate, 1000, 20, 2, ref, run))
from scipy.sparse import csr_matrix
from NetPop import NetPop
import cfunctions as cfn
from functions import simpleaxis, errorfill, init_fig

init_fig()


gamma = .98
net = NetPop(1)
W = np.copy(net.W)
W[:-1, :-1] *= gamma
W -= (1 - gamma) * net.competition

R0 = net.R4flatPi(0, gamma)
Rmax = net.calc_Qvalue(gamma).max(axis=1)[0]

ref = 20
step = .2
rate = 400

## offline ##
try:
    perf = np.load('results/performance.npy')
except IOError:
    try:
        S = np.load('results/spikes.npz')['S']
    except IOError:
        S = [csr_matrix(
            cfn.runpop_js(W, step, 1, rate, 1000, 20, 2, ref, run))
            for run in range(10)]
path.append('../')
from scipy.sparse import csr_matrix
from NetPop import NetPop
import cfunctions as cfn
from functions import simpleaxis, errorfill, init_fig

init_fig()

gamma = .98
net = NetPop(1)
W = np.copy(net.W)
W[:-1, :-1] *= gamma
W -= (1 - gamma) * net.competition

R0 = net.R4flatPi(0, gamma)
Rmax = net.calc_Qvalue(gamma).max(axis=1)[0]

ref = 20
step = .2
rate = 400

## offline ##
try:
    perf = np.load('results/performance.npy')
except IOError:
    try:
        S = np.load('results/spikes.npz')['S']
    except IOError:
        S = [
            csr_matrix(cfn.runpop_js(W, step, 1, rate, 1000, 20, 2, ref, run))
            for run in range(10)
path.append("../")
from scipy.sparse import csr_matrix
from NetPop import NetPop
import cfunctions as cfn
from functions import simpleaxis, errorfill, init_fig

init_fig()


net = NetPop(1)
W = np.copy(net.W)
dt = 1

R0 = net.R4flatPi(net.pstart_state)
Rmax = np.dot(net.calc_Qvalue().max(axis=1), net.pstart_state)

ref = 20
step = 0.2
rate = 400

## offline ##
try:
    perf = np.load("results/performance.npy")
except IOError:
    try:
        S = np.load("results/spikes.npz")["S"]
    except IOError:
        S = [csr_matrix(cfn.runpop_js(net.W, step, 1, rate, 1000, 20, 2, ref, run)) for run in range(10)]
        np.savez_compressed("results/spikes.npz", S=S)
    Tls = range(501)