Home > Practical Examples > Fuzzy Math, Part 2, In Synapse

Fuzzy Math, Part 2, In Synapse

January 1st, 2007

In the first part of this fuzzy logic tutorial we covered some of basics of the fuzzy logic theory. Here instead we will look at how you can use the fuzzy logic component in Synapse to create a fuzzy inference system.

Before proceeding, make sure that you have the latest version of Synapse. If you have automatic updates enabled you will get the latest version automatically.

So what are we going to model? For the sake of simplicity, let’s consider the fuzzy system that we looked at in the first part of the tutorial:

Example

Suppose we want to design a risk-assessment system for some form of project. We wish to determine the risk depending on project funding and staffing. The first step is to design our fuzzy variables, which are funding, staffing and risk. For each of these variables, we define the membership functions:

The next step is to define the rules for the system, using these variables. For instance one such set of rules may be:

  1. If funding is adequate or staffing is small then risk is low
  2. If funding is marginal and staffing is large then risk is normal
  3. If funding is inadequate then risk is high

Suppose we have a funding of f0 and a staffing of s0 people. What would the risk r0 be?

We have hence two fuzzy input variables (funding and staffing) and one fuzzy output variable (risk). There are three fuzzy rules for this system.

The first step in Synapse is to get some data. This is so that we can test and run the system. In this case we don’t have any real data and we will be using the probe post processing component for running the system. We still need a placeholder though and the unit generation format provides us with the means of generating a random data set. The only thing we need to really pay attention to in this stage is the range of each variable. The data unit produced will later go into a data source which will deduce scaling parameters from the data. In the case of a regular adaptive system all scaling is handled automatically, but in our case here some manual adjustments need to be made.

Using the unit generation format creates a new data unit containing three variables: funding, staffing and risk:

All variables should have a range between 0 and 100.

Now go to design mode and add one Data Source component (with the data unit we just created) and one Fuzzy Logic component. On the Fuzzy Logic component set the property “Inputs” to 2.
On the data source zoom in to the component GUI and under “Features” remove the “Risk” feature. Set the Min Out to 0 and Max Out to 100 on the two remaining features. This is needed for providing the probe with range data. If you weren’t interested in using the sliders on the probe you could have simply switched scaling off on the data source.

Zoom back and link up the data source to the fuzzy logic component. Set the “Scale” property on the fuzzy logic component to “False”.

You can download a solution that contains what we have done so far here: Funding1.synx

That’s it for preparations; now let’s move on to the fuzzy stuff. Select the fuzzy logic component. In the property browser you will notice these two fields under the “Editors” category:

MFEditor is the membership function editor where you design your fuzzy variables and the Rule Editor is where you can define your fuzzy rules.

For instructions on how to use the two editors look at the Fuzzy Logic component documentation.

In the MF Editor define the following fuzzy variables:

Input variable “funding

Range: 0-100
MFs: “inadequate”, “marginal”, “adequate”
Leave MF ranges at default values

Output variable “risk

Range: 0-100
MFs: “low”, “normal”, “high”
Leave MF ranges at default values

Input variable “staffing

Range: 0-100
MFs: “small”, “large”
“small” parameters: X0 = -0.4, X1 = 0, X2 = 0.6
“large” parameters: X0=0.4,X1=1,X2=1.4

Or if you wish you can download the solution so far here:

Now open the rule editor. Remember the rules that we had: Funding_mf.synx

  1. If funding is adequate or staffing is small then risk is low
  2. If funding is marginal and staffing is large then risk is normal
  3. If funding is inadequate then risk is high

You can write each rule by hand in the text box (and click “add rule”) or you can use the quick input way.

To enter the first rule double click on these items sequentially in the tree views on the right side:

[adequate] [or] [small] [then] [low] (Add Rule)

[marginal] [and] [large] [then] [normal] (Add Rule)

[inadequate] [then] [high] (Add Rule)

You should now see something like this:

That’s all there is. You can download the final solution here: Funding_Rules.synx

To test the system, go to post processing and select the probe. Click on the “Refresh” button and you should see something like this:

You can move the sliders on “funding” and “staffing” in the left pane and get the resulting risk in the right pane.

Tip: If you have a dual screen set up or a large monitor you can run the membership and rule editors while you use the probe. That way you can test changes in real-time without having to switch between design and post processing.

Practical Examples

  1. Jelena
    February 8th, 2009 at 18:53 | #1

    Is it possible to present some data to Peltarion and let it find fuzzy rules for this data itself?

  1. No trackbacks yet.