Choose pseudorandom first solution in local search
This commit is contained in:
		
							parent
							
								
									27df20f7d1
								
							
						
					
					
						commit
						f73e28fb8a
					
				@ -1,6 +1,7 @@
 | 
				
			|||||||
from preprocessing import parse_file
 | 
					from preprocessing import parse_file
 | 
				
			||||||
from pandas import DataFrame
 | 
					from pandas import DataFrame
 | 
				
			||||||
from sys import argv
 | 
					from sys import argv
 | 
				
			||||||
 | 
					from random import seed, randint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_first_solution(n, data):
 | 
					def get_first_solution(n, data):
 | 
				
			||||||
@ -44,9 +45,19 @@ def greedy_algorithm(n, m, data):
 | 
				
			|||||||
    return solutions
 | 
					    return solutions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_pseudorandom_solution(n, data):
 | 
				
			||||||
 | 
					    seed(42)
 | 
				
			||||||
 | 
					    return data.iloc[randint(a=0, b=n)]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# NOTE In each step, switch to the element that gives the least amount
 | 
					# NOTE In each step, switch to the element that gives the least amount
 | 
				
			||||||
def local_search(n, m, data):
 | 
					def local_search(n, m, data):
 | 
				
			||||||
 | 
					    solutions = DataFrame(columns=["point", "distance"])
 | 
				
			||||||
 | 
					    first_solution = get_pseudorandom_solution(n=n, data=data)
 | 
				
			||||||
 | 
					    solutions = solutions.append(first_solution, ignore_index=True)
 | 
				
			||||||
 | 
					    for _ in range(m):
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					    return solutions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def execute_algorithm(choice, n, m, data):
 | 
					def execute_algorithm(choice, n, m, data):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user