import numpy 
import random
import copy
'''
generate a random tensor representing a DFA
'''
class DfaTensor:
	start = 0
	accept={0}
	state=2
	symbol=2
	tensor = []
	def __init__(self,stateNum,symbolNum):
		self.input(stateNum,symbolNum)
		self.generator()
		self.randomize()
	def input(self,stateNum,symbolNum):
		self.state = stateNum
		self.symbol = symbolNum
	def generator(self):
		row = [0 for i in range(self.state)]
		matrix = [copy.deepcopy(row) for i in range(self.state)]
		self.tensor = [copy.deepcopy(matrix) for i in range(self.symbol)]
	def randomize(self):
		numberAccept = random.randrange(0,self.state)
		for i in range(numberAccept):
			self.accept.add(random.randrange(0,self.state))
		for i in range(self.symbol):
			for j in range(self.state):
				k = random.randrange(0,self.state)
				self.tensor[i][j][k]=1
		return self.tensor
