| Crates.io | fuzzy_logic_engine_rs |
| lib.rs | fuzzy_logic_engine_rs |
| version | 0.9.0 |
| created_at | 2025-11-04 21:39:30.75611+00 |
| updated_at | 2025-11-04 23:59:11.578207+00 |
| description | Fuzzy logic inference engine library in Rust |
| homepage | https://github.com/bieli/fuzzy-logic-engine-rs |
| repository | https://github.com/bieli/fuzzy-logic-engine-rs |
| max_upload_size | |
| id | 1916995 |
| size | 90,449 |
A Rust implementation of a fuzzy inference system (FIS) — inspired by classical fuzzy logic libraries, but designed with Rust’s safety, performance, and ergonomics in mind.
This crate lets you define linguistic variables, membership functions, and rules, then perform fuzzy inference and defuzzification to obtain crisp outputs. It’s useful for decision-making systems, control systems, and AI applications where reasoning with uncertainty is required.
+--------------------------------------+
| fuzzy_logic_engine_rs |
| Rust Fuzzy Inference System Engine |
+--------------------------------------+
Fuzzy logic has always fascinated me because it embraces the shades of gray that classical logic often ignores.
Instead of forcing the world into rigid categories of true or false, it allows us to capture the subtlety of "almost," "somewhat," and "mostly".
This mirrors how humans naturally think and make decisions, blending intuition with reasoning in a way that feels both elegant and practical.
In mathematics, fuzzy sets reveal a beauty where precision and vagueness coexist, showing that uncertainty can be modeled with rigor. In engineering and computer science, fuzzy inference systems transform this beauty into real‑world impact, from robotics to finance to everyday decision support.
What excites me most is how fuzzy logic bridges disciplines: it is at once mathematical, philosophical, and deeply human. It encourages us to see complexity not as a problem to eliminate, but as a richness to embrace and work with. Every fuzzy rule feels like a small story about the world, capturing experience in a form that machines can understand.
Building this Rust library is my way of celebrating that elegance, while also making it accessible for modern, high‑performance applications. Ultimately, fuzzy logic reminds us that the world is not binary, and that’s precisely what makes it so endlessly interesting.
Fuzzy logic extends classical Boolean logic by allowing degrees of truth between 0 and 1.
Instead of saying “the service was good” (true/false), fuzzy logic allows “the service was 0.7 good and 0.3 average.”
Key concepts:
Fuzzy inference systems are widely used in:
Control systems (washing machines, thermostats, robotics)
Decision support (recommendation engines, risk analysis)
AI reasoning under uncertainty
membership.rs[0, 1].impl MembershipKind {
...
/*
μ(x)
^
1.0 | /\
| / \
| / \
0.5 | / \
| / \
0.0 |------/----------\--------->
a b c x
*/
MembershipKind::Triangle { a, b, c }
/*
μ(x)
^
1.0 | _________
| / \
| / \
0.5 | / \
| / \
0.0 |-----/-----------------\--------->
a b c d x
*/
MembershipKind::Trapezoid { a, b, c, d }
/*
μ(x)
^
1.0 | *
| * *
| * *
0.5 | * *
| * *
| * *
0.0 |---*-------------------------*--------->
μ-σ μ μ+σ x
Where:
- σ (sigma) controls the width (spread)
- μ (mu) is the center of the Gaussian (the peak)
*/
MembershipKind::Gauss { sigma, mu }
term.rs
Represents a fuzzy term (e.g., cold, average, generous) with a name and membership function.
variable.rs
Defines a linguistic variable (e.g., temperature, tip) with a range and associated terms.
rule.rs
Encodes fuzzy rules with antecedents (conditions) and consequents (outputs). Supports AND/OR connectives.
math_helpers.rs
Include important utility functions: linspace (for generating vectors values with step) and centroid (center of gravity) method for defuzzification.
output.rs
Output results OutputResult structure with describe() method incl. details for easy debugging outputs.
fis.rs
The fuzzy inference engine.
examples/
Demonstrates a fuzzy logic decission systems with a few real life cases:
[dependencies]
fuzzy_logic_inference_rs = "0.9.0"
Please look at examples/ sub directory.