maniospas / dufuz

Discrete numeric fuzzy sets in Python algorithms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DUFuz

Incorporating discrete numeric fuzzy sets in Python algorithms.

Dependencies: numpy, torch, matplotlib, ply
Contact: Manios Krasanakis (maniospas@hotmail.com)
License: Apache 2

This project is currently in unstable alpha.

🚀 Quickstart

The code below demonstrates a bubblesort algorithm that runs on fuzzy inputs on the DUFuz interpreter. A similar implementation can be written with the Python API.

import random
from timeit import default_timer as time
import matplotlib.pyplot as plt

values = [1, 2, 4? or 3.5?1.5, 5?]  # 1 and 2 are not fuzzy
random.shuffle(values)

def bubblesort(values):
    for i in range(len(values)):
        for j in range(i+1, len(values)):
            vali = values[i]
            valj = values[j]
            comparison = vali < valj
            values[i] = vali if comparison else valj
            values[j] = valj if comparison else vali
            
start_time = time()
bubblesort(values)
print("Completed in", time()-start_time, "sec")

axs = plt.subplots(len(values), 1)[1]
for ax, val in zip(axs, values):
    val.plot(ax, True)
plt.show()

About

Discrete numeric fuzzy sets in Python algorithms.


Languages

Language:Python 100.0%