-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathArbiterPUFFitnessMetric.py
26 lines (22 loc) · 1.2 KB
/
ArbiterPUFFitnessMetric.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from numpy import count_nonzero
from Simplified_Arbiter_PUF import SimplifiedArbiterPUF
from XORArbiterPUF import XORArbiterPUF
class XORArbiterPUFFitnessMetric:
def __init__(self, training_set):
self.training_set = training_set
def get_fitness(self, candidate_vectors):
internal_pufs = [SimplifiedArbiterPUF(candidate_vector) for candidate_vector in candidate_vectors]
candidate_puf = XORArbiterPUF(internal_pufs)
hamming_distance = sum([count_nonzero(training_example.response - candidate_puf.get_response(training_example.challenge))
for training_example in self.training_set])
fitness = len(self.training_set) - hamming_distance
return fitness
class ArbiterPUFFitnessMetric:
def __init__(self, training_set):
self.training_set = training_set
def get_fitness(self, candidate_vector):
candidate_puf = SimplifiedArbiterPUF(candidate_vector)
hamming_distance = sum([count_nonzero(training_example.response - candidate_puf.get_response(training_example.challenge))
for training_example in self.training_set])
fitness = len(self.training_set) - hamming_distance
return fitness