def decode_with_shrinking_expanding(C): def dcenter(j): return min(1.0, max(0.0, C[j])) - 0.5 if self.adjust_center else 1.0 return [ fl.PiSet(r=means[j] * dcenter(j), p=means[j] - (ds[j] * C[j + 1]), q=means[j] + (ds[j] * C[j + 1])) for j in range(self.m) ]
def test_piset(): s = fl.PiSet(r=0.5, p=0.2, q=0.8) print("y", s([0.0, 0.2, 0.35, 0.5, 0.65, 0.8, 1.0])) assert s(0.19) < 0.5 assert abs(s(0.2) - 0.5) < 0.0001 assert s(0.45) > 0.5 and s(0.45) < 1.0 assert abs(s(0.5) - 1.0) < 0.0001 assert s(0.65) > 0.5 and s(0.65) < 1.0 assert abs(s(0.8) - 0.5) < 0.0001 assert s(0.81) < 0.5
def build_pi_membership(chromosome, idx): a, r, b = sorted(chromosome[idx:idx + 3]) return fl.PiSet(a=a, r=r, b=b)
def pi_factory(*args): return fl.PiSet(p=args[0], r=args[1], q=args[2], m=2.0)