print "extra-memory MDP"
states = stateSpaceCreate(numChans * stackNum)
#states                = stateSpaceCreate(numChans)

CountLegacyChanIndex = 0
CountHoppingChanIndex = 0
CountIm = 0
numDqn = 0
dqnIndex = []
''' ===================================================================  '''
'''          Construct different Type of Nodes                                '''
''' ===================================================================  '''

for k in range(0, numNodes):
    if nodeTypes[k] == 0 or nodeTypes[k] == 'legacy':
        t = legacyNode(numChans, numSteps,
                       legacyChanList[CountLegacyChanIndex])
        CountLegacyChanIndex += 1
    elif nodeTypes[k] == 1 or nodeTypes[k] == 'hopping':
        t = hoppingNode(numChans, numSteps,
                        hoppingChanList[CountHoppingChanIndex], hopRate,
                        offSet[CountHoppingChanIndex])
        CountHoppingChanIndex += 1
    elif nodeTypes[k] == 2 or nodeTypes[k] == 'im':
        t = imNode(numChans, numSteps, imPeriod, imDutyCircleList[CountIm],
                   imChanList[CountIm])
        CountIm += 1
    elif nodeTypes[k] == 3 or nodeTypes[k] == 'dsa':
        t = dsaNode(numChans, numSteps)
    elif nodeTypes[k] == 4 or nodeTypes[k] == 'possion':
        t = poissonNode(numChans, numSteps, poissonChanList, arrivalInterval,
                        serviceInterval)
# Initializing Nodes, Observable States, and Possible Actions
nodes                 =  [ ]
states                = stateSpaceCreate(numChans)
CountLegacyChanIndex  = 0
CountHoppingChanIndex = 0
CountIm               = 0
CountDqn              = 0

''' ===================================================================  '''
'''          Construct different Type of Nodes                                '''
''' ===================================================================  '''

for k in range(0,numNodes):
    if   nodeTypes[k] == 0 or nodeTypes[k] == 'legacy':
        t = legacyNode(numChans,numSteps, txProbability[CountLegacyChanIndex], legacyChanList[CountLegacyChanIndex]) 
        CountLegacyChanIndex += 1               
    elif nodeTypes[k] == 1  or nodeTypes[k] == 'hopping':
        t = hoppingNode(numChans,numSteps,hoppingChanList[CountHoppingChanIndex],hopRate)
        CountHoppingChanIndex += 1
    elif nodeTypes[k] == 2 or nodeTypes[k] == 'im':
        t = imNode(numChans,numSteps,imPeriod, imDutyCircleList[CountIm], imChanList[CountIm])
        CountIm += 1
    elif nodeTypes[k] == 3  or nodeTypes[k] == 'dsa':
        t = dsaNode(numChans,numSteps,txProbability)    
    elif nodeTypes[k] == 4  or nodeTypes[k] == 'possion':
        t = poissonNode( numChans, numSteps, poissonChanList, arrivalRate, serviceRate)
    elif nodeTypes[k] == 5  or nodeTypes[k] == 'markovChain':
        t = markovChainNode( numChans, numSteps, mcChanList, alpha, beta)
    elif nodeTypes[k] == 10:
        t = mdpNode(numChans,states,numSteps,'PI')