.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/05_engineering/plot_04_fuzzy_and_paths.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_05_engineering_plot_04_fuzzy_and_paths.py: Fuzzy partitions and robot paths: geometry an expert can judge ============================================================== Two design problems whose quality is easy to see and hard to write down. A fuzzy partition of an input variable should be ordered, cover the domain, and not overlap too much — the interpretability criteria of fuzzy modelling (Setnes et al., 1998; Gacto et al., 2011). A robot path should be short, smooth and keep a safe distance from obstacles. Both problems are *editable*: a person may drag a peak of a membership function or a via point of the path. .. GENERATED FROM PYTHON SOURCE LINES 14-16 Interpretable fuzzy partitions ------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 16-28 .. code-block:: Python import matplotlib.pyplot as plt import easyiec as ei from easyiec.problems import FuzzyPartitionDesign, PathPlanning from easyiec.strategies import InteractiveES, InteractiveGA fuzzy = FuzzyPartitionDesign(n_terms=5) user = ei.SimulatedUser(fuzzy, target="uniform Ruspini", noise=0.04, seed=1) res_f = ei.run(fuzzy, InteractiveES(pop_size=9), user, generations=12, seed=1) print({k: round(v, 3) for k, v in fuzzy.objectives(res_f.best.genome).items()}) ei.viz.plot_history(res_f.log, fuzzy, steps=[0, 4, 11], max_items=9, size=1.0) .. image-sg:: /auto_examples/05_engineering/images/sphx_glr_plot_04_fuzzy_and_paths_001.png :alt: plot 04 fuzzy and paths :srcset: /auto_examples/05_engineering/images/sphx_glr_plot_04_fuzzy_and_paths_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none {'coverage': 0.445, 'max_similarity': 0.354, 'ruspini_error': 0.189}
.. GENERATED FROM PYTHON SOURCE LINES 29-35 Collision-free paths -------------------- The simulated operator penalizes collisions strongly, length and curvature mildly, and rewards clearance. The landscape is rugged — a small move of a via point can cut through an obstacle — and the best path an offline optimizer finds with the same utility scores about 0.8. .. GENERATED FROM PYTHON SOURCE LINES 35-41 .. code-block:: Python paths = PathPlanning(n_via=5, n_obstacles=8, seed=0) user = ei.SimulatedUser(paths, target=None, noise=0.04, seed=2) res_p = ei.run(paths, InteractiveGA(pop_size=9), user, generations=25, seed=2) ei.viz.plot_history(res_p.log, paths, steps=[0, 8, 16, 24], max_items=9, size=0.95) print({k: round(v, 3) for k, v in paths.objectives(res_p.best.genome).items()}, round(res_p.best_true, 3)) plt.show() .. image-sg:: /auto_examples/05_engineering/images/sphx_glr_plot_04_fuzzy_and_paths_002.png :alt: plot 04 fuzzy and paths :srcset: /auto_examples/05_engineering/images/sphx_glr_plot_04_fuzzy_and_paths_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none {'length': 1.806, 'clearance': 0.042, 'collision': 0.0, 'curvature': 0.315} 0.683 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.716 seconds) .. _sphx_glr_download_auto_examples_05_engineering_plot_04_fuzzy_and_paths.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/easyiec/main?urlpath=lab/tree/notebooks/auto_examples/05_engineering/plot_04_fuzzy_and_paths.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_04_fuzzy_and_paths.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_04_fuzzy_and_paths.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_04_fuzzy_and_paths.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_