JSSP.solver module¶
-
class
JSSP.solver.
Solver
(data)¶ Bases:
object
The main solver class which calls tabu search and/or the genetic algorithm.
Parameters: data (Data) – JSSP instance data -
genetic_algorithm_iter
(iterations, population=None, population_size=200, selection_method_enum=<function _tournament_selection>, mutation_probability=0.8, selection_size=10, benchmark=False, verbose=False)¶ Performs the genetic algorithm for a certain number of generations.
First this function generates a random initial population if the population parameter is None, then it runs GA with the parameters specified and updates self.solution.
Parameters: - iterations (int) – number of generations to go through during the GA
- population ([Solution]) – list of Solutions to start the GA from
- population_size (int) – size of the initial population
- selection_method_enum (GASelectionEnum) – selection method to use for selecting parents from the population. Options are GASelectionEnum.TOURNAMENT, GASelectionEnum.FITNESS_PROPORTIONATE, GASelectionEnum.RANDOM
- mutation_probability (float) – probability of mutating a chromosome (i.e change an operation’s machine), must be in range [0, 1]
- selection_size (int) – size of the selection group for tournament style selection
- benchmark (bool) – if true benchmark data is gathered (i.e. # of iterations, makespans, min makespan iteration)
- verbose (bool) – if true runs in verbose mode
Return type: Returns: best solution found
-
genetic_algorithm_time
(runtime, population=None, population_size=200, selection_method_enum=<function _tournament_selection>, mutation_probability=0.8, selection_size=10, benchmark=False, verbose=False, progress_bar=False)¶ Performs the genetic algorithm for a certain number of seconds.
First this function generates a random initial population if the population parameter is None, then it runs GA with the parameters specified and updates self.solution.
Parameters: - runtime (float | datetime.timedelta) – either the number of seconds or timedelta to run the GA for
- population ([Solution]) – list of Solutions to start the GA from
- population_size (int) – size of the initial population
- selection_method_enum (GASelectionEnum) – selection method to use for selecting parents from the population. Options are GASelectionEnum.TOURNAMENT, GASelectionEnum.FITNESS_PROPORTIONATE, GASelectionEnum.RANDOM
- mutation_probability (float) – probability of mutating a chromosome (i.e change an operation’s machine), must be in range [0, 1]
- selection_size (int) – size of the selection group for tournament style selection
- benchmark (bool) – if true benchmark data is gathered (i.e. # of iterations, makespans, min makespan iteration)
- verbose (bool) – if true runs in verbose mode
- progress_bar (bool) – if true a progress bar is spawned
Return type: Returns: best solution found
-
iplot_benchmark_results
()¶ Plots the benchmark results in an ipython notebook.
Returns: None :raise UserWarning if one of the optimization functions was not ran in benchmark mode
-
output_benchmark_results
(output_dir, title=None, auto_open=True)¶ Outputs html files containing benchmark results in the output directory specified.
Parameters: - output_dir (Path | str) – path to the output directory to place the results into
- title (str) – title of the benchmark run
- auto_open (bool) – if true index.html is automatically opened in a browser
Returns: None
:raise UserWarning if one of the optimization functions was not ran in benchmark mode
-
tabu_search_iter
(iterations, num_solutions_per_process=1, num_processes=4, tabu_list_size=50, neighborhood_size=300, neighborhood_wait=0.1, probability_change_machine=0.8, reset_threshold=100, initial_solutions=None, benchmark=False, verbose=False)¶ Performs parallel tabu search for a certain number of iterations.
First the function generates random initial solutions if the initial_solutions parameter is None, then it forks a number of child processes to run tabu search.
The parent process waits for the child processes to finish, then collects their results and updates self.solution.
Parameters: - iterations (int) – number of iterations for each tabu search to go through
- num_solutions_per_process (int) – number of solutions that one tabu search process should gather
- num_processes (int) – number of processes to run tabu search in parallel
- tabu_list_size (int) – size of the tabu list
- neighborhood_size (int) – size of neighborhoods to generate during tabu search
- neighborhood_wait (float) – maximum time to wait while generating a neighborhood in seconds
- probability_change_machine (float) – probability of changing a chosen operations machine, must be in range [0, 1]
- reset_threshold (int) – number of iterations to potentially force a worse move after if the best solution is not improved
- initial_solutions ([Solution]) – initial solutions to start the tabu searches from
- benchmark (bool) – if true benchmark data is gathered (e.g. # of iterations, makespans, etc.)
- verbose (bool) – if true runs in verbose mode
Return type: Returns: best solution found
-
tabu_search_time
(runtime, num_solutions_per_process=1, num_processes=4, tabu_list_size=50, neighborhood_size=300, neighborhood_wait=0.1, probability_change_machine=0.8, reset_threshold=100, initial_solutions=None, benchmark=False, verbose=False, progress_bar=False)¶ Performs parallel tabu search for a certain number of seconds.
First the function generates random initial solutions if the initial_solutions parameter is None, then it forks/spawns num_processes of child processes to run tabu search in parallel.
The parent process waits for the child processes to finish, then collects their results and updates self.solution.
Parameters: - runtime (float | datetime.timedelta) – either the number of seconds or timedelta that tabu search should run for
- num_solutions_per_process (int) – number of solutions that one tabu search process should gather
- num_processes (int) – number of processes to run tabu search in parallel
- tabu_list_size (int) – size of the tabu list
- neighborhood_size (int) – size of neighborhoods to generate during tabu search
- neighborhood_wait (float) – maximum time to wait while generating a neighborhood in seconds
- probability_change_machine (float) – probability of changing a chosen operations machine, must be in range [0, 1]
- reset_threshold (int) – number of iterations to potentially force a worse move after if the best solution is not improved
- initial_solutions ([Solution]) – initial solutions to start the tabu searches from
- benchmark (bool) – if true benchmark data is gathered (e.g. # of iterations, makespans, etc.)
- verbose (bool) – if true runs in verbose mode
- progress_bar (bool) – if true a progress bar is spawned
Return type: Returns: best solution found
-