+amount_of_processes = 27 #how many processors to assign. I recommend 3 or 9 as there are 9 gates and the search space is created by dividing the top level of gates therefore divide 9 by the amount of processors
+ for circuit in generate_all_circuits(num_inputs, num_gates, gate_types, best_area, worker_id):
+ total_area = sum(gate_types[gate] for gate, _, _ in circuit)
+ if(i % 100000 == 0):
+ print(f"Circuit: {i:,} at num_gates: {num_gates} with area: {total_area} in process: {worker_id} with last gate: {circuit[-1]} and total time taken: {time.perf_counter() - tic2:0.4f} seconds")
+ tic2 = time.perf_counter()
+ i += 1
+ if total_area > best_area:
+ continue
+ if all(evaluate_circuit(tuple(circuit), inputs) == target_output
+ for inputs, target_output in zip(truth_table, target_outputs)):
+ if not best_circuit or total_area < best_area:
+ best_circuit = circuit
+ best_area = total_area
+ print("New best circuit found with area", best_area, ":", best_circuit)
+ else:
+ print("Circuit with area", total_area, " on process ",worker_id,":")
+ print(f"processes { worker_id } ran for {toc - tic:0.4f} seconds meaning {((toc - tic)/i):0.4f} seconds per circuit with {i} circuits best area: {best_area}")