=Paper=
{{Paper
|id=Vol-1964/PU2
|storemode=property
|title=Proof-of-Concept: Creating "Fuzzy" Sorting Algorithms
|pdfUrl=https://ceur-ws.org/Vol-1964/PU2.pdf
|volume=Vol-1964
|authors=Stephany Coffman-Wolph
|dblpUrl=https://dblp.org/rec/conf/maics/Coffman-Wolph17
}}
==Proof-of-Concept: Creating "Fuzzy" Sorting Algorithms==
Stephany Coffman-Wolph MAICS 2017 pp. 151–156 Proof-of-Concept: Creating “Fuzzy” Sorting Algorithms Stephany Coffman-Wolph West Virginia University Institute of Technology 405 Fayette Pike, Montgomery, West Virginia 25136 sscoffmanwolph@mail.wvu.edu Abstract Kountanis, 2013a]. (In the event that high precision is re- Sorting algorithms are common tools for manipulating data quired, the results from the fuzzy algorithm could be de- and used in both standalone circumstances and within larger fuzzified and run through a non-fuzzy algorithm to complete more complex algorithms. Thus, it is highly desirable for the sorting). sorting algorithms to be efficient in terms of storage and com- putation. By applying the concept of fuzzy logic (an abstract version of Boolean logic) to any well-known algorithm, it generates an abstract version (i.e., fuzzy algorithm) that often Introduction and Background results in computational improvements. Although the algo- The next five sections provide the necessary background rithm may produce a less precise result, this is counteracted by gaining computational efficiency with minimal acceptable materials for this paper. The first section discusses the trade-offs (e.g., small increase in space requirements, loss of three-step fuzzy algorithm framework used to convert a tra- precision). Using an established three-step framework for ditional non-fuzzy algorithm into the corresponding equiva- fuzzification of an algorithm, the resulting new fuzzy algo- lent fuzzy algorithm. The second section briefly discusses rithm goes beyond a simple conversion of data from raw to sorting algorithms and their use within the paper. In the fuzzy data by converting the operators and concepts within the algorithm to their abstract equivalents. The purpose of third section the author discusses types of data and the fuzzy this paper is to demonstrate, as a proof-of-concept, that sort- sorting algorithms. The fourth section covers the notation ing algorithms can be converted into their corresponding used within the paper to denote when an element is fuzzy. fuzzy sorting algorithms. This paper discusses the prelimi- In the final section, the author provides a description of what nary results of: (1) how to apply the general framework by it means to be fuzzily sorted. developing the corresponding fuzzy algorithms for a variety of sort algorithms, (2) the success of applying the framework through the development of several fuzzy sort algorithms in- The Fuzzy Algorithm Framework cluding fuzzy shell sort, fuzzy strand sort, and fuzzy bucket The general broad-spectrum framework for the fuzzification sort, and (3) the possible applications and benefits of these fuzzy sort algorithms. of any algorithm is a simple three-step conversion process that converts any algorithm from a traditional non-fuzzy version into a corresponding fuzzy version [Coffman- Motivation Wolph and Kountanis, 2013b]. The three steps of the frame- work are as follows: Sorting algorithms are used prolifically and have been thor- oughly researched. This resulted in a wealth of algorithm 1. Decide what can/should be fuzzified and determine options for sorting. Every sort algorithm produces the same the category of each piece to be fuzzified result, but many have unique properties or techniques (e.g., 2. Fuzzify each piece (identified in step 1) based on the used for an almost sorted list, reversing a sorted list, or eas- category ily adding an additional value). Given the frequent use of a. Scale/normalize the data, then fuzzify the data sorting algorithms, being able to sort efficiently (in regards b. Fuzzify the operators to both space and time) is highly desirable. If precise sorting c. Fuzzify the concepts is not necessary, a fuzzy sort algorithm could be advanta- 3. Defuzzification (if needed/applicable) geous as fuzzy algorithms take advantage of integer calcu- As can be seen in the framework, there are three main cat- lations and generally execute fewer steps than the equivalent egories of components within an algorithm that can be fuzz- traditional non-fuzzy algorithm [Coffman-Wolph and ified or made more abstract: (1) data, (2) operators, and (3) Copyright held by the author. 151 Proof-of-Concept: Creating “Fuzzy” Sorting Algorithms pp. 151–156 concepts. The fuzzification of data is the process of taking Data “raw”/non-fuzzy data and converting it into fuzzy data. The Sorting algorithms are generally able to handle a wide vari- fuzzification of operators is the process of converting a ety of data types (e.g., numbers, strings, or combinations). mathematical, logical, or comparative operator to its fuzzy The fuzzy sort algorithms will need to have the data “con- counterpart, which operates on fuzzy sets instead of pure verted” to the fuzzy equivalent. Fuzzy algorithms generally numbers. The fuzzification of concepts, the most difficult take advantage of integer calculations and, usually, have the of the three, is the conversion of an idea into a similar fuzzy data in integer format. In the circumstances that require a idea. Together these three core techniques create a fuzzy conversion of non-integer numeric data, it is often accom- algorithm. plished using scaling. A fuzzy number is not a single value, The first and second steps of the framework are needed to but is represented by a set of values. The size/range of val- apply the fuzzy algorithm to a variety of problems. The first ues is problem/data dependent and can also be affected by step of the framework is to make an in-depth examination of the level of precision the user desires. For strings, there are the traditional (non-fuzzy) algorithm and decide which ele- several possibilities for fuzzifying the data including: con- ments to fuzzify. It is often helpful to determine what the verting to a number or considering only the ASCII value solution will look like in the fuzzy form. This will lay the equivalent of the first character (or the first few characters). foundation for the entire fuzzified algorithm. Therefore, it If there is a combination of data (i.e., records from a data- can be helpful to work backwards through the algorithm to base), then a combination of fuzzy data would be required. determine what elements (data, operators, or concepts) need The greatest performance advantage is obtained using inte- to be changed for the solution to be produced. Defuzzifica- ger values, so the closer the data is to an integer format the tion, the opposite of fuzzification, is used to convert the re- better. sult back to a non-fuzzy result and can be applied to data or concepts. In some cases, this step might be unnecessary and, Notation hence, why the framework denotes this step as optional. De- ciding to do defuzzification is both problem and usage de- Throughout this paper, a subscript f will be used to denote pendent. For example, if the fuzzy algorithm is being used when a value, variable, operator, or concept is fuzzy. Given to narrow the solution space and the information will be fed that not everything is required to be fuzzy within a fuzzy into a non-fuzzy algorithm, then it is important to develop a algorithm, the subscript f will help the reader distinguish be- method of defuzzification. tween portions of the algorithm that remain traditional/non- This process has already been successfully applied to the fuzzy and those that have been converted to a corresponding following algorithms: (1) a concept-oriented fuzzification fuzzy version. As mentioned in the previous section, it is for finding fuzzy patterns [Coffman-Wolph and Kountanis, important to keep in mind that a single fuzzy value is repre- 2013c], (2) a fuzzification of both data and the operators for sented by a set of non-fuzzy traditional values. For example, a fuzzy process particle swarm optimization (FP2SO) [Coff- 5f is a “fuzzy-five” and contains the value 5 and possibly the man-Wolph and Kountanis, 2013a], (3) a fuzzification of values 4 and 6 as well (depending on the definition of 5f in multiple algorithm components to find strategies for adver- the context of the problem). In other circumstances, 5f could sarial situations from game theory [Coffman-Wolph, 2013], represent all the real number values in the range of 4.5 to (4) a fuzzification of the simple simplex method for the 6.5. transportation problem [Coffman-Wolph and Coffman, Jr, 2014], (5) the fuzzification of various linear and nonlinear Definition of Fuzzily Sorted search techniques used in optimization algorithms [Coff- A traditional sort algorithm stops when the algorithm has man-Wolph and Coffman, Jr, 2016], and (6) the fuzzifica- guaranteed that all data are sorted in the required order (e.g., tion of the Golden Ratio Search [Coffman-Wolph, 2016]. numerical order, alphabetical order, reverse order, or a com- bination). To proceed with the fuzzification of the sort al- The Sorting Algorithm gorithm, the key question to answer is: when is the dataf Generally, sort algorithms put data “in order”. This paper from a fuzzy sort algorithm considered sorted sufficiently? will explore a variety of sort algorithms ranging from the In general, adding fuzzy logic to an algorithm creates a more simplistic comparison sorts to slightly more complex distri- abstract version of this algorithm. Therefore, with a fuzzy bution sorts. Given the commonality of these sort algo- sort, it will be a more abstract version of the sort algorithm rithms, this paper will focus only on the specific algorithmic and, thus, the output is abstractly sorted. The definition of details needed for fuzzification conversion and skip in-depth “abstractly sorted” will depend on the circumstances of the discussions of the algorithms themselves. To simplify the application and may be problem specific and/or sorting al- discussion, this paper will primarily consider integer data. gorithm specific (i.e., dependent on the fuzzification pro- These concepts are easily extended to other data types as cess). These definitions have one thing in common, that the discussed in the next section. data will not always be perfectly sorted. One could describe 152 Stephany Coffman-Wolph MAICS 2017 pp. 151–156 the data as “slightly out of order”. For a fuzzy sort, one and the un-sorted portion towards the back of the list). Dur- measure could be an associated percentage which represents ing the process of converting the algorithm to a fuzzy algo- the required/desired level of sufficient “sorted-ness”. The rithm, the concept of the xth element will be fuzzified using level or percentage can be adjusted as needed for desired the concept of a fuzzy set [Zadeh, 1965]. For the traditional precision. Another measure, for a fuzzy sort, could be that shell sort, the algorithm takes every xth element within the the results are sorted within a specific number of significant un-sorted portion of the list and sorts them into the correct digits or letters/symbols. sequence before merging them into the sorted portion of the list. In the corresponding fuzzified version of this algorithm, the algorithm will take every xfth set of elements from the The Fuzzy Sort Algorithm un-sorted portion of the list, sortf these elements, and merge The following sections discuss the fuzzification of several these elements into the sortedf portion of the list. The fuzzy well-known sort algorithms including: selection, insertion, shell sorting algorithms would likely have an advantage in bubble, shell, strand, and bucket sort. Each subsection be- situations where data naturally “clusters”. low will focus on how the algorithm is converted from the Consider the following data points: 88, 92, 98, 100, 7, 5, traditional algorithm to a fuzzy algorithm using the three- 3, 13, 17, 15, 24, 36, 42, 57, 55, 73, and 77 to illustration the step framework for conversion. A discussion of the likely fuzzy shell sort (and the traditional shell sort). When using advantages and disadvantages will be included for each of the fuzzy shell sort, the first step is to determine the defini- the sort algorithms. tion of the xfth element(s). For this small of a list, the fuzzy algorithm will use a two-element range at each xfth element. Fuzzy Version of Selection, Insertion, and Bubble Thus, the algorithm will consider the xth element and the Sort (x+1)th element to be the xfth element. The fuzzy algorithm begins by selecting the 5fth elements: (88, 92), (5, 3), (24, Selection, Insertion, and Bubble sorts are three of the most 36), and (73, 77). These elements are sorted, removed from common comparison-based O(n2) sort algorithms [Sedge- the un-sorted portion of the list, and placed into the sorted wick, 1998; Weiss, 1999]. Each algorithm can be easily part of the list: 3, 5, 24, 36, 73, 77, 88, and 92 and the un- converted from the traditional algorithm into a fuzzy equiv- sorted portion is: 98, 100, 7, 13, 17, 15, 42, 57, and 55. The alent version. The comparison operators, < and >, would be next step is to take the 3fth elements which are (98, 100), (17, converted tof to handle the fuzzified data, but the 15), and (57, 55). These elements are sorted into the existing algorithms would otherwise remain unchanged and operate list and removed from the unsorted list: 3, 5, 15, 17, 24, 36, in the same manner. The fuzzy selection, fuzzy insertion, 55, 57, 73, 77, 88, 92, 98, and 100 and the remaining portion and fuzzy bubble sorts do not experience any computational of the unsorted list is: 7, 13, and 42. These last three ele- advantages except the possible use of integer comparisons ments can be sorted into the sorted portion of the list: 3, 5, over more complex data types. Additionally, the output of 7, 13, 15, 17, 24, 36, 42, 55, 57, 73, 77, 88, 92, 98, and 100. these fuzzy sorts would be dependent on the precision level For each of the xfth elements, the only additional processing the user wants to achieve when they fuzzify the data and de- required is a simple swap (as there are only two elements) cide the exact functionality of the f. Therefore, the before sorting and merging. The traditional version of the author concludes that while these algorithms can be con- shell sort algorithm run on the same data set would require verted to their fuzzy equivalents, there is no advantage to do 5 total passes to get the data in numeric order, which is an this unless they are being applied as part of a more complex additional two passes over this fuzzy algorithm version. The sort algorithm (e.g., the bubble sort as a last step in a more author projects from preliminary data that this technique sophisticated sort algorithm). would cut the number of passes in almost half as each pass pulls twice the amount of data. Fuzzy Version of the Shell Sort The traditional shell sort is an “in-place” sort and considered Fuzzy Version of the Strand Sort an abstract version of an insertion sort [Sedgewick, 1998; The strand sort is a fairly straightforward comparison-based Weiss, 1999]. (The comb sort is a very similar “in-place” sorting algorithm. The algorithm looks for strands of in-or- sort but uses the bubble sort as an underlying basis and ba- der data and slowly builds the sorted list [Black, 2008]. The sically differs only at the implementation level). When the following data points: 55, 57, 89, 92, 98, 95, 100, 3, 5, 7, 13, fuzzified version of the shell sort is implemented, the algo- 15, 17, 24, 36, 42, 73, and 77 will be used to demonstrate rithm will be even further abstracted. Both the fuzzy and tra- the fuzzy strand sort (and the traditional strand sort). The ditional versions of the sort use a single list with portions of traditional algorithm begins by creating a sub-list obtained the list designated as sorted and un-sorted. (Traditional im- by comparing each value to the next value and stopping plementations have the sorted portion at the front of the list 153 Proof-of-Concept: Creating “Fuzzy” Sorting Algorithms pp. 151–156 when the next is less than the previous. The traditional al- and above. The numbers could be sorted as follows using gorithm would find the following strand: 55, 57, 89, 92, 98. the fuzzy algorithm (and fuzzy buckets): The remaining elements are: 95, 100, 3, 5, 7, 13, 15, 17, 24, 1. 0, 7, 15, 21 36, 42, 73, and 77. However, the fuzzy version of the strand 2. 24, 36, 50 sort performs fuzzy “less than” comparisons (e.g.,