QFIE package
QFIE.FuzzyEngines module
This module implements the base class for setting up the quantum fuzzy inference engine proposed in doi: 10.1109/TFUZZ.2022.3202348.
- class QFIE.FuzzyEngines.QuantumFuzzyEngine(verbose=True)[source]
Bases:
objectClass implementing the Quantum Fuzzy Inference Engine proposed in:
G. Acampora, R. Schiattarella and A. Vitiello, “On the Implementation of Fuzzy Inference Engines on Quantum Computers,” in IEEE Transactions on Fuzzy Systems, 2022, doi: 10.1109/TFUZZ.2022.3202348.
- add_input_fuzzysets(var_name, set_names, sets)[source]
Set the partition for the input fuzzy variable ‘var_name’.
- Parameters:
var_name (str) – name of the fuzzy variable defined with input_variable method previously.
set_names (list) – list of fuzzy sets’ name as str.
sets (list) – list of scikit-fuzzy membership function objects.
- Returns:
None
- add_output_fuzzysets(var_name, set_names, sets)[source]
Set the partition for the output fuzzy variable ‘var_name’.
- Parameters:
var_name (str) – name of the fuzzy variable defined with output_variable method previously.
set_names (list) – list of fuzzy sets’ name as str.
sets (list) – list of scikit-fuzzy membership function objects.
- Returns:
None
- build_inference_qc(input_values, draw_qc=False)[source]
This function builds the quantum circuit implementing the QFIE, initializing the input quantum registers according to the ‘input_value’ argument.
- Parameters:
input_values (dict) – dictionary containing the crisp input values of the system. E.g. {‘var_name_1’ (str): x_1 (float), …, ‘var_name_n’ (str): x_n (float)}
draw_qc (Boolean) – True for drawing the quantum circuit built. False otherwise.
- Returns:
None
- counts_evaluator(n_qubits, counts)[source]
Function returning the alpha values for alpha-cutting the output fuzzy sets according to the probability of measuring the related basis states on the output quantum register.
- Parameters:
n_qubits (int) – number of qubits in the output quantum register.
counts (dict) – counting dictionary of the output quantum register measurement.
- Returns:
alpha values for alpha-cutting the output fuzzy sets as ‘dict’.
- execute(backend_name, n_shots, provider=None, plot_histo=False, GPU=False)[source]
Run the inference engine.
- Parameters:
backend_name (str) –
IBMQ backend to use for computing.
Use “qasm_simulator” to simulate the run.
For real devices an IBMQ provider is required.
n_shots (int) – Number of shots.
provider (str) –
IBMQ Provider.
Default ‘None’ to use with ‘qasm_simulator’ backend
plot_histo (Boolean) – True for plotting the counts histogram. False Otherwise.
GPU (Boolean) – True for using GPU for simulation. Use False if backend is a real device.
- Returns:
Crisp output of the system.
- input_variable(name, range)[source]
Define the input variable “name” of the system.
- Parameters:
name (str) – Name of the variable as string.
range (np array) – Universe of the discourse for the input variable.
- Returns:
None
- output_variable(name, range)[source]
Define the output variable “name” of the system.
- Parameters:
name (str) – Name of the variable as string.
range (np array) – Universe of the discourse for the output variable.
- Returns:
None
QFIE.QFS module
- QFIE.QFS.convert_rule(qc, fuzzy_rule, partitions, output_partition)[source]
Function which convert a fuzzy rule in the equivalent quantum circuit. You can use multiple times convert_rule to concatenate the quantum circuits related to different rules.
- QFIE.QFS.generate_circuit(fuzzy_partitions)[source]
Function generating a quantum circuit with width required by QFS