FUZZY SETS FOR ADA
version 5.15
by Dmitry A. Kazakov

(mailbox@dmitry-kazakov.de)
[Home]

This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

As a special exception, if other files instantiate generics from this unit, or you link this unit with other files to produce an executable, this unit does not by itself cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU Public License.


[TOC][Next]

The current version includes distributions of string edit, interval arithmetic and simple components packages. It provides implementations of:

See also the changes log.

Quick reference:

Confidence factors (truth values)
Fuzzy sets
Intuitionistic_fuzzy sets
Fuzzy logic
Fuzzy numbers
Linguistic variables
Sets of linguistic variables
Graphical User Interface  (GTK+ widgets)

fuzzy linguistic set editor vertical

      ARM Intel
Download Fuzzy Sets for Ada Platform:   64- 32- 64- 32 bit
Fedora packages fedora   precompiled and packaged using RPM     [Download page] [Download page] [Download page] [Download page]
CentOS packages CentOS   precompiled and packaged using RPM         [Download page] [Download page]
Debian packages Debian   precompiled and packaged for dpkg   [Download page] [Download page] [Download page] [Download page]
Ubuntu packages Ubuntu      precompiled and packaged for dpkg   [Download page] [Download page] [Download page] [Download page]
Source distribution (any platform)   fuzzy_5_15.tgz (tar + gzip, Windows users may use WinZip)   [Download]

See also changes log.


[Back][TOC][Next]

1. Truth values

The type Confidence is defined in the package Confidence_Factors. A value of the type Confidence indicates the level of certainty  that an element belongs to the fuzzy set. An instance of Confidence can be viewed as a number in [0,1]. The value 0 corresponds to false of Boolean logic. The value 1 is an equivalent of true. The package Confidence_Factors has the constant Resolution that defines the granularity of Confidence. The following operations are defined on the instances of Confidence:

function "not" (Left : Confidence) return Confidence;
function "and" (Left, Right : Confidence) return Confidence;
function "mod" (Left, Right : Confidence) return Confidence;
function "or"  (Left, Right : Confidence) return Confidence;
function "rem" (Left, Right : Confidence) return Confidence;
function "xor" (Left, Right : Confidence) return Confidence;
function "+"   (Left, Right : Confidence) return Confidence;
function "-"   (Left, Right : Confidence) return Confidence;
function "*"  ... -- predefined by the language

These operations are defined as follows:

Operation  Name  Definition
Complement not 1 - x = x
Fuzzy and and min (x, y) = x&y
Truncation mod x if x > y, otherwise 0
Fuzzy or or max (x, y) = xy
Rounding rem x if x < y, otherwise 1
Fuzzy xor (distance) xor max (min (x, 1 - y), min (1 - x, y)) = (x&y) ∨ (x&y)
Distance - | x - y |
Probabilistic or + x + y - x · y
Probabilistic and * x · y

Notes about xor. Fuzzy xor can be defined in two ways equivalent in crisp logic: (x&y) ∨ (x&y) and (xy) & (xy). These two definitions stay equivalent when x and y become fuzzy, despite the fact that x&x might be greater than 0 and xx be less than 1. It can be shown that:

(x&x) ∨ (y&y) ≤ (x&y) ∨ (x&y) = (xy) & (xy) ≤ (xx) & (y∨y).

The upper and lower bounds here characterize fuzziness of the arguments. For x=y xor reaches its lower bound x&x = x xor x. For x=y xor reaches its upper bound: x xor x = xx.

[Back][TOC][Next]

1.1. String I/O of truth values

The child package Confidence_Factors.Edit defines I/O operations on Confidence.

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Confidence
          );

This procedure gets a confidence factor from the string Source. The factor can be given either in a numeric form or as true or false (case insensitive). The process starts from Source (Pointer). Upon successful completion Pointer is advanced to the first unmatched character. The following exceptions are propagated out of the procedure:

Exceptions
Constraint_Error The factor is not in the range 0..1
Data_Error Syntax error in the number
End_Error There is no confidence factor in the string
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value (Source : String) return Confidence;

This function gets a confidence factor from the string Source. The confidence factor specification in the string can be surrounded by the characters representing UTF-8 encoded code points from the set Blanks. The whole string should be matched. Otherwise the exception Data_Error is propagated. The following exceptions are propagated out of the procedure:

Exceptions
Constraint_Error The factor is not in the range 0..1
Data_Error Syntax error in the number
End_Error There is no confidence factor in the string

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Confidence;
             Field       : Natural := 0;
             Justify     : Strings_Edit.Alignment := Strings_Edit.Left;
             Fill        : Character := ' '
          );

This procedure places the confidence factor specified by the parameter Value into the output string Destination. True and false (Confidence'Last, Confidence'First) are put as 1 and 0, correspondingly. Other values are put in a fixed point numeric format. The string is written starting from Destination (Pointer). When the parameter Field is not zero then Justify specifies alignment and Fill is the character used for filling. When Field is greater than Destination'Last - Pointer + 1, the latter is used instead. After successful completion Pointer is advanced to the first character following the output or to Destination'Last + 1.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is
no room for the output

function Image (Value : Confidence) return String;

This function is used to convert Confidence to String. 

function To_Confidence (Value : Boolean) return Confidence;

This function is used to convert a Boolean value to Confidence.


[Back][TOC][Next]

2. Fuzzy sets

A fuzzy set mathematically is a function mapping its domain to [0,1]. So a fuzzy set A over some domain set D is A: D→[0,1]. For any domain value x∈D it gives a confidence factor (or else a level of truth) telling how possible is that x belongs to A, i.e. A(x) = PA|{x} = Px∈A. Customary the membership function of A is distinguished from the set and notated as μA(x), but we will not do it. Though the meaning of A(x) was defined as a possibility, it is both a necessity that x belongs to A. This is because for fuzzy sets we postulate that PA|{x} = NA|{x} = Nx∈A. Which is equivalent to a definition of the fuzzy set complement as A(x) = 1-A(x).

The type Set is defined in the package Fuzzy. It represents a fuzzy set over an interval of integer numbers. A more natural approach would be to define fuzzy sets with the domain of any discrete type. Unfortunately it would make the package generic, with the consequence that it would be almost impossible to use it for things like fuzzy decision trees. So I chose the following definition of the type Set:

type Set is array (Integer range <>) of Confidence;

The package Fuzzy defines various operations on the instances of Set.

[Back][TOC][Next]

2.1. Tests

Confidence of an element can be obtained either by using the predefined array indexing operation or by the function Is_In:

function Is_In (Point : Integer; A : Set) return Confidence;

The function Is_In does not raise an exception even if Point is not in A'Range, in which case it returns 0.

[Back][TOC][Next]

2.2. Operations producing a new set

function "not" (A : Set) return Set;

function "and" (A, B : Set) return Set;
   function
"and" (A : Set; B : Confidence) return Set;
   function
"and" (A : Confidence; B : Set) return Set;

function
"mod" (A, B : Set) return Set;
   function
"mod" (A : Set; B : Confidence) return Set;
   function
"mod" (A : Confidence; B : Set) return Set;

function
"or" (A, B : Set) return Set;
   function
"or" (A : Set; B : Confidence) return Set;
   function
"or" (A : Confidence, B : Set) return Set;

function
"xor" (A, B : Set) return Set;
   function
"xor" (A : Set; B : Confidence) return Set;
   function
"xor" (A : Confidence; B : Set) return Set;

function
"rem" (A, B : Set) return Set;
   function
"rem" (A : Set; B : Confidence) return Set;
   function
"rem" (A : Confidence; B : Set) return Set;

function
"+" (A, B : Set) return Set;
   function
"+" (A : Set; B : Confidence) return Set;
   function
"+" (A : Confidence; B : Set) return Set;

function
"-" (A, B : Set) return Set;
   function
"-" (A : Set; B : Confidence) return Set;
   function
"-" (A : Confidence; B : Set) return Set;

function
"*" (A, B : Set) return Set;
   function
"*" (A : Set; B : Confidence) return Set;
   function
"*" (A : Confidence; B : Set) return Set;

These operations are defined per point as follows from the table:

Operation  Name  Definition
Complement not 1 - ai = ai
Fuzzy and (intersection ∩) and min (ai, bi) = ai&bi
Truncation (α-cut) mod ai if ai > bi, otherwise 0
Fuzzy or (union ∪) or max (ai, bi) = aibi
Fuzzy xor (distance) xor max (min (ai, 1 - bi), min (1 - ai, bi)) = (ai&bi)∨(ai&bi) = (aibi)&(aibi)
Rounding rem ai if ai < bi, otherwise 1
Distance - | ai - bi |
Probabilistic or + ai + bi - ai · bi
Probabilistic and * ai · bi

When both parameters are sets then they must have the domains of same size (i.e. they should have same cardinality). Otherwise the exception Constraint_Error is propagated. When one of the parameters  is of the type Confidence then the result is computed as if it would be a set with all elements having the membership function equal to the value of the parameter.

The package also provides in-place variants for the set operations above:

procedure Not_At (A : in out Set);
procedure Add_At (A : in out Set; B : Set);
   procedure Add_At (A : in out Set; B : Confidence);
procedure And_At (A : in out Set; B : Set);
   procedure And_At (A : in out Set; B : Confidence);
   procedure And_At (A : in out Set; B : Set; C : Confidence);
procedure Diff_At (A : in out Set; B : Set);
   procedure Diff_At (A : in out Set; B : Confidence);
procedure Mod_At (A : in out Set; B : Set);
   procedure Mod_At (A : in out Set; B : Confidence);
procedure Mul_At (A : in out Set; B : Set);
   procedure Mul_At (A : in out Set; B : Confidence);
procedure Or_At (A : in out Set; B : Set);
   procedure Or_At (A : in out Set; B : Confidence);
   procedure Or_At (A : in out Set; B : Set; C : Confidence);
procedure Rem_At (A : in out Set; B : Set);
   procedure Rem_At (A : in out Set; B : Confidence);
procedure Xor_At (A : in out Set; B : Set);
   function Xor_At (A : in out Set; B : Confidence);

In-place variants can be more efficient. The procedure And_At with three parameters A, B, C is an equivalent to A and (B or C). The procedure Or_At with three parameters does A or (B and C).

Some properties of α-cuts:

Inversion of ∪:   x (A mod B)(x)≤C(x) <=> A(x)≤(B∪C)(x)
Association with ∪:   (A∪B) mod C = (A mod C)∪(B mod C)
    A mod (B∪C) = (A mod B)∩(A mod C)
Association with ∩:   (A∩B) mod C = (A mod C)∩(B mod C)
    A mod (B∩C) = (A mod B)∪(A mod C)
Absorption:   (A∩B) mod (A∩C) = (A∩B) mod C
de Morgan's rule:   A mod B = A rem B

Properties of xor:

Equivalent definitions:   (A&B) ∨ (A&B)   =  (A∨B) & (AB)
Lower bound:   x (A xor B)(x) ((A&A) ∨ (B&B))(x)
Upper bound:   x (A xor B)(x) ((A∨A) & (B∨B))(x)
Measure of non-contradiction:   A xor A = A&A
Measure of excluded middle:   A xor A = A∨A

[Back][TOC][Next]

2.3. Possibility theory

The following functions compute the possibility and necessity of fuzzy events. They return the result of Confidence type:

function Possibility (A, B : Set) return Confidence;
function Possibility (A    : Set) return Confidence;
function Necessity   (A, B : Set) return Confidence;
function Necessity   (A    : Set) return Confidence;

The functions are defined as follows:

Function Notation Definition
Conditional possibility (how possible is A if B), PA|B Possibility (A, B)
Max
i
 min (ai, bi)  =  PA∩B
Possibility (how possible is A if true), PA Possibility (A)
Max
i
 ai  =  PA
Conditional necessity (how necessary is A if B), NA|B Necessity (A, B)
Min
i
 max (ai, 1-bi)  =  NA∪B
Necessity (how necessary is A if true), NA Necessity (A)
Min
i
 ai  =  NA

The parameters must have the domains of same size (same cardinality). For an empty set, the possibility is defined as 0 (false), the necessity is defined as 1 (true). Otherwise the exception Constraint_Error is propagated.

Conditional possibilities and necessities. The most important results about the possibility and necessity are:

NA|B = PA|B
PA|B = PB|A
NA|B = NB|A
PA|B ≥ NA|B if ∃x B(x)=1 (B is normal)
PA∪B|C  =  PA|C∨PB|C       NA∪B|C  ≥  NA|C∨NB|C
PA∩B|C PA|C&PB|C   NA∩B|C = NA|C&PB|C
PA|B∪C = PA|B∨PA|C   NA|B∪C = NA|B&NA|C
PA|B∩C PA|B&PA|C   NA|B∩C NA|B∨NA|C

Fuzzy inclusion. NB|A is a fuzzy equivalent of A⊆B. This follows from the definition of ⊆ for crisp sets ∀x x∈A=>x∈B. Which is same:

Inf
x
 (x∈A=>x∈B)  =  Inf
x
 (x∈Ax∈B)  =  Inf
x
 A(x)∨B(x)  =  NB|A

Thus for crisp sets A⊆B = NB|A, so it would be naturally to assume that it is also so for fuzzy sets, i.e. that A⊆B = NA∪B = NB|A. In other words A⊆B can be defined as a measure of A∪B. Note that this definition differs from the traditional one: ∀x A(x) ≤ B(x), which is unsatisfactory for several reasons. First of all, it should be obvious that a subset relation of fuzzy sets cannot be crisp, because the sets are not crisp. Then the traditional definition is inconsistent with the very meaning of the membership function of a fuzzy set. Indeed, consider a singleton A={a}, i.e. ∀xa A(x)=0, A(a)=1. Then according to the traditional definition, we would have {a}⊆B = (1≤B(a)), which contradicts to our intuition expecting {a}⊆B = a∈B = B(a). NB|A is consistent in this respect:, because NB|{a} = B(a).

The properties of fuzzy ⊆ as an order relation are:

Fuzzy complement. The complement set A\B of the fuzzy set B in A is defined as A∩B. Same as for crisp sets, with the domain (universal) set U(x)1, it becomes U\B=B. But in general, the law of excluded middle does not hold for fuzzy sets. So the main property of complement (A\B)∩B=Ø is relaxed to a weaker property:

x ((A\B)∩B)(x) ≤ (B∩B)(x)

i.e. (A\B)∩B is dominated by B∩B. The relation of complement to xor-operation holds for fuzzy sets as well:

A xor B = (A\B)∨(B\A)

[Back][TOC][Next]

2.4. Distance to point

function Distance (Point : Integer; A : Set) return Natural;

The function calculates the distance between the domain point Point and the nearest point of the domain which confidence level in the set Set is not 0. If the set is empty the function returns Natural'Last.

[Back][TOC][Next]

2.5. String I/O with numeric indices

The child package Fuzzy.Edit provides the string I/O for fuzzy sets with the domain set elements specified in a numeric form.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Set
          );

This procedure inputs a fuzzy set from the string Source. The process starts from the position Source (Pointer). After successful completion Pointer is advanced to the position following the measure taken from the string. The parameter Value accepts the set. The set syntax:

<fuzzy_set>  ::=  <item> [,<fuzzy_set>]
<item> ::= <index> [{..|...} <index>] [:<level>]
<index> ::= A domain point specification
<level> ::= A confidence factor specification

Characters representing UTF-8 encoded code points from the set Blanks can be used as delimiters. The domain point specification is an integer number. The confidence factor can be given either in numeric form or as true or false (case insensitive). A trailing commas and colons are ignored and not matched. Examples: 

1,2,6..9   The set contains 1,2,6,7,8,9 with the factor 1 (true)
1:0,2:0.3,3..5:1   The set contains 2 with 0.3 and 3,4,5 with 1
Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source : String;
            First  : Integer;
            Last   : Integer
         )  return Set;

This function gets a fuzzy set from the string Source. The set is defined over First..Last. The set in the string can be surrounded by characters representing UTF-8 encoded code points from the set Blanks. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Set;
             Field       : Natural   := 0;
             Justify     : Alignment := Left;
             Fill        : Character := ' '
          );

This procedure  places the set specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). When the parameter Field is not zero then Justify specifies alignment and Fill is the character used for filling. When Field is greater than Destination'Last - Pointer + 1, the latter is used instead. After successful completion Pointer is advanced to the first character following the output or to Destination'Last + 1.

Exceptions
Constraint_Error Value is an empty array
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image (Value : Set) return String;

This function converts the parameter Value to string. Constraint_Error is propagated if Value is an empty array.

[Back][TOC][Next]

2.6. Generic string I/O

The child package Fuzzy.Generic_Edit provides string I/O with user-defined I/O routines for the domain set elements (the package Fuzzy.Edit is instantiates Fuzzy.Generic_Edit). The package speification starts as:

generic
   type User_Data (<>) is limited private;
   with procedure Get ...
   with procedure Put ...
package Fuzzy.Generic_Edit is ...

Here the generic formal parameters are some type User_Data and two procedures Get and Put. An object of User_Data is passed as the parameter to all procedures of the package. It can be used to keep a description of the domain set elements, such as a list of its names etc. The formal procedures provide I/O for the domain set ranges.

procedure Get
          (  Source    : String;
             Pointer   : in out Integer;
             Data      : User_Data;
             From      : out Integer;
             To        : out Integer;
             Exclusive : out Boolean
          );

This user-defined procedure gets a range of the domain set values from the string Source. The process starts from Source (Pointer). Pointer is then advanced to the string position following the range. The result is From..To, which is an interval of indices in Set (a fuzzy set). The range syntax is usually:

<value> [{..|...}<value>]

Characters representing UTF-8 encoded code points from the set Blanks may surround ellipsis. Ellipsis may be built of two two or three dots. The syntax of <value> depends on the implementation. The result is returned as an interval From..To of the set elements indices. The output parameter Exclusive indicates whether the range may contain already specified elements of the set. When Exclusive is true the truth value specified for From..To have to match already specified values. Otherwise, Data_Error is propagated. When Exclusive is false, then the overlapping values from the range are accumulated. Typically ranges from nominal domains are exclusive, ranges from continuums are non-exclusive.

Expected exceptions
Constraint_Error A value is out of range or illegal range
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data;
             From        : Integer;
             To          : Integer;
             Field       : Natural   := 0;
             Justify     : Alignment := Left;
             Fill        : Character := ' '
          );

This user-defined procedure places a range of the domain set values specified by the parameters From..To into the output string Destination. The string is written starting from Destination (Pointer). Pointer is then advanced to point after the end of the output field. The parameter Field determines the width of the output field. Zero width means the minimal possible width. If Field is not zero Justify determines the way the value should be aligned within the output field. The parameter Fill is then the fill character. If the range From..To contains only one point the syntax <value> should be used. Otherwise, the syntax of output is normally <value>..<value>.

Expected exceptions
Constraint_Error Illegal range
Layout_Error Pointer is not in Destination'Range or there is no room for the output

The package defines the following subroutines:

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data;
             Value   : out Set
          );

This procedure gets a fuzzy set from the string Source. The set has the following syntax:

<fuzzy_set>  ::=  <item> [,<fuzzy_set>]
<item> ::= <range> [:<level>]
<level> ::= A confidence factor specification

Here the syntax of <range> is defined by the formal procedure Get. Commas and colons may be surrounded by characters representing UTF-8 encoded code points from the set Blanks. Trailing comma or colon is ignored and not matched.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source : String;
            Data   : User_Data;
            First  : Integer;
            Last   : Integer
         )  return Set;

This function gets a fuzzy set from the string Source. The set is defined over First..Last. The set in the string can be surrounded by characters representing UTF-8 encoded code points from the set Blanks. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Data_Error Syntax error
End_Error Nothing matched

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data;
             Value       : Set;
             Field       : Natural := 0;
             Justify     : Strings_Edit.Alignment := Strings_Edit.Left;
             Fill        : Character := ' '
          );

This procedure places the fuzzy set specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer).

Exceptions
Constraint_Error Value is an empty array
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image (Data : User_Data; Value : Set) return String;

The function converts the parameter Value to string. Constraint_Error is propagated if Value is an empty array.

[Back][TOC][Next]

2.7. Abstract string I/O

The child package Fuzzy.Abstract_Edit provides an instantiation of Fuzzy.Generic_Edit with an abstract tagged type substituted for the parameter User_Data of  Fuzzy.Generic_Edit. The type is also called User_Data:

type User_Data is abstract
   new
Object.Entity with private;

The advantage of using an abstract tagged type is that one can simply derive from it to get a new functionality without an instantiation of Fuzzy.Generic_Edit. The data type is derived from Entity in order to allow handles to instances of User_Data. Handles to User_Data are provided by the package Fuzzy.Abstract_Edit.Handle. The package is an instance of Object.Handle.

The package Fuzzy.Abstract_Edit defines Get and Put of Fuzzy.Generic_Edit through dispatching abstract procedures of User_Data:

procedure Get
          (  Source    : String;
             Pointer   : in out Integer;
             Data      : User_Data;
             From      : out Value_Index;
             To        : out Value_Index;
             Exclusive : out Boolean
          )  is abstract;

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data;
             From        : Value_Index;
             To          : Value_Index;
             Field       : Natural   := 0;
             Justify     : Alignment := Left;
             Fill        : Character := ' '
          )  is abstract;

Here Value_Index is

type Value_Index is new Positive;

It is an index type to reference the domain set values. The first value of the domain set has the index 1. An implementation of Get should input a contiguous range of domain set values and return the result through From and To. It sets Exclusive to true when the truth value specified for From..To have to match already specified values. It sets Exclusive to false, then the overlapping values from the range can be accumulated. Typically ranges from nominal domains are exclusive, ranges from continuums are non-exclusive. An implementation of Put should output a range of value From..To. Both may use the exceptions described in Fuzzy.Generic_Edit for their generic counterparts.

procedure Get_Max_Range
          (  Data : User_Data;
             From : out Integer;
             To   : out Integer
          )  is abstract;

The abstract procedure Get_Max_Range is used to get the expected range of a fuzzy set when it is returned as a result and thus unknown.

The package defines class-wide Get, Value, Put and Image which can be used for any descendant of User_Data:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data'Class;
             Value   : out Set;
             To      : out Integer
          );

function Value
         (  Source : String;
            Data   : User_Data'Class
         )  return Set;

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data'Class;
             Value       : Set;
             Field       : Natural   := 0;
             Justify     : Alignment := Left;
             Fill        : Character := ' '
          );

function Image (Data : User_Data'Class; Value : Set) return String;

[Back][TOC][Next]

2.8. String I/O with named indices

The child package Fuzzy.Abstract_Edit.Named provides subroutines for string I/O of the sets having domains of named elements. The package defines the type Domain_Description:

type Domain_Description is new User_Data with private;

The following operations are defined on Domain_Description:

procedure Add
          (  Domain    : in out Domain_Description;
             Name      : String;
             Index     : Integer;
             Unchecked : Boolean := False
          );

This procedure adds a new element named Name under Index to Domain. Elements should be added in an order keeping the set of indices contiguous. Otherwise, Constraint_Error is propagated. It is also propagated when Name is invalid and Unchecked is false. Name_Error is propagated when Name matches the name of an existing element of Domain. When Index specifies an element existing in Domain the new one is inserted at exactly this position. The elements right of it are moved to the right.

procedure Copy
          (  Source : Domain_Description;
             Target : in out Domain_Description'Class
          );

This procedure is used to copy a domain set description.

procedure Erase (Domain : in out Domain_Description);

This procedure removes all elements from Domain.

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : Domain_Description;
             From    : out Integer;
             To      : out Integer
          );

This procedure inputs a range of domain elements from Source. A range is specified as <name>[..<name>]. Spaces and tabs may surround ellipsis. Range validity is not checked. Trailing ellipsis is an error, so Data_Error is propagated in this case. End_Error is propagated if nothing matched.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Domain  : Domain_Description;
             Index   : out Integer
          );

This procedure parses the string Source. If a name of an element from Domain is successfully matched starting from Source (Pointer), Pointer is advanced to the position following the matched name and Index is set to respond to the domain value associated with the variable.

Exceptions
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Get_Cardinality (Domain : Domain_Description)
   return Natural;

This function returns the number of elements in Domain.

function Get_Index
         (  Domain : Domain_Description;
            Name   : String
         )  return Integer;

This function returns the index of the element of Domain having the name Name. It is the same index as in Add. End_Error is propagated if thereis no such element.

function Get_Name
         (  Domain : Domain_Description;
            Index  : Integer
         )  return String;

This function returns the name of the element which index is Index. Constraint_Error is propagated if Index is illegal.

procedure Get_Max_Range
          (  Domain : Domain_Description;
             First  : out Integer;
             Last   : out Integer
          );

This procedure returns the actual index range of Domain. The range is always contiguous.

function Is_Empty (Domain : Domain_Description)
   return Boolean;

This function returns true if Domain is empty.

procedure Move
          (  Domain : in out Domain_Description;
             From   : Integer;
             To     : Integer
          );

This procedure moves the element From to the position To in Domain. Note that the elements between From and To will be moved in the course of the operation. Constraint_Error is propagated when From or To are illegal.

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Domain      : Domain_Description;
             From        : Integer;
             To          : Integer;
             Field       : Natural   := 0;
             Justify     : Alignment := Left;
             Fill        : Character := ' '
          );

This procedure places a range From..To of Domain element into the string Destination. For this names of the elements are used.

procedure Remove
          (  Domain : in out Domain_Description;
             Name   : String
          );

This procedure removes an element with the name Name from Domain. Note that the indices of the elements following the removed one will decrease. Nothing happens if there is no element with such name.

procedure Remove
          (  Domain : in out Domain_Description;
             Index  : Integer
          );

This procedure removes the element Index from Domain. Note that the indices of the elements following the removed one will decrease. Constraint_Error is propagated when Index is illegal.

procedure Rename
          (  Domain    : in out Domain_Description;
             Index     : Integer;
             Name      : String;
             Unchecked : Boolean := False
          );

This procedure renames the element Index to Name in Domain. Constraint_Error is propagated when Index illegal. It is also propagated when Name is invalid and Unchecked is false. Name_Error is propagated when there is another element with the name Name in Domain.

procedure Rename
          (  Domain    : in out Domain_Description;
             Old_Name  : String;
             New_Name  : String;
             Unchecked : Boolean := False
          );

This procedure renames the element Old_Name to New_Name in Domain.

Exceptions
Constraint_Error New_Name is invalid and Unchecked is false
End_Error No element named Old_Name exists in Domain
Name_Error Another element exists in Domain under the name New_Name

procedure Swap
          (  Domain  : in out Domain_Description;
             Index_1 : Integer;
             Index_2 : Integer
          );

This procedure swaps two elements in Domain. The elements are specified by Index_1 and Index_2. Constraint_Error is propagated when either of the indices is illegal.

[Back][TOC][Next]

2.9. Basic string I/O

The child package Fuzzy.Basic_Edit provides basic subroutine for string I/O.

type Delimiter_Type is (Arrow, Ellipsis, Comma, Colon, Semicolon);

procedure Get_Delimiter
          (  Source    : String;
             Pointer   : in out Integer;
             Success   : out Boolean;
             Delimiter : Delimiter_Type
          );

This procedure is used to skip in String one of the delimiters {->|:|,|;|..|...} and surrounding it characters representing UTF-8 encoded code points from the set Blanks. Pointer is changed only a delimiter was found. The parameter Delimiter specifies what should be recognized.

Exceptions
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

procedure Get_Weight
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Confidence;
             Default : Confidence := Confidence'Last
          );

This procedure is used to get the weight of a domain point value in the form [:<possibility>]. If no colon present, Default is set into Value. Colon may be surrounded by characters representing UTF-8 encoded code points from the set Blanks.

Exceptions
Data_Error Syntax error or value is not in 0..1
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1
 

[Back][TOC][Next]

2.10. Identifiers

The package Name_Tables determines the way identifiers, such as named domain values are matched. It declares the following sets:

   Capitals   : Unicode_Set := ...;
   Blanks     : Unicode_Set := ...;
   Ignored    : Unicode_Set := ...;
   Name_Body  : Unicode_Set := ...;
   Non_Breaks : Unicode_Set := ...;
   Singletons : Unicode_Set := ...;

Set  Default contents (categories1) Comment
Lu Ll Lt Lm Lo Mn Mc Nd Nl Pc Zs Cf HT2
Capitals + + + + +       +         A valid name begins with an UTF-8 encoded code point from this set. Normally this set should contain letters4.
Blanks                     +   + The code points from this set considered blank. Usually it contains space separators and character tabulation. When appear in a name any non-empty chain of code points from this set is equivalent to one code point.
Ignored                       +   The code points from this set are ignored when names are matched. Hyphenation is a good candidate for this set.
Name_Body + + + + + + + + + + + + + The code points which may appear in a valid name after ones from the set Capitals. Typically it contains digits additionally to the code points from Capitals4.
Non_Breaks + + + + + + + + + +   +   The code points which may not follow a valid name. When a name is recognized in a text, this set is used to determine where it can end at this position by verifying that the character following the name is not a member of the set.
Singletons                   + +   + A valid name cannot contain two consecutive characters from this set after removing all characters from Ignored. It also cannot end with any of these code points3. When a code point from Blanks is a member or Name_Body, it should also be included into Singletons.
1) For code points categories refer Strings_Edit.UTF8.Categorization.
2)
HT refers to character tabulation (code position 0916)
3) For example, if underline is a singleton then a__b is not a valid name. A singleton may not appear in the end of a name. So a_ would be also an invalid name. When a name is being recognized in a string, then appearing of consequent singleton characters ends matching if that does not belong to Non_Breaks. Therefore when a _ is matched, only a is treated as a name, but a_b would as a whole
4) Letters are matched case-insensitive.

The package instantiates Tables.UTF8_Names under the name Name_Maps. This package is used to represent tables of identifiers. Also the following operations are provided:

function Check_Matched
         (  Source  : String;
            Pointer : Integer
         )  return Boolean;

This function returns true if Source does not contain a code point from Non_Breaks or else ends at Pointer.

procedure Check_Name (Name : String);

This procedure checks Name's spelling. Constraint_Error is propagated if Name is not a valid name.

function Get_Name
         (  Source  : String;
            Pointer : access Integer
         )  return String;

This function matches a name in Source starting with Source (Pointer.all). Pointer.all is advanced after successful matching. The result is the identifier name in its canonic form, i.e. after all characters from the set Ignored removed.

Exceptions
Constraint_Error Illegal name, that
Data_Error Syntax error or value is not in 0..1
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1

[Back][TOC][Next]

2.11. Stream I/O

The package Fuzzy.Stream_IO provides operations converting fuzzy set forth and back to a stream elements array:

function Image (Data : Set) return Stream_Element_Array;

This function returns Data stored as a stream elements array.

function Value (Data : Stream_Element_Array) return Set;

This function converts Data to the corresponding set. It is guaranteed that for any given set X, Value (Image (X)) = X. Constraint_Error is propagated when Data is invalid.


[Back][TOC][Next]

3. Fuzzy logic

A fuzzy logical value x is a pair (Px, Nx). The component Px is the possibility that the value is true. The component Nx is the necessity of that. Both are measured in confidence factors. Fuzzy logical values are also known as intuitionistic propositions. Fuzzy logic continues the four-valued logic of J. M. Dunn and N. D. Belnap Jr. on the fuzzy case. The following table summarizes the properties of fuzzy logical values:

Property  Description  Comment
Complementarity Px = Nx The possibility of the complement is the complement of necessity
Consistency Px ≥ Nx The possibility shall be always greater than or equal to the necessity. Otherwise the value is self-contradictory. As in conventional logic no contradiction and thus no self-contradictory values may arise when legal logical operations (and, or, xor, not) are applied to non-contradictory values.
Normality Px=1 ∨ Nx=0 It is desirable but not mandatory to have only normal fuzzy logical values. The property of normality is an equivalent to x x of the conventional logic. In other words, either x or its complement should be certainly possible.
Certainty Px = Nx Fuzzy logic on certain normal values is an equivalent to the conventional logic. Certain true is represented as the pair (1,1). Certain false is represented as the pair (0,0). Absolute uncertainty is represented as the pair (1,0). Absolute contradiction is represented as (0,1).

The following picture explains the meaning of the possibility and necessity components of a fuzzy logical value:

logical values

A complementary view on a fuzzy logical value is the set view. A logical value can be thought as a fuzzy set over B={true, false}, i.e. [0,1]B. In which case the confidence factor of true is the possibility that the value is true. The confidence factor of false is the possibility that the value is false. Its complement is the necessity that the value is true. Some of logical operations are defined in terms of sets. For instance the fuzzy implication is defined as set inclusion.

In four-valued logic contradiction and uncertainty are usually denoted using symbols ┬ and ┴. In the fuzzy logic they are mapped to (0,1) and (1,0) correspondingly. This choice is determined by the meaning of a truth value as a possibility measure Px. If the complementary necessity measure were taken instead, the values would exchange to ┬=(1,0) and ┴=(0,1). The meaning of contradiction is invariant to this choice. It is neither x nor x is possible or equivalently both x and x are necessary. Dually, the meaning of uncertainty is both x and x are possible is equivalent to neither x nor x is necessary.

Most important algebraic results of the fuzzy logic are:

Associativity:    (x & y) & z = x & (y & z)
Commutativity: x & y = y & x
Distributivity: (x & y) ∨ z = (xz) & (yz)
de Morgan's theorems: x & y = xy

The results of conventional logic that do not hold:

x & x is not false     All that one can said is that the possibility Px&x and the necessity Nx&x are less than or equal to ones of both x and x
x ∨ x is not true Here the possibility and the necessity are only greater than or equal to ones of both x and x

The certainty of a logical value determines how close these results are to ones of conventional logic. Certainty is a confidence factor in [0,1]. 0 corresponds to an absolutely uncertain logical value. 1 corresponds to either true or false of conventional logic.

Combining evidences. Fuzzy logic can be applied to combining evidences, which might be fuzzy and contradictory. Let two logical values x and y were obtained from two evidences p and q. So if x and y both describe some event s then x = (Ps|p, Ns|p), y = (Ps|q, Ns|q). There are two ways to combine the evidences p and q. A pessimistic one is to consider how s depends on pq. An optimistic combination is pq. The pessimistic combination of x and y is x*y = (Ps|pq, Ns|pq). It can be shown that Ps|pqmin (Ps|p, Ps|q) and Ns|pqmax (Ns|p, Ns|q). The optimistic combination of x and y is  x+y = (Ps|pq, Ns|pq) = (max (Ps|p, Ps|q), min (Ns|p, Ns|q)). The combinations + and * are sometimes called consensus and gullibility. The difference in their behavior is that the pessimistic combination treats any discrepancy as a contradiction, while the optimistic one treats it as rather an uncertainty. Thus, true * false is contradictory, while true + false is uncertain.

Fuzzy implication. The fuzzy implication x=>y is defined in terms of sets: x=>y = ~xy. Here ~x is the complement of x. Thus x=>y is (max (Px, Py), max (Nx, Ny)). Note that it differs from xy. The difference can be illustrated on the case when both x and y are uncertain. In this case xy is also uncertain, while x=>y is true (uncertainty implies uncertainty). On certain arguments xy and x=>y are same.

Fuzzy inclusion (revisited). The pair (PB|A, NB|A) characterizes A as a subset of B vs. B. It can be viewed as a continuation of the fuzzy ⊆ to [0,1]B. We will use A⊆B notation for both of them. If A⊆B is certain true, then A is a subset of B in the traditional sense: ∀x A(x) ≤ B(x). At the same time if a normal A is a subset of B in the "crisp" sense: ∀x A(x)=0 ∨ 1=B(x), then A⊆B is true. From this we could say that A⊆B <=> normal A is a subset of B and also A⊆B <=> normal A is a subset of B. Further, if A is normal then A⊆B is never contradictory. Other properties of ⊆ are:

PA⊆B PBA   NA⊆B = NBA
PA⊆B = NA⊆B   NA⊆B = PA⊆B
P{a}⊆B  = a∈B = B(a)   N{a}⊆B = a∈B = B(a)
P(A∪B)⊆C  = PA⊆C∨PB⊆C       N(A∪B)⊆C  =  NA⊆C&NB⊆C
P(A∩B)⊆C PA⊆C&PB⊆C   N(A∩B)⊆C NA⊆C∨NB⊆C
PA⊆(B∪C) = PA⊆B∨PA⊆C   NA⊆(B∪C) NA⊆B∨NA⊆C
PA⊆(B∩C) PA⊆B&PA⊆C   NA⊆(B∩C) = NA⊆B&NA⊆C

Fuzzy xor. For fuzzy logic both definitions of xor stay equivalent: (A&B) ∨ (A&B) = (A∨B) & (AB). Similarly to the fuzzy-xor the lower and upper bounds of xor are (A&A) ∨ (B&B) and (A∨A) & (B∨B) correspondingly. Here comparison is made in the sense: A≤B if both PA≤PB and NA≤NB. The bounds are reached for A xor A = A&A and A xor A = A∨A.

Type and operations. The type Fuzzy_Boolean is defined in the child package Fuzzy.Logic:

type Fuzzy_Boolean is record
   Possibility : Confidence;
   Necessity   : Confidence;
end record;

The following operations are defined for Fuzzy_Boolean:

function "not" (Left : Fuzzy_Boolean) return Fuzzy_Boolean;

function "and" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "and" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function "and" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function "or" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "or" (Left : Fuzzy_Boolean; Right : Boolean)  return Fuzzy_Boolean;
   function "or" (Left : Boolean; Right : Fuzzy_Boolean)  return Fuzzy_Boolean;

function "xor" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "xor" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function "xor" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function "*" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "*" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function "*" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function "+" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "+" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function "+" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function
">=" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function ">=" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function ">=" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function
"<=" (Left, Right : Fuzzy_Boolean) return Fuzzy_Boolean;
   function "<=" (Left : Fuzzy_Boolean; Right : Boolean) return Fuzzy_Boolean;
   function "<=" (Left : Boolean; Right : Fuzzy_Boolean) return Fuzzy_Boolean;

function
Certainty (Left : Fuzzy_Boolean) return Confidence;

The type Boolean can be used as any of the arguments in the dyadic operations. The operations are defined as follows from the table:

Operation on x, y  Name  Definition
Complement not Px = Nx Nx = Px
Fuzzy and (&) and Px&y= Px&Py Nx&y= Nx&Ny
Fuzzy or (∨) or Pxy= Px∨Py Nxy= Nx∨Ny
Fuzzy xor xor (x&y) ∨ (x&y) = (xy) & (xy)
Combination (∩) * Px*y= Px&Py Nx*y= Nx∨Ny
Combination (∪) + Px+y= Px∨Py Nx+y= Nx&Ny
Implication (=>) >= Px=>y= Px∨Py Nx=>y= Nx∨ Ny
Implication (<=) <= Px<=y= Py=>x Nx<=y= Ny=>x
Certainty Certainty 1 - | Px - Nx |

The package also defines the following four constants. Certain_True, Certain_False, Uncertain, Contradictory. They correspond to the answers: yes, no, maybe (both true and false, I don't know), none (neither true nor false). The following table summarizes the behavior of some fuzzy operations:

x y x and y (&) x or y () x xor y x * y x + y x=>y not x
false false false false false false false true true
false true false true true contradictory uncertain true true
false uncertain false uncertain uncertain false uncertain true true
false contradictory false contradictory contradictory contradictory false true true
true false false true true contradictory uncertain false false
true true true true false true true true false
true uncertain uncertain true uncertain true uncertain uncertain false
true contradictory contradictory true contradictory contradictory true contradictory false
uncertain false false uncertain uncertain false uncertain contradictory uncertain
uncertain true uncertain true uncertain true uncertain true uncertain
uncertain uncertain uncertain uncertain uncertain uncertain uncertain true uncertain
uncertain contradictory false true false contradictory uncertain contradictory uncertain
contradictory false false contradictory contradictory contradictory false uncertain contradictory
contradictory true contradictory true contradictory contradictory true true contradictory
contradictory uncertain false true false contradictory uncertain uncertain contradictory
contradictory contradictory contradictory contradictory contradictory contradictory contradictory true contradictory

The following tables describe the operations in the form customary for the papers on logic (contradiction is denoted as , uncertainty is as ):

and 0 1       or 0 1      xor 0 1   not  
0 0   1 0   0  
0 0 0 0 0   0 0 1   0 0 1 0   0 1
1 0 1   1 1 1 1 1   1 1 0   1 0
0 0   0 1   0 0  
                                                                                                                                                         
* 0 1   + 0 1   => 0 1      
  0 1   1 1      
0 0 0   0 0 0   0 1 1 1 1      
1 1 1   1 1 1   1 0 1      
0 1     1 1 1      

function To_Fuzzy (Left : Boolean) return Fuzzy_Boolean;

This function converts the argument to the corresponding fuzzy logical value.

function Is_In (A, B : Set) return Fuzzy_Boolean;

This function compares two fuzzy sets and returns a fuzzy logical value. The result is defined as (PB|A, NB|A). It raises Constraint_Error if the arguments have different cardinality.


[Back][TOC][Next]

4. Fuzzy numbers

Most generally a fuzzy number is just a fuzzy set over the corresponding numeric set. For instance the set of fuzzy real numbers is [0,1]R, where R is the set of real numbers. Though such a general definition faces difficulties with both implementation and interpretation of the results. Therefore, several constraints are applied to the distribution of the confidence factors over the domain set (a set of numbers). The first one is the requirement of normality, i.e. that at least one number x of the domain have the confidence 1. The second is that the distribution has to be monotonically ascending before x and monotonically descending after it. The second requirement means that all so-called alpha-cuts of the fuzzy set are intervals. So a fuzzy number can be represented by a set of nested intervals:

{ [ai, bi] | i>j ⇒ [ai, bi]⊆ [aj, bj] }

The deeper an interval is nested the higher is the confidence factor associated with it. Thus a fuzzy number X can be represented as:

X =   U
i
 [ai, bi] Pi

where i>j ⇒ Pi≥Pj and [ai, bi] Pi is a fuzzy set which membership function is zero outside [ai, bi] and Pi inside it. Thus a fuzzy number looks like:

fuzzy number model

The number of intervals representing a number is limited by some reasonable number. The current implementation of fuzzy numbers is based on the interval arithmetic package.

Arithmetical operations on fuzzy numbers are defined as follows. If @ is an operation defined on crisp numbers like +, -, *, / etc, then the corresponding fuzzy number operation X@Y is defined as:

PzX@Y = Sup
x
@y = z
PxX&PyY  =  Sup
x
@y = z
X(x)&Y(y)

Here PxX is the confidence that the fuzzy number X has the value x. For example, the possibility that some z belongs to X+Y is a convolution of the membership functions over all x, y such that x+y=z. Fuzzy arithmetic is a continuation of both crisp and interval arithmetic. So for singletons we have {x}+{y}={x+y}.

When fuzzy numbers have form:

X =   U
i
 [ai, bi] Pi      Y U
i
 [ci, di] Pi

then because operations on intervals are inclusion-monotonic:

X@Y U
i
 [ai, bi]@[ci, di] Pi

This allows an O(n) implementation of fuzzy arithmetic, where n is the number of alpha-cuts, i.e. the resolution of the confidence factors.

Relational operations on fuzzy numbers results in fuzzy logical values. Let @ be a relational operation >, ≥, ≤, < defined on crisp numbers, then the corresponding fuzzy number operation X@Y is defined as:

Component Definition
Possibility PX@Y  
PX@Y Sup
x
@y
PxX&PyY
Necessity NX@Y
NX@Y = Inf
x
@y
PxXPyY  = P X@Y

The necessity component is essential here. For example if we consider an interval [1,2] then certainly [1,2] is greater than 0, so P[1,2] > 0=N[1,2] > 0=1. But P[1,2] > 1.5=1 while N[1,2] > 1.5=0. Indicating that it is uncertain whether [1,2] is greater than 1.5.

[Back][TOC][Next]

4.1. Plain fuzzy numbers

The generic child package Fuzzy.Numbers implements fuzzy numbers. It defines the type Fuzzy_Number. The package has the following generic parameters:

Its specification starts as:

generic
   type Interval_Index is (<>);
   type Interval_Map is array (Interval_Index) of Confidence;
   type Number is private;
   type Interval is private;
   To_Confidence : Interval_Map;
   with function From (Left : Interval) return Number is <>;
   with function Is_In (Left, Right : Interval) return Boolean is <>;
   with function Is_In (Left : Number; Right : Interval)
      return Boolean is <>;
   with function To (Left : Interval) return Number is <>;
   with function To_Interval (Left : Number) return Interval is <>;
   with function To_Interval (Left, Right : Number)
      return Interval is <>;
   with function "abs" (Left : Interval) return Interval is <>;
   with function "+" (Left, Right : Interval) return Interval is <>;
   with function "+" (Left : Interval; Right : Number)
      return Interval is <>;
   with function "+" (Left : Number; Right : Interval)
      return Interval is <>;
   with function "-" (Left : Interval) return Interval is <>;
   with function "-" (Left, Right : Interval) return Interval is <>;
   with function "-" (Left : Interval; Right : Number)
      return Interval is <>;
   with function "-" (Left : Number; Right : Interval)
      return Interval is <>;
   with function "*" (Left : Interval; Right : Number)
      return Interval is <>;
   with function "*" (Left : Number; Right : Interval)
      return Interval is <>;
   with function "*" (Left, Right : Interval) return Interval is <>;
   with function "/" (Left : Interval; Right : Number)
      return Interval is <>;
   with function "/" (Left : Number; Right : Interval)
      return Interval is <>;
   with function "/" (Left, Right : Interval) return Interval is <>;
   with function "**" (Left : Interval; Right : Natural) return Interval is <>;
   with function ">" (Left : Interval; Right : Number)
      return Logical is <>;
   with function ">" (Left : Number; Right : Interval)
      return Logical is <>;
   with function ">" (Left, Right : Interval) return Logical is <>;
   with function ">=" (Left : Number; Right : Number)
      return Boolean is <>;
   with function ">=" (Left : Interval; Right : Number)
      return Logical is <>;
   with function ">=" (Left : Number; Right : Interval)
      return Logical is <>;
   with function ">=" (Left, Right : Interval) return Logical is <>;
   with function "&" (Left, Right : Interval) return Boolean is <>;
package Fuzzy.Numbers is ...

Though it might look extremely complex it is in fact easy to instantiate because most of the formal parameters have reasonable defaults.

The generic child package Fuzzy.Numbers.Edit provides I/O operations on fuzzy numbers. It has two generic parameters:

Integer fuzzy numbers. The generic package Fuzzy.Integers is a specialization of Fuzzy.Numbers for integer numbers. It has the following generic parameters:

generic
   with package Integer_Intervals is new Intervals.Integers (<>);
   type Interval_Index is (<>);
   type Interval_Map is array (Interval_Index) of Confidence;
   To_Confidence : Interval_Map;
package Fuzzy.Integers is ...

. It has the following generic parameters:

The package defines the subtype Fuzzy_Integer. The operations on this type are same as described for Fuzzy.Numbers. An instantiation of Fuzzy.Integers for the standard integer type is Fuzzy_Integers.

There is a generic specializations of the package Fuzzy.Numbers.Edit for integers. It is the generic child package Fuzzy.Integers.Edit. An instantiation of this package for the standard integer type is Fuzzy.Edit.Integers.

Floating-point fuzzy numbers. The generic package Fuzzy.Floats is a specialization of Fuzzy.Numbers for floating-point numbers:

generic
   with package Float_Intervals is new Intervals.Floats (<>);
   type Interval_Index is (<>);
   type Interval_Map is array (Interval_Index) of Confidence;
   To_Confidence : Interval_Map;
package Fuzzy.Floats is ...

. It has the following generic parameters:

The package defines the subtype Fuzzy_Float. The operations on defined on this type are same as described for Fuzzy.Numbers. All imprecise operations on floating-point fuzzy yield a value that contains the precise result. An instantiation of Fuzzy.Floats for the standard float type is Fuzzy_Floats.

There is a generic specializations of the package Fuzzy.Numbers.Edit for integers. It is the generic child package Fuzzy.Floats.Edit. An instantiation of this package for the standard float type is Fuzzy.Edit.Floats.

All imprecise operations on floating-point fuzzy yield a value that contains the precise result.

4.1.1. Interval mapping

The generic parameters Interval_Index, Interval_Map, To_Confidence are used define a mapping of the intervals representing a fuzzy number to the confidence factors.

type Interval_Index is (<>);
type Interval_Map is array (Interval_Index) of Confidence;
To_Confidence : Interval_Map;

Interval_Index is a discrete type determining the number of intervals used to represent a fuzzy number. Interval_Map is an array type of confidence factors indexed by Interval_Index. To_Confidence is an instance of the array. For each value of Interval_Index it has the corresponding confidence factor. The array elements shall ascend. The last element of the array shall be of Confidence'Last. The package Fuzzy.Index_Map provides an interval mapping used for in the packages Fuzzy_Integers and Fuzzy_Floats.

The function Get_Interval in Fuzzy_Number can be used to obtain an interval of a fuzzy number by its index:

function Get_Interval
         (  Value : Fuzzy_Number;
            Index : Interval_Index
         )  return Interval;

The result is [ai, bi] of Value, where i is specified by the parameter Index. The confidence level of the interval can be obtained as To_Confidence (Index). Note that intervals are enumerated in ascending order. The last interval has the confidence Confidence'Last.

4.1.2. Arithmetic operations

The following operations are defined on the type Fuzzy_Number:

function "abs" (Left : Fuzzy_Number) return Fuzzy_Number;
function "+"   (Left : Fuzzy_Number) return Fuzzy_Number;
function "-"   (Left : Fuzzy_Number) return Fuzzy_Number;
function "**"  (Left : Fuzzy_Number; Right : Natural) return Fuzzy_Number;

function "+" (Left, Right : Fuzzy_Number) return Fuzzy_Number;
   function "+" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Number;
   function "+" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Number;
   function "+" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Number;
   function "+" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Number;

function "-" (Left, Right : Fuzzy_Number) return Fuzzy_Number;
   function "-" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Number;
   function "-" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Number;
   function "-" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Number;
   function "-" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Number;

function "*" (Left, Right : Fuzzy_Number) return Fuzzy_Number;
   function "*" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Number;
   function "*" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Number;
   function "*" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Number;
   function "*" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Number;

function "/" (Left, Right : Fuzzy_Number) return Fuzzy_Number;
   function "/" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Number;
   function "/" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Number;
   function "/" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Number;
   function "/" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Number;

These operations are defined as described above.

4.1.3. Possibility theory

The following functions compute the possibility and necessity of fuzzy numbers as events. They return the result of Confidence type:

function Possibility (Left, Right : Fuzzy_Number) return Confidence;
   function Possibility (Left : Fuzzy_Number; Right : Number  ) return Confidence;
   function Possibility (Left : Fuzzy_Number; Right : Interval) return Confidence;
   function Possibility (Left : Number;   Right : Fuzzy_Number) return Confidence;
   function Possibility (Left : Interval; Right : Fuzzy_Number) return Confidence;

function Necessity (Left, Right : Fuzzy_Number) return Confidence;
   function Necessity (Left : Fuzzy_Number; Right : Number  ) return Confidence;
   function
Necessity (Left : Fuzzy_Number; Right : Interval) return Confidence;
   function Necessity (Left : Number;   Right : Fuzzy_Number) return Confidence;
   function
Necessity (Left : Interval; Right : Fuzzy_Number) return Confidence;

These functions tell how possible or necessary is the fuzzy event represented by the left argument under the condition represented by the right argument. They are defined in terms of fuzzy sets:

Function Definition Meaning
Possibility
PX|Y Sup
x
 PxX&PxY
How possible is X if Y
Necessity
NX|Y Inf
x
 PxXPxY  = PX|Y
How necessary is X if Y

When Left is a number then Possibility (Left, Right) is the value of the confidence distribution of Right in Left. If the right argument is an interval then the possibility is the maximum of the confidence distribution on the interval. The necessity is then the minimum of the distribution.

4.1.4. Membership and inclusion relations

The membership and inclusion tests return a result of Fuzzy_Boolean type:

function Is_In (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function Is_In (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Boolean;
   function Is_In (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Boolean;
   function Is_In (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function Is_In (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Boolean;

The result tells how possible and necessary is that Left is included in Right. It is defined in terms of possibility and necessity:

Component Definition
Possibility PXY   PXY = PY|X
Necessity NXY NXY = NY|X

Note that this definition assumes normality of the fuzzy sets involved. For fuzzy numbers it means that at least one number of the domain is fully possible. Observe that if the requirement is not satisfied the result is as expected contradictory, i.e. the necessity is greater than the possibility.

4.1.5. Equality and equivalence

The equality and inequality operations are:

function "=" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"=" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Boolean;
   function
"=" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Boolean;
   function
"=" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"=" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Boolean;

function
"/=" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"/=" (Left : Fuzzy_Number, Right : Number  ) return Fuzzy_Boolean;
   function
"/=" (Left : Fuzzy_Number, Right : Interval) return Fuzzy_Boolean;
   function
"/=" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"/=" (Left : Interval; Right : Fuzzy_Number) return Fuzzy_Boolean;

The equality operation is defined in terms of inclusion X = Y is X Y & Y X:

Component Definition
Possibility PX=Y  PX|Y
Necessity NX=Y NX|Y&NY|X

See notes about normality of the numbers.

function Equal (Left, Right : Fuzzy_Number) return Boolean;

This function returns true if Left and Right are equivalent as sets, i.e.∀x PxLeft = PxRight.

4.1.6. Relational operations

The relational operations are:

function ">" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
">" (Left : Fuzzy_Number; Right : Number  ) return Fuzzy_Boolean;
   function
">" (Left : Fuzzy_Number; Right : Interval) return Fuzzy_Boolean;
   function
">" (Left : Number;   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
">" (Left : Interval, Right : Fuzzy_Number) return Fuzzy_Boolean;

function
">=" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
">=" (Left : Fuzzy_Number, Right : Number  ) return Fuzzy_Boolean;
   function
">=" (Left : Fuzzy_Number, Right : Interval) return Fuzzy_Boolean;
   function
">=" (Left : Number,   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
">=" (Left : Interval, Right : Fuzzy_Number) return Fuzzy_Boolean;

function
"<=" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"<=" (Left : Fuzzy_Number, Right : Number  ) return Fuzzy_Boolean;
   function
"<=" (Left : Fuzzy_Number, Right : Interval) return Fuzzy_Boolean;
   function
"<=" (Left : Number,   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"<=" (Left : Interval, Right : Fuzzy_Number) return Fuzzy_Boolean;

function
"<" (Left, Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"<" (Left : Fuzzy_Number, Right : Number  ) return Fuzzy_Boolean;
   function
"<" (Left : Fuzzy_Number, Right : Interval) return Fuzzy_Boolean;
   function
"<" (Left : Number,   Right : Fuzzy_Number) return Fuzzy_Boolean;
   function
"<" (Left : Interval, Right : Fuzzy_Number) return Fuzzy_Boolean;

4.1.7. Conversions

The following functions are used to convert numbers and intervals to fuzzy numbers:

function To_Fuzzy (Left : Number)   return Fuzzy_Number;
function To_Fuzzy (Left : Interval) return Fuzzy_Number;

[Back][TOC][Next]

4.2. Dimensioned fuzzy numbers

Dimensioned fuzzy values represent physical values inaccurate measured or known. A dimensioned fuzzy number is a fuzzy numeric value with attached dimension to it. The generic package Fuzzy.Measures provides an implementation of dimensioned fuzzy values:

generic
   with package
Interval_Measures is new Intervals.Measures (<>);
   with package
Fuzzy_Floats is
      new
Fuzzy.Floats
          (  Float_Intervals => Interval_Measures.Float_Intervals_Of,
             others          => <>
          );
package
Fuzzy.Measures is
   ...

The package has the following formal parameters:

A non-generic instantiation of Fuzzy.Measures for the standard type Float is named Fuzzy_Measures.

The package Fuzzy.Measures defines the type Fuzzy_Measure:

type Fuzzy_Measure (SI : Unit := Units.Base.Unitless) is record
  
Gain   : Fuzzy_Float;
   Offset : Number'Base := 0.0;
end record
;

The discriminant SI and the field Offset determine the dimension of the value as they do in the type Measure. The field Gain + Offset yields the numeric fuzzy value in the unit specified by the discriminant SI. The operations defined on the type Fuzzy_Measure are designed to be computation errors-safe in the sense that the outcome of any operation contains the precise result. In particular, for necessity and possibility it means that they are estimated from below and above correspondingly.

subtype Interval is Interval_Measures.Float_Intervals.Interval;

This subtype acts as a renaming of the interval type Interval_Measures.Float_Intervals.Interval.

function Get_Unit (Value : Fuzzy_Measure) return Unit;

This function returns the SI measurement unit of the argument.

4.2.1. Arithmetic operations

function "abs" (Left : Fuzzy_Measure) return Fuzzy_Measure;
function "+"   (Left : Fuzzy_Measure) return Fuzzy_Measure;
function "-"   (Left : Fuzzy_Measure) return Fuzzy_Measure;
function "**"  (Left : Fuzzy_Measure; Right : Natural) return Fuzzy_Measure;

function "+" (Left, Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "+" (Left : Fuzzy_Measure;    Right : Measure         ) return Fuzzy_Measure;
   function "+" (Left : Fuzzy_Measure;    Right : Interval_Measure) return Fuzzy_Measure;
   function "+" (Left : Measure;          Right : Fuzzy_Measure   ) return Fuzzy_Measure;
   function "+" (Left : Interval_Measure; Right : Fuzzy_Measure   ) return Fuzzy_Measure;

function "-" (Left, Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "-" (Left : Fuzzy_Measure;    Right : Measure         ) return Fuzzy_Measure;
   function "-" (Left : Fuzzy_Measure;    Right : Interval_Measure) return Fuzzy_Measure;
   function "-" (Left : Measure;          Right : Fuzzy_Measure   ) return Fuzzy_Measure;
   function "-" (Left : Interval_Measure; Right : Fuzzy_Measure   ) return Fuzzy_Measure;

function "*" (Left, Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Measure; Right : Fuzzy_Floats.Number) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Measure; Right : Interval           ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Measure; Right : Fuzzy_Float        ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Measure; Right : Measure            ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Measure; Right : Interval_Measure   ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Floats.Number; Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Interval;            Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Float;         Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Measure;             Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Interval_Measure;    Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "*" (Left : Measure;             Right : Fuzzy_Float  ) return Fuzzy_Measure;
   function "*" (Left : Interval_Measure;    Right : Fuzzy_Float  ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Float;         Right : Measure      ) return Fuzzy_Measure;
   function "*" (Left : Fuzzy_Float;   Right : Interval_Measure   ) return Fuzzy_Measure;

function "/" (Left, Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Measure; Right : Fuzzy_Floats.Number) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Measure; Right : Interval           ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Measure; Right : Fuzzy_Float        ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Measure; Right : Measure            ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Measure; Right : Interval_Measure   ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Floats.Number; Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Interval;            Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Float;         Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Measure;             Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Interval_Measure;    Right : Fuzzy_Measure) return Fuzzy_Measure;
   function "/" (Left : Measure;             Right : Fuzzy_Float  ) return Fuzzy_Measure;
   function "/" (Left : Interval_Measure;    Right : Fuzzy_Float  ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Float;   Right : Measure            ) return Fuzzy_Measure;
   function "/" (Left : Fuzzy_Float;   Right : Interval_Measure   ) return Fuzzy_Measure;

Binary additive operations "+" and "-" accept as one of the arguments:

Multiplicative binary operations "*" and "/" accept as one of the arguments:

Further they accept a plain fuzzy number as one parameter and:

as another. The result in all cases a dimensioned fuzzy number. The exception Unit_Error (defined in Units) is propagated on all unit errors as described in Measures. Constraint_Error is propagated out of multiplicative operations "*", "/" and exponentiation "**" when the dimension of the result cannot be represented because of a base unit power overflow.

4.2.2. Possibility theory

The following functions compute the possibility and necessity of fuzzy numbers as events. They return the result of Confidence type:

function Possibility (Left, Right : Fuzzy_Measure) return Confidence;
   function Possibility (Left : Fuzzy_Measure; Right : Measure) return Confidence;
   function Possibility (Left : Fuzzy_Measure; Right : Interval_Measure) return Confidence;
   function Possibility (Left : Measure;          Right : Fuzzy_Measure) return Confidence;
   function Possibility (Left : Interval_Measure; Right : Fuzzy_Measure) return Confidence;

function Necessity (Left, Right : Fuzzy_Measure) return Confidence;
   function Necessity (Left : Fuzzy_Measure; Right : Measure) return Confidence;
   function
Necessity (Left : Fuzzy_Measure; Right : Interval_Measure) return Confidence;
   function Necessity (Left : Measure;          Right : Fuzzy_Measure) return Confidence;
   function
Necessity (Left : Interval_Measure; Right : Fuzzy_Measure) return Confidence;

One of the parameters can be a dimensioned number or interval. Parameters may have different units in which case the possibility and necessity are both 0. When the parameters are differently shifted the possibility is estimated from above and necessity from below due to possible computation errors while shifting. Unit_Error is propagated when arguments have incompatible units.

4.2.3. Inclusion and other relational operations

The following functions are used to compare numbers. They return a result of Fuzzy_Boolean type:

function Is_In (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function Is_In (Left : Fuzzy_Measure; Right : Measure         ) return Fuzzy_Boolean;
   function Is_In (Left : Fuzzy_Measure; Right : Interval_Measure) return Fuzzy_Boolean;
   function Is_In (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function Is_In (Left : Interval_Measure; Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
"=" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"=" (Left : Fuzzy_Measure; Right : Measure         ) return Fuzzy_Boolean;
   function
"=" (Left : Fuzzy_Measure; Right : Interval_Measure) return Fuzzy_Boolean;
   function
"=" (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"=" (Left : Interval_Measure; Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
"/=" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"/=" (Left : Fuzzy_Measure, Right : Measure         ) return Fuzzy_Boolean;
   function
"/=" (Left : Fuzzy_Measure, Right : Interval_Measure) return Fuzzy_Boolean;
   function
"/=" (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"/=" (Left : Interval_Measure; Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
">" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
">" (Left : Fuzzy_Measure; Right : Measure         ) return Fuzzy_Boolean;
   function
">" (Left : Fuzzy_Measure; Right : Interval_Measure) return Fuzzy_Boolean;
   function
">" (Left : Measure;          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
">" (Left : Interval_Measure, Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
">=" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
">=" (Left : Fuzzy_Measure, Right : Measure         ) return Fuzzy_Boolean;
   function
">=" (Left : Fuzzy_Measure, Right : Interval_Measure) return Fuzzy_Boolean;
   function
">=" (Left : Measure,          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
">=" (Left : Interval_Measure, Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
"<=" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"<=" (Left : Fuzzy_Measure, Right : Measure         ) return Fuzzy_Boolean;
   function
"<=" (Left : Fuzzy_Measure, Right : Interval_Measure) return Fuzzy_Boolean;
   function
"<=" (Left : Measure,          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"<=" (Left : Interval_Measure, Right : Fuzzy_Measure) return Fuzzy_Boolean;

function
"<" (Left, Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"<" (Left : Fuzzy_Measure, Right : Measure         ) return Fuzzy_Boolean;
   function
"<" (Left : Fuzzy_Measure, Right : Interval_Measure) return Fuzzy_Boolean;
   function
"<" (Left : Measure,          Right : Fuzzy_Measure) return Fuzzy_Boolean;
   function
"<" (Left : Interval_Measure, Right : Fuzzy_Measure) return Fuzzy_Boolean;

One of the arguments can be a dimensioned value or a dimensioned interval. The results are defined in the same way as they are for plain fuzzy numbers (see 4.1.5, 4.1.6, 4.1.7). Arguments may have different shifts. The functions outcome of a function contains the precise result in the sense that the possibility component of it is always an upper and the necessity one is a lower estimation of the corresponding precise values. Unit_Error is propagated out of ">", ">=", "<", "<=" when arguments have incompatible units. For Is_In, "=", "/=" it is legal to compare values of different dimension.

function Equal (Left, Right : Fuzzy_Measure) return Boolean;

This function returns true if Left and Right are identical.

4.2.4. Conversions

function Convert (Value : Fuzzy_Measure; Scale : Measure)
   return Fuzzy_Measure;

This function is used to convert Value to the measurement units specified by the parameter Scale. When offsets of Value and Scale are same this is null operation. Unit_Error is propagated when conversion is impossible because units of Value and Scale are incompatible.

function Get_Value (Value : Fuzzy_Measure) return Fuzzy_Float;

This function returns SI equivalent of its argument. The result is a plain fuzzy number of the type Fuzzy_Floats.Fuzzy_Float.

function Get_Value_As (Value : Fuzzy_Measure; Scale : Measure)
   return Fuzzy_Float;

This function returns Scale equivalent of Value. The result is a plain fuzzy number of the type Fuzzy_Floats.Fuzzy_Float. Unit_Error is propagated when conversion is impossible because units of Value and Scale are incompatible.

function Normalize (Value : Fuzzy_Measure) return Fuzzy_Measure;

This function returns unshifted equivalent of its argument. For example when applied to a fuzzy value of Celsius degrees the result will be an equivalent value  in Kelvin.

function Shift (Value : Fuzzy_Measure; Shift : Fuzzy_Floats.Number'Base)
   return Fuzzy_Measure;

This function returns an equivalent of Value. The offset of the result is determined by the parameter Shift.

function To_Fuzzy_Measure (Left : Fuzzy_Floats.Number) return Fuzzy_Measure;
function To_Fuzzy_Measure (Left : Measure            ) return Fuzzy_Measure;
function To_Fuzzy_Measure (Left : Interval           ) return Fuzzy_Measure;
function To_Fuzzy_Measure (Left : Interval_Measure   ) return Fuzzy_Measure;
function To_Fuzzy_Measure (Left : Fuzzy_Float        ) return Fuzzy_Measure;

These function convert a number, dimensioned number, interval or dimensioned interval to the corresponding dimensioned fuzzy number.

[Back][TOC][Next]

4.3. String I/O

4.3.1. Integer I/O

The child package Fuzzy.Integers.Edit defines I/O operations on Fuzzy_Integer. It is a generic package. The parameter is an instantiation of the package Strings_Edit.Integer_Edit with the same numeric type.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Fuzzy_Integer;
             Base    : NumberBase := 10;
          );

This procedure inputs a fuzzy integer number from the string Source. The process starts from the position Source (Pointer). After successful completion Pointer is advanced to the position following the measure taken from the string. The parameter Value accepts the set. The set syntax:

<fuzzy_number>  ::=  <interval> [,<fuzzy_number>]
<interval> ::= <index> [{..|...}<index>] [:<level>]
<index> ::= An integer number, specified according to the parameter Base
<level> ::= A confidence factor specification

Characters representing UTF-8 encoded code points from the set Blanks.can be used as delimiters. Trailing commas and colons are not matched causing no error. The confidence factor can be given either in numeric form or as true or false (case insensitive). The intervals with higher confidence factors shall be subintervals of all ones with lower confidence. If an interval of same confidence factor appears twice, the latter appearance shall include the former one. The result returned via Value includes the input, if the confidence factors cannot be directly mapped .At least one integer number shall have confidence 1. If one of these conditions is not satisfied, Constraint_Error is propagated. Examples: 

1   The number 1
2..5 The interval [2, 5]
2..5:0.1, 2..4:0.3, 3:1   The number: 2:0.1, 3:1, 4:0.3, 5:0.1
Exceptions
Constraint_Error Illegal number
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function
Value
         (  Source : String
            Base   : NumberBase := 10;
         )  return Fuzzy_Integer;

This function gets a fuzzy integer from the string Source. The number in the string can be surrounded by characters representing UTF-8 encoded code points from the set Blanks. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Constraint_Error Illegal number
Data_Error Syntax error
End_Error There is no set in the string
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Fuzzy_Integer;
             Base        : NumberBase := 10;
             Field       : Natural    := 0;
             Justify     : Alignment  := Left;
             Fill        : Character  := ' '
          );

This procedure places the number specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). When the parameter Field is not zero then Justify specifies alignment and Fill is the character used for filling. When Field is greater than Destination'Last - Pointer + 1, the latter is used instead. After successful completion Pointer is advanced to the first character following the output or to Destination'Last + 1.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image
         (  Value : Fuzzy_Integer
            Base  : NumberBase := 10;
         )  return String;

This function converts the parameter Value to string.

There is a non-generic instantiation of the package for Integer which can be referred as Fuzzy.Edit.Integers.

4.3.2. Floating-point I/O

The child package Fuzzy.Floats.Edit defines I/O operations on Fuzzy_Float. It is a generic package. The parameter is an instantiation of the package Strings_Edit.Float_Edit with the same numeric type.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Fuzzy_Float;
             Base    : NumberBase := 10;
          );

This procedure inputs a fuzzy floating-point number from the string Source. The process starts from the position Source (Pointer). After successful completion Pointer is advanced to the position following the measure taken from the string. The parameter Value accepts the set. The set syntax:

<fuzzy_number>  ::=  <interval> [,<fuzzy_number>]
<interval> ::= <index> [{..|...}<index>] [:<level>]
<index> ::= A floating-point number, specified according to the parameter Base
<level> ::= A confidence factor specification

characters representing UTF-8 encoded code points from the set Blanks can be used as delimiters. Trailing commas and colons are not matched causing no error. The confidence factor can be given either in numeric form or as true or false (case insensitive). The intervals with higher confidence factors shall be subintervals of all ones with lower confidence. If an interval of same confidence factor appears twice, the latter appearance shall include the former one. The result returned via Value includes the input, if the confidence factors cannot be directly mapped .At least one number shall have confidence 1. If one of these conditions is not satisfied, Constraint_Error is propagated. Examples: 

1   The number 1.0
2.3..5.1 The interval [2.3, 5.1]
2..5:0.1, 2..4:0.3, 3:1   The number: [2.0, 3.0[:0.1, 3.0:1, ]3.0, 4.0]:0.3, ]4.0, 5]:0.1
Exceptions
Constraint_Error Illegal number
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source : String
            Base   : NumberBase := 10;
         )  return Fuzzy_Float;

This function gets a fuzzy integer from the string Source. The number in the string can be surrounded by characters representing UTF-8 encoded code points from the set Blanks. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Constraint_Error Illegal number
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Fuzzy_Float;
             Base        : NumberBase := 10;
             RelSmall    : Positive   := MaxSmall;
             AbsSmall    : Integer    := -MaxSmall;
             Field       : Natural    := 0;
             Justify     : Alignment  := Left;
             Fill        : Character  := ' '
          );

This procedure places the number specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). When the parameter Field is not zero then Justify specifies alignment and Fill is the character used for filling. When Field is greater than Destination'Last - Pointer + 1, the latter is used instead. After successful completion Pointer is advanced to the first character following the output or to Destination'Last + 1. The parameters RelSmall and AbsSmall determine the precision used to output the interval bounds. For detailed description see the specification of Strings_Edit.Float_Edit package.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image
         (  Value    : Fuzzy_Float
            Base     : NumberBase := 10;
            RelSmall : Positive   := MaxSmall;
            AbsSmall : Integer    := -MaxSmall
         )  return String;

This procedure converts the parameter Value to string.

There is a non-generic instantiation of the package for Float which can be referred as Fuzzy.Edit.Floats.


[Back][TOC][Next]

5. Intuitionistic fuzzy sets

The intuitionistic fuzzy sets were introduced by K. T. Atanassov. They generalize the notion of a fuzzy set by treating membership as a fuzzy logical value rather than a single truth value. For an intuitionistic set the logical value has to be consistent (in the sense γA(x) + μA(x) ≥ 1). However, for the sake of genericity we will drop this constraint allowing contradictory sets as well. We also will use a complement of the complement-set instead of the set itself. It is very important to distinguish two different, though complementary, views on the meaning of an intuitionistic set, which we will call classifications and properly speaking sets.

Proper intuitionistic sets. A fuzzy intuitionistic set A over the domain set D, is A: D→[0,1]2.  It is a function which for any domain value x∈D gives a fuzzy logical value telling whether x belongs to A. One can view an intuitionistic A as a pair of plain fuzzy sets: (A↑, A↓). Here ∀x∈D A↑(x) = PxA, A↓(x) = NxA. In other words the set  A↑ (or the upper set) tells how possible is that the domain value x belongs to A. The lower set A↓ tells how it is necessary. Observe that for a plain fuzzy set A both sets are same, because Px∈A = Nx∈A = A(x), or equivalently PxA + Px∈A = 1. So the membership function of the complement-set can be obtained from one of the fuzzy set. This is untrue for intuitionistic sets: PxA = 1-NxA ≠ 1-PxA. An intuitionistic set is non-contradictory if PxA - NxA ≥ 0.

It can be helpful to consider elements of D as maybe imaginary, fuzzy sets (or classes) over some original domain Ω different from D. The following example illustrates the case:

intuitionistic sets

Let the domain set of some fuzzy set A is being split into a set of intervals {x}i, which then are used as the new domain set. For this new domain one cannot build any fuzzy set corresponding to A, because the membership function of A may take different values on the intervals. So an intuitionistic fuzzy A over the new domain is used instead. For an interval x the upper set of A gives the upper bound of the membership function of A in the interval, the lower set gives the lower bound:

PA|x  ≤  PxA  =   A↑(x)
NA|x NxA = A↓(x)

or equivalently that imaginary A(x)∈[A↓(x), A↑(x)]. This estimation property is the whole idea behind intuitionistic fuzzy sets. An intuitionistic set estimates, or else is an image of some other fuzzy set which original domain is unavailable for some reason. The elements of D are not necessarily intervals. In the most general case they are just some fuzzy sets. If x∈D is normal, i.e. reaches 1 on the original domain, then A↓(x) ≤ A↑(x), i.e. A is non-contradictory.

Intuitionistic classifications. A classification A into the domain set D, is A: D→[0,1]2.  Note that it is formally an intuitionistic fuzzy set, but its membership function has a different meaning. Unlikely to a proper intuitionistic fuzzy set here ∀x∈D:

Px|A  =  PAx  =   A↑(x)
Nx|A = NAx = A↓(x)

The upper set of a classification is same as one of the proper intuitionistic fuzzy set. It is because Px|A = PA|x. But their lower sets differ. If elements of D are viewed as classes, then ∀x∈D A↑(x) = Px|A is the possibility that some observed A is a subset of the class x. A↓(x) = Nx|A is a necessity of that. If A is a singleton in the original domain then PA∈x = NA∈x. Further, A↓(x) ≤ A↑(x), if A is normal. As a rule, the true classification of the prototype set A is unknown, so A only estimates it: A↓(x) ≤ Nx|A ≤ Px|AA↑(x). This is the estimation property for classifications.

Classifications vs. proper sets. It is very important to clearly distinguish intuitionistic fuzzy classifications and proper intuitionistic fuzzy sets. A classification expresses is-a relations. A proper set does has-all relations. Input data are usually given in terms of classifications. When we say that the temperature is hot, we mean a classification of the actual temperature, telling how possible is that the temperature belongs to the set of hot temperatures and how it is necessary. When we say that a bird has the wings, the beak and the feathers, we convey a proper set. This set classifies the particular pair of wings as a part the bird. Note that "birds have wings, beak and feather" is again a classification of birds, because it actually means that any bird is a winged thing, a thing with a beak and feathers. Proper sets represent knowledge rather than just arbitrary observations. A noticeable difficulty is that for inference we often require A has [all] B instead of A is [in] B, because the latter tells nothing about A. Observe also a direct analogy between proper intuitionistic sets and classifications, on one hand, and a posteriori and conditional probabilities on the other.

Operations. The operations on the sets and classifications are defined to preserve the fundamental estimation property:

Operation in
the original domain
Proper set Classification
Possibility Necessity Possibility Necessity
Complement A A A - -
Intersection, A∩B A↑∩B A↓∩B A↑∩B A↓∪B
Union, A∪B A↑∪B A↓∪B A↑∪B A↓∩B
Subset of, A⊆B PB↑|A NB↓|A - -

Note that neither complement nor inclusion can be defined for classifications. For proper sets the definition of inclusion AB conforms to the estimation property in the sense:

PA⊆B  ≤  PAB
NA⊆B  ≥  NAB

We also have AB = AB for sets. Note that AB does not use the lower set A↓. This fact raises a question whether we could get an advantage of knowing A↓. First let us summarize the relationship between AB and AB from one side and conditional possibilities and necessities from another:

A vs. B Possibility Necessity
AB PB↑|A NB↓|A
AB PB↑|A NB↓|A

The values shown in the table above are fundamental in the sense that all others can be obtained as a combination of these four:

A vs. B Possibility Necessity A vs. B Possibility Necessity
AB PB↑|A NB↓|A BA PB↑|A 1-PB↑|A
AB PB↑|A NB↓|A BA 1-NB↓|A NB↓|A
AB 1-NB↓|A 1-PB↑|A BA PB↑|A 1-PB↑|A
AB 1-NB↓|A 1-PB↑|A BA 1-NB↓|A NB↓|A

Now let's note that unlikely to sharp sets, for the fuzzy ones AB does not imply BA, more precisely, it does it only when AB is certain true. We could define a symmetric inclusion AB as AB & BA, which would take BA into account and would have the desired property AB = BA. The symmetric inclusion will use A↓. Note that for the symmetric inclusion Px∈A does not equal to {x}≤A. However in a realistic case it probably will. Another property the symmetric inclusion does not have is that AB ≠ AB. An equivalence relation could be defined in terms of symmetric inclusions: AB = AB & BA. It has the properties AB = BA = AB. The following table summarizes some of interesting variants of intuitionistic comparisons resulting in fuzzy logical values:

A vs. B Possibility Necessity Meaning
AB PB↑|A NB↓|A A is in B (A is a subset of B)
AB PB↑|A NB↓|A The complement of A is in B
AB min (PB↑|A, 1-NB↓|A) NB↓|A A is in B and its complement contains B
AB min (PB↑|A, 1-NB↓|A) 1-PB↑|A A contains B and its complement is in B
AB min (PB↑|A, 1-NB↓|A) min (NB↓|A, 1-PB↑|A) A is B

[Back][TOC][Next]

5.1. Type and operations

The package Fuzzy.Intuitionistic provides an implementation of intuitionistic fuzzy sets.

The type Set is defined as:

type Set (Cardinality : Positive) is record
   Possibility : Fuzzy.Set (1..Cardinality);
   Necessity   : Fuzzy.Set (1..Cardinality);
end record;

The following operations defined on Set:

function "not" (A : Set) return Set;

function "and" (A, B : Set) return Set;
   function "and" (A : Set; B : Fuzzy.Set) return Set;
   function "and" (A : Fuzzy.Set; B : Set) return Set;
   function
"and" (A : Set; B : Confidence ) return Set;
   function
"and" (A : Confidence;  B : Set) return Set;

function
"or" (A, B : Set) return Set;
   function
"or" (A : Set; B : Fuzzy.Set) return Set;
   function
"or" (A : Fuzzy.Set; B : Set) return Set;
   function
"or" (A : Set; B : Confidence ) return Set;
   function
"or" (A : Confidence;  B : Set) return Set;

function
"xor" (A, B : Set) return Set;
   function
"xor" (A : Set; B : Fuzzy.Set) return Set;
   function
"xor" (A : Fuzzy.Set; B : Set) return Set;
   function
"xor" (A : Set; B : Confidence ) return Set;
   function
"xor" (A : Confidence;  B : Set) return Set;

These operations are defined as follows from the table:

Operation  Name 
Complement A not
Intersection AB and
Union AB or
xor-distance (AB)∪(AB) xor

When the parameters are both ether a fuzzy set or an intuitionistic set then they must have the domains of same size (i.e. they should have same cardinality). Otherwise the exception Constraint_Error is propagated. When one of the parameters is of the type Confidence then the result is computed as if it would be a set with all elements having the belonging level equal to the value of the parameter. When a parameter is a set, then the result is computed as if the possibility and the necessity components were equal to the set.

The variants with the first argument used as an accumulator:

procedure Not_At (A : in out Set);

procedure And_At (A : in out Set; B : Set);
   procedure And_At (A : in out Set; B : Fuzzy.Set);
   procedure And_At (A : in out Set; B : Confidence);

procedure Or_At (A : in out Set; B : Set);
   procedure Or_At (A : in out Set; B : Fuzzy.Set);
   procedure Or_At (A : in out Set; B : Confidence);

procedure Xor_At (A : in out Set; B : Set);
   procedure Xor_At (A : in out Set; B : Fuzzy.Set);
   procedure Xor_At (A : in out Set; B : Confidence);

The comparisons:

function Is_In (A, B : Set) return Fuzzy_Boolean;
   function
Is_In (A : Set; B : Fuzzy.Set) return Fuzzy_Boolean;
   function
Is_In (A : Fuzzy.Set; B : Set) return Fuzzy_Boolean;
   function
Is_In (A : Set; B : Integer) return Fuzzy_Boolean;
   function
Is_In (A : Integer; B : Set) return Fuzzy_Boolean;

function
">=" (A, B : Set) return Fuzzy_Boolean;
   function
">=" (A : Set; B : Fuzzy.Set) return Fuzzy_Boolean;
   function
">=" (A : Fuzzy.Set; B : Set) return Fuzzy_Boolean;
   function
">=" (A : Set; B : Integer) return Fuzzy_Boolean;

function
"<=" (A, B : Set) return Fuzzy_Boolean;
   function
"<=" (A : Set; B : Fuzzy.Set) return Fuzzy_Boolean;
   function
"<=" (A : Fuzzy.Set; B : Set) return Fuzzy_Boolean;
   function
"<=" (A : Set; B : Integer) return Fuzzy_Boolean;

function
"=" (A, B : Set) return Fuzzy_Boolean;
   function
"=" (A : Set; B : Fuzzy.Set) return Fuzzy_Boolean;
   function
"=" (A : Fuzzy.Set; B : Set) return Fuzzy_Boolean;
   function
"=" (A : Set; B : Integer) return Fuzzy_Boolean;

function
"/=" (A, B : Set) return Fuzzy_Boolean;
   function
"/=" (A : Set; B : Fuzzy.Set) return Fuzzy_Boolean;
   function
"/=" (A : Fuzzy.Set; B : Set) return Fuzzy_Boolean;
   function
"/=" (A : Set; B : Integer) return Fuzzy_Boolean;

They are defined as:

Operation  Name 
Membership AB Is_In
Symmetric inclusion AB <=
Symmetric inclusion AB >=
Equality AB =
Inequality /=

When both parameters are sets then they must have the domains of same size (i.e. they should have same cardinality). Otherwise the exception Constraint_Error is propagated. When one of the parameters is Integer, then it specifies Set which consists of the domain point specified by the parameter value (singleton). Certain_False is returned when the parameter's value is out of 1..Cardinality. When a parameter is a set, then the result is computed as if the possibility and the necessity components were equal to the set.

The type Classification is defined as:

type Classification is new Set;

The following operations defined on Classification:

function "and" (A, B : Classification) return Classification;
   function "and" (A : Classification; B : Fuzzy.Set) return Classification;
   function "and" (A : Fuzzy.Set; B : Classification) return Classification;
   function
"and" (A : Classification; B : Confidence ) return Classification;
   function
"and" (A : Confidence;  B : Classification) return Classification;
function
"or" (A, B : Classification) return Classification;
   function
"or" (A : Classification; B : Fuzzy.Set) return Classification;
   function
"or" (A : Fuzzy.Set; B : Classification) return Classification;
   function
"or" (A : Classification; B : Confidence ) return Classification;
   function
"or" (A : Confidence;  B : Classification) return Classification;

These operations are defined as follows from the table:

Operation  Name 
Intersection AB and
Union AB or

When the parameters are both ether a fuzzy set or a classification then they must have the domains of same size (i.e. they should have same cardinality). Otherwise the exception Constraint_Error is propagated. When one of the parameters is of the type Confidence then the result is computed as if it would be a set with all elements having the belonging level equal to the value of the parameter. When a parameter is a set, then the result is computed as if the possibility and the necessity components were equal to the set.

The variants with the first argument used as an accumulator:

procedure And_At (A : in out Classification; B : Classification);
   procedure And_At (A : in out Classification; B : Fuzzy.Set);
   procedure And_At (A : in out Classification; B : Confidence);
procedure Or_At (A : in out Classification; B : Classification);
   procedure Or_At (A : in out Classification; B : Fuzzy.Set);
   procedure Or_At (A : in out Classification; B : Confidence);

The membership test:

function Is_In (A : Classification; B : Integer) return Fuzzy_Boolean;

is defined as the value of the membership function of A in B. I.e. it tells how possible and necessary is the domain value specified by B provided that A was observed. Certain_False is returned when the parameter's value is out of 1..A.Cardinality.

[Back][TOC][Next]

5.2. String I/O with numeric indices

The child package Fuzzy.Edit.Intuitionistic provides the string I/O for fuzzy intuitionistic sets with the domain set elements specified in a numeric form.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Fuzzy.Intuitionistic.Set;
             Default : Fuzzy_Boolean := Certain_True
          );
procedure
Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Fuzzy.Intuitionistic.Classification;
             Default : Fuzzy_Boolean := Certain_True
          );

These procedures input a fuzzy intuitionistic set (either a proper one or a classification) from the string Source. The process starts from the position Source (Pointer). After successful completion Pointer is advanced to the position following the measure taken from the string. The parameter Value accepts the Fuzzy.Intuitionistic.Set. The syntax is

<set>  ::=  <item> [,<set>]
<item> ::= <index> [{..|...} <index>] [:<possibility>[:<necessity>]]
<index> ::= A domain point specification
<possibility> ::= A confidence factor specification
<necessity> ::= A confidence factor specification

In [:<possibility>[:<necessity>]] the first one specifies the confidence factor of the possibility component (the upper set), the second one specifies the necessity component (the upper set). When both are omitted the value of the parameter Default determines the result. When only the possibility is specified the necessity is defaulted to the possibility combined with Default.Necessity using and. Characters representing UTF-8 encoded code points from the set Blanks can be used as delimiters. The domain point specification is an integer number. The confidence factor can be given either in numeric form or as true or false (case insensitive). A trailing commas and colons are ignored and not matched. Examples: 

1,2,6..9
1:0,2:0.3,3..5:1:0.5
Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source      : String;
            Cardinality : Positive;
            Default     : Fuzzy_Boolean := Certain_True
         )  return Fuzzy.Intuitionistic.Set;

These functions are a shortcuts for the procedures Get. The get a set from the string Source. The parameter Cardinality defines one of the result. The input in the string can be surrounded by characters representing UTF-8 encoded code points from the set Blanks. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Fuzzy.Intuitionistic.Set;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );
procedure
Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Fuzzy.Intuitionistic.Classification;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );

These procedures  place a fuzzy intuitionistic set specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). The parameter Default determines how to omit the confidence factors for possibility and necessity. If they are equal to ones of Default, they are omitted. Further the necessity is omitted if equal to the possibility combined with Default.Necessity using and. When the parameter Field is not zero then Justify specifies alignment and Fill is the character used for filling. When Field is greater than Destination'Last - Pointer + 1, the latter is used instead. After successful completion Pointer is advanced to the first character following the output or to Destination'Last + 1.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image
         (  Value   : Fuzzy.Intuitionistic.Set;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;
function
Image
         (  Value   : Fuzzy.Intuitionistic.Classification;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;

These functions convert the parameter Value to string.

[Back][TOC][Next]

5.3. Generic string I/O

The child package Fuzzy.Generic_Edit.Intuitionistic provides string I/O with user-defined I/O routines for the domain set elements (the package Fuzzy.Edit.Intuitionistic instantiates Fuzzy.Generic_Edit.Intuitionistic). The package has no formal parameters of its own. It uses the formal procedures of its parent.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data;
             Value   : out Fuzzy.Intuitionistic.Set;
             Default : Fuzzy_Boolean := Certain_True
          );
procedure
Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data;
             Value   : out Fuzzy.Intuitionistic.Classification;
             Default : Fuzzy_Boolean := Certain_True
          );

These procedures get an intuitionistic set (Fuzzy.Intuitionistic.Set or Fuzzy.Intuitionistic.Classification) from the string Source. The set has the following syntax:

<set>  ::=  <item> [,<set>]
<item> ::= <range> [:<possibility>[:<necessity>]]
<possibility> ::= A confidence factor specification
<necessity> ::= A confidence factor specification

Here the syntax of <range> is defined by the formal procedure Get of Fuzzy.Generic_Edit. Commas and colons may be surrounded by characters representing UTF-8 encoded code points from the set Blanks. A trailing comma or colon is ignored and not matched. The parameter Default determines the confidence factors when omitted. If both are not present then the possibility is defaulted to Default.Possibility and the necessity is defaulted to Default.Necessity. When only a necessity is missing it is defaulted to the specified possibility combined with Default.Necessity using and. For example: if Default is Uncertain, the necessity is defaulted to 0; if Default is Certain_True, the necessity is defaulted to the specified possibility. The ranges of the domain set may overlap when the output parameter Exclusive of Get is returned as false. In case of overlapping the possibilities of the overlapped values are combined using the operation or (max), the necessities are using and (min).

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source      : String;
            Data        : User_Data;
            Cardinality : Positive;
            Default     : Fuzzy_Boolean := Certain_True
         )  return Fuzzy.Intuitionistic.Set;
function
Value
         (  Source      : String;
            Data        : User_Data;
            Cardinality : Positive;
            Default     : Fuzzy_Boolean := Certain_True
         )  return Fuzzy.Intuitionistic.Classification;

These functions get either a Fuzzy.Intuitionistic.Set or a Fuzzy.Intuitionistic.Classification from the string Source. The result has the cardinality defined by Cardinality. The input in the string can be surrounded by characters representing UTF-8 encoded code points from the set Blanks. The whole string Source should be matched. Otherwise the exception Data_Error is propagated.

Exceptions
Data_Error Syntax error
End_Error Nothing matched

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data;
             Value       : Fuzzy.Intuitionistic.Set;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );
procedure
Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data;
             Value       : Fuzzy.Intuitionistic.Classification;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );

These procedures place either a Fuzzy.Intuitionistic.Set or a Fuzzy.Intuitionistic.Classification specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). The parameter Default specifies the way the confidence factors can be omitted in output. Both are omitted if the possibility equals to Default.Possibility and the necessity equals to Default.Necessity. Further the necessity can be omitted if it equals to the possibility combined with Default.Necessity using and.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image
         (  Data    : User_Data;
            Value   : Fuzzy.Intuitionistic.Set;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;
function
Image
         (  Data    : User_Data;
            Value   : Fuzzy.Intuitionistic.Classification;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;

These functions convert the parameter Value to string.

[Back][TOC][Next]

5.4. Abstract string I/O

The child package Fuzzy.Abstract_Edit.Intuitionistic provides an instantiation of Fuzzy.Generic_Edit.Intuitionistic. It defines the following class-wide routines for the type User_Data from Fuzzy.Abstract_Edit:

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data'Class;
             Value   : out Fuzzy.Intuitionistic.Set;
             Default : Fuzzy_Boolean := Certain_True
          );
procedure
Get
          (  Source  : String;
             Pointer : in out Integer;
             Data    : User_Data'Class;
             Value   : out Fuzzy.Intuitionistic.Classification;
             Default : Fuzzy_Boolean := Certain_True
          );

function
Value
         (  Source  : String;
            Data    : User_Data'Class;
            Default : Fuzzy_Boolean := Certain_True
         )  return Fuzzy.Intuitionistic.Set;
function
Value
         (  Source  : String;
            Data    : User_Data'Class;
            Default : Fuzzy_Boolean := Certain_True
         )  return Fuzzy.Intuitionistic.Classification;

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data'Class;
             Value       : Fuzzy.Intuitionistic.Set;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );
procedure
Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Data        : User_Data'Class;
             Value       : Fuzzy.Intuitionistic.Classification;
             Default     : Fuzzy_Boolean := Certain_True;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );

function
Image
         (  Data    : User_Data'Class;
            Value   : Fuzzy.Intuitionistic.Set;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;
function
Image
         (  Data    : User_Data'Class;
            Value   : Fuzzy.Intuitionistic.Classification;
            Default : Fuzzy_Boolean := Certain_True
         )  return String;

[Back][TOC][Next]

5.5. String I/O with named indices

The type Domain_Description from the child package Fuzzy.Abstract_Edit.Named can be used with Fuzzy.Abstract_Edit.Intuitionistic.

[Back][TOC][Next]

5.6. Basic string I/O

The child package Fuzzy.Intuitionistic.Basic_Edit provides basic subroutine for string I/O.

procedure Get_Weight
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Fuzzy_Boolean;
             Default : Fuzzy_Boolean := Certain_True
          );

This procedure is used to get the weight of a domain point value in the form [:<possibility>[:<necessity>]]. If no colon present, Default is set into Value. If only the necessity component is missing then it is evaluated as the specified possibility and Default.Necessity. Thus if Default is Certain_True, then the necessity is defaulted to the specified possibility. If Default is Uncertain, then necessity is defaulted to 0.

Exceptions
Data_Error Syntax error or value is not in 0..1
Layout_Error The value of Pointer is not in the range Source'First..Source'Last+1 

[Back][TOC][Next]

6. Linguistic variables

A linguistic variable is some fuzzy set joining values sharing some common property, usually familiar to human beings. For example, if we consider outdoor temperatures, then warm could be a linguistic variable. A set of linguistic variables is used to represent the original domain set in terms of the variables. In the case of outdoor temperatures, this set could be (chill, cold, tepid, warm, hot):

outdoor temperatures

With this set the temperature 16ºC could be classified warm: 0.3, tepid:1, and cold: 0.15. The main purpose of linguistic variables is to reduce the original domain set, which is usually infinite (in our case it is the set of all possible temperatures), to a small conceivable set. The commonly considered operations on linguistic variables and their subsets are:

Let v={vi: R→[0,1]}i be a set of linguistic variables vi, such as warm, tepid etc.

Fuzzification is a process of conversion some, usually crisp, data from the domain set to a set of linguistic variables, as we did it with the temperature 16ºC. The membership function of the result yields the possibility of a variable under condition of the given value. In our example "warm: 0.3 " formally means:

P16ºC∈ warm = Pwarm |{16ºC} = 0.3

One could also say that 16ºC is classified as warm with the confidence 0.3. A set of linguistic variables is complete if its union gives the domain set. This, very frequently disregarded, requirement allows to avoid contradictory (in the sense of fuzzy logic) results (a statement about some x is contradictory when Px + Px is less than 1). Carefully observe, that the result of a fuzzification is in general case an intuitionistic classification (Fuzzy.Intuitionistic.Classification) as the following picture shows:

fuzzification

Here the fuzzified set T of temperatures is painted grey. It produces a classification of T: cold: 1:1, tepid: 0.9:0.4, others are 0:0. This notation means:

PT⊆ cold  =  1,     NT⊆ cold  =  1,
PT⊆ tepid  =  0.9,   NT⊆ tepid  =  0.4,
etc

Formally fuzzified T is v(T) defined as ∀xv v(T)(x) = (Px|T, Nx|T).

Accumultation maps a proper subset of linguistic variables into the original domain. The following figure illustrates the accumulation process for an intuitionistic set warm: 0.3, tepid: 1.0 and cold: 0.15. The result is painted in grey:

accumulation

Formally, if T: v→[0,1] is a fuzzy subset of v. Then accumulated Ta is a fuzzy subset of R (which can be viewed as a fuzzy number or a linguistic variable):

Ta(t)  =  Max
x
v
 min (x(t), T(x))

The interpretation of Ta(t) is as follows. For some variable xv T(x)=PT|x is the possibility that the variable x is a subset of some, maybe, imaginary set T, and x(t)=Px|{t}=Ptx is the possibility that t belongs to x. So provided that the set of linguistic variables is complete Ta(t) ≥ PtT. Thus an accumulated variable gives an estimated image of the argument in the original domain set. Should we have T, a fuzzy intuitionistic subset of v, i.e. both an upper and a lower set, we could estimate T from both above and below:

Min
x
v
 max (1-x(t), T↓(x))  ≤  T(t)  ≤  Max
x
v
 min (x(t), T↑(x))

Beware that accumulation of the lower set of some classification has no sense. Only the upper set of a classification can be accumulated. Accumulation is often used as a part of some defuzzification process. The accumulated result is converted to a crisp number using various empirical methods, such as center of gravity, center of area, etc.

Defuzzification is an operation reverse to fuzzification. The following figure shows the result of defuzzification of an intuitionistic fuzzy classification: cold: 0.4: 0, tepid: 1: 0.7, warm: 0.5: 0, others are 0: 0. The result is a crisp set painted in gray:

defuzzification

Note that the result of defuzzification is a general case crisp set. The set is not empty if correct inference rules and valid data are used. Additional restrictions imposed on the membership functions of the linguistic variables may further ensure that the result is a contiguous set. Formally the result of a defuzzification is defined as follows. Let v(T) be an intuitionistic classification of some unknown T: ∀xv v(T)(x) = (Px|T, Nx|T).. Then defuzzified v(T) is a set of numbers tR, such that for any linguistic variable x: x(t)↑≤v(T)↑ and x(t)↓≥v(T)↓.

There exist various defuzzification methods applied in practice which cannot be justified without additional assumptions about the application domain. Let v: R→[0,1] be a linguistic variable, then

vCoG =  +∞
x v(x) dx
-∞                 
+∞
v(y) dy
-∞
    The center of gravity was borrowed from mathematical statistics. Its result numerically equals to the expectation value of the probability density p:
p(x) =  v(x)
+∞
v(y) dy
-∞             
    Though the membership function v is a distribution of possibilities. Whether p(·), which is numerically v divided by a constant, is indeed a distribution of probability density, and what the meaning the expectation of the latter might have depends on the application domain.
vDCoG = 
 xi v(xi)
i   
 v(xk)
k
    As the continuous center of gravity, the discrete one has a probabilistic interpretation. It numerically equals to the expectation of the distribution of probabilities Pi:
Pi =  v(xi)
 v(xk)
k
vCoA +∞
v(x) dx  =  v(y) dy
-∞               vCoA             
    Note that the center of area is ill-defined. For many continuous distributions of possibilities it is not defined. Infinitely small variations of the distribution may influence existence of the center of area. That means, when using vCoA for outputs in a control loop of a fuzzy control system, one should take into account a possibility of abrupt changes of the outputs. Especially sensible are the cases where the membership function takes small values along an interval between two spikes of equal area: like double hump of a Bactrian camel.

The following picture illustrates the empirical defuzzification methods:

Empirical defuzzification methods

[Back][TOC][Next]

6.1. Variables

6.1.1. Plain variables

The package Fuzzy.Linguistics provides an implementation of linguistic variables built over a domain of real numbers. The package is generic:

generic
   with package Fuzzy_Floats is new Fuzzy.Floats (<>);
package Fuzzy.Linguistics is ...
   subtype Number is Fuzzy_Floats.Number;
   subtype Fuzzy_Number is Fuzzy_Floats.Fuzzy_Float;

The formal generic parameter Fuzzy_Floats of the package is an instance of the package Fuzzy.Floats implementing fuzzy floating-point numbers. There is a pre-instantiated version of Fuzzy.Linguistics for the standard type Float: Fuzzy_Linguistics.

The package defines the type Variable representing a linguistic variable:

type Variable is private;

The implementation supports variables with the membership functions linear on a finite number of intervals. In the points of joining the membership function may have different left, right limits and two different values. The first value is the value of the membership function itself. It tells how possible is that the point belongs to the linguistic variable. The second value tells how necessary it is. Normally both are equal. This allows to represent commonly used shapes of membership function such as "shoulder", "trapezoid",  "triangle", "rectangle" and "singleton".

type Pair is record
   Value : Number;
   Level : Confidence;
end record;

This type is used to represent points from which a membership function of a variable is composed.

Composing a variable:

The following operations are used to compose a Variable:

procedure Append
          (  Var   : in out Variable;
             Value : Number;
             Level : Confidence
          );

This function is used to form the membership function of a linguistic variable Var. It adds a new point to the function. Points have to be added in ascending order. It is allowed to provide several points with same argument (Value). The parameter Level defines the confidence level of the added point. A linguistic variable have to have at least one point defined. The following table shows some examples of using Append:

Membership function Code example
shoulder declare
   Shoulder : Variable;
begin
   Append (Shoulder,  0.0, Confidence'Last);
   Append (Shoulder, 10.0, Confidence'First);
   ...
rectangle declare
   Rectangle : Variable;
begin
   Append (Rectangle, -10.0, Confidence'First);
   Append (Rectangle, -10.0, Confidence'Last);
   Append (Rectangle,  10.0, Confidence'Last);
   Append (Rectangle,  10.0, Confidence'First);
   ...
trapezoid declare
   Trapezoid : Variable;
begin
   Append (Trapezoid, -10.0, Confidence'First);
   Append (Trapezoid,   0.0, Confidence'Last);
   Append (Trapezoid,  10.0, Confidence'Last);
   Append (Trapezoid,  15.0, Confidence'First);
   ...
singleton declare
   Singleton : Variable;
begin
   Append (Singleton, 10.0, Confidence'First);
   Append (Singleton, 10.0, Confidence'Last);
   Append (Singleton, 10.0, Confidence'First);
   ...
pulse declare
   Pulse : Variable;
begin
   Append (Pulse, 0.0, 0.75);
   Append (Pulse, 0.0, Confidence'Last);
   Append (Pulse, 0.0, 0.25);
   Append (Pulse, 0.0, 0.5);
   ...

Data_Error is propagated when the specified value is out of order.

procedure Erase (Var : Variable);

This procedure makes its argument an empty set.

An alternative variant to compose a variable is to use

function "&" (Left : Pair;     Right : Pair) return Variable;
function "&" (Left : Variable; Right : Pair) return Variable;

The left parameter is either a Pair or a Variable. The result is the left parameter with the point added from Right. Data_Error is propagated when the value specified by Right value is out of order. For example, Pulse from the table above could be obtained as:

(0.0, 0.75) & (0.0, Confidence'Last) & (0.0, 0.25) & (0.0, 0.5)

Set-theoretic operations:

function "not" (A : Variable) return Variable;
function "and" (A, B : Variable) return Variable;
   function "and" (A : Variable;   B : Confidence) return Variable;
   function "and" (A : Confidence; B : Variable  ) return Variable;
function "or"  (A, B : Variable) return Variable;
   function "or"  (A : Variable;   B : Confidence) return Variable;
   function "or"  (A : Confidence; B : Variable  ) return Variable;
function "xor" (A, B : Variable) return Variable;
   function "xor" (A : Variable;   B : Confidence) return Variable;
   function "xor" (A : Confidence; B : Variable  ) return Variable;

When one of the parameters is of the type Confidence then the result is computed as if it would be a set with all elements having the belonging level equal to the value of the parameter.

Equality and equivalence tests:

The equality and inequality operations are:

function "=" (A, B : Variable) return Fuzzy_Boolean;
   function
"=" (A : Variable; B : Number) return Fuzzy_Boolean;
   function
"=" (A : Variable; B : Interval    ) return Fuzzy_Boolean;
   function
"=" (A : Variable; B : Fuzzy_Number) return Fuzzy_Boolean;
   function
"=" (A : Number; B : Variable) return Fuzzy_Boolean;
   function "=" (A : Interval;     B : Variable) return Fuzzy_Boolean;
   function
"=" (A : Fuzzy_Number; B : Variable) return Fuzzy_Boolean;
function
"/=" (A, B : Variable) return Fuzzy_Boolean;
   function
"/=" (A : Variable; B : Number) return Fuzzy_Boolean;
   function
"/=" (A : Variable; B : Interval    ) return Fuzzy_Boolean;
   function
"/=" (A : Variable; B : Fuzzy_Number) return Fuzzy_Boolean;
   function
"/=" (A : Number; B : Variable) return Fuzzy_Boolean;
   function
"/=" (A : Interval;     B : Variable) return Fuzzy_Boolean;
   function
"/=" (A : Fuzzy_Number; B : Variable) return Fuzzy_Boolean;

The result of equality is defined as AB & BA. The result of inequality is defined as not (A = B). Numbers, intervals, fuzzy numbers and variables are supported as arguments. At least one argument should be a variable.

function Equal
         (  A, B : Variable;
            Eps  : Number'Base := 0.0
        
return Boolean;
   function
Equal
            (  A    : Pair;
               B    : Variable;
               Eps  : Number'Base := 0.0
            )  return Boolean;
   function Equal
            (  A    : Variable;
                 : Pair;
               Eps  : Number'Base := 0.0
            )  return Boolean;
   function Equal
            (  A, B : Pair;
               Eps  : Number'Base := 0.0
           
return Boolean;

These functions return true if A and B have equivalent membership functions. It means that the membership functions have same number of intervals between distinct joining points. The abscissas of the interval ends iffer no more than by the value of the parameters Eps, ordinates of the points are exactly same. Any of parameters can be either a Variable of Pair.

Scalar arithmetic:

function "+" (Left : Variable; Right : Number) return Variable;
function
"-" (Left : Variable; Right : Number) return Variable;
function
"*" (Left : Variable; Right : Number) return Variable;
function
"/" (Left : Variable; Right : Number) return Variable;

A variable can be multiplied and divided by a number. Also a number can be added to or subtracted from a variable.

Informational functions:

procedure Find
          (  Var  : Variable;
             Span : Interval;
             From : out Positive;
             To   : out Natural
          );

This procedure is used to find points of the membership function of Var.on the interval Span. It returns From and To indices defined as follows. From is the index of the first point such that the domain value of is greater than or equal to the lower bound of Span (Span.From). When there is no such point From is Get_Points_Number (Var) + 1..To is the index of the last point such that the domain value of is less than or equal to the upper bound of Span (Span.To). When no such point exists, To is set to 0.

procedure Get
          (  Var   : Variable;
             Value : Number'Base;
             Left  : out Confidence;
             Min   : out Confidence;
             Max   : out Confidence;
             Right : out Confidence
          );

This procedure is used to get the membership function of Var.in Value. It returns Left, Min, Max and Right. Left and Right are the corresponding limits of the membership function in Value. Min and Max are the lower and the upper bounds of the function in Value. Between the point all four values are equal. In the points they can differ. See also Get_Point. Note that when Value is not exact then an interval membership test is almost always more appropriate than this procedure. Consider

Is_In (Values_Interval, Var);

as an alternative which yields Max in the possibility and Min in the necessity components of the result.

procedure Get_Point
          (  Var   : Variable;
             Index : Positive;
             Value : out Number;
             Left  : out Confidence;
             Min   : out Confidence;
             Max   : out Confidence;
             Right : out Confidence
          );

This procedure is used to enumerate distinct points of the membership function of Var. Index is the number of a point. The total number of points can be obtained by using Get_Points_Number. Constraint_Error is propagated when Index is invalid. The procedure returns the abscissa of the point in Value, and the membership function in Left, Min, Max and Right. Left and Right are the corresponding limits of the membership function in Value. Min and Max are the lower and the upper bounds of the function in Value, i.e. when Value=t. Var↑(t)=Max, Var↓(t)=Min. All these four values can be different. Though it is always MinLeft, RightMax. Note that membership functions having different sets of joint points can be equivalent. The operations defined in the package try to represent the membership function using a minimal possible number of points. However the end points of the function can be redundant after its composition. Use the procedure Trim to remove redundant points.

function Get_Span (Var : Variable) return Interval;

This function returns the interval of domain values between the first and the last distinct points of the membership function. Constraint_Error is propagated when Var is empty. It is equivalent to:

(Get_Value (Var, 1), Get_Value (Var, Get_Points_Number (Var)))

where

function Get_Value (Var : Variable; Index : Positive)
   return Number;

is the function that returns the domain value of the membership function point specified by Index. Constraint_Error is propagated when Index is invalid.

function Get_Points_Number (Var : Variable) return Natural;

This function returns the number of distinct points in the membership function of Var. For the singleton in an example above it would be 1. For the trapezoid it would be 4.

function Is_Empty (Var : Variable) return Boolean;

This function returns true if Var is an empty set, i.e. if its membership function is everywhere false.

function Is_Interval (Var : Variable) return Boolean;

This function returns true if Var is an interval, i.e. if its membership function is true on a finite contiguous range of values and false outside the range. Note that a membership function of variable takes its left and right limits in any point. Thus formally no variable can be an interval. This difference is disregarded. So more precisely Is_Interval returns true if there exist a, b such that Var↑(t)=1 if t∈[a, b] , otherwise Var↑(t)=0 and Var↓(t)=1 if t∈]a, b[ , otherwise Var↓(t)=0.

function Is_Singleton (Var : Variable) return Boolean;

This function returns true if the membership function of Var is true in one point and false elsewhere. More precisely, there is t0 such that Var↑(t0)=1, for any tt0 Var↑(t)=0.

Membership and subset tests:

function Is_In (A, B : Variable) return Fuzzy_Boolean;
   function
Is_In (A : Number; B : Variable) return Fuzzy_Boolean;
   function Is_In (A : Interval;     B : Variable) return Fuzzy_Boolean;
   function Is_In (A : Fuzzy_Number; B : Variable) return Fuzzy_Boolean;
   function
Is_In (A : Variable; B : Number) return Fuzzy_Boolean;
   function Is_In (A : Variable; B : Interval    ) return Fuzzy_Boolean;
   function Is_In (A : Variable; B : Fuzzy_Number) return Fuzzy_Boolean;

These functions implement membership / subset tests or else fuzzification of A using B. The result is a fuzzy logical value indicating whether A is a member / subset to B. It is defined as fuzzy inclusion ⊆. I.e. as Is_In (A, B) = (PB|A, NB|A). The parameters can be numbers, intervals, fuzzy numbers, variables. At least one of them should be a variable. Carefully observe, that for a singleton in the table above and the value 10,

Is_In (10.0, Singleton)

would return Uncertain, because the membership function takes [0, 1] range in 10.

The possibility theory:

function Possibility (A : Variable) return Confidence;
function Possibility (A, B : Variable) return Confidence;
   function
Possibility (A : Number; B : Variable) return Confidence;
   function
Possibility (A : Interval;     B : Variable) return Confidence;
   function
Possibility (A : Fuzzy_Number; B : Variable) return Confidence;
   function Possibility (A : Variable; B : Number) return Confidence;
   function
Possibility (A : Variable; B : Interval    ) return Confidence;
   function
Possibility (A : Variable; B : Fuzzy_Number) return Confidence;

These functions return PA and PA|B correspondingly. The parameters can be numbers, intervals, fuzzy numbers, variables. At least one of them should be a variable.

function Necessity (A : Variable) return Confidence;
function Necessity (A, B : Variable) return Confidence;
   function
Necessity (A : Number; B : Variable) return Confidence;
   function
Necessity (A : Interval;     B : Variable) return Confidence;
   function
Necessity (A : Fuzzy_Number; B : Variable) return Confidence;
   function Necessity (A : Variable; B : Number) return Confidence;
   function
Necessity (A : Variable; B : Interval    ) return Confidence;
   function
Necessity (A : Variable; B : Fuzzy_Number) return Confidence;

These functions return NA and NA|B. Observe that for an empty set NA is defined as true. The parameters can be numbers, intervals, fuzzy numbers, variables. At least one of them should be a variable.

Conversions:

function To_Variable (Value : Number      ) return Variable;
function To_Variable (Value : Interval    ) return Variable;
function To_Variable (Value : Fuzzy_Number) return Variable;

These functions can be used to convert a number, interval or fuzzy number to a variable.

function To_Number (Value : Variable) return Number;
function To_Interval (Value : Variable) return Interval;

These functions perform backward conversions to number and interval. When the conversion is impossible because the parameter is a more general set then Constraint_Error is propagated.

Membership function manipulation:

procedure Insert_Point
          (  Var   : in out Variable;
             Index : Positive;
             Value : Number;
             Left  : Confidence;
             Min   : Confidence;
             Max   : Confidence;
             Right : Confidence;
             Purge : Boolean := True
          );

This procedure inserts a new point into the membership function at the specified by Index position. The parameter Index shall be in the range 1..Get_Points_Number (Var) + 1. Otherwise, Constraint_Error is propagated. The parameter Value specifies the abscissa of the point. If it is not greater than one of the point on the left or not less than one of the point on the right, then Constraint_Error is propagated. The parameters Left and Right determine the left and right limits of the function in the inserted point. The parameter Min is ignored when it is greater than both Left and Right. The parameter Max is ignored when it is less than both Left and Right. When Purge is true the inserted point and its two immediate neighbours are checked for being redundant. Eventually they can be removed.

When it is necessary to insert several points or modify the membership function on per-point basis, the parameter Purge should be set to false. After insertion and other modifications of the membership function the procedure Purge is called to canonize the membership function representation.

procedure Insert_Point
          (  Var   : in out Variable;
             Index : Positive;
             Value : Number;
             Left  : Confidence;
             Right : Confidence;
             Purge : Boolean := True
          );

This procedure inserts a new point at the specified by Index position. The parameters Left and Right determine the left and right limits of the function in the point correspondingly. The upper and lower bounds are evaluated as the maximum and minimum of Left and Right. Constraint_Error is propagated when Index or Value is wrong. This is a simplified version without the parameters Max and Min.

procedure Insert_Point
          (  Var   : in out Variable;
             Index : Positive;
             Value : Number;
             Level : Confidence;
             Purge : Boolean := True
          );

This procedure inserts a new point at the specified by Index postion. The parameter Level determine the membership function in the point. Constraint_Error is propagated when Index or Value is wrong.

procedure Remove_Point
          (  Var   : in out Variable;
             Index : Positive;
             Purge : Boolean := True
          );

This procedure removes one point of the membership function. The point is specified by Index as in Get_Point. Constraint_Error is propagated when Index is wrong. When Purge is true the immediate neighbours of the removed point are checked for redundancy and eventually removed.

procedure Move_Point
          (  Var   : in out Variable;
             Index : Positive;
             Value : Number;
             Purge : Boolean := True
          );

This procedure moves a point of the membership function at the specified by Index position. The parameter Index shall be in the range 1..Get_Points_Number (Var). Otherwise, Constraint_Error is propagated. The parameter Value specifies the new abscissa of the point. If it is not greater than one of the point on the left or not less than one of the point on the right, then Constraint_Error is propagated. When Purge is true the modified point and its mmediate neighbours are checked for redundancy and eventually removed.

procedure Purge
          (  Var       : in out Variable,
             Keep_Ends : Boolean := False
          );

This procedure removes redundant points of the membership function. A point is redundant if the function is contiguous and linear in the point. The parameter Keep_Ends when true prevents the first and the last points of the membership function from being removed.

procedure Set_Point
          (  Var   : in out Variable;
             Index : Positive;
             Left  : Confidence;
             Min   : Confidence;
             Max   : Confidence;
             Right : Confidence;
             Purge : Boolean := True
          );

This procedure changes the membership function in the specified by Index point. The parameters Left and Right determine the left and right limits of the function in the point. The parameter Min is ignored when it is greater than both Left and Right. The parameter Max is ignored when it is less than both Left and Right. Constraint_Error is propagated when Index is wrong. When Purge is true the modified point and its mmediate neighbours are checked for redundancy and eventually removed.

procedure Set_Point
          (  Var   : in out Variable;
             Index : Positive;
             Left  : Confidence;
             Right : Confidence
          );

This procedure changes the membership function in the specified by Index point. The parameters Left and Right determine the left and right limits of the function in the point correspondingly. The upper and lower bounds are evaluated as the maximum and minimum of Left and Right. Constraint_Error is propagated when Index is wrong.

procedure Set_Point
          (  Var   : in out Variable;
             Index : Positive;
             Level : Confidence;
             Purge : Boolean := True
          );

This procedure changes the membership function in the specified by Index point. The parameter Level determine the membership function in the point. Constraint_Error is propagated when Index is wrong.

procedure Trim (Var : in out Variable);

This procedure removes redundant end point of the membership function. The result is a variable which is equivalent to the argument.

The package also defines the constant variable Empty which membership function is everywhere 0.

6.1.2. Dimensioned variables

The package Fuzzy.Measures.Linguistics provides an implementation of linguistic variables built over a domain of dimensioned real numbers. The package is generic:

generic
   with package
Fuzzy_Linguistics is
      new
Fuzzy.Linguistics (Fuzzy_Floats);
package
Fuzzy.Measures.Linguistics is ...

The formal generic parameter of the package is an instance of Fuzzy.Linguistics based on the same package of fuzzy floating numbers (see Fuzzy.Floats) as the parent package.

There is a pre-instantiated version of Fuzzy.Measures.Linguistics for the standard type Float: Fuzzy_Measure_Linguistics also renamed as Fuzzy_Linguistic_Measures.

The package Fuzzy.Measures.Linguistics defines the type Variable_Measure representing a dimensioned linguistic variable:

type Variable_Measure (SI : Unit := Units.Base.Unitless) is record
   Gain   : Variable;
   Offset : Number'Base := 0.0;
end record;

The discriminant SI and the field Offset determine the dimension of the value as they do in the type Measure. The field Gain represents the numeric value of the variable in these units.

type Pair_Measure is record
   Value : Measure;
   Level : Confidence;
end record;

This type is used to represent points from which a membership function of a variable is composed.

Composing a variable:

The following operations are used to compose a Variable_Measure:

procedure Append
          (  Var   : in out Variable_Measure;
             Value : Measure;
             Level : Confidence
          );

This function is used to form the membership function of a linguistic variable Var. It adds a new point to the function. Points have to be added in ascending order. It is allowed to provide several points with same argument (Value). The parameter Level defines the confidence level of the added point. A linguistic variable have to have at least one point defined. Var and Value should have compatible dimension units, though maybe differently shifted. Otherwise Unit_Error is propagated. Data_Error is propagated when the specified value is out of order.

function Empty (Scale : Measure) return Variable_Measure;

This function returns an empty variable with the membership function that is everywhere 0. The dimension of the result is determined by the parameter Scale. The field Gain of Scale is ignored.

function Empty (SI : Unit; Offset : Number'Base := 0.0)
   return Variable_Measure;

This function returns an empty variable with the membership function that is everywhere 0. The dimension of the result is determined by the parameters SI and Offset.

procedure Erase (Var : Variable_Measure);

This procedure makes its argument an empty set.

function "&" (Left : Pair_Measure; Right : Pair_Measure)
   return Variable_Measure;
function "&" (Left : Variable; Right : Pair_Measure)
   return Variable_Measure;

The left parameter is either a Pair_Measure or a Variable_Measure. The result is the left parameter with the point added from Right. Data_Error is propagated when the value specified by Right value is out of order. When Left and Right are of Pair_Measure then they have to have exactly same dimension units. Otherwise Unit_Error is propagated. When Left is of Variable_Measure then the dimension of Right has to be compatible though might be differently shifted.

Set-theoretic operations:

function "not" (A : Variable_Measure) return Variable_Measure;
function "and" (A, B : Variable_Measure) return Variable_Measure;
   function "and" (A : Variable_Measure; B : Confidence)
      return Variable_Measure;
   function "and" (A : Confidence; B : Variable_Measure_Measure)
      return Variable_Measure;
function "or" (A, B : Variable_Measure) return Variable_Measure;
   function "or" (A : Variable_Measure; B : Confidence)
      return Variable_Measure;
   function "or" (A : Confidence; B : Variable_Measure)
      return Variable_Measure;
function "xor" (A, B : Variable_Measure) return Variable_Measure;
   function "xor" (A : Variable_Measure; B : Confidence)
      return Variable_Measure;
   function "xor" (A : Confidence; B : Variable_Measure)
      return Variable_Measure;

When one of the parameters is of the type Confidence then the result is computed as if it would be a set with all elements having the belonging level equal to the value of the parameter. When both parameters are of Variable_Measure then their dimension units have to be compatible. Otherwise Unit_Error is propagated.

Equality and equivalence tests:

The equality and inequality operations are:

function "=" (A, B : Variable_Measure) return Fuzzy_Boolean;
   function
"="  (A : Variable_Measure; B : Measure         ) return Fuzzy_Boolean;
   function
"="  (A : Variable_Measure; B : Interval_Measure) return Fuzzy_Boolean;
   function
"="  (A : Variable_Measure; B : Fuzzy_Measure   ) return Fuzzy_Boolean;
   function
"="  (A : Measure;          B : Variable_Measure) return Fuzzy_Boolean;
   function "="  (A : Interval_Measure; B : Variable_Measure) return Fuzzy_Boolean;
   function
"="  (A : Fuzzy_Measure;    B : Variable_Measure) return Fuzzy_Boolean;
function
"/=" (A, B : Variable_Measure) return Fuzzy_Boolean;
   function
"/=" (A : Variable_Measure; B : Measure         ) return Fuzzy_Boolean;
   function
"/=" (A : Variable_Measure; B : Interval_Measure) return Fuzzy_Boolean;
   function
"/=" (A : Variable_Measure; B : Fuzzy_Measure   ) return Fuzzy_Boolean;
   function
"/=" (A : Measure;          B : Variable_Measure) return Fuzzy_Boolean;
   function
"/=" (A : Interval_Measure; B : Variable_Measure) return Fuzzy_Boolean;
   function
"/=" (A : Fuzzy_Measure;    B : Variable_Measure) return Fuzzy_Boolean;

The result of equality is defined as AB & BA. The result of inequality is defined as not (A = B). Dimensioned numbers, intervals, fuzzy numbers and variables are supported as arguments. At least one argument should be a Variable_Measure. It is allowed to compare entities of different dimension units.

function Equal
         (  A, B : Variable_Measure;
            Eps  : Number'Base := 0.0
        
)  return Boolean;
   function
Equal
            (  A    : Pair_Measure;
               B    : Variable_Measure;
               Eps  : Number'Base := 0.0
            )  return Boolean;
   function Equal
            (  A    : Variable_Measure;
                 : Pair_Measure;
               Eps  : Number'Base := 0.0
            )  return Boolean;
   function Equal
            (  A, B : Pair_Measure;
               Eps  : Number'Base := 0.0
           
)  return Boolean;

These functions return true if A and B have equivalent membership functions. It means that the membership functions have same number of distinct joining points, the ordinates of the corresponding points differ no more than by the value of the parameters Eps, abscissas of the points are exactly same. Any of parameters can be either a Variable_Measure of Pair_Measure. Values of different units are considered unequal.

Scalar arithmetic:

function "+" (Left : Variable_Measure; Right : Measure) return Variable_Measure;
function
"-" (Left : Variable_Measure; Right : Measure) return Variable_Measure;

A dimensioned value can be added to a Variable_Measure. Both arguments must have same dimension, otherwise Unit_Error is propagated.

function "*" (Left : Variable_Measure; Right : Number) return Variable_Measure;
function
"*" (Left : Variable_Measure; Right : Measure) return Variable_Measure;
function
"*" (Left : Variable;         Right : Measure) return Variable_Measure;
function
"/" (Left : Variable_Measure; Right : Number ) return Variable_Measure;
function
"/" (Left : Variable_Measure; Right : Measure) return Variable_Measure;
function
"/" (Left : Variable;         Right : Measure) return Variable_Measure;

These functions multiply and divide a dimensioned variable by a scalar. When Right is dimensioned then Constraint_Error is propagated on unit power overflow. Unit_Error is propagated when Left and Right have incompatible shifts (see the description of the type Measure for further information.) Also a plain variable can be multiplied to or divided by a dimensioned number. The result is a dimensioned linguistic variable.

Informational functions:

procedure Find
          (  Var  : Variable_Measure;
             Span : Interval_Measure;
             From : out Positive;
             To   : out Natural
          );

This procedure is used to find points of the membership function of Var.on the interval Span. It returns From and To indices defined as follows. From is the index of the first point such that the domain value of is greater than or equal to the lower bound of Span (Span.From). When there is no such point From is Get_Points_Number (Var) + 1..To is the index of the last point such that the domain value of is less than or equal to the upper bound of Span (Span.To). When no such point exists, To is set to 0. Unit_Error is propagated when Var and Span have incompatible units.

procedure Get
          (  Var   : Variable_Measure;
             Value : Measure;
             Left  : out Confidence;
             Min   : out Confidence;
             Max   : out Confidence;
             Right : out Confidence
          );

This procedure is used to get the membership function of Var.in Value. It returns Left, Min, Max and Right. Left and Right are the corresponding limits of the membership function in Value. Min and Max are the lower and the upper bounds of the function in Value. Between the point all four values are equal. In the points they can differ. See also Get_Point. Unit_Error is propagated when Var and Value have incompatible units. Note that when Value is not exact then an interval membership test is almost always more appropriate than this procedure. Consider

Is_In (Values_Interval, Var);

as an alternative which yields Max in the possibility and Min in the necessity components of the result.

procedure Get_Point
          (  Var   : Variable_Measure;
             Index : Positive;
             Value : out Measure;
             Left  : out Confidence;
             Min   : out Confidence;
             Max   : out Confidence;
             Right : out Confidence
          );

This procedure is used to enumerate distinct points of the membership function of Var. Index is the number of a point. The total number of points can be obtained by using Get_Points_Number. Constraint_Error is propagated when Index is invalid. The procedure returns the abscissa of the point in Value, and the membership function in Left, Min, Max and Right. Left and Right are the corresponding limits of the membership function in Value. Min and Max are the lower and the upper bounds of the function in Value, i.e. when Value=t. Var↑(t)=Max, Var↓(t)=Min. All these four values can be different. Though it is always MinLeft, RightMax.

function Get_Points_Number (Var : Variable_Measure) return Natural;

This function returns the number of distinct points in the membership function of Var.

function Get_Span (Var : Variable_Measure) return Interval_Measure;

This function returns the interval of domain values between the first and the last distinct points of the membership function. Constraint_Error is propagated when Var is empty.

function Get_Unit (Value : Variable_Measure) return Unit;

This function returns the SI measurement unit of the argument.

function Get_Value (Var : Variable_Measure; Index : Positive)
   return Meaasure;

This function returns the domain value of the membership function point specified by Index. Constraint_Error is propagated when Index is invalid.

function Is_Empty (Var : Variable_Measure) return Boolean;

This function returns true if Var is an empty set, i.e. if its membership function is everywhere false.

function Is_Interval (Var : Variable_Measure) return Boolean;

This function returns true if Var is an interval, i.e. if its membership function is true on a finite contiguous range of values and false outside the range.

function Is_Singleton (Var : Variable_Measure) return Boolean;

This function returns true if the membership function of Var is true in one point and false elsewhere.

Membership and subset tests:

function Is_In (A, B : Variable_Measure) return Fuzzy_Boolean;
   function
Is_In (A : Measure;          B : Variable_Measure) return Fuzzy_Boolean;
   function Is_In (A : Interval_Measure; B : Variable_Measure) return Fuzzy_Boolean;
   function Is_In (A : Fuzzy_Measure;    B : Variable_Measure) return Fuzzy_Boolean;
   function
Is_In (A : Variable_Measure; B : Measure         ) return Fuzzy_Boolean;
   function Is_In (A : Variable_Measure; B : Interval_Measure) return Fuzzy_Boolean;
   function Is_In (A : Variable_Measure; B : Fuzzy_Measure   ) return Fuzzy_Boolean;

These functions implement membership / subset tests or else fuzzification of A using B. The result is a fuzzy logical value indicating whether A is a member / subset to B. The parameters can be dimensioned numbers, intervals, fuzzy numbers, variables. At least one of them should be a Variable_Measure. The parameters may have any units.

The possibility theory:

function Possibility (A : Variable_Measure) return Confidence;
function Possibility (A, B : Variable_Measure) return Confidence;
   function
Possibility (A : Measure;          B : Variable_Measure) return Confidence;
   function
Possibility (A : Interval_Measure; B : Variable_Measure) return Confidence;
   function
Possibility (A : Fuzzy_Measure;    B : Variable_Measure) return Confidence;
   function Possibility (A : Variable_Measure; B : Measure         ) return Confidence;
   function
Possibility (A : Variable_Measure; B : Interval_Measure) return Confidence;
   function
Possibility (A : Variable_Measure; B : Fuzzy_Measure   ) return Confidence;

function
Necessity (A : Variable) return Confidence;
function Necessity (A, B : Variable) return Confidence;
   function Necessity (A : Measure;          B : Variable_Measure) return Confidence;
   function
Necessity (A : Interval_Measure; B : Variable_Measure) return Confidence;
   function
Necessity (A : Fuzzy_Measure;    B : Variable_Measure) return Confidence;
   function
Necessity (A : Variable_Measure; B : Measure         ) return Confidence;
   function
Necessity (A : Variable_Measure; B : Interval_Measure) return Confidence;
   function
Necessity (A : Variable_Measure; B : Fuzzy_Measure   ) return Confidence;

Parameters may have different units in which case the possibility is 0 and the necessity is defined as not Possibility (B). Note that numbers and intervals are normal sets thus for them the result necessity will always be 0. For a variable it is 0 only if the variable is normal.

Conversions:

function Convert (Value : Variable_Measure; Scale : Measure)
   return Variable_Measure;

This function is used to convert Value to the measurement units specified by the parameter Scale. When offsets of Value and Scale are same this is null operation. Unit_Error is propagated when conversion is impossible because units of Value and Scale are incompatible.

function Get_Value (Value : Variable_Measure) return Variable;

This function returns SI equivalent of its argument. The result is a plain linguistic variable.

function Get_Value_As (Value : Variable_Measure; Scale : Measure)
   return Variable;

This function returns Scale equivalent of Value. The result is a plain linguistic variable. Unit_Error is propagated when conversion is impossible because units of Value and Scale are incompatible.

This function converts Value to its shifted equivalent. The parameter Shift specifies the required shift of the result.

function Normalize (Value : Variable_Measure) return Variable_Measure;

This function returns an unshifted equivalent of Value.

function Shift (Value : Variable_Measure; Shift : Number'Base)
   return Variable_Measure;

This function converts Value to its shifted equivalent. The parameter Shift specifies the required shift of the result.

function To_Variable_Measure (Value : Number    ) return Variable_Measure;
function To_Variable_Measure (Value : Interval        ) return Variable_Measure;
function To_Variable_Measure (Value : Fuzzy_Number    ) return Variable_Measure;
function
To_Variable_Measure (Value : Variable        ) return Variable_Measure;
function
To_Variable_Measure (Value : Measure         ) return Variable_Measure;
function To_Variable_Measure (Value : Interval_Measure) return Variable_Measure;
function To_Variable_Measure (Value : Fuzzy_Measure   ) return Variable_Measure;

These functions can be used to convert plain and dimensioned numbers, intervals and also fuzzy numbers and linguistic variables to the corresponding dimensioned linguistic variable.

function To_Measure (Value : Variable_Measure) return Measure;
function To_Interval_Measure (Value : Variable_Measure) return Interval_Measure;

These functions perform backward conversions to number and interval. When the conversion is impossible because Value represents a more general set then Constraint_Error is propagated.

Membership function manipulation:

procedure Insert_Point
          (  Var   : in out Variable_Measure;
             Index : Positive;
             Value : Measure;
             Left  : Confidence;
             Min   : Confidence;
             Max   : Confidence;
             Right : Confidence;
             Purge : Boolean := True
          );

This procedure inserts a new point into the membership function at the specified by Index position. The parameter Index shall be in the range 1..Get_Points_Number (Var) + 1. Otherwise, Constraint_Error is propagated. The parameter Value specifies the abscissa of the point. If it is not greater than one of the point on the left or not less than one of the point on the right, then Constraint_Error is propagated. Unit_Error is propagated when Value has an incompatible unit. The parameters Left and Right determine the left and right limits of the function in the inserted point. The parameter Min is ignored when it is greater than both Left and Right. The parameter Max is ignored when it is less than both Left and Right. When Purge is true the inserted point and its two immediate neighbours are checked for being redundant. Eventually they can be removed.

When it is necessary to insert several points or modify the membership function on per-point basis, the parameter Purge should be set to false. After insertion and other modifications of the membership function the procedure Purge is called to canonize the membership function representation.

procedure Insert_Point
          (  Var   : in out Variable_Measure;
             Index : Positive;
             Value : Measure;
             Left  : Confidence;
             Right : Confidence;
             Purge : Boolean := True
          );

This procedure inserts a new point at the specified by Index position. The parameters Left and Right determine the left and right limits of the function in the point correspondingly. The upper and lower bounds are evaluated as the maximum and minimum of Left and Right. Constraint_Error is propagated when Index or Value is wrong. Unit_Error is propagated when Value has an incompatible unit. The number of points in the membership function may eventually decrease.

procedure Insert_Point
          (  Var   : in out Variable_Measure;
             Index : Positive;
             Value : Measure;
             Level : Confidence;
             Purge : Boolean := True
          );

This procedure inserts a new point at the specified by Index postion. The parameter Level determine the membership function in the point. Unit_Error is propagated when Value has an incompatible unit. Constraint_Error is propagated when Index or Value is wrong. The number of points in the membership function may eventually decrease.

procedure Move_Point
          (  Var   : in out Variable_Measure;
             Index : Positive;
             Value : Measure;
             Purge : Boolean := True
          );

This procedure moves a point of the membership function at the specified by Index position. The parameter Index shall be in the range 1..Get_Points_Number (Var). Otherwise, Constraint_Error is propagated. The parameter Value specifies the new abscissa of the point. If it is not greater than one of the point on the left or not less than one of the point on the right, then Constraint_Error is propagated. Unit_Error is propagated when Value has an incompatible unit. When Purge is true the modified point and its mmediate neighbours are checked for redundancy and eventually removed.

procedure Purge
          (  Var       : in out Variable_Measure,
             Keep_Ends : Boolean := False
          );

This procedure removes redundant points of the membership function. A point is redundant if the function is contiguous and linear in the point. The parameter Keep_Ends when true prevents the first and the last points of the membership function from being removed.

procedure Remove_Point
          (  Var   : in out Variable_Measure;
             Index : Positive;
             Purge : Boolean := True
          );

This procedure removes one point of the membership function. The point is specified by Index as in Get_Point. Constraint_Error is propagated when Index is wrong. When Purge is true the immediate neighbours of the removed point are checked for redundancy and eventually removed.

procedure Set_Point
          (  Var   : in out Variable_Measure;
             Index : Positive;
             Left  : Confidence;
             Min   : Confidence;
             Max   : Confidence;
             Right : Confidence;
             Purge : Boolean := True
          );

This procedure changes the membership function in the specified by Index point. The parameters Left and Right determine the left and right limits of the function in the point. The parameter Min is ignored when it is greater than both Left and Right. The parameter Max is ignored when it is less than both Left and Right. Constraint_Error is propagated when Index is wrong. When Purge is true the modified point and its mmediate neighbours are checked for redundancy and eventually removed.

procedure Set_Point
          (  Var   : in out Variable_Measure;
             Index : Positive;
             Left  : Confidence;
             Right : Confidence;
             Purge : Boolean := True
          );

This procedure changes the membership function in the specified by Index point. The parameters Left and Right determine the left and right limits of the function in the point correspondingly. The upper and lower bounds are evaluated as the maximum and minimum of Left and Right. Constraint_Error is propagated when Index is wrong.

procedure Set_Point
          (  Var   : in out Variable_Measure;
             Index : Positive;
             Level : Confidence;
             Purge : Boolean := True
          );

This procedure changes the membership function in the specified by Index point. The parameter Level determine the membership function in the point.Constraint_Error is propagated when Index is wrong.

procedure Trim (Var : in out Variable_Measure);

This procedure removes redundant end point of the membership function. The result is a variable which is equivalent to the argument.

6.1.3. String I/O

The generic child package Fuzzy.Linguistics.Edit provides string I/O for linguistic variables:

generic
   with package Float_Edit is
      new
Strings_Edit.Float_Edit
          (  Fuzzy_Floats_Of.Float_Intervals_Of.Number
          );
package Fuzzy.Linguistics.Edit is ...

The formal generic parameter of the package is an instance of the package Strings_Edit.Float_Edit implementing floating-point string I/O for the numbers used by the parent package.

There is a pre-instantiated version of Fuzzy.Linguistics.Edit for the standard type Float: Fuzzy.Edit.Linguistics.

Input routines:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Value   : out Variable;
             Base    : NumberBase := 10
          );

This procedure gets a linguistic variable from the string Source. The process starts from Source (Pointer). Pointer is advanced to the string position following the variable.

The syntax of a variable is:

<variable>  ::=  [->] <item> [ {,|->} <variable>] [->]
<item> ::= <value>[{..|...}<value>] [:<level>]

Here <number> has the syntax of a floating-point number as the formal parameter Float_Edit requires. The parameter Base determines its base. <level> is a confidence factor. When missing it is assumed to be Confidence'Last. A variable is specified as a list of items. Items can be joined by either commas or arrows (->). Each item determines a value of the membership function in one domain point or in a range of points. The value is specified by <level>. Numbers of items in the list are specified in ascending order. When items are joined by arrows, the membership function is linear in between. Otherwise, it is 0 in between. Arrows can be given in front of the first item and/or after the last item to specify an extrapolation of the membership function to the left and/or right. Numbers specified in singular points may repeat to specify multiple values of the function. Commas, arrows, colons and ellipsis may be surrounded by characters representing UTF-8 encoded code points from the set Blanks. When trailing they are not matched. Examples:

->0->10:0   The shoulder shape from the table above
-10:0->0..10->15:0   The trapezoid from the table
-10:0,-10,10,10:0   The rectangle from the table
-10..10   Same rectangle
->0:0.75, 0:1, 0:0.25, 0.5-> The pulse variable from the table
Exceptions
Constraint_Error A number is not in range
Data_Error Syntax error or order error
End_Error Nothing matched
Layout_Error Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source : String;
            Base   : NumberBase := 10
         )  return Variable;

This function is a simplified version of the procedure Get. It converts the string Source. The variable in Source may be surrounded by characters representing UTF-8 encoded code points from the set Blanks..The whole string shall be matched. Otherwise Data_Error is propagated.

Exceptions
Constraint_Error A number is not in range
Data_Error Syntax error
End_Error Nothing matched

Output routines:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Variable;
             Base        : NumberBase := 10;
             RelSmall    : Positive   :=-MaxSmall;
             AbsSmall    : Positive   := MaxSmall;
             Field       : Natural    := 0;
             Justify     : Alignment  := Left;
             Fill        : Character  := ' '
          );

This procedure places the variable specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). Pointer is then advanced to point after the end of the output field. The parameters Base, RelSmall, AbsSmall have meaning described in Strings_Edit.Float_Edit. They are used for output of the domain set values. The output has the syntax described in the procedure Get. The parameter Field determines the width of the output field. Zero width means the minimal possible width. If Field is not zero Justify determines the way the value should be aligned within the output field. The parameter Fill is then the fill character.

Exceptions
Layout_Error Pointer is not in Destination'Range or there is no room for the output

function Image
         (  Value    : Variable;
            Base     : NumberBase := 10;
            RelSmall : Positive   :=-MaxSmall;
            AbsSmall : Positive   := MaxSmall;
         )  return String;

This function converts a linguistic variable (the parameter Value) to string.

6.1.4. Empirical defuzzification methods

Dimensionless variables. The package Fuzzy.Linguistics has the following generic child functions implementing empirical defuzzification methods:

generic
   function
Fuzzy.Linguistics.Center_Of_Area
            (  A : Variable
            )  return Number;

This function defuzzifies the variable A by the center of area method. The result does not depend on any finite number of singular values (which measure is zero). It is undefined if the support set of the variable is unbounded. It is also undefined if the variable is an empty set, i.e. when the membership function is zero everywhere, except than in a finite number of points. In which case Constraint_Error is propagated.

generic
   function
Fuzzy.Linguistics.Center_Of_Gravity
            (  A : Variable
            )  return Number;

This function defuzzifies the variable A by the center of gravity method. The result does not depend on any finite number of singular values (which measure is zero). It is undefined if the support set of the variable is unbounded. It is also undefined if the variable is an empty set, i.e. when the membership function is zero everywhere, except than in a finite number of points. In which case Constraint_Error is propagated.

generic
   function
Fuzzy.Linguistics.Discrete_Center_Of_Gravity
            (  A : Variable
            )  return Number;

This function defuzzifies the variable A by the discrete center of gravity method. The support set of the variable should comprise a finite non-empty set. That is its membership function shall be non-zero in a non-empty finite number of points. The result is otherwise undefined and Constraint_Error is propagated.

generic
   function
Fuzzy.Linguistics.Leftmost_Max
            (  A : Variable
            )  return Number;

This function defuzzifies the variable A by the leftmost maximum method. The result is undefined if there is no local maximums.  In which case Constraint_Error is propagated.

generic
   function
Fuzzy.Linguistics.Rightmost_Max
            (  A : Variable
            )  return Number;

This function defuzzifies the variable A by the rightmost maximum method. The result is undefined if there is no local maximums.  In which case Constraint_Error is propagated.

There are pre-instantiated versions of these generic functions for the standard type Float. They are:

Dimensioned variables. The package Fuzzy.Measures.Linguistics provides a generic child function Empirical_Defuzzification for empirical defuzzification of dimensioned linguistic variables:

generic
   with function
Method (A : Variable) return Number is <>;
function
Fuzzy.Measures.Linguistics.Empirical_Defuzzification
         (  A : Variable_Measure
         )  return Measure;

The generic parameter of this function is the corresponding dimensionless defuzzification method, such as:

The result has the dimension and the offset of the parameter A. When the result is undefined Constraint_Error is propagated.

There are pre-instantiated versions of these generic functions for the standard type Float:

[Back][TOC][Next]

6.2. Sets of variables

6.2.1. Plain sets

The child package Fuzzy.Linguistics.Sets provides an implementation of sets of linguistic variables, like {chill, cold, tepid, warm, hot} is in the case of outdoor temperatures. The package is generic because its parent is generic:

generic
package Fuzzy.Linguistics.Sets is ...

There is a pre-instantiated version of Fuzzy.Linguistics.Sets for the standard type Float: Fuzzy_Linguistic_Sets. The package Fuzzy.Linguistics.Sets defines the type Linguistic_Set representing a set of linguistic variables:

type Linguistic_Set is private;

Each variable in a set has an unique name and index. For instance in the set of outdoor temperatures {chill, cold, tepid, warm, hot} the third variable has the name tepid.

The package also defines an enumeration type

type Defuzzification_Result_Class is
     (  Empty,
        Singleton,
        Segment,
        Subset
     );

of possible outcomes of a defuzzification process. That is conversion of a Fuzzy.Intuitionistic.Set to a crisp set of linguistic variables to a set of values from the original domain set. In our example with outdoor temperatures it would be a crisp set of temperatures. The possible outcomes are:

The following type is used to store a result of defuzzification. It is a variant record depending on the actual class of outcome:

type Defuzzification_Result
     (  Class : Defuzzification_Result_Class
     )  is
record
   case Class is
      when Empty     => null;
      when Singleton => Singleton : Number;
      when Segment   => Segment   : Interval;
      when Subset    => Subset    : Variable;
   end case;
end record;

The following operations are defined on Linguistic_Set:

function Accumulate
         (  Set          : Linguistic_Set;
            Distribution : Fuzzy.Set
         )  return Variable;

This function returns an accumulated result of a fuzzy subset Set. The parameter Distribution defines the subset of Set. Distribution'Length should be equal to the number of the variables in Set. Otherwise Constraint_Error is propagated.

procedure Add
          (  Set   : in out Linguistic_Set;
             Name  : String;
             Value : Variable
          );

This procedure is used to add a new variable to linguistic set. The parameter Set is the linguistic set. The parameter Name is the name of the variable. The package Name_Tables determines valid names. Constraint_Error is propagated if Name is invalid. Name_Error is propagated if Set contains a variable with the specified name. The parameter Value is the variable to be added.

function Classify
         (  Set   : Linguistic_Set;
            Value : Number
         )  return Classification;
function Classify
         (  Set   : Linguistic_Set;
            Value : Interval
         )  return Classification;
function Classify
         (  Set   : Linguistic_Set;
            Value : Fuzzy_Number
         )  return Classification;
function
Classify
         (  Set   : Linguistic_Set;
            Value : Variable
         )  return Classification;

These functions fuzzify a value. The parameter Value is either a number or an interval or a fuzzy number or a variable. The result is a classification of the value on the set of linguistic variables Set. I.e. a pair of fuzzy subsets of Set. The upper set of the pair tells how possible is that Value is in the given linguistic variable. The lower set tells how it is necessary. Constraint_Error is propagated if Set is empty.

function Defuzzify
         (  Set   : Linguistic_Set;
            Value : Classification
         )  return Defuzzification_Result;

The result of the function is defuzzified Value, i.e. a set of numbers which being fuzzified (see Classify) might produce Value. Constraint_Error is propagated when the cardinality of Value differs from one of Set.

function Empty return Linguistic_Set;

This function returns an empty linguistic set.

procedure Erase (Set : Linguistic_Set);

This procedure removes all variables from Set.

function Equal
         (  Left, Right : Lingustic_Set;
            Eps         : Number'Base := 0.0
        
return Boolean;

This function returns true is Left and Right are equal. Two sets of linguistic variable are equal if:

function Get
         (  Set   : Linguistic_Set;
            Index : Positive
         )  return Variable;

This function returns a variable by its index. The first variable in a set has the index 1. Constraint_Error is propagated if there is no variable with the index specified.

function Get (Set : Linguistic_Set; Name : String)
   return Positive;

This function returns the variable index by its name. The names of variables are case-insensitive. End_Error is propagated if there is no variable with the name Name.

function Get (Set : Linguistic_Set; Name : String)
   return Variable;

This function returns a variable by its name. The names of variables are case-insensitive. End_Error is propagated if there is no variable with the name Name.

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Set     : Linguistic_Set;
             Index   : out Positive
          );

This procedure parses the string Source. If a name of a linguistic variable from Set is successfully matched starting from Source (Pointer), then Pointer is advanced to the position following the matched name and Index is set to the variable index. End_Error is propagated if no variable matches the string. Layout_Error is propagated if Pointer is not in the range Source'First..Source'Last + 1.

function Get_Cardinality (Set : Linguistic_Set) return Natural;

This function returns the number of variables in Set.

function Get_Domain (Set : Linguistic_Set)
   return Domain_Description_Ptr;

This function is used get the domain description of the linguistic set. The result is a constant pointer to a Domain_Description object.

function Get_Name (Set : Linguistic_Set; Index : Positive)
   return String;

This function is used to obtain the name of a variable by its index. Though names are case-insensitive, the original case is preserved. Constraint_Error is propagated if there is no variable with the index specified.

procedure Insert
          (  Set   : in out Linguistic_Set;
             Index : Positive;
             Name  : String;
             Value : Variable
          );

This procedure is used to insert a new variable into linguistic set. The parameter Set is the linguistic set. The parameter Index specifies the domain value index of the added variable. When Index is the set cardinality + 1, Insert is equivalent to Add. When index is less than the cardinality of the set, the new variable is placed at the specified position and the domain set values of the variables on the right are increased by one. For values of Index greater than the set cardinality + 1 Constraint_Error is propagated. The parameter Name is the name of the variable. The package Name_Tables determines valid names. Constraint_Error is propagated if Name is invalid. Name_Error is propagated if Set contains a variable with the specified name. The parameter Value is the variable to be inserted.

function Is_Empty (Set : Linguistic_Set) return Boolean;

This function returns true if Set is empty.

procedure Move
          (  Set  : in out Linguistic_Set;
             From : Positive;
             To   : Positive
          );

This procedure moves a variable in Set from the domain value index From to the index To. The indices of the variables in the interval of indices From..To will change. Constraint_Error is propagated when either of From or To is greater than the cardinality of Set.

procedure Remove
          (  Set   : in out Linguistic_Set;
             Index : Positive
          );

This procedure removes a variable by its index. The variables with the indices greater than Index will have indices decreased by one. Constraint_Error is propagate when Index is greater than the cardinality of Set.

procedure Remove
          (  Set  : in out Linguistic_Set;
             Name : String
          );

This procedure removes a variable by name. The variables with the indices greater than the removed one will have indices decreased by one. Nothing happens when there is no variable with the name Name.

procedure Rename
          (  Set   : in out Linguistic_Set;
             Index : Positive;
             Name  : String
          );

This procedure renames a variable specified by its index. The parameter Name is the new name. Constraint_Error is propagated when Index does not specify a variable in Set or else Name is an invalid name. Name_Error is propagated if Set contains a variable which name is Name.

procedure Replace
          (  Set   : in out Linguistic_Set;
             Index : Positive;
             Name  : String;
             Value : Variable
          );
procedure
Replace
          (  Set   : in out Linguistic_Set;
             Index : Positive;
             Value : Variable
          );

These procedures replace a variable by its index. Either both the variable value and its name or only the value can be replaced. See also Rename which changes only the name. Constraint_Error is propagated when Index does not specify a variable in Set or else Name is an invalid name. Name_Error is propagated if Set contains a variable which name is Name.

procedure Swap
          (  Set     : in out Linguistic_Set;
             Index_1 : Positive;
             Index_2 : Positive
          );

This procedure exchanges two variables specified by their indices. Constraint_Error is propagated when either Index_1 or Index_2 do not specify a variable in Set.

function To_Set
         (  Set   : Linguistic_Set;
            Value : Number
         )  return Fuzzy.Intuitionistic.Set;
function To_Set
         (  Set   : Linguistic_Set;
            Value : Interval
         )  return Fuzzy.Intuitionistic.Set;
function To_Set
         (  Set   : Linguistic_Set;
            Value : Fuzzy_Number
         )  return Fuzzy.Intuitionistic.Set;
function
To_Set
         (  Set   : Linguistic_Set;
            Value : Variable
         )  return Fuzzy.Intuitionistic.Set;

These functions convert a value into a subset of the linguistic variables. The parameter Value is either a number or an interval or a fuzzy number or a variable. The result is an estimation of the value on the Set. I.e. a pair of fuzzy subsets of Set. The upper set of the pair tells how possible is that Value contains the given linguistic variable. The lower set tells how it is necessary. Constraint_Error is propagated if Set is empty.

The package also defines:

type Array_Of_Variables is array (Positive range <>) of Variable;

and instantiates Generic_Unbounded_Array to provide unbounded arrays of variables:

package Unbounded_Arrays is
   new
Generic_Unbounded_Array ...

6.2.2. Dimensioned sets

The child package Fuzzy.Measures.Linguistics.Sets provides an implementation of sets of dimensioned linguistic variables, like {chill, cold, tepid, warm, hot} is in the case of outdoor temperatures with the dimension °C attached to the values. The package is generic:

generic
   with package
Linguistic_Sets is new Fuzzy.Linguistics.Sets;
package
Fuzzy.Measures.Linguistics.Sets is ...

The formal generic parameter Linguistic_Sets is an instance of the package Fuzzy.Linguistics.Sets that provides the type Linguistic_Set (of plain sets of linguistic variables.) There is a pre-instantiated version of Fuzzy.Measures.Linguistics.Sets for the standard type Float: Fuzzy_Measure_Linguistic_Sets also renamed as Fuzzy_Linguistic_Set_Measures.

The package Fuzzy.Measures.Linguistics.Sets defines the type Set_Measure representing a set of dimensioned linguistic variables:

type Set_Measure (SI : Unit := Units.Base.Unitless) is record
   Gain   : Linguistic_Set;
   Offset : Number'Base := 0.0;
end record;

The discriminant SI and the field Offset determine the dimension of all variables in the set. The field Gain represents the set of the plain (dimensionless) variables specified in the units determined by SI and Offset.

Analogously to the package Fuzzy.Linguistics.Sets the type Defuzzification_Result is defined to describe a result of defuzzification. It is a variant record depending on the actual class of outcome (the type Defuzzification_Result_Class defined in Fuzzy.Linguistics.Sets):

type Defuzzification_Result
     (  Class : Defuzzification_Result_Class
     )  is
record
   case Class is
      when Empty     => null;
      when Singleton => Singleton : Measure;
      when Segment   => Segment   : Interval_Measure;
      when Subset    => Subset    : Variable_Measure;
   end case;
end record;

The following operations are defined on Set_Measure:

function Accumulate
         (  Set          : Set_Measure;
            Distribution : Fuzzy.Set
         )  return Variable_Measure;

This function returns an accumulated result of a fuzzy subset Set. The parameter Distribution defines the subset of Set. Distribution'Length should be equal to the number of the variables in Set. Otherwise Constraint_Error is propagated.

procedure Add
          (  Set   : in out Set_Measure;
             Name  : String;
             Value : Variable_Measure
          );

This procedure is used to add a new variable to linguistic set. The parameter Set is the linguistic set. The parameter Name is the name of the variable. The package Name_Tables determines valid names. The parameter Value is the variable to be added. The dimension of Value should be compatible with the dimension of Set. Otherwise Unit_Error is propagated. Value and Set may have differently shifted units, though.

Exceptions
Constraint_Error Name is invalid
Name_Error Set contains a variable with the name Name
Unit_Error Improperly dimensioned Value

function Classify
         (  Set   : Set_Measure;
            Value : Measure
         )  return Classification;
function Classify
         (  Set   : Set_Measure;
            Value : Interval_Measure
         )  return Classification;
function Classify
         (  Set   : Set_Measure;
            Value : Fuzzy_Measure
         )  return Classification;
function
Classify
         (  Set   : Set_Measure;
            Value : Variable_Measure
         )  return Classification;

These functions fuzzify a value. The parameter Value is can be a dimensioned number, interval, fuzzy number, variable. The result is a classification of the value on the set of linguistic variables Set. I.e. a pair of fuzzy subsets of Set. The upper set of the pair tells how possible is that Value is in the given linguistic variable. The lower set tells how it is necessary. Constraint_Error is propagated if Set is empty. When Set and Value have different units the membership function of the upper set is always constant 0, i.e. the upper set is empty. The lower set is also empty if all variables in the set are normal.

function Defuzzify
         (  Set   : Set_Measure;
            Value : Classification
         )  return Defuzzification_Result;

The result of the function is defuzzified Value, i.e. a set of numbers which being fuzzified (see Classify) might produce Value. The result has the same dimension as the original set. Constraint_Error is propagated when the cardinality of Value differs from one of Set.

function Empty (Scale : Measure) return Set_Measure;

This function returns an empty linguistic set. The dimension of the result is determined by the parameter Scale. The field Gain of Scale is ignored.

function Empty (SI : Unit; Offset : Number'Base := 0.0)
   return Set_Measure;

This function returns an empty linguistic set. The dimension of the result is determined by the parameters SI and Offset.

procedure Erase (Set : Set_Measure);

This procedure removes all variables from Set.

function Equal
         (  Left, Right : Set_Measure;
            Eps         : Number'Base := 0.0
        
return Boolean;

This function returns true is Left and Right are equal. Two sets of dimensioned linguistic variable are equal if:

function Get
         (  Set   : Set_Measure;
            Index : Positive
         )  return Variable_Measure;

This function returns a variable by its index. The first variable in a set has the index 1. Constraint_Error is propagated if there is no variable with the index specified.

function Get (Set : Set_Measure; Name : String)
   return Positive;

This function returns the variable index by its name. The names of variables are case-insensitive. End_Error is propagated if there is no variable with the name Name.

function Get (Set : Set_Measure; Name : String)
   return Variable_Measure;

This function returns a variable by its name. The names of variables are case-insensitive. End_Error is propagated if there is no variable with the name Name.

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Set     : Set_Measure;
             Index   : out Positive
          );

This procedure parses the string Source. If a name of a linguistic variable from Set is successfully matched starting from Source (Pointer), then Pointer is advanced to the position following the matched name and Index is set to the variable index. End_Error is propagated if no variable matches the string. Layout_Error is propagated if Pointer is not in the range Source'First..Source'Last + 1.

function Get_Cardinality (Set : Set_Measure) return Natural;

This function returns the number of variables in Set.

function Get_Domain (Set : Set_Measure)
   return Domain_Description_Ptr;

This function is used get the domain description of the linguistic set. The result is a constant pointer to a Domain_Description object.

function Get_Name (Set : Set_Measure; Index : Positive)
   return String;

This function is used to obtain the name of a variable by its index. Though names are case-insensitive, the original case is preserved. Constraint_Error is propagated if there is no variable with the index specified.

function Get_Unit (Set : Set_Measure) return Unit;

This function returns the SI measurement unit of the argument.

function Get_Value (Set : Set_Measuree) return Linguistic_Set;

This function returns SI equivalent of its argument. The result is a plain linguistic set.

function Get_Value_As (Set : Set_Measure; Scale : Measure)
   return Linguistic_Set;

This function returns Scale equivalent of Value. The result is a plain linguistic set. Unit_Error is propagated when conversion is impossible because units of Value and Scale are incompatible.

procedure Insert
          (  Set   : in out Set_Measure;
             Index : Positive;
             Name  : String;
             Value : Variable_Measure
          );

This procedure is used to insert a new variable into linguistic set. The parameter Set is the linguistic set. The parameter Index specifies the domain value index of the added variable. When Index is the set cardinality + 1, Insert is equivalent to Add. When index is less than the cardinality of the set, the new variable is placed at the specified position and the domain set values of the variables on the right are increased by one. The parameter Name is the name of the variable. The package Name_Tables determines valid names. The parameter Value is the variable to be inserted. The dimension of Value should be compatible with the dimension of Set. Otherwise Unit_Error is propagated. Value and Set may have differently shifted units, though.

Exceptions
Constraint_Error Name is invalid
Name_Error Set contains a variable with the name Name
Unit_Error Improperly dimensioned Value

function Is_Empty (Set : Set_Measure) return Boolean;

This function returns true if Set is empty.

procedure Move
          (  Set  : in out Set_Measure;
             From : Positive;
             To   : Positive
          );

This procedure moves a variable in Set from the domain value index From to the index To. The indices of the variables in the interval of indices From..To will change. Constraint_Error is propagated when either of From or To is greater than the cardinality of Set.

procedure Remove
          (  Set   : in out Set_Measure;
             Index : Positive
          );

This procedure removes a variable by its index. The variables with the indices greater than Index will have indices decreased by one. Constraint_Error is propagate when Index is greater than the cardinality of Set.

procedure Remove
          (  Set  : in out Set_Measure;
             Name : String
          );

This procedure removes a variable by name. The variables with the indices greater than the removed one will have indices decreased by one. Nothing happens when Set has no variable with the name Name.

procedure Rename
          (  Set   : in out Set_Measure;
             Index : Positive;
             Name  : String
          );

This procedure renames a variable specified by its index. The parameter Name is the new name. Constraint_Error is propagated when Index does not specify a variable in Set or else Name is an invalid name. Name_Error is propagated if Set contains a variable which name is Name.

procedure Replace
          (  Set   : in out Set_Measure;
             Index : Positive;
             Name  : String;
             Value : Variable_Measure
          );
procedure
Replace
          (  Set   : in out Set_Measure;
             Index : Positive;
             Value : Variable_Measure
          );

These procedures replace a variable by its index. Either both the variable value and its name or only the value can be replaced. See also Rename which changes only the name.

Exceptions
Constraint_Error Index does not specify a variable or Name is invalid
Name_Error Set contains a variable with the name Name
Unit_Error Improperly dimensioned Value

procedure Swap
          (  Set     : in out Linguistic_Set;
             Index_1 : Positive;
             Index_2 : Positive
          );

This procedure exchanges two variables specified by their indices. Constraint_Error is propagated when either Index_1 or Index_2 do not specify a variable in Set.

function To_Set
         (  Set   : Set_Measure;
            Value : Measure
         )  return Fuzzy.Intuitionistic.Set;
function To_Set
         (  Set   : Set_Measure;
            Value : Interval_Measure
         )  return Fuzzy.Intuitionistic.Set;
function To_Set
         (  Set   : Set_Measure;
            Value : Fuzzy_Measure
         )  return Fuzzy.Intuitionistic.Set;
function
To_Set
         (  Set   : Set_Measure;
            Value : Variable_Measure
         )  return Fuzzy.Intuitionistic.Set;

These functions convert a value into a subset of the dimensioned linguistic variables. The parameter Value is a dimensioned number, interval, fuzzy number, variable. The result is an estimation of the value on the Set. I.e. a pair of fuzzy subsets of Set. The upper set of the pair tells how possible is that Value contains the given linguistic variable. The lower set tells how it is necessary. Constraint_Error is propagated if Set is empty. When Set and Value have different units the membership function of the upper set is always constant 0, i.e. the upper set is empty. The lower set is also empty if Value is a normal set, which might be untrue when it is a linguistic variable.

6.2.3. String I/O

The generic child package Fuzzy.Linguistics.Sets.Edit provides string I/O for sets of linguistic variables:

generic
   with package Linguistics_Edit is new Variables_Edit (<>);
package Fuzzy.Linguistics.Sets.Edit is ...

The formal generic parameters of the package is an instance of the package Fuzzy.Linguistics.Edit (in the package it is specified via its renaming Varaibles_Edit) implementing floating-point string I/O for the individual variables.

There is a pre-instantiated version of Fuzzy.Linguistics.Sets.Edit for the standard type Float named Fuzzy.Edit.Linguistic_Sets.

Input routines for sets:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Set     : Linguistic_Set;
             Base
    : NumberBase := 10
          );

This procedure gets a set of linguistic variables from the string Source. The process starts from Source (Pointer). Pointer is advanced to the string position following the description of a set. The syntax of a set is:

<set>  ::=  <item>[,<set>]
<item> ::= <name>[(<variable>)]

Here <name> is defined as specified by the package Name_Tables. Invalid names treated as syntax errors. <variable> has the same syntax as described in Fuzzy.Linguistics.Edit for the procedure Get. The parameter Base determines the base of the joining points. Commas and brackets can be surrounded by characters representing UTF-8 encoded code points from the set Blanks. The set of outdoor temperatures could be specified as:

chill (->-10->-4:0),
cold  (->11->17:0),
tepid (3:0->8..21->28:0),
warm  (15:0->21->29->35:0),
hot   (25:0->28->)

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Layout_Error Pointer is not in the range Source'First..Source'Last+1 
Name_Error A duplicated name

function Value
         
(  Source : String;
            Base   : NumberBase := 10
        
)  return Linguistic_Set;

This function is used to convert string Source to a set of linguistic variables. The description of a set in Source may be surrounded by characters representing UTF-8 encoded code points from the set Blanks. The whole string shall be matched. Otherwise Data_Error is propagated.

Exceptions
Data_Error Syntax error
End_Error Nothing matched
Name_Error A duplicated name

Output routines for sets:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Value       : Linguistic_Set;
             Base        : NumberBase := 10;
             RelSmall    : Positive   := -MaxSmall;
             AbsSmall    : Positive   := MaxSmall;
             Field       : Natural    := 0;
             Justify     : Alignment  := Left;
             Fill        : Character  := ' '
          );

This procedure places a description of a linguistic set specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). Pointer is then advanced to point after the end of the output field. The output has the syntax compatible with the input procedure. The parameters Base, RelSmall, AbsSmall have meaning described in Strings_Edit.Float_Edit. They are used for output of the domain set values. The parameter Field determines the width of the output field. Zero width means the minimal possible width. If Field is not zero Justify determines the way the value should be aligned within the output field. The parameter Fill is then the fill character. Layout_Error is propagated if Pointer is not in the range Destination'Range or there is no room for the output.

function Image
         (  Value    : Linguistic_Set;
            Base     : NumberBase := 10;
            RelSmall : Positive   := -MaxSmall;
            AbsSmall : Positive   := MaxSmall
         )  return String;

This function converts a linguistic set (the parameter Value) to string.

Input routines for classifications and subsets:

procedure Get
          (  Source  : String;
             Pointer : in out Integer;
             Set     : Linguistic_Set;
             Value   : Fuzzy.Intuitionistic.Set;
             Default : Fuzzy_Boolean := Uncertain;
             Base    : NumberBase    := 10
          );
procedure
Get
          (  Source  : String;
             Pointer : in out Integer;
             Set     : Linguistic_Set;
             Value   : Fuzzy.Intuitionistic.Classification;
             Default : Fuzzy_Boolean := Uncertain;
             Base    : NumberBase    := 10
          );

These procedure get either a proper subset of Set (a set of linguistic variables) or a classification on Set from the string Source. The process starts from Source (Pointer). Pointer is advanced to the string position following the input. Input can be specified:

tepid..warm:1:0.2, hot

16..18

The mentioned variants cannot be mixed, so input has to be specified in either variant. The parameter Default specifies the defaults for the confidence levels in case of an input in terms of the variables. The parameter Base specified the base of the numeric values in case of an input in terms of the numeric domain.

Exceptions
Constraint_Error A number is not in range
Data_Error Syntax error or order error
End_Error Nothing matched
Layout_Error Pointer is not in the range Source'First..Source'Last+1 

function Value
         (  Source  : String;
            Set     : Linguistic_Set;
            Default : Fuzzy_Boolean := Uncertain;
            Base    : NumberBase    := 10
         )  return Fuzzy.Intuitionistic.Set;
function
Value
         (  Source  : String;
            Set     : Linguistic_Set;
            Default : Fuzzy_Boolean := Uncertain;
            Base    : NumberBase    := 10
         )  return Fuzzy.Intuitionistic.Classification;

These functions convert the string Source. A value in Source may be surrounded by characters representing UTF-8 encoded code points from the set Blanks. The whole string shall be matched. Otherwise Data_Error is propagated.

Exceptions
Constraint_Error A number is not in range
Data_Error Syntax error
End_Error Nothing matched

Output routines for classifications and subsets:

procedure Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Set         : Linguistic_Set;
             Value       : Fuzzy.Intuitionistic.Set;
             Default     : Fuzzy_Boolean := Uncertain;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );
procedure
Put
          (  Destination : in out String;
             Pointer     : in out Integer;
             Set         : Linguistic_Set;
             Value       : Fuzzy.Intuitionistic.Classification;
             Default     : Fuzzy_Boolean := Uncertain;
             Field       : Natural       := 0;
             Justify     : Alignment     := Left;
             Fill        : Character     := ' '
          );

These procedures place either a proper subset of or a classification on Set specified by the parameter Value into the output string Destination. The string is written starting from Destination (Pointer). Pointer is then advanced to point after the end of the output field. The output has the syntax compatible with in the input routines. Note that Value is always output in terms of the names from Set. The parameter Default determines how to omit confidence factors for the possibilities and necessities. For an output in terms of the original numeric domain, one can use Fuzzy.Linguistics.Edit.Put on a result of Accumulate. The parameter Field determines the width of the output field. Zero width means the minimal possible width. If Field is not zero Justify determines the way the value should be aligned within the output field. The parameter Fill is then
the fill character.

Exceptions
Constraint_Error Different cardinalities of Set and Value
Layout_Error The value of Pointer is not in the range Destination'Range or there is no room for the output

function Image
         (  Set     : Linguistic_Set;
            Value   : Fuzzy.Intuitionistic.Set;
            Default : Fuzzy_Boolean := Uncertain
         )  return String;
function
Image
         (  Set     : Linguistic_Set;
            Value   : Fuzzy.Intuitionistic.Classification;
            Default : Fuzzy_Boolean := Uncertain
         )  return String;

These functions convert the parameter Value to string.

Exceptions
Constraint_Error Different cardinalities of Set and Value

[Back][TOC][Next]

7. Graphical user interface. GTK+ support

The packages described in this chapter rely on GtkAda, which is Ada bindings to GTK+, a portable platform-independent graphical framework. GtkAda contributions is also required. Other packages are fully independent from GTK+ and do not require GTK+, GtkAda and GtkAda contributions installed.

The interface is subdivided into two parts:

[Back][TOC][Next]

7.1. GLib values of fuzzy objects

The GTK+ framework provides its own type system unrelated to one of the programming language. For this reason the Ada types of fuzzy entities have their GTK+ counterparts described in the following table:

Ada type GTK+ type GTK+ type name
Classification GType_Classification GIntuitionisticFuzzyClassification
Confidence GType_Confidence GConfidence
Fuzzy_Boolean GType_Fuzzy_Boolean GFuzzyBoolean
Set (Fuzzy.Intuitionistic) GType_Set GIntuitionisticFuzzySet
Set (Fuzzy) GType_Set GFuzzySet

The objects of GTK+ types are declared as GValue in GtkAda. GValue is a dynamically typed object which actual type can be changed any time. Objects of this type can be passed to GTK+ procedures and stored in other GTK+ objects, like tree models, for example. The following packages are children of the GtkAda GLib.Values package which provides declaration and basic functionality of GValue.

7.1.1. Confidence factors

The package GLib.Values.Confidence_Factors provides GTK+ type of values corresponding to Confidence_Factor:

function Get (Value : GValue) return Confidence;

This function returns the confidence stored in Value. Constraint_Error is propagated when Value is not of GType_Confidence type or undefined.

function GType_Confidence return GType;

This function returns the GTK+ type of confidence.

function Is_Confidence (Value : GValue) return Boolean;

This function returns true if Value is defined and of the GType_Confidence type.

function Is_Defined (Value : GValue) return Boolean;

This function returns true if Value is of GType_Confidence type and defined.

procedure Set (Value : in out GValue; Level : Confidence);

This procedure sets Level into Value, which should be initialized with the GType_Confidence type before this call using Init from GLib.Values. Otherwise Constraint_Error is propagated.

procedure Set_Undefined (Value : in out GValue);

This procedure sets Value undefined. Undefined values propagate Constraint_Error out of Get. Value should be initialized with the GType_Confidence type before this call using Init from GLib.Values. Otherwise Constraint_Error is propagated.

Confidence_Type_Name : constant String := "GConfidence";

The type name.

7.1.2. Fuzzy set values

The package GLib.Values.Fuzzy provides GTK+ type of values corresponding to Set:

function Get (Value : GValue) return Set;

This function returns the fuzzy set stored in Value. Constraint_Error is propagated when Value is not of GType_Set type or else is not defined. Fuzzy set values can be set undefined using the procedure Set_Undefined.

function Get_Cardinality (Value : GValue) return Natural;

This function returns the cardinality of the fuzzy set stored in Value. Constraint_Error is propagated when Value is not of GType_Set type or undefined. Fuzzy set values can be set undefined using the procedure Set_Undefined.

function GType_Set return GType;

This function returns the GTK+ type of fuzzy sets.

function Is_Defined (Value : GValue) return Boolean;

This function returns true if Value is of GType_Set type and has a defined value.

function Is_Set (Value : GValue) return Boolean;

This function returns true if Value is defined and of the GType_Set type.

procedure Set (Value : in out GValue; Data : Set);

This procedure sets Data into Value, which should be initialized with the GType_Set type before this call using Init from GLib.Values. Otherwise Constraint_Error is propagated.

procedure Set_Undefined (Value : in out GValue);

This procedure sets Value undefined. Value should be initialized with the GType_Set type before this call using Init from GLib.Values. Otherwise Constraint_Error is propagated. Undefined fuzzy set values can be used in tree stores to indicate undefined cells.

Fuzzy_Set_Type_Name : constant String := "GFuzzySet";

The type name.

7.1.3. Fuzzy logical values

The package GLib.Values.Fuzzy.Logic provides GTK+ type of values corresponding to Fuzzy_Boolean:

function Get (Value : GValue) return Fuzzy_Boolean;

This function returns the fuzzy logical value stored in Value. Constraint_Error is propagated when Value is not of GType_Fuzzy_Boolean type or undefined.

function GType_Fuzzy_Boolean return GType;

This function returns the GTK+ type of fuzzy logical values.

function Is_Fuzzy_Boolean (Value : GValue) return Boolean;

This function returns true if Value is defined and of the GType_Fuzzy_Boolean type.

function Is_Defined (Value : GValue) return Boolean;

This function returns true if Value is of GType_Fuzzy_Boolean type and defined.

procedure Set (Value : in out GValue; Level : Fuzzy_Boolean);

This procedure sets Level into Value, which should be initialized with the GType_Fuzzy_Boolean type before this call using Init from GLib.Values. Otherwise Constraint_Error is propagated.

procedure Set_Undefined (Value : in out GValue);

This procedure sets Value to undefined. Value which should have been initialized with the GType_Fuzzy_Boolean type before this call using Init from GLib.Values. Otherwise Constraint_Error is propagated.

Fuzzy_Boolean_Type_Name : constant String := "GFuzzyBoolean";

The type name.

7.1.4. Intuitionistic fuzzy set values

The package GLib.Values.Fuzzy.Intuitionistic provides GTK+ type of values corresponding to intuitionistic Classification and Set:

function Get (Value : GValue) return Classification;
function
Get (Value : GValue) return Set;

These function return the intuitionistic fuzzy classifications or intuitionistic fuzzy sets of Value correspondingly. Constraint_Error is propagated when Value is not of either GType_Classification or GType_Set type, or else when the value is not defined. Intuitionistic set values can be set undefined using the procedure Set_Undefined.

function Get_Cardinality (Value : GValue) return Natural;

This function returns the cardinality of the fuzzy set stored in Value. Constraint_Error is propagated when Value is not of either a fuzzy set, an intuitionistic fuzzy set or classification (i.e. of GType_Classification, GType_Set or GType_Set of the parent package) or undefined.

function GType_Classification return GType;

This function returns the GTK+ type of intuitionistic fuzzy classifications.

function GType_Set return GType;

This function returns the GTK+ type of intuitionistic fuzzy sets.

function Is_Classification (Value : GValue) return Boolean;

This function returns true if Value is defined and of the GType_Classification type.

function Is_Defined (Value : GValue) return Boolean;

This function returns true if Value is either a fuzzy set, an intuitionistic fuzzy set or classification (i.e. of GType_Classification, GType_Set or GType_Set of the parent package) and has a defined value.

function Is_Set (Value : GValue) return Boolean;

This function returns true if Value is defined and of the GType_Set type.

procedure Set (Value : in out GValue; Data : Classification);
procedure
Set (Value : in out GValue; Data : Set);

This procedure sets Data into Value, which should be initialized with correspondingly the GType_Classification or GType_Set type before this call using Init from GLib.Values. Otherwise Constraint_Error is propagated.

procedure Set_Undefined (Value : in out GValue);

This procedure sets Value undefined. Value should be initialized with either of the types: GType_Classification, GType_Set or GType_Set of the parent package before this call using Init from GLib.Values. Otherwise Constraint_Error is propagated. Undefined fuzzy set values can be used in tree stores to indicate undefined cells.

Intuitionistic_Set_Type_Name : constant String :=
   "GIntuitionisticFuzzySet";
Intuitionistic_Classification_Type_Name : constant String :=
   "GIntuitionisticFuzzyClassification";

The names of the types.

[Back][TOC][Next]

7.2. Widgets and renderers of fuzzy objects

The provided set of widgets and tree view cell renderes covers:

The linguistic variables sets editor features:

The following table lists the GTK+ widgets and cell renderers used to represent fuzzy entities:

Ada type GTK+ widget GTK+ cell renderer
Classification Gtk_Fuzzy_Set, Gtk_Fuzzy_Set_Entry Gtk_Cell_Renderer_Fuzzy
Confidence Gtk_Fuzzy_Boolean Gtk_Cell_Renderer_Fuzzy_Boolean
Fuzzy_Boolean Gtk_Fuzzy_Boolean Gtk_Cell_Renderer_Fuzzy_Boolean
Linguistic_Set Gtk_Fuzzy_Linguistic_Set_Editor -
Set (Fuzzy.Intuitionistic) Gtk_Fuzzy_Set Gtk_Cell_Renderer_Fuzzy
Set (Fuzzy) Gtk_Fuzzy_Set Gtk_Cell_Renderer_Fuzzy
Set_Measure Gtk_Fuzzy_Linguistic_Set_Measure_Editor -

Visual appearance of some widgets
 
fuzzy linguistic set domain
Gtk_Fuzzy_Linguistic_Set_Domain

          

         fuzzy linguistic set measure tree view 
Gtk_Fuzzy_Linguistic_Set_Tree_View,
Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View
fuzzy linguistic set zoom panel
Gtk_Fuzzy_Linguistic_Set_
Zoom_Panel
        fuzzy set
Gtk_Fuzzy_Set
 

fuzzy boolean bullet

fuzzy boolean
Gtk_Fuzzy_Boolean 
         fuzzy linguistic set measure editor
Gtk_Fuzzy_Linguistic_Set_Editor, Gtk_Fuzzy_Linguistic_Set_Measure_Editor
 
fuzzy set entry
Gtk_Fuzzy_Set_Entry
 

7.2.1. Confidence factors and fuzzy logical values

The widget and the renderer share some GTK+ properties:

Name GTK+ type Default Description
confidence-value GType_Confidence - The Confidence value of. When the indicated value is Fuzzy_Boolean, then it is the possibility component of. When the indicated value is invalid then the result is the undefined value. When this property is set, it changes the indicated value type to Confidence.
fuzzy-boolean-value GType_Fuzzy_Boolean - The Fuzzy_Boolean value of. When the indicated value is Confidence, then the necessity component is 0. When the indicated value is invalid then it is has the undefined value. When this property is set, it changes the indicated value type to Fuzzy_Boolean.

They also use same style properties:

Name GTK+ type Default Description
look relief flat relief The value flat disables 3D effects in the shapes bar and bullet.
error-color color #FF5040 In bar shape this color is used for impossible (contradictory Fuzzy_Boolean values). A value is painted by this color when its less or equal to the necessity component but greater than the possibility component. In bullet shape this color is used in the mix for the necessity component when its is greater than the possibility component.
necessity-color color #E0D080 In bar shape this color is used for necessary Fuzzy_Boolean values. A value is painted by this color when it is less or equal to necessity and possibility components. In bullet shape this color is used in the mix for the necessity component when its is less or equal to the possibility component.
possibility-color color #A0C080 In bar shape this color is used for possible Fuzzy_Boolean values. A value is painted by this color when it is greater than the necessity component but less or equal to the possibility one. Confidence values are also painted using this color. In bullet shape this color is used in the mix for the possibility component.
shape bar
bullet
text
bar This style controls the appearance of the indicated value:
bar fuzzy boolean
bullet fuzzy boolean bullet
text 0.298:1

Note that cell renderers do not posses style properties of their own. The renderer takes the sepcified above style properties from the widget it renders for. If that widget does not have these properties, the default values apply.

Widget. The package Gtk.Fuzzy_Boolean provides the widget for confidence factors and fuzzy logical values. It defines the type Gtk_Fuzzy_Boolean of the corresponding GTK+ widget:

type Gtk_Fuzzy_Boolean_Record is
   new Gtk_Drawing_Area_Record with private;
type Gtk_Fuzzy_Boolean is
   access all Gtk_Fuzzy_Boolean_Record'Class;
       fuzzy boolean

The widget's properties and style properties are as described above. The following subprograms are defined in the package:

function Get
         (  Widget : not null access Gtk_Fuzzy_Boolean_Record
         )  return Confidence;

This function returns the currently indicated value of the widget. Constraint_Error is propagated when the indicated value is not Confidence or undefined.

function Get
         (  Widget : not null access Gtk_Fuzzy_Boolean_Record
         )  return Fuzzy_Boolean;

This function returns the currently indicated value of the widget. Constraint_Error is propagated when the indicated value is not Fuzzy_Boolean or undefined.

function Get
         (  Widget : not null access Gtk_Fuzzy_Boolean_Record
         )  return GValue;

This function returns the currently indicated value in the form of a GTK+ value. The GTK+ type of the result depends on the indicated value. When the indicated value is Confidence then it is GType_Confidence. When the indicated value is Fuzzy_Boolean then it GType_Fuzzy_Boolean.

function Get_Type return Gtk_Type;

This function returns the GTK+ type of the widget.

function Get_Shape
         (  Widget : not null access Gtk_Fuzzy_Boolean_Record
         )  return Shape;

This function returns the shape used for the widget indicated value. The type Shape is declared in the package Gtk.Cell_Renderer_Fuzzy_Boolean.

procedure Gtk_New
          (  Widget : out Gtk_Fuzzy_Boolean;
             Value  : Fuzzy_Boolean / Confidence
          );

These procedures creates a new widget. It is returned through the Widget parameter. The parameter Value is the value to indicate. It can be either of Fuzzy_Boolean or Confidence type. The parameter Tooltips is the tooltips group the widget shall use. When omitted, no tooltips are shown.

procedure Initialize
          (  Widget : not null access Gtk_Fuzzy_Boolean_Record'Class;
             Value  : Fuzzy_Boolean / Confidence
          );

This procedure shall be called by any derived type from its Initialize.

procedure Put
          (  Widget : not null access Gtk_Fuzzy_Boolean_Record;
             Value  : Fuzzy_Boolean / Confidence
          );

These procedures change the value indicated. The parameter Value is the new value to indicate. It can be either of Fuzzy_Boolean or Confidence type, the widget's value type is changed when necessary.

procedure Put
          (  Widget : not nul access Gtk_Fuzzy_Boolean_Record;
             Value  : GValue
          );

This procedure changes the value indicated. The type of the parameter Value determines the type of the indicated value:

When Value is of GType_String it has the following syntax:

<value>  ::=  <interval> | <item> | <confidence>
<interval> ::= <necessity> {..|...} <possibility>
<item> ::= <possibility> : <necessity>
<possibility> ::= <confidence>
<necessity> ::= <confidence>
<confidence> ::= see Confidence_Factors.Edit

characters representing UTF-8 encoded code points from the set Blanks can be used as separators. When the value has the form <interval> or <item> the result type is Fuzzy_Boolean. When it is <confidence> the result type is Confidence. On syntax errors the indicated value is set to invalid state.

procedure Set_Shape
          (  Widget : not null access Gtk_Fuzzy_Boolean_Record;
             Form   : Shape
          );

This procedure changes the shape of the indicated value. Normally it is controlled by the shape style property. When this procedure is used it overrides the style property setting. The type Shape is declared in the package Gtk.Cell_Renderer_Fuzzy_Boolean.

Class_Name : constant String := "GtkFuzzyBoolean";

This is the GTK+ name of the widget's class.

Renderer. The package Gtk.Cell_Renderer_Fuzzy_Boolean provides an editable tree view cell renderer for confidence factors and fuzzy logical values. It defines the type Gtk_Cell_Renderer_Fuzzy_Boolean of the corresponding GTK+ object:

type Gtk_Cell_Renderer_Fuzzy_Boolean_Record is
   new
Gtk.Cell_Renderer.Abstract_Renderer.
       Gtk_Abstract_Renderer_Record with private;
type Gtk_Cell_Renderer_Fuzzy_Boolean is
   access all
Gtk_Cell_Renderer_Fuzzy_Boolean_Record'Class;

The renderer's properties are as described above, and additionally

Name GTK+ type Default Description
editable-undefined Boolean false When this property is true the undefined cells are editable. Otherwise they are not, so that the user cannot change them even.

The style properties of the widget using the renderer control its appearance as described above. One might wish to install these styles to the widget's class using the procedure Install_Style_Properties from this package. The renderer inherits the commit signal of its parent object. It gets signaled when its value gets changed due to editing. The signature of the event handler is:

procedure On_Commit
          (  Cell : not null access
                  
 Gtk_Cell_Renderer_Fuzzy_Boolean_Record'Class
          );

The handler should set the value of Cell into the corresponding tree model. The following type is used to identify the shapes of indicated values.

type Fuzzy_Boolean_Shape is (Bar, Bullet, Text);

The following subprograms are defined in the package:

function Get (Cell : not null access Gtk_Cell_Renderer_Fuzzy_Boolean_Record)
   return GValue;

This function returns the current value in the form of a GTK+ value. The GTK+ type of the result depends on the indicated value. When the indicated value is Confidence then it is GType_Confidence. When the indicated value is Fuzzy_Boolean then it GType_Fuzzy_Boolean.

function Get (Cell : access Gtk_Cell_Renderer_Fuzzy_Boolean_Record)
   return Confidence;

This function returns the currently indicated value of the widget. Constraint_Error is propagated when the indicated value is not Confidence or undefined.

function Get (Cell : access Gtk_Cell_Renderer_Fuzzy_Boolean_Record)
   return Fuzzy_Boolean;

This function returns the currently indicated value of the widget. Constraint_Error is propagated when the indicated value is not Fuzzy_Boolean or undefined.

function Get_Shape
         (  Cell   : access Gtk_Cell_Renderer_Fuzzy_Boolean_Record;
            Widget
: access Gtk_Widget_Record
         )  return Shape;

This function returns the shape used for the indicated value. The parameter Widget is the widget the renderer is used with.

function Get_Type return Gtk_Type;

This function returns the GTK+ type of the renderer.

procedure Gtk_New (Cell : out Gtk_Cell_Renderer_Fuzzy_Boolean);

These procedures creates a new renderer. It is returned through the Cell parameter.

procedure Initialize
          (  Cell : access Gtk_Cell_Renderer_Fuzzy_Boolean_Record'Class
          );

This procedure shall be called by any derived type from its Initialize.

procedure Install_Style_Properties (Class : Ada_GObject_Class);

This procedure installs style properties of the renderer into the GTK+ class shall specified by the parameter Class. Typically it is used during the class initialization of a widget that will use the renderer, so that the widget's style may control the renderer appearance.

procedure Install_Value_Properties (Class : Ada_GObject_Class);

This procedure installs properties of the renderer into the GTK+ class shall specified by the parameter Class.

function Is_Editable_Undefined
         (  Cell : access Gtk_Cell_Renderer_Fuzzy_Boolean_Record
         )  return Boolean;

This function returns the value of the editable-undefined property.

procedure Put
          (  Cell  : access Gtk_Cell_Renderer_Fuzzy_Boolean_Record;
             Value : GValue
          );

This procedure changes the value. The parameter Value is same is in Gtk.Fuzzy_Boolean.Put.

procedure Put
          (  Cell  : access Gtk_Fuzzy_Boolean_Record;
             Value : Fuzzy_Boolean / Confidence
          );

These procedures change the value indicated. The parameter Value is the new value to indicate. It can be either of Fuzzy_Boolean or Confidence type, the widget's value type is changed when necessary.

procedure Set_Shape
          (  Cell : access Gtk_Cell_Renderer_Fuzzy_Boolean_Record;
             Form : Shape
          );

This procedure changes the shape of indicated values. It overrides style property.

procedure Set_Editable_Undefined
          (  Cell     : access Gtk_Cell_Renderer_Fuzzy_Boolean_Record;
             Editable : Boolean
          );

This procedure allows or disables editing of undefined cells. Undefined values are rendered as empty. When they stay undefined and cannot be changed when editable-undefined property is set to false.

Class_Name : constant String := "GtkCellRendererFuzzyBoolean";

This is the GTK+ name of the widget's class.

7.2.2. Fuzzy sets, intuitionistic fuzzy sets and classifications

They also use same style properties:

Widget. The package Gtk.Fuzzy_Set provides a widget for displaying and editing fuzzy sets, intuitionistic fuzzy sets and intuitionistic classifications. It defines the type Gtk_Fuzzy_Set of the corresponding GTK+ widget:

type Gtk_Fuzzy_Set_Record is
   new
Gtk_Widget_Record with private;
type Gtk_Fuzzy_Set is
   access all
Gtk_Fuzzy_Set_Record'Class;
       fuzzy set

In editable mode (activated using Set_Editable) the widget allows editing individual truth values. The truth values can be edited either visually or by direct editing. Visual editing is achieved by selection of one or multiple rows of the widget and then by pressing the keys:

Alt     
 +  
  -   
  or   
Alt     
 +  
 <  
       decreases possibility
                 
Alt     
 +  
  +  

or

Alt     
 +  
 >   
  increases possibility
                 
Ctrl    
 +  
  -   
or
Ctrl    
 +  
 <   
  decreases necessity
                 
Ctrl    
 +  
  +  
   or    
Ctrl    
 +  
 >   
  increases necessity
                 
   
  -   
  or  
 <   
  decreases both necessity and possibility
                 
   
 +   
  or  
 >   
  increases both necessity and possibility

Direct editing is made through activating the corresponding cell by double clicking on the left button or pressing the enter key. Then the truth value can be entered as a text. The value can be specified as a single number from [0,1] or as a range <necessity>..<possibility> or as <possibility>..<necessity>.

The widget has the following style properties:

Name GTK+ type Default Description
domain-column-title string Domain The title of the first column
value-column-title string Value The title of the second column

Its tree view component has additional style properties, same as ones of Gtk_Cell_Renderer_Fuzzy_Boolean (see). The following additional signals are emitted by the widget:

Name Description
changed Emitted when the user changes the widget content by editing

The package defines the type:

type Content_Type is
     (  Plain_Set,
        Intuitionistic_Set,
        Intuitionistic_Classification
     );

to classify the content rendered by the widget:

The following subprograms are defined in the package:

function Edited (Widget : access Gtk_Fuzzy_Set_Record)
   return Boolean;

This function returns the modification flag. The flag is set when the user modifies the indicated value. It is reset when the value is changed programmatically using the procedures Put of this package.

function Get (Widget : access Gtk_Fuzzy_Set_Record)
   return Set / Intuitionistic.Set / Classification;

These functions return the current value. The type of the result shall correspond to the type of the indicated value. Otherwise Constraint_Error is propagated.

function Get (Widget : access Gtk_Fuzzy_Set_Record)
   return GValue;

This function returns the current value in the form of a GTK+ value. The GTK+ type of the result depends on the indicated value. When the indicated value is fuzzy sets then result has the type GType_Set (from GLib.Values.Fuzzy). When the value is intuitionistic fuzzy set, the result is GType_Set (from GLib.Values.Fuzzy.Intuitionistic). When the then the value is result's type is intuitionistic classification, then the result has the type GType_Classification.

function Get_Cardinality
          (  Widget : access Gtk_Fuzzy_Set_Record
          )  return Natural;

This function returns the cardinality of the domain set.

function Get_Content_Type (Widget : access Gtk_Fuzzy_Set_Record)
   return Content_Type;

This function returns the type of the currently rendered value.

function Get_Name
         (  Widget : access Gtk_Fuzzy_Set_Record;
            Index  : Positive
         )  return String;

This function returns the name of the domain set element which index is Index. Constraint_Error is propagated if Index is illegal, that is out of the range 1..Get_Cardinality (Widget).

function Get_Shape (Widget : access Gtk_Fuzzy_Set_Record)
   return Shape;

This function returns the shape used for the indicated truth values. See style properties of the cell renderer Gtk_Cell_Renderer_Fuzzy_Boolean.

function Get_Tree_View (Widget : access Gtk_Fuzzy_Set_Record)
   return Gtk_Tree_View;

This function returns the tree view widget that implements the Gtk_Fuzzy_Set widget.

function Get_Type return Gtk_Type;

This function returns the GTK+ type of the widget.

procedure Gtk_New
          (  Widget : out Gtk_Fuzzy_Set;
             Data   : User_Data'Class;
             Value  : Set / Intuitionistic.Set / Classification
          );

These procedure create a new widget. It is returned through the Widget parameter. The parameter Data specifies the way individual values of the fuzzy set domain are indicated in the first column. The widget uses the package Fuzzy.Abstract_Edit for rendering these value. The parameter Value is the initial value indicated by the widget. It can be either a fuzzy set or an intuitionistic fuzzy sets or an intuitionistic classifications..Its type determines the type of values Widget will be capable to show. If Value and Date are incompatible, Constraint_Error is propagated.

procedure Gtk_New
          (  Widget : out Gtk_Fuzzy_Set;
             Data   : User_Data'Class;
             Value  : GValue
          );

This variant uses a GTK+ value to initialize the widget. Value shall be of either GType_Set (from GLib.Values.Fuzzy), or GType_Set (from GLib.Values.Fuzzy.Intuitionistic) or GType_Classification. Other types and undefined Value cause Constraint_Error propagation.

procedure Initialize
          (  Widget : access Gtk_Fuzzy_Set_Record'Class;
             Data   : User_Data'Class;
             Value  : Set / Intuitionistic.Set / Classification / GValue;
          );

This procedure shall be called by any derived type from its Initialize.

function Is_Editable (Widget : access Gtk_Fuzzy_Set_Record)
   return Boolean;

This function returns the editable flag. An editable widget allows modification of the indicated value by the user.

procedure Put
          (  Widget : access Gtk_Fuzzy_Set_Record;
             Value  : Set / Intuitionistic.Set / Classification;
          );

This procedure changes the indicated value. The parameter Value type shall be same type and cardinality as one used upon widget creation. If its type is different or else the cardinality is different, Constraint_Error is propagated.

procedure Put
          (  Widget : access Gtk_Fuzzy_Set_Record;
             Value  : GValue
          );

This procedure changes the indicated value. When the indicated value is fuzzy sets then Value shall have the GTK+ type GType_Set (from GLib.Values.Fuzzy). When it is intuitionistic fuzzy set, then Value shall be of GType_Set (from GLib.Values.Fuzzy.Intuitionistic). When it is intuitionistic classification, then Value shall be GType_Classification. Other types, undefined values and ones of wrong cardinality cause Constraint_Error propagation.

procedure Put
          (  Widget : access Gtk_Fuzzy_Set_Record;
             Data   : User_Data'Class;
             Value  : Set / Intuitionistic.Set / Classification / GValue;
          );

This procedure change both the domain and the indicated value. They can be used to change the type and or cardinality of the indicated values. Constraint_Error is propagated when Value is undefined or incompatible with Data. The procedures have the effect of resetting the modification flag to false.

procedure Set_Editable
          (  Widget   : access Gtk_Fuzzy_Set_Record;
             Editable : Boolean
          );

This procedure changes editable flag of the widget.

procedure Set_Shape
          (  Widget : access Gtk_Fuzzy_Set_Record;
             Form   : Shape
          );

This procedure changes the shape of indicated values. It overrides style property.

Class_Name : constant String := "GtkFuzzySet";

This is the GTK+ name of the widget's class. The tree view component of the widget has the name GtkFuzzySetTreeView.

Entry box widget. The package Gtk.Fuzzy_Set_Entry provides an entry box for displaying and editing fuzzy sets, intuitionistic fuzzy sets and intuitionistic classifications. The package defines the type Gtk_Fuzzy_Set_Entry of the corresponding GTK+ widget:

type Gtk_Fuzzy_Set_Entry_Record is
   new
Gtk_Entry_Record with private;
type Gtk_Fuzzy_Set_Entry is
   access all
Gtk_Fuzzy_Set_Entry_Record'Class;
       fuzzy set entry

The widget functions as a combo box. The fuzzy object is shown in the entry in textual from. Upon activation it drops a pop-up window with a Gtk.Fuzzy_Set in it. The object can then be edited either directly in the entry or in the Gtk.Fuzzy_Set. The entry box of the widget uses the packages Fuzzy.Abstract_Edit and Fuzzy.Abstract_Edit.Intuitionistic for rendering the fuzzy object and parsing it from the user input. When edited as Gtk.Fuzzy_Set additionally to the visual editing keys of Gtk.Fuzzy_Set:

Alt     
 +  
  -   
  or   
Alt     
 +  
 <  
       decreases possibility
                 
Alt     
 +  
  +  

or

Alt     
 +  
 >   
  increases possibility
                 
Ctrl    
 +  
  -   
or
Ctrl    
 +  
 <   
  decreases necessity
                 
Ctrl    
 +  
  +  
   or    
Ctrl    
 +  
 >   
  increases necessity
                 
   
  -   
  or  
 <   
  decreases both necessity and possibility
                 
   
 +   
  or  
 >   
  increases both necessity and possibility

the following keys can be used:

Ins    
               commits changes made and then closes the pop-up window
         
Del   
  or   
 Backspace  
  discards changes and then closes the pop-up window

The widget has the following style properties:

Name GTK+ type Default Description
default-truth-value GType_Fuzzy_Boolean Certain_True This parameter controls the rendering of the intuitionistic fuzzy sets and intuitionistic classifications as described in Fuzzy.Abstract_Edit.Intuitionistic.
has-header Boolean false Controls if the columns header appears in Gtk.Fuzzy_Set

function Edited (Widget : access Gtk_Fuzzy_Set_Entry_Record)
   return Boolean;

This function returns the update flag. It is set when the user changes the widget content. It is reset when the value or the domain are set using Put calls.

function Editing_Canceled
         (  Widget : access Gtk_Fuzzy_Set_Entry_Record
         )  return Boolean;

This function is used when the widget serves as an editable widget for a cell renderer. When the renderer handles the editing-done signal it may check if the user has cancelled editing.

function Get (Widget : access Gtk_Fuzzy_Set_Entry_Record)
   return Set / Intuitionistic.Set / Classification;

These functions return the current value. The type of the result shall correspond to the type of the indicated value. Otherwise Constraint_Error is propagated.

function Get (Widget : access Gtk_Fuzzy_Set_Entry_Record)
   return GValue;

This function returns the current value in the form of a GTK+ value. The GTK+ type of the result depends on the indicated value. When the indicated value is fuzzy sets then result has the type GType_Set (from GLib.Values.Fuzzy). When the value is intuitionistic fuzzy set, the result is GType_Set (from GLib.Values.Fuzzy.Intuitionistic). When the then the value is result's type is intuitionistic classification, then the result has the type GType_Classification.

function Get_Cardinality
          (  Widget : access Gtk_Fuzzy_Set_Entry_Record
          )  return Natural;

This function returns the cardinality of the domain set.

function Get_Content_Type (Widget : access Gtk_Fuzzy_Set_Entry_Record)
   return Content_Type;

This function returns the type of the currently rendered value.

function Get_Domain
         (  Widget : access Gtk_Fuzzy_Set_Entry_Record
         )  return Entry_Domain;

This function returns a handle to the parameters used for rendering and editing. It has the type Entry_Domain. The widget can work with user-defined domains through the implementations of the abstract type Abstract_Entry_Edit.

function Get_Name
         (  Widget : access Gtk_Fuzzy_Set_Entry_Record;
            Index  : Positive
         )  return String;

This function returns the name of the domain set element which index is Index. Constraint_Error is propagated if Index is illegal, that is out of the range 1..Get_Cardinality (Widget).

function Get_Shape (Widget : access Gtk_Fuzzy_Set_Entry_Record)
   return Shape;

This function returns the shape used for the indicated truth values in the drop-down window. See style properties of the cell renderer Gtk_Cell_Renderer_Fuzzy_Boolean. This style applies to the widget Gtk.Fuzzy_Set used in the window.

function Get_Type return Gtk_Type;

This function returns the GTK+ type of the widget.

procedure Gtk_New
          (  Widget : out Gtk_Fuzzy_Set_Entry;
             Domain : Entry_Domain;
             Value  : Set / Intuitionistic.Set / Classification
          );

These procedure create a new widget. It is returned through the Widget parameter. The parameter Domain is a handle to the parameters used for rendering and editing indicated values. The parameter Value is the initial value indicated by the widget. It can be either a fuzzy set or an intuitionistic fuzzy sets or an intuitionistic classifications. Its type determines the type of values Widget will be capable to show. The parameters Value and Domain shall be conformant. Otherwise Constraint_Error is propagated. When formatting facilities of on the packages Fuzzy.Abstract_Edit and Fuzzy.Abstract_Edit.Intuitionistic.are sufficient for formatting the corresponding domain can be created from a handle to User_Data object using the function Create from this package. For instance, it can be a handle to a domain description when the domain consists of named values.

procedure Gtk_New
          (  Widget : out Gtk_Fuzzy_Set_Entry;
             Domain : Entry_Domain;
             Value  : GValue
          );

This variant uses a GTK+ value to initialize the widget. Value shall be of either GType_Set (from GLib.Values.Fuzzy), or GType_Set (from GLib.Values.Fuzzy.Intuitionistic) or GType_Classification. Other types, and undefined values cause Constraint_Error propagation. It is also propagated when the parameters Value and Domain are not conformant.

procedure Initialize
          (  Widget : access Gtk_Fuzzy_Set_Entry_Record'Class;
             Domain : Entry_Domain;
             Value  : Set / Intuitionistic.Set / Classification / GValue
          );

This procedure shall be called by any derived type from its Initialize.

function Is_Editable (Widget : access Gtk_Fuzzy_Set_Entry_Record)
   return Boolean;

This function returns the editable flag. An editable widget allows modification of the indicated value by the user.

procedure Put
          (  Widget : access Gtk_Fuzzy_Set_Entry_Record;
             Value  : Set / Intuitionistic.Set / Classification;
          );

This procedure changes the indicated value. The parameter Value type shall be same type and cardinality as one used upon widget creation. If its type is different or else the cardinality is different to the one of the domain set, Constraint_Error is propagated.

procedure Put
          (  Widget : access Gtk_Fuzzy_Set_Entry_Record;
             Value  : GValue
          );

This procedure changes the indicated value. When the indicated value is fuzzy sets then Value shall have the GTK+ type GType_Set (from GLib.Values.Fuzzy). When it is intuitionistic fuzzy set, then Value shall be of GType_Set (from GLib.Values.Fuzzy.Intuitionistic). When it is intuitionistic classification, then Value shall be GType_Classification. Other types, undefined values and ones of wrong cardinality cause Constraint_Error propagation.

procedure Put
          (  Widget : access Gtk_Fuzzy_Set_Entry_Record;
             Domain : Entry_Domain;
             Value  : Set / Intuitionistic.Set / Classification / GValue;
          );

These procedures change both the parameters of the domain and the indicated value. They can be used to change the type and or cardinality of the indicated values. Constraint_Error is propagated when Domain and Value are not conformant. The procedure has the effect of resetting the modification flag to false.

procedure Set_Editable
          (  Widget   : access Gtk_Fuzzy_Set_Entry_Record;
             Editable : Boolean
          );

This procedure changes editable flag of the widget.

procedure Set_Shape
          (  Widget : access Gtk_Fuzzy_Set_Entry_Record;
             Form   : Shape
          );

This procedure changes the shape of indicated values. It overrides style property.

Class_Name : constant String := "GtkFuzzySetEntry";

This is the GTK+ name of the widget's class.

Renderer. The package Gtk.Cell_Renderer_Fuzzy provides a cell renderer for displaying and editing fuzzy sets, intuitionistic fuzzy sets and intuitionistic classifications in tree view: It defines the type Gtk_Cell_Renderer_Fuzzy of the corresponding GTK+ object:

type Gtk_Cell_Renderer_Fuzzy_Record is
   new
Gtk.Cell_Renderer.Abstract_Renderer.
       Gtk_Abstract_Renderer_Record with private;
type Gtk_Cell_Renderer_Fuzzy is
   access all
Gtk_Cell_Renderer_Fuzzy_Record'Class;

The renderer uses Gtk_Fuzzy_Set_Entry for editing its content when editable. It has the following properties:

Name GTK+ type Default Description
classification-value GType_Classification - The currently indicated value. When the indicated value is not of this type, then the result is set to undefined.
default-truth-value GType_Fuzzy_Boolean Certain_True The default truth value which controls input and output of intuitionistic fuzzy classifications and sets, as described in the I/O package Fuzzy.Abstract_Edit.Intuitionistic.
editable-undefined Boolean false When the value this property is true the undefined cells are editable. The user can then change the undefined value and thus make it defined. When an undefined value is edited it is first indicated as all truth values set to zero. By default undefined cells cannot be edited.
set-value GType_Set - The currently indicated value. When the indicated value is not of this type, then the result is set to undefined.
intuitionistic-set-value GType_Set
(GLib.Values.Fuzzy.Intuitionistic)
- The currently indicated value. When the indicated value is not of this type, then the result is set to undefined.
prefix-text GType_String empty string The text is added in front of the string indicating the value

procedure Finalize (Cell : access Gtk_Cell_Renderer_Fuzzy_Record);

This procedure has to be called by any derived type upon its finalization.

function Get (Cell : access Gtk_Cell_Renderer_Fuzzy_Record)
   return Fuzzy.Set;
function Get (Cell : access Gtk_Cell_Renderer_Fuzzy_Record)
   return Fuzzy.Intuitionistic.Classification;
function Get (Cell : access Gtk_Cell_Renderer_Fuzzy_Record)
   return Fuzzy.Intuitionistic.Set;

These functions return the current renderer's value. Constraint_Error is propagated when the type of the result does not match the type of the indicated value or value is undefined.

function Get (Cell : access Gtk_Cell_Renderer_Fuzzy_Record)
   return GValue;

This function returns the current renderer's value  in the form of a GTK+ value. Depending on the indicated value it can be of GType_Set or intuitionistic GType_Classification or GType_Set.

function Get_Cardinality
         (  Cell : access Gtk_Cell_Renderer_Fuzzy_Record
         )  return Natural;

This function returns the cardinality of the indicated values.

function Get_Domain
         (  Widget : access Gtk_Cell_Renderer_Fuzzy_Record
         )  return Entry_Domain;

This function returns a handle to the parameters used for rendering and editing. It has the type Entry_Domain.

function Get_Text
         (  Cell : access Gtk_Cell_Renderer_Fuzzy_Record
         )  return String;

This function returns the text being rendered. A derived type may wish override it.

function Get_Type return Gtk_Type;

This function returns the GTK+ of the renderers.

procedure Gtk_New
          (  Cell       : out Gtk_Cell_Renderer_Fuzzy;
             Domain     : Entry_Domain;
             Value_Type : Gtk_Type := GLib.Values.Fuzzy.GType_Set
          );

This procedure creates a new rederer. The result is returned through the Cell output parameter. The parameter Domain is a handle (Entry_Domain) to the parameters used for rendering and editing indicated values. Constraint_Error is propagated when Domain is invalid. The parameter Value_Type is the type of values the renderer initially deals with. It is changed when the renderer's value is changed to another type.

procedure Initialize
          (  Cell       : access Gtk_Cell_Renderer_Fuzzy_Record'Class;
             Domain     : Entry_Domain;
             Cell_Type  : Gtk_Type;
             Value_Type : Gtk_Type
          );

This procedure has to be called as a part of initialization of a new renderer when a new type is derived from. The parameter Cell_Type is the GTK+ type of the renderer if differs from the result of Get_Type. The parameter Value_Type is the type of values the renderer initially deals with.

function Is_Editable_Undefined
         (  Cell : access Gtk_Cell_Renderer_Fuzzy_Record
         )  return Boolean;

This function returns the value of the editable-undefined property.

procedure Put
          (  Cell  : access Gtk_Cell_Renderer_Fuzzy_Record;
             Value : Set / Intuitionistic.Set / Classification
          );

These procedures change the value indicated. The parameter Value is the new value to indicate. The value type is changed as specified. When the cardinality of the value set does not match the cardinality of the renderer, its state is set to undefined, indicated as blank.

procedure Put
          (  Cell  : access Gtk_Cell_Renderer_Fuzzy_Record;
             Value : GValue
          );

This procedure changes the value. The parameter Value can be of GType_Set or intuitionistic GType_Classification or GType_Set. The actual type of the value determines the type of the renderer's value. The value's cardinality should match one of the renderer. Otherwise, the renderer's value will be set to an undefined state, indicated as blank. Alternatively Value can be of GType_String, in which case it is parsed using an appropriate function Value from Fuzzy.Abstract_Edit or Fuzzy.Abstract_Edit.Intuitionistic. The choice depends on the current render's value type. Parsing errors and other types of Value cause renderer to indicate an undefined state.

procedure Put
          (  Cell   : access Gtk_Cell_Renderer_Fuzzy_Record;
             Domain : Entry_Domain;
             Value  : Set / Intuitionistic.Set / Classification / GValue
          );

These procedures change both the value indicated and the domain of. Constraint_Error is propagated when Domain is invalid.

procedure Set_Domain
          (  Cell   : access Gtk_Cell_Renderer_Fuzzy_Record;
             Domain : Entry_Domain
          );

This procedure changes the domain and sets value undefined. Constraint_Error is propagated when Domain is invalid.

procedure Set_Editable_Undefined
          (  Cell     : access Gtk_Cell_Renderer_Fuzzy_Record;
             Editable : Boolean
          );

This procedure allows or disables editing of undefined cells. Undefined values are rendered as empty. When they stay undefined and cannot be changed when editable-undefined property is set to false.

Class_Name : constant String := "GtkCellRendererFuzzy";

Abstract entry edit. The package Gtk.Fuzzy_Set_Entry declares the abstract type Abstract_Entry_Edit controlling rendered object conversion to text and backwards.

type Abstract_Entry_Edit is
   abstract new
Object.Entity with null record;
type Abstract_Entry_Edit_Ptr is access Abstract_Entry_Edit'Class;

All primitive operations of the type are abstract:

function Get_Cardinality
         (  Editor : Abstract_Entry_Edit
         )  return Natural is abstract;

This function returns the cardinality of the rendered objects.

function Get_Default
         (  Editor : Abstract_Entry_Edit
         )  return Fuzzy_Boolean is abstract;

This function returns the currently used default value of the intuitionistic truth values. Usage of this value is described in Fuzzy.Abstract_Edit.Intuitionistic.

function Get_Domain
         (  Editor : Abstract_Entry_Edit
         )  return Fuzzy.Abstract_Edit.Handle.Handle is abstract;

This function returns a handle (Entry_Domain) to the object which can be used with the subprograms of Fuzzy.Abstract_Edit and Fuzzy.Abstract_Edit.Intuitionistic to format fuzzy sets, intuitionistic fuzzy set and intuitionistic classification.

function Image
         (  Editor : Abstract_Entry_Edit;
            Value  : Fuzzy.Set
         )  return UTF8_String is abstract;
function Image
         (  Editor : Abstract_Entry_Edit;
            Value  : Fuzzy.Intuitionistic.Set
         )  return UTF8_String is abstract;
function Image
         (  Editor : Abstract_Entry_Edit;
            Value  : Classification
         )  return UTF8_String is abstract;

These functions provide object to text conversions.

function Value
         (  Editor : Abstract_Entry_Edit;
            Text   : UTF8_String
         )  return Fuzzy.Set is abstract;
function Value
         (  Editor : Abstract_Entry_Edit;
            Text   : UTF8_String
         )  return Fuzzy.Intuitionistic.Set is abstract;
function Value
         (  Editor : Abstract_Entry_Edit;
            Text   : UTF8_String
         )  return Classification is abstract;

These functions perform text to object conversions. Exceptions propagating out of them indicate a conversion error.

procedure Set_Default
          (  Editor  : in out Abstract_Entry_Edit;
             Default : Fuzzy_Boolean
          )  is abstract;

This procedure changes the default value of the intuitionistic truth values. Usage of this value is described in Fuzzy.Abstract_Edit.Intuitionistic.

package Entry_Edit_Handles is
   new
Object.Handle
       (  Abstract_Entry_Edit'Class,
          Abstract_Entry_Edit_Ptr
       );
subtype Entry_Domain is Entry_Edit_Handles.Handle;

The type Entry_Domain is a handle to Abstract_Entry_Edit.

type Entry_Edit is new Abstract_Entry_Edit with private;

This type is a concrete implementation of Abstract_Entry_Edit based on the packages Fuzzy.Abstract_Edit and Fuzzy.Abstract_Edit.Intuitionistic.

function Create
         (  Data    : Fuzzy.Abstract_Edit.Handle.Handle;
            Default : Fuzzy_Boolean := Certain_True
         )  return Entry_Domain;

This function creates an instance of Entry_Edit and returns a handle to it. It can be used with Gtk.Fuzzy_Set_Entry and Gtk_Cell_Renderer_Fuzzy when Fuzzy.Abstract_Edit and Fuzzy.Abstract_Edit.Intuitionistic are sufficient for formatting.

7.2.3. Domains of fuzzy linguistic sets (basic)

The domain of fuzzy linguistic set is a set of linguistic variables. The generic package Gtk.Generic_Fuzzy_Linguistic_Set_Domain provides a GTK+ widget for visualization of the membership functions of the linguistic variables:

fuzzy linguistic set domain

Additionally to representing sets of linguistic variables, the widget provides the following functionality:

generic
   Class_Name : String;
   with package Fuzzy_Linguistics is new Fuzzy.Linguistics (<>);
   with package Fuzzy_Linguistic_Sets is new Fuzzy_Linguistics.Sets;
   use Fuzzy_Linguistics.Fuzzy_Floats.Float_Intervals;
   with package Domain_Edit is new Strings_Edit.Float_Edit (Number);
package Gtk.Generic_Fuzzy_Linguistic_Set_Domain is ...

The package is generic with the following formal parameters:

The package Gtk.Fuzzy_Linguistic_Set_Domain is an instance of Gtk.Generic_Fuzzy_Linguistic_Set_Domain based on the standard type Float.

The package Gtk.Generic_Fuzzy_Linguistic_Set_Domain declares the type Gtk_Fuzzy_Linguistic_Set_Domain of the GTK+ widget:

type Gtk_Fuzzy_Linguistic_Set_Domain_Record is
   new
Gtk_Widget_Record with private;
type
Gtk_Fuzzy_Linguistic_Set_Domain is
   access all
Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class;

The widget has the following style properties:

Name GTK+ type Default Description
actions-merge-timeout GDouble 0.3 The timeout in seconds within which two consequent zoom or scroll actions are merged into one. An undo would roll back both of them. The timeout is specified in seconds
background-color color #FFFFFF The color of the background
first-color color #E8B5B5 The color of the first variable. The colors of the membership function line is derived from this color, as well as the color in selected state. The colors of the consequent variables are obtained from the first color by incrementing its hue component. The colors of removed variables are reused.
line-color color #000000 The color of the lines used to draw scales.
major-tick-length GInt 10 The length of a major tick in pixels.
minor-tick-length GInt 5 The length of a minor tick in pixels
tick-gap GInt 4 The gap between a major tick and its annotation under or left of it.
selection-color color #FF0000 The color of selection circle. The selection circle is drawn around membership function points in the current selection. When the point is not singular a circle is drawn for each distinct value (such as left / right limits and the bounds). These circles are merged into ellipses if two values come closer than 3 radii.
selection-radius GInt 20 The radius of point selection circle or minor axis of the ellipse.
x-move-tip string Move along X-axis The tip of X-move scale slider, when applied
x-tick-step GInt 50 The minimal step of horizontal major ticks in pixels
x-zoom-tip string Zoom X-axis The tip of X-zoom scale slider, when applied
y-move-tip string Move along Y-axis The tip of Y-move scale slider, when applied
y-tick-step GInt 50 The minimal step of vertical major ticks in pixels
y-zoom-tip string Zoom Y-axis The tip of Y-zoom scale slider, when applied

The widget emits the following signals:

Name Description
marked The signal is emitted when the rectangular selection area of the widget is modified
zoomed The signal is emitted when either of the zooming factors of the widget is changed otherwise than by the corresponding zoom sliders. The handler shall readjust the sliders to reflect the new state of zooming.

The following subprograms are provided for Gtk_Fuzzy_Linguistic_Set_Domain:

procedure Deselect_All
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
          );

This procedure removes any selections of the variables and points in the widget.

function Get
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
            Index  : Positive
         )  return Variable;

This function returns the variable from the set indicated by Widget. The variable is specified by its index. Constraint_Error is propagated when Index is illegal.

function Get_Cardinality
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
         )  return Natural;

This function returns number of variables from the set indicated by Widget.

function Get_Domain_Note
         (  Widget : not null access
                    
Gtk_Fuzzy_Linguistic_Set_Domain_Record
         )  return UTF8_String;

This function returns the domain note set into the widget. When Widget has annotation the domain note is shown on the horizontal scale of.

function Get_Selection
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
         )  return Selection;
function Get_Selection
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
         )  return Selection_Subtype;

These functions return the current selection in Widget. There can be returned either a Selection (a map of variable index to set of points) or else as a more detailed description of (Selection_Subtype).

function Get_X_Adjustment
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
         )  return Gtk_Adjustment;
function
Get_Y_Adjustment
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
         )  return Gtk_Adjustment;

These functions return the adjustment of the widget's horizontal and vertical scroll bars correspondingly. When the scroll bar is not shown, the result is null. A parent widget might connect to the value-changed signal of the adjustment to provide horizontal scrolling of the widget content. Note that the widget itself does not react to any signals from the adjustment.

function Get_X_Zoom
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
         )  return Zoom_X_Range;
function
Get_Y_Zoom
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
         )  return Zoom_Y_Range;

These functions return the zoom factors of the widget.

procedure Gtk_New
          (  Widget      : out Gtk_Fuzzy_Linguistic_Set_Domain;
             Value       : Linguistic_Set;
             Annotated   : Boolean     := True;
             Domain_Note : UTF8_String := "";
             X_Scroll    : Boolean     := True;
             Y_Scroll    : Boolean     := True
          );

This procedure creates a new widget. The result is returned through the parameter Widget. The parameter Value is the linguistic set the widget initially indicates. When the parameter Annotated is true, the widget will show the annotation of its vertical and horizontal axes. The parameter Domain_Note is sets the text to be shown on the annotation of the horizontal axis. The parameters X_Scroll and Y_Scroll control whether the horizontal and vertical scroll bars will be shown.

procedure Hide_Accumulated
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
          );

This procedure hides the accumulated representation of a set from Widget, if any. Accumulated set is shown by the procedure Show_Accumulated.

procedure Initialize
          (  Widget      : not null access
                           Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class;
             Value       : Linguistic_Set;
             Annotated   : Boolean;
             Domain_Note : UTF8_String;
             X_Scroll    : Boolean;
             Y_Scroll    : Boolean
          );

This procedure has to be called by any derived type upon its initialization. It is also called when the widget is created by the allocator new.

function Is_Annotated
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
         )  return Boolean;

This function returns true if Widget shows an annotation for its axes.

procedure Marked
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
          );

This procedure emits the signal marked.

procedure Put
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Value  : Linguistic_Set
          );

This procedure replaces the widget content with a new set of variables. It should only be used when the widget is used alone. Otherwise the supplementary widgets will probably take control over the widget's content. Note that this operation affects the horizontal zoom factor, which is set to no zoom.

procedure Refresh
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Domain_Record
          );

This procedure queues necessary drawing actions if Widget data were modified. Normally there is no  need to call it explicitly.

procedure Scroll
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Value  : Interval;
             Level  : Fuzzy_Boolean
          );

This procedure scrolls and zooms Widget to make the rectangle with the corner points (Value.From, Level.Necessity) and (Value.To,.Level.Possibility) visible. When this action causes zooming and/or scrolling the signal zoomed is emitted. Note that the Widget scroll bars, if any, are adjusted as necessary, so the handler need not to touch them.

procedure Select_Point
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Index    : Positive;
             Point    : Positive;
             Selected : Boolean
          );

This procedure selects or deselect a membership function point in Widget. The parameter Index identifies the linguistic variable which membership's function point is selected. The parameter Point specifies the point. The parameter Selected when true causes the selection of the point, or removes selection otherwise. Constraint_Error is propagated when either Index or Point is invalid. Selected points are indicated by small circles or ellipses drawn around them. When two or more points on the same abscissa are selected an ellipse is drawn around them if they are not too wide apart on the ordinate axis.

procedure Select_Variable
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Index    : Positive;
             Selected : Boolean
          );

This procedure selects or deselect a linguistic variable in Widget. The parameter Index identifies the linguistic variable. The parameter Selected when true causes the selection of the variable, or removes selection otherwise. Constraint_Error is propagated when Index is invalid. Selected variables are indicated by a more intense color.

procedure Set_Annotated
          (  Widget    : not null access
                       
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Annotated : Boolean
          );

This procedure changes axes annotation of Widget. The parameter Annotated controls if the annotation has to be shown or not.

procedure Set_Domain_Note
          (  Widget      : not null access
                         
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Domain_Note : UTF8_String
          );

This procedure changes the domain node indicated on the horizontal axis of Widget. The parameter Domain_Note is the new text of.

procedure Set_Selection
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Selected : Selection
          );

This procedure changes the selection of Widget. The parameter Selection is the new selection.

procedure Set_X_Scroll
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Scroll : Boolean
          );

This procedure shows or removes the horizontal scroll bar of Widget. The parameter Scroll is controls whether the bar has to be shown or not.

procedure Set_Y_Scroll
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Scroll : Boolean
          );

This procedure shows or removes the vertical scroll bar of Widget. The parameter Scroll is controls whether the bar has to be shown or not.

procedure Show_Accumulated
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Set    : Fuzzy.Set
          );

This procedure shows Set as an accumulated variable in Widget. The cardinality of Set must be one of the set of the variables indicated by Widget. Otherwise, Constraint_Error is propagated. The set indication can be removed by the procedure Hide_Accumulated or else by any operation that changes the set of variables indicated by Widget.

procedure Zoom
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             X_Factor : Zoom_X_Range;
             Y_Factor : Zoom_Y_Range
          );
procedure Zoom
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             X_Factor : Zoom_X_Range
          );
procedure Zoom
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Y_Factor : Zoom_Y_Range
          );

This procedure changes the zooming factors of the widget axes. The parameters X_Factor and Y_Factor specify the desired factors. The value Zoom_{X|Y}_Range'First corresponds to minimal possible resolution. The value Zoom_{X|Y}_Range'Last corresponds to the maximal resolution. When a factor parameter is omitted, the resolution of the corresponding axis is not changed. When this action causes zooming and/or scrolling the signal zoomed is emitted.

procedure Zoomed
          (  Widget    : not null access
                       
 Gtk_Fuzzy_Linguistic_Set_Domain_Record;
             Immediate : Boolean := False
          );

This procedure emits the signal zoomed. When the parameter Immediate is true, the signal is emitted only if the appearance has been changed but not yet updated on the screen. In that case it also queues necessary redraw action (see Refresh).

The package Gtk.Generic_Fuzzy_Linguistic_Set_Domain also declares the following supplementary types:

subtype Zoom_X_Range is Zoom_X_Factor range 1.0..
subtype Zoom_Y_Range is Zoom_Y_Factor range 1.0..

These subtypes define zoom factors. The factor Zoom_{X|Y}_Range'First corresponds to no zoom. All domain points of the set of variables are visible. The factor Zoom_{X|Y}_Range'Last corresponds to the maximal possible zoom. The zooming scale is linear. When controlled by a slider it is expedient to translate the slider position into a zoom factor using exponentiation. The base types are floating-point types.

type Point_Index is new Natural;
package Points_Indices is new Generic_Set (Point_Index, 0);

The type Point_Index and sets of declared in the instance Points_Indices are used in selections of points.

type Variable_Index is new Positive;
package Selections is
   new
Generic_Map
       (  Key_Type    => Variable_Index,
          Object_Type => Points_Indices.Set
       );

The type Variable_Index and maps of to Points_Indices declared in the instance Selections are used in selections of variables.

subtype Selection is Selections.Map;

The map variable index to set of points defines a selection in the widget. The variables presented in Selection are highlighted. The points of for the corresponding keys of the map are marked by small circles or ellipses.

type Selection_Mode is
     (  Empty,
        Single_Point,
        Points_Range,
        All_Points,
        Single_Variable,
        Variables_Range,
        Complete_Variables,
        Complex
     );

The type classifies a selection in the widget. The classes of selections are:

Among two intersecting classes a more narrow is used.

type Selection_Subtype (Mode : Selection_Mode) is record
   case
(Mode) is
      when
Single_Variable =>
         Variable : Variable_Index;
      when Single_Point =>
         Point_At : Variable_Index;
         Point_No : Point_Index;
      when Variables_Range =>
         From_Variable : Variable_Index;
         To_Variable   : Variable_Index;
      when Points_Range | All_Points =>
         Range_At   : Variable_Index;
         From_Point : Point_Index;
         To_Point : Point_Index;
      when Complete_Variables | Complex =>
         Selected : Selection;
      when Empty =>
         null;
   end case;
end record;

This type describes a selection of the widget.

7.2.4. Domains. Zooming and scrolling

The child generic package Gtk.Generic_Fuzzy_Linguistic_Set_Domain.Generic_Zoom_Panel provides widgets for zooming and scrolling content of a Gtk_Fuzzy_Linguistic_Set_Domain widget. The functionality supported are:

fuzzy linguistic set zoom panel

generic
package
Gtk.Generic_Fuzzy_Linguistic_Set_Domain.
            Generic_Zoom_Panel is ...

The package Gtk.Fuzzy_Linguistic_Set_Zoom_Panel is an instance of Gtk.Generic_Fuzzy_Linguistic_Set_Domain.Generic_Zoom_Panel based on the standard type Float.

The package Gtk.Generic_Fuzzy_Linguistic_Set_Domain.Generic_Zoom_Panel declares the types of the following widgets:

The package provides the following subprograms:

function Get_Y_Tracker
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
         )  return Gtk_Fuzzy_Linguistic_Set_Membership;
function Get_X_Tracker
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
         )  return Gtk_Fuzzy_Linguistic_Set_Value;
function Get_Zoom_100_Button
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
         )  return Gtk_Fuzzy_Linguistic_Set_Zoom_100;
function Get_Zoom_Fit_Button
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
         )  return Gtk_Fuzzy_Linguistic_Set_Zoom_Fit;
function Get_Zoom_In_Button
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
         )  return Gtk_Fuzzy_Linguistic_Set_Zoom_In;
function Get_Zoom_Out_Button
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
         )  return Gtk_Fuzzy_Linguistic_Set_Zoom_Out;
function Get_Zoom_Redo_Button
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
         )  return Gtk_Fuzzy_Linguistic_Set_Zoom_Redo;
function Get_Zoom_Undo_Button
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
         )  return Gtk_Fuzzy_Linguistic_Set_Zoom_Undo;
function Get_Zoom_X_Scale
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
         )  return Gtk_Fuzzy_Linguistic_Set_Zoom_X;
function Get_Zoom_Y_Scale
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
         )  return Gtk_Fuzzy_Linguistic_Set_Zoom_Y;

These functions are used to obtain the corresponding button or scale of the widget specified by the parameter Widget. When no such button or scale yet exists it is created as appropriate. The result of a function is typically placed into a container widget. Note that only one widget of given type is created. Consequent calls to the same function will return the same object until the finalization of.

procedure Gtk_New
          (  Panel  : out Gtk_Fuzzy_Linguistic_Set_Zoom_Panel;
             Widget : not null access
                      Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
          );

This procedure creates a zoom panel widgets for a linguistic set domain widget specified by the parameter Widget. The parameter Tooltips when not null is the tool tip group to use. When null, no tool tips are shown. The zoom panel creates some of the objects mentioned above.

function Get_Domain_View
         (  Widget : not null access
                     Gtk_Fuzzy_Linguistic_Set_Zoom_Panel_Record
         )  return not null access
                   Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class;

This function is used to obtain the linguistic set domain widget associated with the panel Widget.

procedure Initialize
          (  Panel  : not null access
                      Gtk_Fuzzy_Linguistic_Set_Zoom_Panel_Record'Class;
             Widget : not null access
                      Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class
          );

This procedure has to be called by any derived type from its initialize.

7.2.5. Domains. Editing and list of names

The child generic package Gtk.Generic_Fuzzy_Linguistic_Set_Domain.Generic_Tree_View provides widgets for editing and viewing the variables and their individual points in the set, in particular:

The main widget declared in the package is a specialized tree-view widget Gtk_Fuzzy_Linguistic_Set_Tree_View:

fuzzy linguistic set tree view

generic
package
Gtk.Generic_Fuzzy_Linguistic_Set_Domain.
        Generic_Tree_View is ...

The package Gtk.Fuzzy_Linguistic_Set_Tree_View contains an instance of Gtk.Generic_Fuzzy_Linguistic_Set_Domain.Generic_Tree_View based on the standard type Float.

The package Gtk.Generic_Fuzzy_Linguistic_Set_Domain.Generic_Tree_View also declares the types of the following supplementary widgets:

The widget Gtk_Fuzzy_Linguistic_Set_Tree_View is declared as:

type Gtk_Fuzzy_Linguistic_Set_Tree_View_Record is
   new
Gtk_Widget_Record with private;
type
Gtk_Fuzzy_Linguistic_Set_Tree_View is
   access all
Gtk_Fuzzy_Linguistic_Set_Tree_View_Record'Class;

The widget has the following style properties:

Name GTK+ type Default Description
accumulation-dialog-title string Accumulate The title of the accumulation dialog
accumulate-button-label string gtk-ok The label of the button in the accumulation dialog. The label may refer to a stock button
cancel-button-label string gtk-cancel The label of the button in the accumulation dialog. The label may refer to a stock button
checked-color color #000000 The color used for valid names of the variables and valid values of the points of.
domain-column-title string Domain The title of the first column. The column contains the variables names and the domain values
hide-button-label string gtk-delete The label of the button in the accumulation dialog. The label may refer to a stock button
illegal-color color #FF0000 The color used for invalid names. When a variable name is edited and the result name is illegal, it is rendered in this color.
left-column-title string Left The title of the third column. The column contains the left limit of the membership function
range-column-title string Range The title of the second column. The column contains the range of the membership function
right-column-title string Right The title of the fourth column. The column contains the right limit of the membership function
Style properties of Gtk_Cell_Renderer_Fuzzy_Boolean (see)

The package provides the following subprograms defined for Gtk_Fuzzy_Linguistic_Set_Tree_View:

function Edited
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Boolean;

This function returns true if the widget content was modified by the user.

function Get
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
            Purge  : Boolean := True
         )  return Linguistic_Set;

This function returns the current set indicated by Widget. When Purge is true the variables of the result are scanned for redundant membership function points, and those are removed. Constraint_Error is propagated when some names of the variables in the widget are illegal. The legality of names is checked according to Name_Tables  Additionally, illegal names are shown in a different color in the tree view. Name_Error is propagated when some names are duplicated.

function Get
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
            Index  : Positive
         )  return Variable;

This function returns a variable from the set indicated by Widget by the variable index. Constraint_Error is propagated when Index is illegal.

function Get_Cardinality
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Natural;

This function returns number of variables from the set indicated by Widget.

function Get_Domain_Column_Note
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return UTF8_String;

This function returns the domain note used by Widget. It is shown next to the title of the first column of the tree view.

function Get_Domain_View
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return not null access
                   Gtk_Fuzzy_Linguistic_Set_Domain_Record'Class;

This function returns the associated Gtk_Fuzzy_Linguistic_Set_Domain widget.

function Get_Name
         (  Widget : not null access
          
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
            Index  : Positive
         )  return UTF8_String;

This function returns the name of the linguistic variable indicated by Widget. The variable is specified by its index. Constraint_Error is propagated when Index is wrong. Note that the name returned might be duplicated or illegal according to the package Name_Tables.

function Get_Selection
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Selection;
function Get_Selection
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Selection_Subtype;

These functions return the current selection in Widget. There can be returned either a Selection (a map of variable index to set of points) or else as a more detailed description of (Selection_Subtype).

function Get_Tree_View
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Tree_View;

This function returns the tree view of Widget.

procedure Gtk_New
          (  Widget : out Gtk_Fuzzy_Linguistic_Set_Tree_View;
             Value  : Linguistic_Set
          );

This procedure creates the widgets for editing and viewing a set of linguistic variables. This call also creates a Gtk_Fuzzy_Linguistic_Set_Domain widget, which can be obtained using Get_Domain_View applied to Widget. The parameter Value is the set indicated by the widget initially.

function Image
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
            Value  : Number
         )  return UTF8_String;

This function renders a domain value to string. It is used by the widget for indicating the abscissas of the membership function points. It can be overridden by a derived type to alter functionality of.

procedure Initialize
          (  Widget : not null access
                 
    Gtk_Fuzzy_Linguistic_Set_Tree_View_Record'Class;
             Value  : Linguistic_Set
          );

This procedure has to be created by a derived type of Gtk_Fuzzy_Linguistic_Set_Tree_View from its Initialize.

procedure Insert
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
             Index  : Positive;
             Name   : UTF8_String;
             Value  : Variable
          );

This procedure insert a new variable into Widget at the position specified by Index. When Index is greater than the number of variables in the widget + 1 Constraint_Error is propagated..Name is the new variable name. It is checked against according to the rules of the package Name_Tables and when found illegal, rendered with the color specified by the illegal-color style property. The parameter Value is the variable to insert. The inserted variable is selected in the Widget. The overall effect of the procedure is as if the insertion happened due to a user action. The undo/redo buffer is modified appropriately.

function Is_Editable
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Boolean;

This function returns true if Widget is editable.

procedure Put
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
             Index  : Positive;
             Value  : Variable
          );

This procedure sets a variable in Widget. The variable is specified by the variable index. The parameter Value is the new value of the variable. It also removes the variable from selection if any and erases the undo/redo buffer. Constraint_Error is propagated when Index is illegal.

procedure Put
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
             Value  : Linguistic_Set
          );

This procedure replaces the Widget content. The parameter Value is the new set of variables to indicate. It also removes any selections, erases the undo/redo buffer and zooms the horizontal axis out.

procedure Remove
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
             Index  : Positive
          );

This procedure removes a variable at the position specified by Index. Nothing happens when Index is greater  than the number of variables in the widget. The overall effect of the procedure is as if the removal happened due to a user action. The undo/redo buffer is modified appropriately.

procedure Replace
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
             Index  : Positive;
             Name   : UTF8_String;
             Value  : Variable
          );

This procedure replaces a variable at the position specified by Index. The overall effect of the procedure is as if the removal happened due to a user action. The undo/redo buffer is modified appropriately. Constraint_Error is propagated when Index is wrong.

procedure Select_Duplicated
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
          );

This procedure sets the tree view selection to all variables with duplicated names. The undo/redo buffer is modified as if the selection were made in result of user actions.

procedure Set_Editable
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
             Editable : Boolean
          );

This procedure changes the editable flag of Widget according to the value of Editable. When the widget is not editable the buttons and other supplementary widgets that can modify the widget content are set insensitive. The cells of the tree view as set non-editable.

procedure Set_Domain_Column_Note
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
             Note   : UTF8_String
          );

This procedure sets the note shown next to the title of the first column of Widget's tree view. Usually it is the measurement units of the domain values.

procedure Set_Name
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
             Index  : Positive;
             Name   : UFT8_String
          );

This procedure changes the name of a variable in Widget. The variable is specified by the variable index. The name is not checked. Constraint_Error is propagated when Index is illegal.

procedure Update
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
             Selected : Selection
          );

This procedure synchronizes the part of tree view with the current linguistic set of Widget. The part is specified by the parameter Selected of the type Selection. Normally it is not necessary to call.

function Value
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record;
            Source : UTF8_String
         )  return Number;

This function parses the string Source and returns the domain value stored in. It is used while editing the domain values in the first column of tree view. User input is discarded when an exception is propagated. The implementation provided uses Constraint_Error to indicate values out of range, Data_Error for syntax errors and End_Error for blank string. A derived type can override it to provide additional functionality.

Buttons and scroll bars.

function Get_Accumulate_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Accumulate;
function Get_Add_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Add;
function Get_Copy_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Copy;
function Get_Down_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Down;
function Get_Exec_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Exec;
function Get_Find_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Find;
function Get_New_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_New;
function Get_Purge_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Purge;
function Get_Redo_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Redo;
function Get_Remove_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Remove;
function Get_Undo_Button
         Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Undo;
function Get_Up_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Up;
function Get_X_Move_Bar
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_X;
function Get_Y_Move_Bar
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Y;

These functions are used to obtain the corresponding button or scroll bar of the widget specified by the parameter Widget. When no such button or scale yet exists it is created as appropriate. The result of a function is typically placed into a container widget. Note that only one widget of given type is created. Consequent calls to the same function will return the same object until the finalization of.

Execution of operations. The widget provides a combo box with a list of operation and a button to insert the result of the operation. The operation takes its argument from the current selection. The result is inserted as a new variable immediately following the selection. Operations can be defined, added and removed dynamically. The package defines the following types to support this functionality:

type Operation is abstract
   new
Ada.Finalization.Controlled with private;

This is the base type of a user-defined operation executed on variables. A derived type has to implement:

function Check (Op : Operation; Selected : Selection_Subtype)
   return Boolean is abstract;

This function is called to determine if the operation can be applied to a selection. The selection is specified by the parameter Selected of Selection_Subtype. The function returns true if the operation is defined for this selection type. Note that only selections of complete variables can be used. For other types of selections the result returned by this procedure is ignored.

function Execute (Op : Operation; Arguments : Array_Of_Variables)
   return Variable is abstract;

This function is called to execute the operation on a list of arguments of the type Array_Of_Variables.

type Unary_Operation    is abstract new Operation with private;
type Binary_Operation   is abstract new Operation with private;
type Multiple_Operation is abstract new Operation with private;

These are predefined specializations of the type Operation with the function Check defined to accept one, two or more than one arguments correspondingly.

type And_Operation is new Multiple_Operation with private;
type Not_Operation is new Unary_Operation    with private;
type Or_Operation  is new Multiple_Operation with private;
type Xor_Operation is new Multiple_Operation with private;

These are the types of the set-theoretic operations on variables: intersection (and), complement (not), union (or) and xor.

Selection of operations. The button Gtk_Fuzzy_Linguistic_Set_Edit_Exec has the following operations defined for handling operation selection:

procedure Add
          (  Button : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Edit_Exec_Record;
             Name   : UTF8_String;
             Op     : Operation'Class
          );

This procedure adds a new operation to the combo box associated with Button. The parameter Name is the operation name in the combo box. Name_Error is propagated when the combo box already contains an operation under this name. Initially the combo box of any Button is filled with operations: intersection (and), complement (not), union (or) and xor.

function Get_Combo
         (  Button : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Edit_Exec_Record
         )  return Gtk_Combo_Box_Text;

This function returns the combo box associated with Button. Typically it is put in a container widget along with Button itself.

procedure Remove
          (  Button : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Edit_Exec_Record;
             Name   : UTF8_String
          );

This procedure removes an operation from the Button's combo box. Nothing happens if Name does not specify any operation there.

Abstract factory. Sometimes it is necessary to create a Gtk_Fuzzy_Linguistic_Set_Tree_View widget while construction of another widget. An abstract factory type serves this purpose:

type Gtk_Fuzzy_Tree_View_Factory is
   new
Ada.Finalization.Limited_Controlled with null record;

The factory has the subprogram:

function Create
         (  Factory  : Gtk_Fuzzy_Tree_View_Factory;
            Value    : Linguistic_Set
         )  return Gtk_Fuzzy_Linguistic_Set_Tree_View;

This function is called to create a widget. Exceptions propagate to the caller to indicate errors as described in Gtk_New.

7.2.6. Composite widget for sets of linguistic variables

The generic package Gtk.Generic_Fuzzy_Linguistic_Set_Editor provides a high level widget for editing and viewing sets of fuzzy linguistic variables.

fuzzy linguistic set editor horizontal

The editor / viewer widgets are composite widgets consisting out of:

The widget has two layouts. The horizontally-oriented layout has the horizontal pane separating the tree view and the rest of the widget as shown on the figure above. The vertically oriented variant has the vertical pane.

generic
   with package
Domain is
      new
Gtk.Generic_Fuzzy_Linguistic_Set_Domain (<>);
   with package
Zoom_Panel is new Domain.Generic_Zoom_Panel;
   with package
Tree_View  is new Domain.Generic_Tree_View;
package
Gtk.Generic_Fuzzy_Linguistic_Set_Editor is ...

The package takes three formal parameters:

The package Gtk.Fuzzy_Linguistic_Set_Editor is an instance of Gtk.Generic_Fuzzy_Linguistic_Set_Editor based on the standard type Float.

The package Gtk.Generic_Fuzzy_Linguistic_Set_Editor provides the composite widget:

type Gtk_Fuzzy_Linguistic_Set_Editor_Record is
   new
Gtk_Widget_Record with private;
type
Gtk_Fuzzy_Linguistic_Set_Editor is
   access all
Gtk_Fuzzy_Linguistic_Set_Editor_Record'Class;

for editing and viewing sets of linguistic variables. The following subprograms are defined in the package:

function Edited
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Editor_Record
         )  return Boolean;

The function returns true if the set indicated by Widget was edited.

function Get
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Editor_Record;
            Purge  : Boolean := True
         )  return Linguistic_Set;

These functions return the set indicated by Widget. The membership functions of the variables are scanned for redundant points, which are removed from the result, if the parameter Purge is set to true. Constraint_Error is propagated when the variables of Widget have illegal names. Name_Error is propagated when variables of Widget have duplicated names.

function Get_Edit_Buttons
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Editor_Record
         )  return Gtk_Box;

This function returns box containing the editing buttons of Widget. The result box is empty when Widget is not editable.

function Get_Exec_Buttons
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Editor_Record
         )  return Gtk_Box;

This function returns box containing the widgets used to execute operations on the content of Widget. The result box is empty when Widget is not editable.

function Get_Pane
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Editor_Record
         )  return Gtk_Paned;

These functions return the pane separating the list view of the variables and the domain view of their membership functions.

function Get_Tracker
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Editor_Record
         )  return Gtk_Box;

These functions return the box containing the mouse cursor tracking widgets.

function Get_Tree_View
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Editor_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Tree_View;

These functions return the Gtk_Fuzzy_Linguistic_Set_Tree_View component of Widget.

function Get_View_Buttons
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Editor_Record
         )  return Gtk_Box;

These functions return the box containing viewing and navigational buttons.

procedure Gtk_New
          (  Widget   : out Gtk_Fuzzy_Linguistic_Set_Editor;
             Value    : Linguistic_Set;
             Tooltips : Gtk_Tooltips    := null;
             Layout   : Gtk_Orientation := Orientation_Vertical;
             Editable : Boolean         := True
          );

These procedures create a new widget. The parameter Widget accepts the result. The parameter Value is the initial set the widget shows. The parameter Tooltips is the group of tooltips to use. When set to null, no tooltips will be used. The parameter Layout determines the widget's layout. The parameter Editable when set to false restricts the widget to only viewing the content of.

procedure Initialize
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Editor_Record'Class;
             Value    : Linguistic_Set;
             Tooltips : Gtk_Tooltips;
             Layout   : Gtk_Orientation;
             Editable : Boolean
          );
procedure
Initialize
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Editor_Record'Class;
             Value    : Linguistic_Set;
             Tooltips : Gtk_Tooltips;
             Layout   : Gtk_Orientation;
             Editable : Boolean;
             View     : Gtk_Fuzzy_Tree_View_Factory'Class
          );

A derived type is responsible to call Initialize upon its initialization. When the parameter View is supplied it is a factory used to create the Gtk_Fuzzy_Linguistic_Set_Tree_View component of the widget. The factory can return an existing widget or create a new one. When View is omitted the component is created using default Gtk_New.

function Is_Editable
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Editor_Record
         )  return Boolean;

This function returns true if Widget is editable.

procedure Put
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Editor_Record;
             Value  : Linguistic_Set
          );

This procedure replaces the Widget content. The parameter Value is the new set of variables to indicate. It also removes any selections, erases the undo/redo buffer and zooms the horizontal axis out.

procedure Set_Editable
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Editor_Record;
             Editable : Boolean
          );

This procedure sets Widget editable or not, according to the parameter Editable. In the effect of the operation the widget appearance is changed.

7.2.7. Dimensioned domains. Editing and list of names

The generic package Gtk.Generic_Fuzzy_Linguistic_Set_Measure_Tree_View provides widgets for handling dimensioned domains of fuzzy linguistic variables. It is a counterpart of Gtk.Generic_Fuzzy_Linguistic_Set_Domain.Generic_Tree_View. The difference is in functionality is that the domain set of the linguistic variables is dimensioned. The widget has a dimensioned scale used in all cases where the domain value is rendered. When edited a domain value can be specified either numeric, in which case the scale is applied, or dimensioned, automatically converted to the scale. The package is generic:

generic
   with package Fuzzy_Measures is new Fuzzy.Measures (<>);
   with package Fuzzy_Measure_Linguistics is
      new
Fuzzy_Measures.Linguistics (<>);
   with package Fuzzy_Measure_Linguistic_Sets is
      new
Fuzzy_Measure_Linguistics.Sets (<>);
   with package Float_Edit is
      new
Strings_Edit.Float_Edit
          (  Fuzzy_Measures.Fuzzy_Floats.Float_Intervals_Of.Number
          );
   with package Derived_Measures is
      new
Measures_Derived
          (  Fuzzy_Measures.Interval_Measures_Of.Float_Measures_Of
          );
   with package Irregular_Measures is
      new
Measures_Irregular (Derived_Measures);
   with package Measure_Edit is
      new
Measures_UTF8_Edit
          (  Irregular_Measures => Irregular_Measures,
             Float_Edit         => Float_Edit
          );
   with package Domain is
      new
Gtk.Generic_Fuzzy_Linguistic_Set_Domain
          (  Fuzzy_Linguistics =>
                Fuzzy_Measure_Linguistics.Fuzzy_Linguistics_Of,
             Fuzzy_Linguistic_Sets =>
                Fuzzy_Measure_Linguistic_Sets.Fuzzy_Linguistic_Sets_Of,
             Float_Edit =>
                Float_Edit,
             Class_Name => <>
          );
   with package Tree_View is new Domain.Generic_Tree_View (<>);
package Gtk.Generic_Fuzzy_Linguistic_Set_Measure_Tree_View is ...

The package has the following formal parameters:

The package Gtk.Fuzzy_Linguistic_Set_Measure_Tree_View is an instance of Gtk.Generic_Fuzzy_Linguistic_Set_Measure_Tree_View for the standard Float type.

Tree view lists of dimensioned_variables. The package Gtk.Generic_Fuzzy_Linguistic_Set_Measure_Tree_View provides the widget handling lists of variables similar to Gtk_Fuzzy_Linguistic_Set_Tree_View, but for sets of dimensioned variables. In fact it extends the Gtk_Fuzzy_Linguistic_Set_Tree_View widget

type Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record is
   new
Gtk_Fuzzy_Linguistic_Set_Tree_View_Record with private;
type
Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View is access
   all
Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record'Class;

The widget has same style properties described above. The following subprograms are defined for Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View:

function Edited
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Boolean;

This function returns true if the widget content was modified by the user.

function Get
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
            Purge  : Boolean := True
         )  return Set_Measure;

This function returns the current set indicated by Widget. When Purge is true the variables of the result are scanned for redundant membership function points, and those are removed. Constraint_Error is propagated when some names of the variables in the widget are illegal. The legality of names is checked according to Name_Tables  Additionally, illegal names are shown in a different color in the tree view. Name_Error is propagated when some names are duplicated.

procedure Get
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Value  : out Linguistic_Set;
             Scale  : out Measure;
             Purge  : Boolean := True
          );

This procedure returns the current set indicated by Widget in the form of a dimensionless set of linguistic variables (Value) and the scale (Scale). When Purge is true the variables of the result are scanned for redundant membership function points, and those are removed. Constraint_Error is propagated when some names of the variables in the widget are illegal. The legality of names is checked according to Name_Tables  Additionally, illegal names are shown in a different color in the tree view. Name_Error is propagated when some names are duplicated.

function Get
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
            Index  : Positive
         )  return Variable_Measure;

This function returns a variable from the set indicated by Widget by the variable index. Constraint_Error is propagated when Index is illegal.

function Get_Cardinality
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Natural;

This function returns number of variables from the set indicated by Widget.

function Get_Domain_View
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Domain;

This function returns the associated Gtk_Fuzzy_Linguistic_Set_Domain widget.

function Get_Name
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
            Index  : Positive
         )  return UTF8_String;

This function returns the name of the linguistic variable indicated by Widget. The variable is specified by its index. Constraint_Error is propagated when Index is wrong. Note that the name returned might be duplicated or illegal according to the package Name_Tables.

function Get_Tree_View
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Tree_View;

This function returns the tree view of Widget.

function Get_Unit
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Unit;

This function returns the unit of the variables in the set indicated by Widget.

procedure Gtk_New
          (  Widget   : out Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Value    : Set_Measure;
             Scale    : UTF8_String  := ""
          );

This procedure creates the widgets for editing and viewing a set of dimensioned linguistic variables. This call also creates a Gtk_Fuzzy_Linguistic_Set_Domain widget, which can be obtained using Get_Domain_View applied to Widget. The parameter Value is the set indicated by the widget initially. The parameter Scale is the preferred unit to be used to scale domain values. It must be a valid dimensioned value specification as expected by the function Measures_UTF8_Edit.Value. The unit must be compatible with one of Value otherwise Unit_Error is propagated. Data_Error is propagated when Scale is syntactically wrong. Scale can be an empty string, in which case the unit (Value.SI, 1.0, Value.Offset) will be used as the scale. The gain of Scale has to be positive, otherwise Constraint_Error is propagated.

Exceptions
Constraint_Error Gain of the specified scale is less or equal to 0
Data_Error Syntactically illegal scale
Unit_Error Incompatible units in Scale and Value

function Image
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
            Value  : Number
         )  return UTF8_String;

This function renders a domain value to string. It is used by the widget for indicating the abscissas of the membership function points. It can be overridden by a derived type to alter functionality of.

procedure Initialize
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record'Class;
             Value    : Set_Measure;
             Scale    : UTF8_String
          );

This procedure is to be created by a derived type of Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View from its Initialize. The Data_Error and Unit_Error exceptions propagate as described above.

Exceptions
Constraint_Error Gain of the specified scale is less or equal to 0
Data_Error Syntactically illegal scale
Unit_Error Incompatible units in Scale and Value

procedure Insert
          (  Widget : access Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Index  : Positive;
             Name   : UTF8_String;
             Value  : Variable_Measure
          );

This procedure insert a new variable into Widget at the position specified by Index. When Index is greater than the number of variables in the widget + 1 Constraint_Error is propagated.. Name is the new variable name. It is checked against according to the rules of the package Name_Tables and when found illegal, rendered with the color specified by the illegal-color style property. The parameter Value is the variable to insert. Unit_Error is propagated when it has incompatible units. The inserted variable is selected in the Widget. The overall effect of the procedure is as if the insertion happened due to a user action. The undo/redo buffer is modified appropriately.

function Is_Editable
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Boolean;

This function returns true if Widget is editable.

procedure Put
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Index  : Positive;
             Value  : Variable_Measure
          );

This procedure sets a variable in Widget. The variable is specified by the variable index. The parameter Value is the new value of the variable. It also removes the variable from selection if any and erases the undo/redo buffer. Constraint_Error is propagated when Index is illegal. Unit_Error is propagated when Value has incompatible units.

procedure Put
          (  Widget : not null access
                     
Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Value  : Set_Measure
          );

This procedure replaces the entire Widget's content. The parameter Value is the new set of variables to indicate. It also removes any selections, erases the undo/redo buffer and zooms the horizontal axis out. Unit_Error is propagated when Value has units incompatible with Widget.

procedure Put
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Value  : Set_Measure;
             Scale  : UTF8_String
          );

This procedure replaces the Widget content and its dimension when necessary. The parameter Value is the new set of variables to indicate.  The parameter Scale is the preferred unit to be used to scale domain values. It must be a valid dimensioned value specification as expected by the function Measures_UTF8_Edit.Value. The unit must be compatible with one of Value otherwise Unit_Error is propagated. Data_Error is propagated when Scale is syntactically wrong. Scale can be an empty string, in which case the unit (Value.SI, 1.0, Value.Offset) will be used as the scale. The procedure removes any selections, erases the undo/redo buffer and zooms the horizontal axis out.

procedure Remove
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Index  : Positive
          );

This procedure removes a variable at the position specified by Index. Nothing happens when Index is greater  than the number of variables in the widget. The overall effect of the procedure is as if the removal happened due to a user action. The undo/redo buffer is modified appropriately.

procedure Replace
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Index  : Positive;
             Name   : UTF8_String;
             Value  : Variable_Measure
          );

This procedure replaces a variable at the position specified by Index. The overall effect of the procedure is as if the removal happened due to a user action. The undo/redo buffer is modified appropriately. Constraint_Error is propagated when Index is wrong. Unit_Error is propagated when Value has incompatible units.

procedure Select_Duplicated
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
          );

This procedure sets the tree view selection to all variables with duplicated names. The undo/redo buffer is modified as if the selection were made in result of user actions.

procedure Set_Editable
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Editable : Boolean
          );

This procedure changes the editable flag of Widget according to the value of Editable. When the widget is not editable the buttons and other supplementary widgets that can modify the widget content are set insensitive. The cells of the tree view as set non-editable.

procedure Set_Name
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Index  : Positive;
             Name   : UFT8_String
          );

This procedure changes the name of a variable in Widget. The variable is specified by the variable index. The name is not checked. Constraint_Error is propagated when Index is illegal.

procedure Update
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
             Selected : Selection
          );

This procedure synchronizes the part of tree view with the current linguistic set of Widget. The part is specified by the parameter Selected of the type Selection. Normally it is not necessary to call.

function Value
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record;
            Source : UTF8_String
         )  return Number;

This function parses the string Source and returns the domain value stored in. It is used while editing the domain values in the first column of tree view. User input is discarded when an exception is propagated. The implementation provided uses Constraint_Error to indicate values out of range, Data_Error for syntax errors and End_Error for blank string. A derived type can override it to provide additional functionality.

Buttons and scroll bars.

function Get_Accumulate_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Accumulate;
function Get_Add_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Add;
function Get_Copy_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Copy;
function Get_Down_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Down;
function Get_Exec_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Exec;
function Get_Find_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Find;
function Get_New_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_New;
function Get_Purge_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Purge;
function Get_Redo_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Redo;
function Get_Remove_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Remove;
function Get_Undo_Button
         Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Undo;
function Get_Up_Button
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Up;
function Get_X_Move_Bar
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_X;
function Get_Y_Move_Bar
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Edit_Y;

These functions are used to obtain the corresponding button or scroll bar of the widget specified by the parameter Widget. When no such button or scale yet exists it is created as appropriate. The result of a function is typically placed into a container widget. Note that only one widget of given type is created. Consequent calls to the same function will return the same object until the finalization of.

Abstract factory.

type Gtk_Fuzzy_Measure_Tree_View_Factory (Length : Natural) is
   new
Gtk_Fuzzy_Tree_View_Factory with
record

   SI     : Unit   := Units.Base.Unitless;
   Offset : Number := 1.0;
   Scale  : UTF8_String (1..Length);
end record;

7.2.8. Composite widget for sets of dimensioned linguistic variables

The generic package Gtk.Generic_Fuzzy_Linguistic_Set_Measure_Editor provides a composite widget for editing and viewing sets of dimensioned linguistic variables.

generic
   with package
Measure_Tree_View is
      new
Gtk.Generic_Fuzzy_Linguistic_Set_Measure_Tree_View (<>);
   with package
Zoom_Panel is
      new
Measure_Tree_View.Domain_Of.Generic_Zoom_Panel (<>);
   with package
Editor is
      new
Gtk.Generic_Fuzzy_Linguistic_Set_Editor
          (  Domain     => Measure_Tree_View.Domain_Of,
             Zoom_Panel => Zoom_Panel,
             Tree_View  => Measure_Tree_View.Tree_View_Of
          );
package
Gtk.Generic_Fuzzy_Linguistic_Set_Measure_Editor is ...

The package has the following formal parameters:

The package Gtk.Fuzzy_Linguistic_Set_Measure_Editor is an instance of Gtk.Generic_Fuzzy_Linguistic_Set_Measure_Editor for the standard type Float type.

The widget type:

type Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record is
   new
Gtk_Widget_Record with private;
type
Gtk_Fuzzy_Linguistic_Set_Measure_Editor is
   access all
Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record'Class;

The following subprograms are defined in the package:

function Edited
         (  Widget : not null access
                    
Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record
         )  return Boolean;

The function returns true if the set indicated by Widget was edited.

function Get
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record;
            Purge  : Boolean := True
         )  return Set_Measure;

These functions return the set indicated by Widget. The membership functions of the variables are scanned for redundant points, which are removed from the result, if the parameter Purge is set to true. Constraint_Error is propagated when the variables of Widget have illegal names. Name_Error is propagated when variables of Widget have duplicated names.

procedure Get
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record;
             Value  : out Linguistic_Set;
             Scale  : out Measure;
             Purge  : Boolean := True
          );

This procedure returns the current set indicated by Widget in the form of a dimensionless set of linguistic variables (Value) and the scale (Scale). The membership functions of the variables are scanned for redundant points, which are removed from the result, if the parameter Purge is set to true. Constraint_Error is propagated when the variables of Widget have illegal names. Name_Error is propagated when variables of Widget have duplicated names.

function Get_Edit_Buttons
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record
         )  return Gtk_Box;

This function returns box containing the editing buttons of Widget. The result box is empty when Widget is not editable.

function Get_Exec_Buttons
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record
         )  return Gtk_Box;

This function returns box containing the widgets used to execute operations on the content of Widget. The result box is empty when Widget is not editable.

function Get_Pane
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record
         )  return Gtk_Paned;

These functions return the pane separating the list view of the variables and the domain view of their membership functions.

function Get_Tracker
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record
         )  return Gtk_Box;

These functions return the box containing the mouse cursor tracking widgets.

function Get_Tree_View
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record
         )  return Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View;

These functions return the Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View component of Widget.

function Get_View_Buttons
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record
         )  return Gtk_Box;

These functions return the box containing viewing and navigational buttons.

function Get_Unit
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record
         )  return Unit;

This function returns the unit of the variables in the set indicated by Widget.

procedure Gtk_New
          (  Widget   : out Gtk_Fuzzy_Linguistic_Set_Editor;
             Value    : Set_Measure;
             Scale    : UTF8_String     := "";
             Layout   : Gtk_Orientation := Orientation_Vertical;
             Editable : Boolean         := True
          );

These procedures create a new widget. The parameter Widget accepts the result. The parameter Value is the initial set the widget shows. The parameter Scale is the preferred unit to be used to scale domain values. It must be a valid dimensioned value specification as expected by the function Measures_UTF8_Edit.Value. The unit must be compatible with one of Value otherwise Unit_Error is propagated. Data_Error is propagated when Scale is syntactically wrong. Scale can be an empty string, in which case the unit (Value.SI, 1.0, Value.Offset) will be used as the scale. The gain of Scale has to be positive, otherwise Constraint_Error is propagated. The parameter Layout determines the widget's layout. The parameter Editable determines whether the widget will be editable.

Exceptions
Constraint_Error Gain of the specified scale is less or equal to 0
Data_Error Syntactically illegal scale
Unit_Error Incompatible units in Scale and Value

procedure Initialize
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record'Class;
             Value    : Linguistic_Set;
             Scale    : UTF8_String;
             Layout   : Gtk_Orientation;
             Editable : Boolean;
             View     : Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View := null
          );

A derived type is responsible to call Initialize upon its initialization. When the parameter View is null, an instance of Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View is created. Otherwise, View has to be a newly allocated object of Gtk_Fuzzy_Linguistic_Set_Measure_Tree_View, which is then initialized. Typically, this is when View is of a derived type. The procedure does the mandatory base initialization for it. The custom initialization is then accomplished by the caller.

Exceptions
Constraint_Error Gain of the specified scale is less or equal to 0
Data_Error Syntactically illegal scale
Unit_Error Incompatible units in Scale and Value

function Is_Editable
         (  Widget : not null access
                   
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record
         )  return Boolean;

This function returns true if Widget is editable.

procedure Put
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record;
             Value  : Set_Measure
          );

This procedure replaces the entire Widget's content. The parameter Value is the new set of variables to indicate. It also removes any selections, erases the undo/redo buffer and zooms the horizontal axis out. Unit_Error is propagated when Value has units incompatible with Widget.

procedure Put
          (  Widget : not null access
                    
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record;
             Value  : Set_Measure;
             Scale  : UTF8_String
          );

This procedure replaces the Widget content and its dimension when necessary. The parameter Value is the new set of variables to indicate.  The parameter Scale is the preferred unit to be used to scale domain values. It must be a valid dimensioned value specification as expected by the function Measures_UTF8_Edit.Value. The unit must be compatible with one of Value otherwise Unit_Error is propagated. Data_Error is propagated when Scale is syntactically wrong. Scale can be an empty string, in which case the unit (Value.SI, 1.0, Value.Offset) will be used as the scale. The procedure removes any selections, erases the undo/redo buffer and zooms the horizontal axis out.

procedure Set_Editable
          (  Widget   : not null access
                      
 Gtk_Fuzzy_Linguistic_Set_Measure_Editor_Record;
             Editable : Boolean
          );

This procedure sets Widget editable or not, according to the parameter Editable. In the effect of the operation the widget appearance is changed.


[Back][TOC][Next]

8. Packages and other compilation units

The following figure illustrates major generic packages and the formal parameters of.

fuzzy packages

An instantiation of the packages starts from the numeric type of plain floating-point values. As new packages are instantiated they are used as the actual parameters of the instances of other packages. The packages on the left side of the figure provide dimensionless types: interval → fuzzy number → linguistic variable → set of. The right side of the figure represents their dimensioned counterparts.

[Back][TOC][Next]

8.1. Basic source compilation units

Package / Subprogram Provides
Confidence_Factors The type Confidence and operations on it
       Edit I/O operations for Confidence
Fuzzy The type Set and operations on it
  Abstract_Edit I/O operations for fuzzy sets over an abstract domain
       Handle Handles to instances of User_Data type
Named The type Domain_Description and operations on it (named domain sets)
Intuitionistic I/O operations for fuzzy Intuitionistic over an abstract domain
Basic_Edit Basic I/O subroutines for set I/O
Edit I/O operations for fuzzy sets with numeric indices
  Intuitionistic I/O operations for fuzzy Intuitionistic with numeric indices
Floats Generic fuzzy floating-point numbers, the type Fuzzy_Float
  Edit Generic I/O operations for Fuzzy_Float
Generic_Edit Generic I/O operations for fuzzy sets
  Intuitionistic Generic I/O operations for fuzzy intuitionistic sets
Integers Generic fuzzy integers numbers, the type Fuzzy_Integer
  Edit Generic I/O operations for Fuzzy_Integer
Intuitionistic The type Fuzzy.Intuitionistic.Set (an intuitionistic fuzzy set)
  Basic_Edit Basic I/O subroutines for Intuitionistic I/O
Linguistics Generic linguistic variables
      Center_of_Area Generic function implementing center of area defuzzification method
Center_of_Gravity Generic function implementing center of gravity defuzzification method
Discrete_Center_of_Gravity Generic function implementing discrete_center of gravity defuzzification method
Edit Generic I/O operations for linguistic variables
Leftmost_Max Generic function implementing leftmost maximum defuzzification method
Rightmost_Max Generic function implementing rightmost maximum defuzzification method
Sets Generic sets of linguistic variables, the type Linguistic_Set
       Edit Generic I/O operations for sets of linguistic variables and their intuitionistic sets
Logic Fuzzy logic, the type Fuzzy_Boolean
Measures Generic dimensioned fuzzy numbers, the type Fuzzy_Measure
  Linguistics Generic dimensioned linguistic variables
  Empirical_Defuzzification Generic function which instances provide defuzzification methods for dimensioned variables
Sets Generic sets of dimensioned linguistic variables, the type Set_Measure
Numbers Generic fuzzy numbers, the type Fuzzy_Number
  Edit Generic I/O operations for fuzzy numbers
Stream_IO Conversion to stream elements array
Name_Tables Determines matching identifiers of the domain values and linguistic variables

[Back][TOC][Next]

8.2. GUI compilation units

Package / Subprogram Provides
GLib GLib root package
       Values GLib values package
  Confidence_Factors Truth values corresponding to Confidence_Factor:
Fuzzy Fuzzy set values corresponding to fuzzy Set:
   Intuitionistic Intuitionistic fuzzy classification and set values corresponding to Classification and Set:
Logic Fuzzy logical values corresponding to Fuzzy_Boolean
Gtk GTK+ root package
        Cell_Renderer_Fuzzy Cell renderer of fuzzy Set, intuitionistic fuzzy Classification and Set:.
Cell_Renderer_Fuzzy_Boolean Cell renderer of Confidence_Factor and Fuzzy_Boolean
Fuzzy_Boolean Widget for Confidence_Factor and Fuzzy_Boolean
Fuzzy_Set Widget for dealing with fuzzy sets (Set), intuitionistic fuzzy sets (Set) and classifications (Classification)
Fuzzy_Set_Entry Combo box widget for dealing with fuzzy sets (Set), intuitionistic fuzzy sets (Set) and classifications (Classification)
Generic_Fuzzy_Linguistic_Set_Domain Visualization of the membership functions of linguistic variables (Linguistic_Set)
    Generic_Tree_View Tree view of the sets linguistic variables (Linguistic_Set)
Generic_Zoom_Panel Zooming and scrolling the membership function of linguistic variables (Linguistic_Set)
Generic_Fuzzy_Linguistic_Set_Editors Editing and viewing sets of linguistic variables (Linguistic_Set)
Generic_Fuzzy_Linguistic_Set_Measure_Editor Editing and viewing sets of dimensioned linguistic variables (Set_Measure)
Generic_Fuzzy_Linguistic_Set_Measure_Tree_View Tree view of the sets dimensioned linguistic variables (Set_Measure)

[Back][TOC][Next]

8.3. Instances of generic compilation units

Package / Subprogram Provides
Fuzzy The type Set and operations on it
       Edit I/O operations for fuzzy sets with numeric indices
   Floats An instance of Fuzzy.Floats with Float
Integers An instance of  Fuzzy.Integers with Integer
Linguistic_Sets An instance of Fuzzy.Linguistics.Sets.Edit based on Float
Linguistics An instance of Fuzzy.Linguistics.Edit based on Float
Fuzzy_Floats An instantiation of Fuzzy.Floats with Float
Fuzzy_Integers An instantiation of  Fuzzy.Integers with Integer
Fuzzy_Linguistic_Center_Of_Area An instance of Fuzzy.Linguistics.Center_of_Area for Float
Fuzzy_Linguistic_Center_Of_Gravity An instance of Fuzzy.Linguistics.Center_of_Gravity for Float
Fuzzy_Linguistic_Discrete_Center_Of_Gravity An instance of Fuzzy.Linguistics.Discrete_Center_of_Gravity for Float
Fuzzy_Linguistic_Leftmost_Max An instance of Fuzzy.Linguistics.Leftmost_Max for Float
Fuzzy_Linguistic_Measures An instantiation of Fuzzy.Measures.Linguistics with Float, renames Fuzzy_Measure_Linguistics
Fuzzy_Linguistic_Measure_Center_Of_Area An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Center_Of_Area, same as  Fuzzy_Measure_Linguistic_Center_Of_Area
Fuzzy_Linguistic_Measure_Center_Of_Gravity An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Center_Of_Gravity, same as Fuzzy_Measure_Linguistic_Center_Of_Gravity
Fuzzy_Linguistic_Measure_Discrete_Center_Of_Gravity An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Discrete_Center_Of_Gravity, same as Fuzzy_Measure_Linguistic_Discrete_Center_Of_Gravity
Fuzzy_Linguistic_Measure_Leftmost_Max An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Leftmost_Max, same as Fuzzy_Measure_Linguistic_Leftmost_Max
Fuzzy_Linguistic_Measure_Rightmost_Max An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Rightmost_Max, same as Fuzzy_Measure_Linguistic_Rightmost_Max
Fuzzy_Linguistic_Rightmost_Max An instance of Fuzzy.Linguistics.Rightmost_Max for Float
Fuzzy_Linguisitc_Set_Measures An instantiation of Fuzzy.Measures.Linguistics.Sets with Float, renames Fuzzy_Measure_Linguistic_Sets
Fuzzy_Linguistic_Sets An instantiation of Fuzzy.Linguistics.Sets with Float
Fuzzy_Linguistics An instantiation of Fuzzy.Linguistics with Float
Fuzzy_Measures An instantiation of Fuzzy.Measures with Float
Fuzzy_Measure_Linguistic_Center_Of_Area An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Center_Of_Area
Fuzzy_Measure_Linguistic_Center_Of_Gravity An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Center_Of_Gravity
Fuzzy_Measure_Linguistic_Discrete_Center_Of_Gravity An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Discrete_Center_Of_Gravity
Fuzzy_Measure_Linguistic_Leftmost_Max An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Leftmost_Max
Fuzzy_Measure_Linguistic_Rightmost_Max An instance of Empirical_Defuzzification with Fuzzy_Linguistic_Rightmost_Max
Fuzzy_Measure_Linguistics An instantiation of Fuzzy.Measures.Linguistics with Float
Fuzzy_Measure_Linguistic_Sets An instantiation of Fuzzy.Linguistics.Sets with Float
Gtk GTK+ root package
  Fuzzy_Linguistic_Set_Domain An instance of Gtk.Generic_Fuzzy_Linguistic_Set_Domain with Float
Fuzzy_Linguistic_Set_Editor An instance of Gtk.Generic_Fuzzy_Linguistic_Set_Editors with Float
Fuzzy_Linguistic_Set_Measure_Editor An instance of Gtk.Generic_Fuzzy_Linguistic_Set_Measure_Editor with Float
Fuzzy_Linguistic_Set_Measure_Tree_View An instance of Gtk.Generic_Fuzzy_Linguistic_Set_Measure_Tree_View with Float
Fuzzy_Linguistic_Set_Tree_View An instance of Gtk.Generic_Fuzzy_Linguistic_Set_Domain.Generic_Tree_View with Float
Fuzzy_Linguistic_Set_Zoom_Panel An instance of Gtk.Generic_Fuzzy_Linguistic_Set_Domain.Generic_Zoom_Panel with Float

[Back][TOC][Next]

8.4. Related  packages

The following packages are described in the separate documents:

[Back][TOC][Next]

8.5. Tests

The subdirectory test_fuzzy contains a self-test program test_fuzzy.adb. It is recommended to use project files to build tests.


[Back][TOC][Next]

9. Installation

The software does not require special installation. The archive's content can be put in a directory and used as-is. For users of GNAT compiler the software provides gpr project files, which can be used in the Gnat Programming Studio (GPS).

For CentOS, Debian, Fedora, Ubuntu Linux distributions there are pre-compiled packages, see the links on the top of the page.

The packages based on GtkAda require it installed. When these packages are not planned for use, the corresponding failures during the installation can be safely ignored.

Project files Provides Use in custom project
fuzzy Fuzzy Sets for Ada, Simple Components for Ada, Strings Edit for Ada, Tables for Ada with "fuzzy.gpr";
fuzzy-gtk Same as above with GTK+ widgets. Includes the packages of GtkAda, GtkAda contributions, Strings Edit for Ada, Tables for Ada with "fuzzy-gtk.gpr";

[Back][TOC][Next]

10. Changes log

The following versions were tested with the compilers:

and the GtkAda versions:

Changes (16 April 2022) to the version 5.14:

Changes (31 May 2020) to the version 5.13:

The following versions were tested with the compilers:

and the GtkAda versions:

Changes (5 Aug 2018) to the version 5.12:

The following versions were tested with the compilers:

and the GtkAda versions:

Changes (25 July 2017) to the version 5.11:

The following versions were tested with the compilers:

and the GtkAda versions:

Changes (25 July 2016) to the version 5.10:

The following versions were tested with the compilers:

and the GtkAda versions:

Changes (29 June 2015) to the version 5.9:

The following versions were tested with the compilers:

and the GtkAda versions:

Changes (2 April 2015) to the version 5.8:

Changes (1 June 2014) to the version 5.7:

The following versions were tested with the compilers:

and the GtkAda:

Changes to the version 5.5.

The following versions were tested with the compilers:

and the GtkAda:

Changes to the version 5.4.

The following versions were tested with the compilers:

and the GtkAda:

Changes to the version 5.3.

The following versions were tested with the compilers:

and the GtkAda:

Changes to the version 5.2:

The following versions were tested with the compilers:

and the GtkAda versions:

Changes to the version 5.1:

Changes to the version 5.0:

The following versions were tested with the compilers:

and the GtkAda:

Changes to the version 4.2:

The following versions were tested with the compilers:

Changes to the version 4.1:

The following versions were tested with the GNAT 3.15p compiler

Changes to the version 4.0:

Changes to the version 3.9:

Changes to the version 3.8:

Changes to the version 3.7:

Changes to the version 3.6:

Changes to the version 3.5:

Changes to the version 3.4:

Changes to the version 3.3:

Changes to the version 3.2:

Changes to the version 3.1:

Changes to the version 3.0:

Changes to the version 2.0:

The following changes were made since the version 1.0:


[Back][TOC]

11. Table of Contents

1 Truth values
    1.1. String I/O of truth values
2 Fuzzy sets
    2.1. Tests
    2.2. Operations producing a new set
    2.3. Possibility theory
    2.4. Distance to point
    2.5. String I/O with numeric indices
    2.6. Generic string I/O
    2.7. Abstract string I/O
    2.8. String I/O with named indices
    2.9. Basic string I/O
    2.10. Identifiers
    2.11. Stream I/O
3 Fuzzy logic
4 Fuzzy numbers
    4.1. Plain fuzzy numbers
        4.1.1. Interval mapping
        4.1.2. Arithmetic operations
        4.1.3. Possibility theory
        4.1.4. Membership and inclusion relations
        4.1.5. Equality and equivalence
        4.1.6. Relational operations
        4.1.7. Conversions
    4.2. Dimensioned fuzzy numbers
        4.2.1. Arithmetic operations
        4.2.2. Possibility theory
        4.2.3. Inclusion and other relational operations
        4.2.4. Conversions
    4.3. Floating-point I/O
        4.3.1. Integer I/O
        4.3.2. Floating-point I/O
5 Intuitionistic fuzzy sets
    5.1. Type and operations
    5.2. String I/O with numeric indices
    5.3. Generic string I/O
    5.4. Abstract string I/O
    5.5. String I/O with named indices
    5.6. Basic string I/O
6 Linguistic variables
    6.1. Variables
        6.1.1. Plain variables
        6.1.2. Dimensioned variables
        6.1.3. String I/O
        6.1.4. Empirical defuzzification methods
    6.2. Sets of variables
        6.2.1. Plain sets
        6.2.2. Dimensioned sets
        6.2.3. String I/O
7 Graphical user interface. GTK+ support
    7.1. GTK+ values of fuzzy objects
        7.1.1. Confidence factors
        7.1.2. Fuzzy set values
        7.1.3. Fuzzy logical values
        7.1.4. Intuitionistic fuzzy set values
    7.2. Widgets and renderers of fuzzy objects
        7.2.1. Confidence factors and fuzzy logical values
        7.2.2. Fuzzy sets, intuitionistic fuzzy sets and classifications
        7.2.3. Domains of fuzzy linguistic sets (basic)
        7.2.4. Domains. Zooming and scrolling
        7.2.5. Domains. Editing and list of names
        7.2.6. Composite widget for sets of linguistic variables
        7.2.7. Dimensioned domains. Editing and list of names
        7.2.8. Composite widget for sets of dimensioned linguistic variables
8 Packages and other compilation units
    8.1. Basic source compilation units
    8.2. GUI compilation units
    8.3. Instances of generic compilation units
    8.4. Related packages
    8.5. Tests
9 Installation
10 Changes log
11 Table of contents