amount_of_processes=5#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
@lru_cache(None)
defevaluate_circuit(circuit,inputs):
intermediate_outputs=list(inputs[:])
forgate,in1,in2incircuit:
intermediate_out1=intermediate_outputs[in1]
intermediate_out2=intermediate_outputs[in2]
ifgate=='AND':
output=intermediate_out1&intermediate_out2
elifgate=='OR':
output=intermediate_out1|intermediate_out2
elifgate=='XOR':
output=intermediate_out1^intermediate_out2
elifgate=='XNOR':
output=~(intermediate_out1^intermediate_out2)&1
elifgate=='NAND':
output=~(intermediate_out1&intermediate_out2)&1
elifgate=='NOR':
output=~(intermediate_out1|intermediate_out2)&1
elifgate=='INV':
output=~intermediate_out1&1
elifgate=='ANDNOT':
output=intermediate_out1&(~intermediate_out2&1)
elifgate=='ORNOT':
output=intermediate_out1|(~intermediate_out2&1)# & 1 to ensure output is 0 or 1 else it will be -1
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")
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}")