2016-12-21 20:54:39 +04:00
|
|
|
import numpy as np
|
|
|
|
import math
|
|
|
|
import random as rnd
|
2016-12-26 17:21:28 +04:00
|
|
|
import functools, operator
|
|
|
|
from pyFTS.common import FuzzySet, Membership
|
2016-12-21 20:54:39 +04:00
|
|
|
|
|
|
|
|
2016-12-26 17:21:28 +04:00
|
|
|
# print(common.__dict__)
|
|
|
|
|
|
|
|
def GridPartitionerTrimf(data, npart, names=None, prefix="A"):
|
2016-12-21 20:54:39 +04:00
|
|
|
sets = []
|
|
|
|
dmax = max(data)
|
2016-12-26 17:21:28 +04:00
|
|
|
dmax += dmax * 0.10
|
2016-12-21 20:54:39 +04:00
|
|
|
dmin = min(data)
|
2016-12-26 17:21:28 +04:00
|
|
|
dmin -= dmin * 0.10
|
2016-12-21 20:54:39 +04:00
|
|
|
dlen = dmax - dmin
|
|
|
|
partlen = math.ceil(dlen / npart)
|
|
|
|
partition = math.ceil(dmin)
|
|
|
|
for c in range(npart):
|
2016-12-26 17:21:28 +04:00
|
|
|
sets.append(
|
|
|
|
FuzzySet.FuzzySet(prefix + str(c), Membership.trimf, [round(partition - partlen, 3), partition, partition + partlen],
|
|
|
|
partition))
|
|
|
|
partition += partlen
|
2016-12-21 20:54:39 +04:00
|
|
|
|
|
|
|
return sets
|