Skip to content
Snippets Groups Projects
Commit 6c3d5324 authored by Levecque Etienne's avatar Levecque Etienne
Browse files

feat: use the config seed for the search

parent b89a770d
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,8 @@ class Block:
max_iter: int,
shared_dict: dict = None,
task_id: int = None,
verbose: bool = False):
verbose: bool = False,
rng: np.random.RandomState = None):
"""
Search a dct antecedent to the spatial_block assuming it was obtained with the given pipeline.
......@@ -43,12 +44,13 @@ class Block:
shared_dict: a manager shared memory to track tasks status
task_id: an integer to track the task status
verbose: if true, the function will use the task_id and the shared_dict to communicate advancement
rng: random number generator
Returns:
results: an antecedent if it has been found, None otherwise
iter_count: iteration counter
"""
np.random.seed(123)
if rng is None:
rng = np.random.RandomState(123)
iter_counter = 0
c, n, m = self.value.shape
target = np.array([self.value], dtype=np.int16)
......@@ -110,7 +112,7 @@ class Block:
else:
for idx in error_idx:
to_enqueue = (int(error[idx]), np.random.random(),
to_enqueue = (int(error[idx]), rng.random(),
children[not_ignored][idx].copy())
heappush(queue, to_enqueue)
......
......@@ -98,10 +98,10 @@ def handle_image(filename, config, shared_dict, task_id, verbose):
img.set_selection_parameter(preprocessing['sorting_method'], preprocessing['percentage_block_per_image'], rng=rng)
if search_config['heuristic_solver']['use']:
img.search_antecedent(max_iter_heuristic, shared_dict, task_id, verbose)
img.search_antecedent(max_iter_heuristic, shared_dict, task_id, verbose, rng)
if search_config['gurobi_solver']['use']:
img.search_antecedent_ilp(search_config['gurobi_solver'], shared_dict, task_id, verbose)
img.search_antecedent_ilp(search_config['gurobi_solver'], shared_dict, task_id, verbose, rng)
return img
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment