1           b+  X ` ` a b b NORMAL.STY                                                                                        	       Graphical Interface for the Knowledge Base Generator 2.00 
						KGB 2.00

I. Overview & System Requirements:
	This program is designed to be used with the FUZZY11B Inference Engine.  It follows the same format as the Knowledge Base Generator written by John Dumas but makes graphical additions to the area of membership functions.  
	An IBM PC compatible with CGA, EGA, or VGA capabilities is needed.  No mouse is necessary.  (At this time, CGA capabilities are not fully operational.)

0. Version.
	This Knowledge Base Generator(KBG) is considered version 2.00.  All older versions(those without any graphical interface) are considered versions 1.0x.  Each version creates a data structure file <filename.knb>.  There are currently two versions of this data file. (one for KGB 2.00 and one for the older versions)  The older versions stores the data in the user-defined representation.  The newer version can store the data in the internal representation or in the user-defined representation.  It is recommended the internal version be used
1. Format.
	
	As with the previous version, this knowledge base generator can accept the following configurations:
1)	8 inputs per fuzzy application
2)	4 outputs per fuzzy application
3)	8 membership functions per input
4)	8 membership functions per output
5)	1024 rule clauses(antecedents or consequents)
6)	any number of antecedents or consequents per rule
7)	15 characters per name(inputs, outputs, labels, units...)
8)	trapezoidal input membership functions(see section II.Discretization for more about what types of trapezoids are possible)
9)	singleton output membership functions

	The flow of control and general organization of the original version is maintained in the new version. The user defines a fuzzy system through a series of menus and questions.  The user has a choice whether to use the raphical interface to define functions.  For more on the use of the non-graphical portion of the Knowledge Base Generator see KBG_11B.EXE Tutorial.

	The graphical interface is composed of two modes; a select mode and an edit mode.  See figures 2 and 3 for typical examples of these modes.  The primary activities of select mode are creating new functions, and selecting a point or function for editting.  The primary activities of edit mode are moving, copying, or deleting a selected object.


	In both modes, the screen is divided into three windows; the GRAPH window, the INFO window and the OPTION/PROMPT window.  

	The GRAPH window is the top window.  It contains the graphical representations of the membership functions.  The input name and units of measurement are shown below the horizontal axis.  The horizontal axis has four tick marks.  The vertical axis has two tick marks.  The pairs of numbers denote x(or y) values of the original data points followed by the internal value representation(see section II. Discretization for more about the internal representation of the functions).

	The INFO window is the middle window and displays the same info shown in the GRAPH window, but in text mode.  Depending on the vertical resolution capabilities of your computer, this window may contain two sets of data, the original data points and the internal representation of the data points.

	The OPTION/PROMPT window contains a menu of available options and also will contain questions and information for the user when certain options are performed.

	Membership functions can be manipulated one point at a time, in the case of input functions, or as entire functions(input and output functions).  A selected function will be drawn in magenta and all its points drawn in white, all other functions will be drawn in white.  In the case of input membership functions, a selected point will be drawn in white, all other points of the function drawn in magenta.  This is summarized below.



This color scheme is repeated in the textual representation of the functions in the INFO window.

2. OPTIONS.

SELECT MODE:

DOWN,UP - SELECT FUNCTION.
move down,up respectively the function list to select the next defined function.

RIGHT,LEFT - SELECT POINT.
move right,left respectively to the next point on the selected function

t - PICK FUNCTION.
toggle between selecting an entire function or a single point.

s - SCALE TOGGLE.
For screens with low vertical resolution, only one set of data points will be shown in the INFO window.  's' will toggle which set of data will be shown, either the original data points or the internal representation of the data points.  For screens with both representations(high vertical resolution necessary), 's' will toggle between which representation is within the top half of the INFO window.  For more information about the two representations see section II. Discretization.

r - REDRAW.
Redraws the screen.

n - RENAME FUNCTION.
Allows the user to rename the highlighted membership function.  The new name  cannot be a duplicate of another function within the same input/output.

q - QUIT.
Exit graphics mode and return to previous menu.

a - ADD FUNCTION.
If there is an available slot (i.e. less than 8 functions are defined for the input/output) then this allows a new function to be added.  First the function name must be entered.  Next the user must enter the four points defining the function.
The resulting points may differ from the points entered, see section II Discretization for more about these differences.  Hitting return when prompted for a point will default to the last point entered.  This allows singleton functions and triangular functions to be entered more easily(note this only applies to input functions).  Triangular functions are characterized by having the two or three adjacent points equal.  Singleton functions are characterized by having all points equal.

<CR> - EDIT MODE.
This enters the point/function selected for editing and enters the edit mode.


EDIT MODE:

RIGHT,LEFT - MOVE POINT/FUNCTION.
move the selected point or function right or left respectively.  Movement of points of an input function will be non-linear.  See section II Discretization for a discussion of how points are moved.

s - SCALE TOGGLE.
Same as in SELECT MODE above.

r - REDRAW.
Same as in SELECT MODE above.

q - QUIT.
Exit graphics mode and return to previous menu.

c - COPY FUNCTION.
If there is an available slot (i.e. less than 8 functions are defined for the input/output) then this allows a new function to be added that is identical in shape to the currently selected function.  First the new function name must be entered.  The new function will be placed directly over the old function.

x - DELETE FUNCTION.
The currently selected function will be deleted and the next defined function will become the highlighted function.  Note that the function must have been selected in select mode using the t-pick function  option.

<CR> - EDIT MODE.
This enters the point/function selected for editing and enters the edit mode.


II. Discretization/Round-Off/Truncation:
	
1. How the inference engine interprets functions.
	When an input(respectively output) is defined, minimum and maximum values that the input(respectively output) may take on are also defined.  A user defines an input function by specifying four monotonically increasing points(see figure 4a).  In the case of an output function(a singleton) one point defines the function.  In both cases the points are defined within the domain specified by the minimum and maximum values associated with the input or output.  The inference engine expects values between 0 and 255.  Therefore the original domain is scaled to fit this range.  This applies to the horizontal axis as well, that is, membership values of 0-1 are scaled to 0-255.

	In the case of input(trapezoidal,triangular...) functions, an additonal conversion takes place.  Internally a trapezoid is defined by two points and two slopes(see figure 4a,b).  These four values may only take integral values between 0 and 255.  A slope of 0 is treated as a vertical line.  The trapezoid is treated this way to speed up the fuzzification process within the engine.




2.Discretization problems and how they relate to the interface.
	Scaling the original domain to 0-255 results in truncation errors.  Only 256 discrete points exist along the internal domain, therefore to minimize truncation errors, one should not define a domain with significantly more points(e.g. -1000..5000).  

	Using slopes to define a trapezoidal function and limiting these slopes to integral values has a significant effect on what manipulations can be done to a trapezoid.  When a point is moved it is moved by changing the slope of the line it lies on(see figure 5).  Therefore the horizontal resolution gets coarser the farther one moves from the vertical.  When a point is moved, the user can see the changing slope by looking at the appropriate data value of the selected function in the INFO window(under the POINT SLOPE representation).
			

Trapezoids must have a non-negatively sloped left side and a non-positively sloped right side.  This means that the top must be no larger than the base and the top cannot 'overhang'(This allows 'crisp' or rectangular functions).

	Possibly the most disconcerting affect of discretization and truncation errors occurs when adding a new function.  The first point of a newly added function may take any value within the original domain.  The second point will be used in conjunction with the first to determine a usable value for the second point.  Therefore the point used may differ from the value entered.  This also occurs for third and fourth points.  The process used is described below.

	1.	scale the first point to the 0..255 domain.
	2.	scale the second point.
	3.	calculate the slope from the results of steps 1 and 2, round to the nearest integer.
	4.	calculate the second point from the result of steps 1 and 3.  If this value is within the range 0..255, use it, else adjust the slope and repeat.
	5.	scale both points back to the original domain and use these values.
	
	To define triangular or singleton input membership functions, hit <CR> to repeat the last point!  This not only saves keystrokes but insures that the calculations described above will not be used(so truncation errors will not cause the points to differ).
	If truncation errors make it difficult to create a function precisely, most errors can be mitigated within edit mode by moving points to the desired values.  But be aware that many errors will be unavoidable due to the discretized nature of the internal representation.  
	Truncation error is invisible to the user in the original version.  In this version it is painfully obvious.  Nevertheless one can now be aware of the limitations of the fuzzy engine and can possibly redefine functions to compensate for these limitations.  Good luck!
 nff offff pff33 qff   b+  x                                                                                                                    @      n    n    n    n   n u  n w  n   n   n   n   n   n >  n b  n   n   n   n   n   <          S  n   n   n   n n  n p  n 	  n 	  n 	  n L
  n N
  n .  n 0  n [
  n ]
  n 
  n    n   n   <            n   n   n   n   n +  n -  n ;  n =  n Y  n   n   n   n   n   n (  n h  n j  n   <        j  }  n c  n e  n r  n   n   n   n 6  n 8  n C  n t  n v  n   n ~  n g  n i  n |  n   n   <            n   n   n   n    n   n   n   n   n   n 
  n )  n +  n 6  n g  n i  n }  n   n   <            n   n   n   n   n   n 	  n   n 5  n 8  n k  n   n   n    n    n    n    n    n   <              n !  n !  n #  n #  n #  n $  n $  n &  n &  n &  n '  n ^'  n '  n >(  n A(  n B)  n T*  n   <        T*  b+  n c+  n                                                                                                   <        =/2! ;   -ffff ff33 ff   33 33 33 33ff 3333 33             !   *     0  *     	U      	    r 	=      	I      	       	      	      	_ h  	c      	g      	k      	o      	s      	w      	{      	      	Ƀ      	ʇ      	ʓ      	