fistree

Network of connected fuzzy inference systems

Description

Use a fistree object to represent a tree of interconnected fuzzy inference systems.

Creation

Description

example

fisTree = fistree(fis,connections) creates a network of interconnected fuzzy inference system objects, setting its FIS and Connections properties.

fisTree = fistree(___,'DisableStructuralChecks',disableChecks) sets the DisableStructuralChecks property.

Properties

expand all

This property is read-only.

Fuzzy inference systems, specified as an array FIS objects. You can specify any combination of mamfis, sugfis, mamfistype2, and sugfistype2 objects. Each fuzzy inference system in the FIS array must have at least one input and one output for fistree construction. To evaluate a fistree, each fuzzy inference system must have at least one rule.

Connections between fuzzy inference systems, specified as a two-dimensional string array. Each row represents a connection between two FIS objects. Specify connections as follows:

  1. Output-to-input connections, ["fromFISName/fromFISOutputName" "toFISName/toFISInputName"]. In this case, output of "fromFISName" is used as the input of "toFISName". "fromFISName" and "toFISName" must be different.

  2. Input-to-input connections, ["fromFISName/fromFISInputName" "toFISName/toFISInputName"]. In this case, inputs of "fromFISName" and "toFISName" use the same input values for evaluation. "fromFISName" and "toFISName" can be same or different.

The following diagram describes different connection types.

Connection ["fis1/x" "fis2/c"] is specified between output "x" of "fis1" and input "c" of "fis2". Connection ["fis1/a" "fis1/b"] is specified between inputs "a" and "b" of "fis1". In this diagram, the fistree inputs are "fis1/a" and "fis2/d" and the output is "fis2/y".

Connections must satisfy the following conditions:

  1. A fistree object must have at least one FIS input without any incoming connection and one FIS output without any outgoing connection.

  2. A FIS input cannot have more than one incoming connection.

  3. A FIS output can have more than one outgoing connection.

  4. An input and output of the same FIS cannot be connected. In other words, you cannot create loops between connected FIS objects.

  5. Symmetric connections cannot be specified between two inputs, ["fis1/a" "fis1/b";"fis1/b" "fis1/a"] is not allowed. Either ["fis1/a" "fis1/b"] or ["fis1/b" "fis1/a"] can be specified.

  6. Self-input loops are not allowed, ["fis1/a" "fis1/a"] cannot be specified.

Inputs to the FIS tree, specified as an array of strings. Inputs are automatically determined using the specified connections of the fistree object. FIS inputs with no incoming connections are included in Inputs. Update this property by updating the connections of the fistree object.

Outputs of the FIS tree, specified as a string. Outputs are automatically determined using the specified connections of the fistree object. FIS outputs without any outgoing connections are included in Outputs. You can update this property after initial construction of the fistree object. Existing outputs can be removed or new outputs can be added. Outputs cannot be empty.

Flag for disabling structural checks, inputs, and outputs, specified as either false or true. Set DisableStructuralChecks to true to disable automatic updates of connections, inputs, and outputs when a FIS is updated after construction of a fistree object. Disabling structural checks can produce an unexpected failure in the evalfis function.

Object Functions

evalfisEvaluate fuzzy inference system
getTunableSettingsObtain tunable settings from fuzzy inference system
getTunableValuesObtain values of tunable parameters from fuzzy inference system
setTunableValuesSpecify tunable parameter values of a fuzzy inference system

Examples

collapse all

Create a Mamdani fuzzy inference system and a Sugeno fuzzy inference system.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis2 = sugfis('Name','fis2','NumInputs',2,'NumOutputs',1);

Define the desired connections between the two fuzzy inference systems.

con1 = ["fis1/output1" "fis2/input1"];
con2 = ["fis1/input1" "fis1/input2"];

Create a tree of fuzzy inference systems.

tree = fistree([fis1 fis2],[con1; con2])
tree = 
  fistree with properties:

                        FIS: [1x2 FuzzyInferenceSystem]
                Connections: [2x2 string]
                     Inputs: [2x1 string]
                    Outputs: "fis2/output1"
    DisableStructuralChecks: 0

	See 'getTunableSettings' method for parameter optimization.

Create a FIS tree.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis2 = mamfis('Name','fis2','NumInputs',2,'NumOutputs',1);

fisT = fistree([fis1 fis2],[]);

Display the FIS tree configuration.

plotfis(fisT)
FIS Names:
	fis1
	fis2

Connections:
	[]

Inputs:
	fis1/input1
	fis1/input2
	fis2/input1
	fis2/input2

Outputs:
	fis1/output1
	fis2/output1

Add FIS

Add fis3 to fisT.

fis3 = mamfis('Name','fis3','NumInputs',2,'NumOutputs',1);
fisT.FIS(end+1) = fis3;

Add connections between fis1, fis2, and fis3.

fisT.Connections = ["fis1/output1" "fis3/input1";"fis2/output1" "fis3/input2"];

Display the updated FIS tree configuration.

plotfis(fisT)
FIS Names:
	fis1
	fis2
	fis3

Connections:
	From        	To
	------------	-----------
	fis1/output1	fis3/input1
	fis2/output1	fis3/input2

Inputs:
	fis1/input1
	fis1/input2
	fis2/input1
	fis2/input2

Outputs:
	fis3/output1

Remove FIS

Remove fis1 from fisT.

fisT.FIS(1) = [];

Display the updated FIS tree configuration.

plotfis(fisT)
FIS Names:
	fis2
	fis3

Connections:
	From        	To
	------------	-----------
	fis2/output1	fis3/input2

Inputs:
	fis2/input1
	fis2/input2
	fis3/input1

Outputs:
	fis3/output1

Create fis1, fis2, and fis3, each with two inputs and one input.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis2 = mamfis('Name','fis2','NumInputs',2,'NumOutputs',1);
fis3 = mamfis('Name','fis3','NumInputs',2,'NumOutputs',1);

Create a connection between output 1 of fis1 and input 1 of fis3.

con1 = ["fis1/output1" "fis3/input1"];

Create a connection between output 1 of fis2 and input 2 of fis3.

con2 = ["fis2/output1" "fis3/input2"];

Create a connection between input 2 of fis1 and input 1 of fis2.

con3 = ["fis1/input2" "fis2/input1"];

Create the FIS tree.

fuzzTree = fistree([fis1 fis2 fis3],[con1;con2;con3]);

Display the inputs of the FIS tree.

fuzzTree.Inputs
ans = 3x1 string array
    "fis1/input1"
    "fis1/input2"
    "fis2/input2"

Evaluate the fuzzy tree. Specify values for input 1 of fis1, input 2 of fis1, and input 2 of fis2. The value for input 2 of fis1 is also sent to input 1 of fis2.

output = evalfis(fuzzTree,[0.8 0.25 0.7]);

This example shows how to add or remove FIS tree outputs.

Add Outputs

Create fis1, fis2, and fis3, each with two inputs and one input.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis2 = mamfis('Name','fis2','NumInputs',2,'NumOutputs',1);
fis3 = mamfis('Name','fis3','NumInputs',2,'NumOutputs',1);

Create a connection between output 1 of fis1 and input 1 of fis3.

con1 = ["fis1/output1" "fis3/input1"];

Create a connection between output 1 of fis2 and input 2 of fis3.

con2 = ["fis2/output1" "fis3/input2"];

Create the FIS tree.

fuzzTree = fistree([fis1 fis2 fis3],[con1;con2]);

Display outputs of the FIS tree. By default, the only open FIS output (from fis3) is an output of the FIS tree.

fuzzTree.Outputs
ans = 
"fis3/output1"

Add the output of fis2 outputs to the tree output list.

fuzzTree.Outputs(end+1) = "fis2/output1";

Display the updated output list of the FIS tree.

fuzzTree.Outputs
ans = 2x1 string array
    "fis3/output1"
    "fis2/output1"

Evaluate the FIS tree. The result contains the outputs from fis3 and fis2.

evalfis(fuzzTree,[0.5 0.2 0.8 0.45])
ans = 1×2

    0.1507    0.1579

Remove Outputs

Remove the first output from the list.

fuzzTree.Outputs(1) = [];

Display the updated output list of the FIS tree.

fuzzTree.Outputs
ans = 
"fis2/output1"

Evaluate the FIS tree again. The result now contains the output of only fis2.

evalfis(fuzzTree,[0.5 0.2 0.8 0.45])
ans = 0.1579

This example shows construction of an incremental FIS tree. For more information on the types of fuzzy tree structures, see Fuzzy Trees.

Create fuzzy systems fis1, fis2, and fis3, each with two inputs and one input.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis1.Inputs(1).Name = "color";
fis1.Inputs(2).Name = "doors";
fis2 = mamfis('Name','fis2','NumInputs',2,'NumOutputs',1);
fis2.Inputs(2).Name = "power";
fis3 = mamfis('Name','fis3','NumInputs',2,'NumOutputs',1);
fis3.Inputs(2).Name = "autopilot";
fis3.Outputs(1).Name = "predition";

Create a connection between output 1 of fis1 and input 1 of fis2.

con1 = ["fis1/output1" "fis2/input1"];

Create a connection between output 1 of fis2 and input 1 of fis3.

con2 = ["fis2/output1" "fis3/input1"];

Create the FIS tree.

incTree = fistree([fis1 fis2 fis3],[con1;con2]);

Display the inputs of the FIS tree.

incTree.Inputs
ans = 4x1 string array
    "fis1/color"
    "fis1/doors"
    "fis2/power"
    "fis3/autopilot"

Display outputs of the FIS tree.

incTree.Outputs
ans = 
"fis3/predition"

This example shows construction of a cascaded FIS tree. For more information on the types of fuzzy tree structures, see Fuzzy Trees.

Create fuzzy systems fis1, fis2, fis3, and fis4, each with two inputs and one input.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis1.Inputs(1).Name = "dist_obs";
fis1.Inputs(2).Name = "angle_obs";
fis2 = mamfis('Name','fis2','NumInputs',2,'NumOutputs',1);
fis2.Inputs(1).Name = "dist_tar";
fis2.Inputs(2).Name = "angle_tar";
fis3 = mamfis('Name','fis3','NumInputs',2,'NumOutputs',1);
fis4 = mamfis('Name','fis4','NumInputs',2,'NumOutputs',1);
fis4.Inputs(2).Name = "preheading_robot";
fis4.Outputs(1).Name = "heading_robot";

Create a connection between output 1 of fis1 and input 1 of fis3.

con1 = ["fis1/output1" "fis3/input1"];

Create a connection between output 1 of fis2 and input 2 of fis3.

con2 = ["fis2/output1" "fis3/input2"];

Create a connection between output 1 of fis3 and input 1 of fis4.

con3 = ["fis3/output1" "fis4/input1"];

Create the FIS tree.

casTree = fistree([fis1 fis2 fis3 fis4],[con1;con2;con3]);

Display the inputs of the FIS tree.

casTree.Inputs
ans = 5x1 string array
    "fis1/dist_obs"
    "fis1/angle_obs"
    "fis2/dist_tar"
    "fis2/angle_tar"
    "fis4/preheading_robot"

Display the outputs of the FIS tree.

casTree.Outputs
ans = 
"fis4/heading_robot"

This example shows construction of an aggregated FIS tree. For more information on the types of fuzzy tree structures, see Fuzzy Trees.

Create fuzzy systems fis1, fis2, and fis3, each with two inputs and one input.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis1.Inputs(1).Name = "dist_obs";
fis1.Inputs(2).Name = "angle_obs";
fis2 = mamfis('Name','fis2','NumInputs',2,'NumOutputs',1);
fis2.Inputs(1).Name = "dist_tar";
fis2.Inputs(2).Name = "angle_tar";
fis3 = mamfis('Name','fis3','NumInputs',2,'NumOutputs',1);
fis3.Outputs(1).Name = "heading_robot";

Create a connection between output 1 of fis1 and input 1 of fis3.

con1 = ["fis1/output1" "fis3/input1"];

Create a connection between output 1 of fis2 and input 2 of fis3.

con2 = ["fis2/output1" "fis3/input2"];

Create the FIS tree.

aggTree = fistree([fis1 fis2 fis3],[con1;con2]);

Display the inputs of the FIS tree.

aggTree.Inputs
ans = 4x1 string array
    "fis1/dist_obs"
    "fis1/angle_obs"
    "fis2/dist_tar"
    "fis2/angle_tar"

Display the outputs of the FIS tree.

aggTree.Outputs
ans = 
"fis3/heading_robot"

This example shows construction of a parallel FIS tree. For more information on the types of fuzzy tree structures, see Fuzzy Trees.

Create fuzzy systems fis1, fis2, and fis3, each with two inputs and one input.

fis1 = mamfis('Name','fis1','NumInputs',2,'NumOutputs',1);
fis2 = mamfis('Name','fis2','NumInputs',2,'NumOutputs',1);

Create the FIS tree such that all of the FIS objects are in parallel; that is, there are no interconnections and all the FIS outputs are FIS tree outputs.

parTree = fistree([fis1 fis2],[]);

Display the inputs of the FIS tree.

parTree.Inputs
ans = 4x1 string array
    "fis1/input1"
    "fis1/input2"
    "fis2/input1"
    "fis2/input2"

Display the outputs of the FIS tree.

parTree.Outputs
ans = 2x1 string array
    "fis1/output1"
    "fis2/output1"

Evaluate the FIS tree.

output = evalfis(parTree,[0.1 0.3 0.8 0.4]);

Generate the final output by summing the FIS tree outputs.

finalOutput = sum(output);

Introduced in R2019a