Professional Documents
Culture Documents
Project Description
Implement a basic Fuzzy Logic Processor that utilizes user provided Fuzzy Sets, Fuzzy
Rules and "crisp" input parameters to determine a "crisp" output. The solver will be
implemented in MatLab, follow the standard Fuzzy Logic methodology and will have the
following specifications:
• Fuzzy Sets, Fuzzy Rules & Crisp Inputs will be provided as text (CSV) files
• All antecedent membership functions will be defined using the trapezoidal
function
• Consequent membership grades will be determined using Mamdani's fuzzy
implication method
• The "defuzzification" will implement the Center of Area method to determine
the Crisp Output
Project Flowchart
Fuzzy Sets
(CSV)
CrispInput FuzzyRules
(object) (object)
Fuzzification
(function)
De-Fuzzification
(function)
Crisp Output
(object)
5/5/2014 Page 1 of 8
Object Definitions
Fuzzy Sets
% This function reads in a CSV delimited text file containing the details
% of the fuzzy set and formats the detail in the form of a structure
% array
%
% Input
% file_dir - the path and filename of the CSV file
%
% Output
% output - a FuzzySet object
Crisp Input
5/5/2014 Page 2 of 8
• The number of columns in the input file needs to equal to the number of sets
,excluding the Output set, and contain the crisp value for the set
% This function reads in a CSV delimited text file containing the crisp
% input values and creates a matrix with the values in a column
% corresponding to the order of the sets in FuzzySet. The first row of
% the CSV file should contain a header row that matches the name of the
% sets in the FuzzySet object.
%
% Input
% FuzzySet - a FuzzySet object generated by FLP_LoadFuzzySets
% file_dir - the path and filename of the CSV file
%
% Output
% output - a CrispInput object
Fuzzy Rules
5/5/2014 Page 3 of 8
MatLab Function Definition
function [ output ] = FLP_LoadFuzzyRules( FuzzySet, file_dir )
% FLP_LoadFuzzyRules Reads the fuzzy rules from comma delimited text file
% This function reads in a CSV delimited text file containing the fuzzy
% rules and creates a matrix with the item values in a column
% corresponding to the order of the sets in FuzzySet
%
% Input
% FuzzySet - a FuzzySet object generated by FLP_LoadFuzzySets
% file_dir - the path and filename of the CSV file
%
% Output
% output - a FuzzyRules object
Object Definition
• i - the number of input sets in the Fuzzy Sets
• ji - the number of items in the ith Fuzzy Set
• m - the number of rows CrispInput
• Object will be a {i,1} cell array
• Within each cell, there will be a [m,ji] matrix containing the antecedent membership
grades.
Object Definition
• j - the number of items in the "Output" Fuzzy Set
• m - the number of rows CrispInput
• Object will be a [m,j] matrix containing the consequent membership grades
Crisp Output
Object Definition
• m - the number of rows CrispInput
• Object will be a [m,1] matrix containing the crisp output values
5/5/2014 Page 4 of 8
Function Definitions
Fuzzification
Algorithm:
Input: FuzzySet Object, CrispInput Object
Output: Antecedent Membership Grades
Algorithm:
Input: Antecedent Membership Grades (AMG), FuzzyRules Object
Output: Consequent Membership Grades
5/5/2014 Page 5 of 8
Matlab Function Definition
function [ consequentGrades ] = FLP_FuzzyRuleEval( AntMemberGrades, FuzzyRules )
% FLP_FuzzyRuleEval Evaluates Fuzzy Rules & Consequent Membership Grades
%
% Based on the antecedent membership grades, each of the fuzzy rules is
% evaluated using the Mamdani procedure. The Mamdani procedure consists of
% taking the minimum antecedant grade as the membership grade for the rule.
% The consequent membership grade is then determined by taking the maximum
% of the rule grades for each consequent.
%
% Input
% AntMemberGrades - a antecedent membership grade object generated by FLP_Fuzzification
% FuzzyRules - a fuzzy rules object generated by FLP_LoadFuzzyRules
%
% Output
% the consequent membership grades
De-Fuzzification
Algorithm:
Input: Consequent Membership Grades (CMG), FuzzySet Object
Output: CrispOutput
5/5/2014 Page 6 of 8
Helper Functions
5/5/2014 Page 7 of 8
References
Dourra H., Siy P. (2002). Investment using technical analysis and fuzzy logic, Fuzzy Sets
and Systems, Volume 127, Issue 2, Pages 221-240
Iancu I. (2012). A Mamdani Type Fuzzy Logic Controller, Fuzzy Logic - Controls, Concepts,
Theories and Applications, Prof. Elmer Dadios (Ed.), ISBN: 978-953-51-0396-7, InTech
Mamdani, E., Assilian S. (1975), An experiment in linguistic synthesis with a fuzzy logic
controller, International journal of man-machine studies 7, no. 1, Pages 1-13
5/5/2014 Page 8 of 8