The Xfuzzy 3 development environment

The Java code generation tool - Xfj

The tool xfj generates a Java representation of the fuzzy system. The tool can be executed from the command line, with the expression "xfj [-p package] file.xfl [out_dir]" or from the Synthesis menu in the main window of the environment. When invoked from the command line no graphical interface is shown. In this case the Java code files are generated in the output directory specified when executing the tool (or in the directory that contains the system file, if nothing else is indicated), and a package instruction is added in the Java classes when the -p option is used. When xfj is invoked from the Xfuzzy main window, the package name and the target directory can be chosen in the tool graphical user interface.

Given the specification of a fuzzy system in XFL3 format, systemname.xfl, the tool generates four files:,,, and The first three files are descriptions of two interfaces and one class that are common to all fuzzy inference systems, while the last one contains the specific description of the fuzzy system.

The file describes a Java interface defining a general fuzzy inference system. This interface defines four methods to implement the inference process with crisp and fuzzy values.

public interface FuzzyInferenceEngine {
 public double[] crispInference(double[] input);
 public double[] crispInference(MembershipFunction[] input);
 public MembershipFunction[] fuzzyInference(double[] input);
 public MembershipFunction[] fuzzyInference(MembershipFunction[] input);

The file contains the description of an interface used to describe a fuzzy number. It has just one method, called compute, which computes the membership degree for each value of the universe of discourse of the fuzzy number.

public interface MembershipFunction {
 public double compute(double x);

The class FuzzySingleton implements the MembershipFunction interface, and represents a crisp value as a fuzzy number.

public class FuzzySingleton implements MembershipFunction {
 private double value;

 public FuzzySingleton(double value) { this.value = value; }
 public double getValue() { return this.value; }
 public double compute(double x) { return (x==value? 1.0: 0.0); }

Finally, the contains the class which describes the fuzzy system. This class is an implementation of the interface FuzzyInferenceEngine. Hence, the public methods which develop the inference are those of the interface (crispInference and fuzzyInference).

For comments, patches, bug reports, etc contact us at:

©IMSE-CNM 2018