# === OFFLINE ===

if MODELGENERATION:
	if os.path.isfile(EXPORTFILENAME+'.sta'):
		print "WARINING: Model files already exist, delete them to generate them again"
	else:
		# explicit MDP out of the POMDP
	    print "-> MODEL GENERATION"
	    start = time.time()

	    explicit = mdp.mdp()
	    explicit.initExplicit(P)
	    exp.export2sta(explicit, P.L, P.M, P.O, "(c,pos,obs)", EXPORTFILENAME+'.sta')
	    exp.export2tra(explicit, EXPORTFILENAME+'.tra')
	    exp.export2lab(EXPORTFILENAME+'.lab')
	    
	    end = time.time()
	    print "-> DONE (time: "+ str(end-start) + ")"

if MODELCHECKING:
	if os.path.isfile(PRISMFILENAME):
		print "WARNING: Probability file already exists, delete it to generate it again"
	else:
	    command = PRISMPATH + " -importmodel " + EXPORTFILENAME + \
	        ".all -mdp " + FORMULAFILENAME + ".props -prop " + \
	        PROPNAME + " > " + PRISMFILENAME
	    print "-> EXECUTING: " + command
	    start = time.time()
	    os.system(command)
	    end = time.time()
        else:
            P.Z[(l,m)] = { 'none' : 1 }

# === OFFLINE ===

if MODELGENERATION:
    # implicit MDP out of the POMDP
    print "-> MODEL GENERATION"
    imp = mdp.mdp()
    imp.initImplicit(P)
    print "--> export sta"
    exp.export2sta(imp, P.L, P.M, P.O, NROB, filename+'.sta')
    print "--> export tra"
    exp.export2tra(imp, filename+'.tra')
    print "--> export lab"
    exp.export2lab(filename+'.lab')

if MODELCHECKING:
    print "-> MODEL CHECKING"
    command = PRISMPATH + " -importmodel " + filename + \
        ".all -mdp " + formulaeFileName + ".props -prop " + \
        propName + " > " + tempFileName
    print "--> EXECUTING: " + command
    start = time.time()
    os.system(command)
    end = time.time()
    print "--> DONE (time: "+ str(end-start) + ")"

# === ONLINE ===

if SIMULATION: