.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/run_python_script/02_3_oscillator_optimization_on_EA.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 .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_run_python_script_02_3_oscillator_optimization_on_EA.py: .. _ref_oscillator_optimization_on_EA: Oscillator optimization using EA flow ------------------------------------- This example demonstrates how to create and run a direct optimization. It uses the ``oscillator_optimization_ea.py`` file to create and run a direct optimization for an oscillator with the EA (Evolutionary Algorithm) optimizer. It then explains how you can optionally save the project to a desired location. .. GENERATED FROM PYTHON SOURCE LINES 38-41 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform the required imports. .. GENERATED FROM PYTHON SOURCE LINES 41-45 .. code-block:: Python from ansys.optislang.core import Optislang import ansys.optislang.core.examples as examples .. GENERATED FROM PYTHON SOURCE LINES 46-49 Create optiSLang instance ~~~~~~~~~~~~~~~~~~~~~~~~~ Create the optiSLang instance. .. GENERATED FROM PYTHON SOURCE LINES 49-53 .. code-block:: Python osl = Optislang(ini_timeout=60) print(osl) .. GENERATED FROM PYTHON SOURCE LINES 54-58 Get paths of example scripts and run them ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the paths of the example scripts and then run these scripts. .. GENERATED FROM PYTHON SOURCE LINES 58-62 .. code-block:: Python paths = examples.get_files("oscillator_optimization_ea") osl.application.project.run_python_file(paths[0]) .. GENERATED FROM PYTHON SOURCE LINES 63-66 Run workflow ~~~~~~~~~~~~ Run the workflow created by the preceding scripts. .. GENERATED FROM PYTHON SOURCE LINES 66-69 .. code-block:: Python osl.application.project.start() .. GENERATED FROM PYTHON SOURCE LINES 70-80 Optionally save project ~~~~~~~~~~~~~~~~~~~~~~~ If you want to save the project to some desired location, uncomment and edit these lines: .. code:: python path = r'' osl.application.save_as(os.path.join(path, "test_project.opf")) .. GENERATED FROM PYTHON SOURCE LINES 82-85 Stop and cancel project ~~~~~~~~~~~~~~~~~~~~~~~ Stop and cancel the project. .. GENERATED FROM PYTHON SOURCE LINES 85-88 .. code-block:: Python osl.dispose() .. GENERATED FROM PYTHON SOURCE LINES 89-97 View generated workflow ~~~~~~~~~~~~~~~~~~~~~~~ This image shows the generated workflow. .. image:: ../../_static/02_3_optimization_on_EA.png :width: 400 :alt: Result of script. .. _sphx_glr_download_examples_run_python_script_02_3_oscillator_optimization_on_EA.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 02_3_oscillator_optimization_on_EA.ipynb <02_3_oscillator_optimization_on_EA.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 02_3_oscillator_optimization_on_EA.py <02_3_oscillator_optimization_on_EA.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_