.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/05_engineering/plot_01_pid_tuning.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_01_pid_tuning.py: PID tuning by looking at step responses ======================================= Control engineers judge a loop by its step response — rise, overshoot, oscillation, the effort of the actuator, the recovery after a load disturbance — and weigh these properties differently from plant to plant. This was the first application of EASY-IEC (Madár, Abonyi and Szeifert, 2005). The plant is a first-order process with dead time, :math:`G(s)=Ke^{-\theta s}/(\tau s+1)`; the controller is a two-degree-of-freedom PID with setpoint weight *b* and derivative filter *N*. The SIMC rules of Skogestad (2003) give a well-known reference tuning. .. GENERATED FROM PYTHON SOURCE LINES 16-18 An evaluator who prefers the SIMC response ------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 18-30 .. code-block:: Python import matplotlib.pyplot as plt import easyiec as ei from easyiec.problems import PIDTuning from easyiec.strategies import EasyIEC problem = PIDTuning(K=1.0, tau=10.0, theta=3.0) simc = problem.presets()["SIMC"] print(problem.describe(simc)) user = ei.SimulatedUser(problem, target="SIMC", noise=0.04, seed=3) result = ei.run(problem, EasyIEC(pop_size=9), user, generations=12, seed=3) print(problem.describe(result.best.genome)) .. rst-class:: sphx-glr-script-out .. code-block:: none PID controller Kc=1.67, Ti=10 s, Td=0.011 s, b=1.00, N=10.0. Setpoint step: IAE=6.58, overshoot=4.5 %, settling time=18.4 s; disturbance IAE=3.51; control-signal total variation=1.77. PID controller Kc=1.69, Ti=7.95 s, Td=0.109 s, b=0.78, N=7.5. Setpoint step: IAE=7.21, overshoot=4.4 %, settling time=21.7 s; disturbance IAE=2.82; control-signal total variation=1.64. .. GENERATED FROM PYTHON SOURCE LINES 31-33 The first and the last gallery ------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 33-35 .. code-block:: Python ei.viz.plot_history(result.log, problem, steps=[0, 11], max_items=9, size=1.25) .. image-sg:: /auto_examples/05_engineering/images/sphx_glr_plot_01_pid_tuning_001.png :alt: plot 01 pid tuning :srcset: /auto_examples/05_engineering/images/sphx_glr_plot_01_pid_tuning_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 36-38 Best response against the SIMC reference ---------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 38-45 .. code-block:: Python fig, axes = plt.subplots(1, 3, figsize=(11, 3.2)) for ax, (lab, x) in zip(axes, [("sluggish preset", problem.presets()["sluggish"]), ("SIMC (Skogestad, 2003)", simc), ("best found by IEC", result.best.genome)]): problem.render(x, ax=ax) o = problem.objectives(x) ax.set_title(f"{lab}\nIAE {o['iae']:.1f}, overshoot {o['overshoot']:.0f} %", fontsize=8) plt.show() .. image-sg:: /auto_examples/05_engineering/images/sphx_glr_plot_01_pid_tuning_002.png :alt: sluggish preset IAE 38.5, overshoot 0 %, SIMC (Skogestad, 2003) IAE 6.6, overshoot 5 %, best found by IEC IAE 7.2, overshoot 4 % :srcset: /auto_examples/05_engineering/images/sphx_glr_plot_01_pid_tuning_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.993 seconds) .. _sphx_glr_download_auto_examples_05_engineering_plot_01_pid_tuning.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_01_pid_tuning.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_pid_tuning.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_pid_tuning.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_pid_tuning.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_