local_search/local_search.py
def read_job_data(self, fname, B):
		''' expects a file with lines of the form "job_id release_time deadline processing_length".
		This function reads this file and constructs a bipartite graph of jobs and timeslots for
		future flow computations. '''

		jobs = {}
		with open(fname) as f:
			for line in f:
				if len(line.strip()) == 0: continue
				if line.strip().startswith("#"): continue
				job_id, r, d, p = line.strip().split()
				jobs[job_id] = map(int, (r, d, p))

		self.T = max([jobs[j][1] for j in jobs]) + 1	# T = maximum deadline + 1. range = [0, T)
		self.jobs = jobs.keys()
		self.B = B

		self.g = nx.DiGraph()

		# add source and sink nodes
		self.g.add_nodes_from([self.SOURCE, self.SINK])

		# add timeslot nodes and join them to the sink
		for t in range(self.T):
			self.g.add_edge(t, self.SINK, capacity=self.B)

		for j in jobs:
			# edge from source to job node with capacity = p_j
			self.g.add_edge(self.SOURCE, j, capacity=jobs[j][2])

			# edge from job node to each valid time node [r, d]
			for t in range(jobs[j][0], jobs[j][1] + 1):
				self.g.add_edge(j, t, capacity=1)
 expects a file with lines of the form "job_id release_time deadline processing_length".
		This function reads this file and constructs a bipartite graph of jobs and timeslots for
		future flow computations. 
expects a file with lines of the form "job_id release_time deadline processing_length".
This function reads this file and constructs a bipartite graph of jobs and timeslots for
future flow computations.
expects a file with lines of the form " job_id release_time deadline processing_length " . This function reads this file and constructs a bipartite graph of jobs and timeslots for future flow computations .
def read_job_data(self, fname, B):
		jobs = {}
		with open(fname) as f:
			for line in f:
				if len(line.strip()) == 0: continue
				if line.strip().startswith("#"): continue
				job_id, r, d, p = line.strip().split()
				jobs[job_id] = map(int, (r, d, p))
		self.T = max([jobs[j][1] for j in jobs]) + 1	
		self.jobs = jobs.keys()
		self.B = B
		self.g = nx.DiGraph()
		self.g.add_nodes_from([self.SOURCE, self.SINK])
		for t in range(self.T):
			self.g.add_edge(t, self.SINK, capacity=self.B)
		for j in jobs:
			self.g.add_edge(self.SOURCE, j, capacity=jobs[j][2])
			for t in range(jobs[j][0], jobs[j][1] + 1):
				self.g.add_edge(j, t, capacity=1)
def read_job_data ( self , fname , B ) : jobs = { } with open ( fname ) as f : for line in f : if len ( line . strip ( ) ) == 0 : continue if line . strip ( ) . startswith ( "#" ) : continue job_id , r , d , p = line . strip ( ) . split ( ) jobs [ job_id ] = map ( int , ( r , d , p ) ) self . T = max ( [ jobs [ j ] [ 1 ] for j in jobs ] ) + 1 self . jobs = jobs . keys ( ) self . B = B self . g = nx . DiGraph ( ) self . g . add_nodes_from ( [ self . SOURCE , self . SINK ] ) for t in range ( self . T ) : self . g . add_edge ( t , self . SINK , capacity = self . B ) for j in jobs : self . g . add_edge ( self . SOURCE , j , capacity = jobs [ j ] [ 2 ] ) for t in range ( jobs [ j ] [ 0 ] , jobs [ j ] [ 1 ] + 1 ) : self . g . add_edge ( j , t , capacity = 1 )
expects a file with lines of the form "job_id release_time deadline processing_length".
expects a file with lines of the form " job_id release_time deadline processing_length " .
''' expects a file with lines of the form "job_id release_time deadline processing_length".
		This function reads this file and constructs a bipartite graph of jobs and timeslots for
		future flow computations. ''' # T = maximum deadline + 1. range = [0, T) # add source and sink nodes # add timeslot nodes and join them to the sink # edge from source to job node with capacity = p_j # edge from job node to each valid time node [r, d]
self
fname
B