Note
Go to the end to download the full example code.
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.
Perform required imports#
Perform the required imports.
from ansys.optislang.core import Optislang
import ansys.optislang.core.examples as examples
Create optiSLang instance#
Create the optiSLang instance.
osl = Optislang(ini_timeout=60)
print(osl)
Get paths of example scripts and run them#
Get the paths of the example scripts and then run these scripts.
paths = examples.get_files("oscillator_optimization_ea")
osl.application.project.run_python_file(paths[0])
Run workflow#
Run the workflow created by the preceding scripts.
osl.application.project.start()
Optionally save project#
If you want to save the project to some desired location, uncomment and edit these lines:
path = r'<insert-desired-location>'
osl.application.save_as(os.path.join(path, "test_project.opf"))
Stop and cancel project#
Stop and cancel the project.
osl.dispose()
View generated workflow#
This image shows the generated workflow.