Commit c1575ddc authored by Bowen Wu's avatar Bowen Wu
Browse files

New scheduler heuristic

parent 2de2eb5b
......@@ -53,13 +53,15 @@ class OptFuzzer(object):
for s in self.seed:
mutant = {
"id" : self.next_id,
"root" : self.next_id,
"parent" : [-1], # root seed, no parent
"mut_method" : "",
"mps" : load_mps_dict(s),
"mps" : load_mps_dict(s)
}
heapq.heappush(self.queue, ((-1, self.next_id), mutant))
heapq.heappush(self.queue, ((-1, self.next_id, 1), mutant))
self.next_id += 1
# self.queue.put_nowait(mutant)
self.mut_cnt_per_seed = [0] * len(self.seed)
print("Seeds initialized")
def get_mutant(self, mut_choice : str, nr_mutations: int = 3) -> Tuple[dict, dict]:
......@@ -67,6 +69,7 @@ class OptFuzzer(object):
parent_ent = heapq.heappop(self.queue)
parent = parent_ent[1]
# print(parent_ent[0])
self.mut_cnt_per_seed[parent["root"]] += 1
mps = deepcopy(parent["mps"])
idx = 0
......@@ -98,7 +101,9 @@ class OptFuzzer(object):
"id" : self.next_id,
"parent" : [parent["id"]], # root seed, no parent
"mut_method" : self.mut_method[idx].__str__(),
"mps" : mps_prime
"mps" : mps_prime,
"root" : parent["root"],
"mut_no" : self.mut_cnt_per_seed[parent["root"]]
}
self.next_id += 1
......@@ -166,7 +171,9 @@ class OptFuzzer(object):
are_equal = self.sol_equal(cplex_sol, gurobi_sol)
scaled_time_diff = self.get_scaled_time_diff(c_time, g_time)
heapq.heappush(self.queue, ((-self.get_perturbed_time_diff(scaled_time_diff), p[1]["id"]), p[1]))
new_key = scaled_time_diff * 0.5 + math.fabs(scaled_time_diff - p[0][2]) * 0.5
new_key = self.get_perturbed_time_diff(new_key)
heapq.heappush(self.queue, ((-new_key, p[1]["id"], scaled_time_diff), p[1]))
# print("time-diff = ", self.get_perturbed_time_diff(scaled_time_diff))
if not are_equal:
......@@ -188,6 +195,10 @@ class OptFuzzer(object):
print("Mutation methods used: ", self.mut_method)
print("# Mutations: ", self.next_id - len(self.seed))
print("# Mutants that caused a difference: ", len(self.diff))
for i, s in enumerate(self.seed):
print(i, " ", s, "\t", self.mut_cnt_per_seed[i])
for i, d in enumerate(self.diff):
print("Difference ", i, " is derived from ", d["root"], " at round ", d["mut_no"])
def checkpoint(self):
# store all the mutants that have been generated to disks
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment