Пример #1
0
def cost_func(x):
    A1 = IT2FS_Gaussian_UncertStd(domain, np.append(x[:3], 1))
    A2 = IT2FS_Gaussian_UncertStd(domain, np.append(x[3:6], 1))
    A3 = IT2FS_Gaussian_UncertStd(domain, np.append(x[6:9], 1))

    B1 = IT2FS_Gaussian_UncertStd(domain, np.append(x[9:12], 1))
    B2 = IT2FS_Gaussian_UncertStd(domain, np.append(x[12:15], 1))
    B3 = IT2FS_Gaussian_UncertStd(domain, np.append(x[15:18], 1))

    C1 = IT2FS_Gaussian_UncertStd(domain, np.append(x[18:21], 1))
    C2 = IT2FS_Gaussian_UncertStd(domain, np.append(x[21:24], 1))
    C3 = IT2FS_Gaussian_UncertStd(domain, np.append(x[24:27], 1))

    O1 = IT2FS_Gaussian_UncertStd(domain, np.append(x[27:30], 1))
    O2 = IT2FS_Gaussian_UncertStd(domain, np.append(x[30:33], 1))
    O3 = IT2FS_Gaussian_UncertStd(domain, np.append(x[33:36], 1))

    it2fls = IT2FLS()
    it2fls.add_input_variable("A")
    it2fls.add_input_variable("B")
    it2fls.add_input_variable("C")
    it2fls.add_output_variable("O")

    it2fls.add_rule([("A", A1), ("B", B1), ("C", C1)], [("O", O1)])
    #it2fls.add_rule([("A", A2), ("B", B2), ("C", C2)], [("O", O2)])
    #it2fls.add_rule([("A", A3), ("B", B3), ("C", C3)], [("O", O3)])
    #it2fls.add_rule([("A", A1), ("B", B1), ("C", C1)], [("O", O1)])
    it2fls.add_rule([("A", A2), ("B", B2), ("C", C2)], [("O", O2)])
    #it2fls.add_rule([("A", A3), ("B", B3), ("C", C3)], [("O", O3)])
    #it2fls.add_rule([("A", A1), ("B", B1), ("C", C1)], [("O", O1)])
    #it2fls.add_rule([("A", A2), ("B", B2), ("C", C2)], [("O", O2)])
    it2fls.add_rule([("A", A3), ("B", B3), ("C", C3)], [("O", O3)])

    err = 0
    for L in LearningSet:
        tr = it2fls.evaluate({
            "A": L[0][0],
            "B": L[0][1],
            "C": L[0][2]
        },
                             min_t_norm,
                             max_s_norm,
                             domain,
                             method="Height",
                             algorithm="EIASC")
        o = tr["O"]
        err += ((o[0] + o[1]) / 2 - L[1])**2
    return err / len(LearningSet)
Пример #2
0
def calculate(x, i):
    A1 = IT2FS_Gaussian_UncertStd(domain, np.append(x[:3], 1))
    A2 = IT2FS_Gaussian_UncertStd(domain, np.append(x[3:6], 1))
    A3 = IT2FS_Gaussian_UncertStd(domain, np.append(x[6:9], 1))

    B1 = IT2FS_Gaussian_UncertStd(domain, np.append(x[9:12], 1))
    B2 = IT2FS_Gaussian_UncertStd(domain, np.append(x[12:15], 1))
    B3 = IT2FS_Gaussian_UncertStd(domain, np.append(x[15:18], 1))

    C1 = IT2FS_Gaussian_UncertStd(domain, np.append(x[18:21], 1))
    C2 = IT2FS_Gaussian_UncertStd(domain, np.append(x[21:24], 1))
    C3 = IT2FS_Gaussian_UncertStd(domain, np.append(x[24:27], 1))

    O1 = IT2FS_Gaussian_UncertStd(domain, np.append(x[27:30], 1))
    O2 = IT2FS_Gaussian_UncertStd(domain, np.append(x[30:33], 1))
    O3 = IT2FS_Gaussian_UncertStd(domain, np.append(x[33:36], 1))

    it2fls = IT2FLS()
    it2fls.add_input_variable("A")
    it2fls.add_input_variable("B")
    it2fls.add_input_variable("C")
    it2fls.add_output_variable("O")

    it2fls.add_rule([("A", A1), ("B", B1), ("C", C1)], [("O", O1)])
    #it2fls.add_rule([("A", A2), ("B", B2), ("C", C2)], [("O", O2)])
    #it2fls.add_rule([("A", A3), ("B", B3), ("C", C3)], [("O", O3)])
    #it2fls.add_rule([("A", A1), ("B", B1), ("C", C1)], [("O", O1)])
    it2fls.add_rule([("A", A2), ("B", B2), ("C", C2)], [("O", O2)])
    #it2fls.add_rule([("A", A3), ("B", B3), ("C", C3)], [("O", O3)])
    #it2fls.add_rule([("A", A1), ("B", B1), ("C", C1)], [("O", O1)])
    #it2fls.add_rule([("A", A2), ("B", B2), ("C", C2)], [("O", O2)])
    it2fls.add_rule([("A", A3), ("B", B3), ("C", C3)], [("O", O3)])

    tr = it2fls.evaluate({
        "A": i[0],
        "B": i[1],
        "C": i[2]
    },
                         min_t_norm,
                         max_s_norm,
                         domain,
                         method="Height",
                         algorithm="EIASC")
    o = tr["O"]
    return (o[0] + o[1]) / 2
Пример #3
0
    def build_rules(self, rules_dir: str) -> IT2FLS:

        assert os.path.exists(rules_dir),\
         ('[Fuzzy Logic System T2 model][build_rules][ERROR]'
          ' rules_dir not found!{}').format(rules_dir)

        rules_files = os.listdir(rules_dir)

        #build fuzz logic system (type 2)
        fuzz_inf = IT2FLS()
        fuzz_inf.add_input_variable('Velocity')
        fuzz_inf.add_input_variable('Acceleration')
        fuzz_inf.add_input_variable('Deceleration')
        fuzz_inf.add_input_variable('LateralJerk')
        fuzz_inf.add_output_variable('DrivingStyle')

        #get rules
        rules = None
        if self.expert_mode == 'single':
            rules_files[0] = 'rules_0.csv'
            print('[Fuzzy Logic System T2 mode][build rules]', end='')
            print(f' single expert system! (rule:{rules_files[0]})')

            rules = self._single_expert_rules(
                os.path.join(rules_dir, rules_files[0]))
        elif self.expert_mode == 'multiple':
            print('[Fuzzy Logic System - T2][build_rules]', end='')
            print(f' multiple expert system: (n_e: {len(rules_files)})')
            rules = self._multiple_expert_rules(rules_files,
                                                root_dir=rules_dir)
        else:
            assert False,\
             ('[Fuzzy Logic System T2 model][build_rules][ERROR]'
              ' expert_mode invalid! {}').format(self.expert_mode)

        assert rules is not None,\
         ('[Fuzzy Logic System T2 model][build_rules][ERROR]'
          ' error while building rules..')

        for rule in rules:
            fuzz_inf.add_rule(rule[0], rule[1])

        return fuzz_inf
Пример #4
0
def IT2FL_v2_fun(x):
    # print("chenggong")
    domain = linspace(-1, 1., 100)

    NB = IT2FS_Gaussian_UncertStd(domain, [-1, 0.15, 0.1])
    NS = IT2FS_Gaussian_UncertStd(domain, [-0.5, 0.15, 0.1])
    MM = IT2FS_Gaussian_UncertStd(domain, [0, 0.15, 0.1])
    PS = IT2FS_Gaussian_UncertStd(domain, [0.5, 0.15, 0.1])
    PB = IT2FS_Gaussian_UncertStd(domain, [1., 0.15, 0.1])
    # IT2FS_plot(NB, NS, MM,PS,PB, legends=["NB", "NS", "NN","PS","PB"], filename="v1_input_$y")

    LB = IT2FS_Gaussian_UncertStd(domain, [-1, 0.15, 0.1])
    LS = IT2FS_Gaussian_UncertStd(domain, [-0.5, 0.15, 0.1])
    ZO = IT2FS_Gaussian_UncertStd(domain, [0, 0.15, 0.1])
    RS = IT2FS_Gaussian_UncertStd(domain, [0.5, 0.15, 0.1])
    RB = IT2FS_Gaussian_UncertStd(domain, [1., 0.15, 0.1])
    # IT2FS_plot(GB,GS,ZO,BS,BB, legends=["GB", "GS", "ZO","BS","BB"], filename="V1_output")

    #输入和输出都只有一个,输入为y方向的偏离值,输出为速度大小即前进或者后退的快慢
    myIT2FLS = IT2FLS()
    myIT2FLS.add_input_variable("x1")

    myIT2FLS.add_output_variable("y1")

    myIT2FLS.add_rule([("x1", NB)], [("y1", LB)])
    myIT2FLS.add_rule([("x1", NS)], [("y1", LS)])
    myIT2FLS.add_rule([("x1", MM)], [("y1", ZO)])
    myIT2FLS.add_rule([("x1", PS)], [("y1", RS)])
    myIT2FLS.add_rule([("x1", PB)], [("y1", RB)])

    it2out, tr = myIT2FLS.evaluate({"x1": x}, min_t_norm, max_s_norm, domain)
    # it2out["y1"].plot(filename="y1_out")
    # TR_plot(domain, tr["y1"], filename="y1_tr")
    print("v2_output:", crisp(tr["y1"]))
    if crisp(tr["y1"]) < 0:
        print("速度方向:左转", crisp(tr["y1"]) * 90)
    elif crisp(tr["y1"]) == 0:
        print("速度方向:0")
    else:
        print("速度方向:右转", crisp(tr["y1"]) * 90)

    return (crisp(tr["y1"]) * 90)
Пример #5
0
def IT2FL_fun(x, y):
    # print("chenggong")
    domain = linspace(0., 1., 100)
    # domain = linspace(-1., 1., 100)

    Small = IT2FS_Gaussian_UncertStd(domain, [0, 0.15, 0.1])
    Medium = IT2FS_Gaussian_UncertStd(domain, [0.5, 0.15, 0.1])
    Large = IT2FS_Gaussian_UncertStd(domain, [1., 0.15, 0.1])
    # IT2FS_plot(Small, Medium, Large, legends=["Small", "Medium", "large"], filename="asb(x1,x2)_ex_sets")

    S = IT2FS_Gaussian_UncertStd(domain, [0, 0.15, 0.1])
    M = IT2FS_Gaussian_UncertStd(domain, [0.5, 0.15, 0.1])
    L = IT2FS_Gaussian_UncertStd(domain, [1., 0.15, 0.1])
    # IT2FS_plot(S, M, L, legends=["S", "M", "L"], filename="y1_ex_sets")

    myIT2FLS = IT2FLS()
    myIT2FLS.add_input_variable("x1")
    myIT2FLS.add_input_variable("x2")
    myIT2FLS.add_output_variable("y1")
    #myIT2FLS.add_output_variable("y2")

    myIT2FLS.add_rule([("x1", Small), ("x2", Small)], [("y1", S)])
    myIT2FLS.add_rule([("x1", Small), ("x2", Medium)], [("y1", S)])
    myIT2FLS.add_rule([("x1", Small), ("x2", Large)], [("y1", M)])

    myIT2FLS.add_rule([("x1", Medium), ("x2", Small)], [("y1", S)])
    myIT2FLS.add_rule([("x1", Medium), ("x2", Medium)], [("y1", M)])
    myIT2FLS.add_rule([("x1", Medium), ("x2", Large)], [("y1", L)])

    myIT2FLS.add_rule([("x1", Large), ("x2", Small)], [("y1", M)])
    myIT2FLS.add_rule([("x1", Large), ("x2", Medium)], [("y1", L)])
    myIT2FLS.add_rule([("x1", Large), ("x2", Large)], [("y1", L)])

    # it2out, tr = myIT2FLS.evaluate({"x1":0.6, "x2":0.8}, min_t_norm, max_s_norm, domain)
    it2out, tr = myIT2FLS.evaluate({
        "x1": x,
        "x2": y
    }, min_t_norm, max_s_norm, domain)
    # it2out["y1"].plot(filename="y1_out")
    # TR_plot(domain, tr["y1"], filename="y1_tr")
    print("v1_output:", crisp(tr["y1"]))
Пример #6
0
NM = IT2FS_Gaussian_UncertStd(domain, [-0.5, 0.1, 0.05, 1.])
ZZ = IT2FS_Gaussian_UncertStd(domain, [0., 0.1, 0.05, 1.])
PM = IT2FS_Gaussian_UncertStd(domain, [0.5, 0.1, 0.05, 1.])
PB = IT2FS_Gaussian_UncertStd(domain, [1., 0.1, 0.05, 1.])
IT2FS_plot(NB,
           NM,
           ZZ,
           PM,
           PB,
           legends=[
               "Negative Big", "Negative Medium", "Zero", "Positive Medium",
               "Positive Big"
           ],
           filename="delay_pid_output_sets")

it2fls = IT2FLS()
it2fls.add_input_variable("I1")  # E
it2fls.add_input_variable("I2")  # dot E
it2fls.add_output_variable("O")

it2fls.add_rule([("I1", N), ("I2", N)], [("O", NB)])
it2fls.add_rule([("I1", N), ("I2", Z)], [("O", NM)])
it2fls.add_rule([("I1", N), ("I2", P)], [("O", ZZ)])
it2fls.add_rule([("I1", Z), ("I2", N)], [("O", NM)])
it2fls.add_rule([("I1", Z), ("I2", Z)], [("O", ZZ)])
it2fls.add_rule([("I1", Z), ("I2", P)], [("O", NM)])
it2fls.add_rule([("I1", P), ("I2", N)], [("O", ZZ)])
it2fls.add_rule([("I1", P), ("I2", Z)], [("O", PM)])
it2fls.add_rule([("I1", P), ("I2", P)], [("O", PB)])

Пример #7
0
from pyit2fls import IT2FLS, IT2FS_Gaussian_UncertStd, IT2FS_plot, \
                     min_t_norm, max_s_norm, TR_plot, crisp
from numpy import linspace

domain = linspace(0., 1., 100)

Small = IT2FS_Gaussian_UncertStd(domain, [0, 0.15, 0.1, 1.])
Medium = IT2FS_Gaussian_UncertStd(domain, [0.5, 0.15, 0.1, 1.])
Large = IT2FS_Gaussian_UncertStd(domain, [1., 0.15, 0.1, 1.])
IT2FS_plot(Small,
           Medium,
           Large,
           legends=["Small", "Medium", "large"],
           filename="simp_ex_sets")

myIT2FLS = IT2FLS()
myIT2FLS.add_input_variable("x1")
myIT2FLS.add_input_variable("x2")
myIT2FLS.add_output_variable("y1")
myIT2FLS.add_output_variable("y2")

myIT2FLS.add_rule([("x1", Small), ("x2", Small)], [("y1", Small),
                                                   ("y2", Large)])
myIT2FLS.add_rule([("x1", Medium), ("x2", Medium)], [("y1", Medium),
                                                     ("y2", Small)])
myIT2FLS.add_rule([("x1", Large), ("x2", Large)], [("y1", Large),
                                                   ("y2", Small)])

it2out, tr = myIT2FLS.evaluate({
    "x1": 0.9,
    "x2": 0.9
def calculate_FLS(cough_inp, fever_inp, breath_inp, age, env_inp,
                  hypertension_inp, diabetes_inp, cardiovascular_inp,
                  respiratory_inp, immune_inp):
    severity = linspace(0.0, 10.0, 100)

    # For IT2FS_Gaussian_UncertMean, the parameters define:
    # 1 - The tip of the center point of the curve
    # 2 - The width of the lower curve (higher value = lower width)
    # 3 - The height of the lower curve (higher value = higher tip)
    # 4 - The height of the center point of the outer curve.

    Cough_neg = IT2FS(severity, trapezoid_mf, [0., 0.001, 3, 7, 1.0], tri_mf,
                      [0, 0.001, 2, 0.5])
    Cough_pos = IT2FS(severity, trapezoid_mf, [5, 8, 9.999, 10, 1.0], tri_mf,
                      [8.5, 9.999, 10, 0.5])

    Fever_low = IT2FS_Gaussian_UncertMean(severity, [0, 2.65, 1, 1.0])
    Fever_mod = IT2FS_Gaussian_UncertMean(severity, [5, 2.65, 1, 1.0])
    Fever_high = IT2FS_Gaussian_UncertMean(severity, [10, 2.65, 1, 1.0])

    BreathDiff_low = IT2FS_Gaussian_UncertMean(severity, [0, 1.75, 1, 1.0])
    BreathDiff_mod = IT2FS_Gaussian_UncertMean(severity, [5, 2.5, 1, 1.0])
    BreathDiff_extr = IT2FS_Gaussian_UncertMean(severity, [10, 1.75, 1, 1.0])

    Add_low = IT2FS_Gaussian_UncertMean(severity, [0, 5, 2, 1.0])
    Add_high = IT2FS_Gaussian_UncertMean(severity, [10, 5, 2, 1.0])

    Risk_low = IT2FS_Gaussian_UncertMean(severity, [0, 3, 1, 1.0])
    Risk_high = IT2FS_Gaussian_UncertMean(severity, [6.5, 2, 1, 1.0])
    Risk_veryhigh = IT2FS_Gaussian_UncertMean(severity, [10.7, 1, 1, 1.0])

    def plot_cough_mf():
        IT2FS_plot(
            Cough_neg,
            Cough_pos,
            title="Cough",
            legends=["Negative", "Positive"],
        )

    def plot_fever_mf():
        IT2FS_plot(
            Fever_low,
            Fever_mod,
            Fever_high,
            title="Fever",
            legends=["Low", "Moderate", "High"],
        )

    def plot_additional_mf():
        IT2FS_plot(
            Add_low,
            Add_high,
            title="Additional Risks",
            legends=["Low", "High"],
        )

    def plot_breathdiff_mf():
        IT2FS_plot(
            BreathDiff_low,
            BreathDiff_mod,
            BreathDiff_extr,
            title="Breathing Difficulty",
            legends=["Low", "Moderate", "High"],
        )

    def plot_risk_mf():
        IT2FS_plot(
            Risk_low,
            Risk_high,
            Risk_veryhigh,
            title="Overall Risk",
            legends=["Unlikely", "Likely", "Extremely Likely"],
        )

    plot_fever_mf()
    plot_cough_mf()
    plot_breathdiff_mf()
    plot_additional_mf()

    plot_risk_mf()

    myIT2FLS = IT2FLS()

    myIT2FLS.add_input_variable("cough")
    myIT2FLS.add_input_variable("fever")
    myIT2FLS.add_input_variable("breath")
    myIT2FLS.add_input_variable("add")
    myIT2FLS.add_output_variable("risk")

    myIT2FLS.add_rule([("cough", Cough_neg), ("fever", Fever_low),
                       ("breath", BreathDiff_low), ("add", Add_low)],
                      [("risk", Risk_low)])
    myIT2FLS.add_rule([("cough", Cough_pos), ("fever", Fever_mod),
                       ("breath", BreathDiff_low), ("add", Add_low)],
                      [("risk", Risk_low)])
    myIT2FLS.add_rule([("cough", Cough_neg), ("fever", Fever_high),
                       ("breath", BreathDiff_low), ("add", Add_low)],
                      [("risk", Risk_low)])
    myIT2FLS.add_rule([("cough", Cough_neg), ("fever", Fever_high),
                       ("breath", BreathDiff_low), ("add", Add_high)],
                      [("risk", Risk_low)])
    myIT2FLS.add_rule([("cough", Cough_neg), ("fever", Fever_low),
                       ("breath", BreathDiff_extr), ("add", Add_low)],
                      [("risk", Risk_high)])
    myIT2FLS.add_rule([("cough", Cough_neg), ("fever", Fever_high),
                       ("breath", BreathDiff_mod), ("add", Add_low)],
                      [("risk", Risk_high)])
    myIT2FLS.add_rule([("cough", Cough_pos), ("fever", Fever_mod),
                       ("breath", BreathDiff_mod), ("add", Add_high)],
                      [("risk", Risk_veryhigh)])
    myIT2FLS.add_rule([("cough", Cough_pos), ("fever", Fever_low),
                       ("breath", BreathDiff_extr), ("add", Add_high)],
                      [("risk", Risk_veryhigh)])
    myIT2FLS.add_rule([("cough", Cough_pos), ("fever", Fever_mod),
                       ("breath", BreathDiff_mod), ("add", Add_high)],
                      [("risk", Risk_veryhigh)])
    myIT2FLS.add_rule([("cough", Cough_pos), ("fever", Fever_high),
                       ("breath", BreathDiff_extr), ("add", Add_high)],
                      [("risk", Risk_veryhigh)])

    # cough_inp = float(input("Enter severity of coughing, between 0 and 10: "))
    # fever_inp = float(input("Enter severity of fever, between 0 and 10: "))
    # breath_inp = float(input("Enter severity of breathing difficulty, between 0 and 10: "))
    # print("Input age and other additional risk factors.")
    add_inp = calc_additional_risks(age, env_inp, hypertension_inp,
                                    diabetes_inp, cardiovascular_inp,
                                    respiratory_inp, immune_inp)

    it2out, tr = myIT2FLS.evaluate(
        {
            "cough": cough_inp,
            "fever": fever_inp,
            "breath": breath_inp,
            "add": add_inp
        },
        min_t_norm,
        max_s_norm,
        severity,
        method="Centroid",
        algorithm="EKM")
    print(tr)
    print(it2out)

    it2out["risk"].plot(title="Type-2 output MF converted to Type-1")
    TR_plot(severity, tr["risk"])
    print("Chance of C19 Infection: ", int((crisp(tr["risk"])) * 10), "%")

    return int((crisp(tr["risk"])) * 10)
Пример #9
0
def IT2FL_v2(x,y):
    #domain = linspace(0., 1., 100)
    domain = linspace(-1., 1., 100)
    '''
    Small = IT2FS_Gaussian_UncertStd(domain, [0, 0.15, 0.1])
    Medium = IT2FS_Gaussian_UncertStd(domain, [0.5, 0.15, 0.1])
    Large = IT2FS_Gaussian_UncertStd(domain, [1., 0.15, 0.1])
    IT2FS_plot(Small, Medium, Large, legends=["Small", "Medium", "large"], filename="asb(x1,x2)_ex_sets")

    S = IT2FS_Gaussian_UncertStd(domain, [0, 0.15, 0.1])
    M = IT2FS_Gaussian_UncertStd(domain, [0.5, 0.15, 0.1])
    L = IT2FS_Gaussian_UncertStd(domain, [1., 0.15, 0.1])
    IT2FS_plot(S, M, L, legends=["S", "M", "L"], filename="y1_ex_sets")

    myIT2FLS = IT2FLS()
    myIT2FLS.add_input_variable("x1")
    myIT2FLS.add_input_variable("x2")
    myIT2FLS.add_output_variable("y1")
    #myIT2FLS.add_output_variable("y2")

    myIT2FLS.add_rule([("x1", Small), ("x2", Small)], [("y1", S)])
    myIT2FLS.add_rule([("x1", Small), ("x2", Medium)], [("y1", S)])
    myIT2FLS.add_rule([("x1", Small), ("x2", Large)], [("y1", M)])

    myIT2FLS.add_rule([("x1", Medium), ("x2", Small)], [("y1", S)])
    myIT2FLS.add_rule([("x1", Medium), ("x2", Medium)], [("y1", M)])
    myIT2FLS.add_rule([("x1", Medium), ("x2", Large)], [("y1", L)])

    myIT2FLS.add_rule([("x1", Large), ("x2", Small)], [("y1", M)])
    myIT2FLS.add_rule([("x1", Large), ("x2", Medium)], [("y1", L)])
    myIT2FLS.add_rule([("x1", Large), ("x2", Large)], [("y1", L)])

    it2out, tr = myIT2FLS.evaluate({"x1":0.8, "x2":0.4}, min_t_norm, max_s_norm, domain)

    it2out["y1"].plot(filename="y1_out")
    TR_plot(domain, tr["y1"], filename="y1_tr")
    print(crisp(tr["y1"]))
    '''
    NB = IT2FS_Gaussian_UncertStd(domain, [-1, 0.15, 0.1])
    NS = IT2FS_Gaussian_UncertStd(domain, [-0.5, 0.15, 0.1])
    ZO= IT2FS_Gaussian_UncertStd(domain, [0, 0.15, 0.1])
    PS = IT2FS_Gaussian_UncertStd(domain, [0.5, 0.15, 0.1])
    PB = IT2FS_Gaussian_UncertStd(domain, [1., 0.15, 0.1])
    # IT2FS_plot(NB, NS, ZO,PS,PB, legends=["NB", "NS", "ZO","PS","PB"], filename="asb(x1,x2)_ex_sets")

    LVB = IT2FS_Gaussian_UncertStd(domain, [-0.875, 0.15, 0.1])
    LB = IT2FS_Gaussian_UncertStd(domain, [-0.625, 0.15, 0.1])
    LS= IT2FS_Gaussian_UncertStd(domain, [-0.375, 0.15, 0.1])
    LVS = IT2FS_Gaussian_UncertStd(domain, [-0.125, 0.15, 0.1])
    Z = IT2FS_Gaussian_UncertStd(domain, [0, 0.15, 0.1])
    RVS = IT2FS_Gaussian_UncertStd(domain, [0.125, 0.15, 0.1])
    RS = IT2FS_Gaussian_UncertStd(domain, [0.375, 0.15, 0.1])
    RB= IT2FS_Gaussian_UncertStd(domain, [0.625, 0.15, 0.1])
    RVB = IT2FS_Gaussian_UncertStd(domain, [0.875, 0.15, 0.1])
    # IT2FS_plot(LVB, LB, LS,LVS,Z,RVS,RS,RB,RVB, legends=["LVB", "LB", "LS","LVS","Z","RVS","RS","RB","RVB"], filename="y2_ex_sets")

    myIT2FLS = IT2FLS()
    myIT2FLS.add_input_variable("x1")
    myIT2FLS.add_input_variable("x2")
    #myIT2FLS.add_output_variable("y1")
    myIT2FLS.add_output_variable("y2")

    myIT2FLS.add_rule([("x1", NB), ("x2", NB)], [("y2", LS)])
    myIT2FLS.add_rule([("x1", NB), ("x2", NS)], [("y2", LS)])
    myIT2FLS.add_rule([("x1", NB), ("x2", ZO)], [("y2", LS)])
    myIT2FLS.add_rule([("x1", NB), ("x2", PS)], [("y2", LB)])
    myIT2FLS.add_rule([("x1", NB), ("x2", PB)], [("y2", LVB)])

    myIT2FLS.add_rule([("x1", NS), ("x2", NB)], [("y2", LVS)])
    myIT2FLS.add_rule([("x1", NS), ("x2", NS)], [("y2", LS)])
    myIT2FLS.add_rule([("x1", NS), ("x2", ZO)], [("y2", LS)])
    myIT2FLS.add_rule([("x1", NS), ("x2", PS)], [("y2", LVB)])
    myIT2FLS.add_rule([("x1", NS), ("x2", PB)], [("y2", LVB)])

    myIT2FLS.add_rule([("x1", ZO), ("x2", NB)], [("y2", Z)])
    myIT2FLS.add_rule([("x1", ZO), ("x2", NS)], [("y2", Z)])
    myIT2FLS.add_rule([("x1", ZO), ("x2", ZO)], [("y2", Z)])
    myIT2FLS.add_rule([("x1", ZO), ("x2", PS)], [("y2", LVB)])
    myIT2FLS.add_rule([("x1", ZO), ("x2", PB)], [("y2", LVB)])

    myIT2FLS.add_rule([("x1", PS), ("x2", NB)], [("y2", RVS)])
    myIT2FLS.add_rule([("x1", PS), ("x2", NS)], [("y2", RS)])
    myIT2FLS.add_rule([("x1", PS), ("x2", ZO)], [("y2", RB)])
    myIT2FLS.add_rule([("x1", PS), ("x2", PS)], [("y2", RVB)])
    myIT2FLS.add_rule([("x1", PS), ("x2", PB)], [("y2", RVB)])

    myIT2FLS.add_rule([("x1", PB), ("x2", NB)], [("y2", RS)])
    myIT2FLS.add_rule([("x1", PB), ("x2", NS)], [("y2", RS)])
    myIT2FLS.add_rule([("x1", PB), ("x2", ZO)], [("y2", RB)])
    myIT2FLS.add_rule([("x1", PB), ("x2", PS)], [("y2", RB)])
    myIT2FLS.add_rule([("x1", PB), ("x2", PB)], [("y2", RVB)])

    it2out, tr = myIT2FLS.evaluate({"x1":x, "x2":y}, min_t_norm, max_s_norm, domain)
    print("v2_output:",crisp(tr["y2"]))