First experiment
Prerequisites: Python + an IDE (a code editor)
Optionally, to more easily manage Python packages, you’ll need a Python package manager.
See the Setup page if you’re missing any of these.
Initialising a code repository
To create and run a Generative Function you need somewhere to store and run the code. This is simply a folder anywhere on your computer that has access to Python.
Create an empty folder
If you are using an IDE (code editor), you can probably do this step there.
We recommend you do not create a venv, which some IDEs will do by default when making a new project, unless you’re already comfortable with virtual environments.
If you want to manage different Python packages per repository, we recommend you use a package manager - see the ‘Advanced’ track in the Setup guide for how to set one up.
Install the Generative packages
Install Generative packages generative-core
and generative-server
from pypi.generative.vision.
Open a terminal window, navigate to the folder you created, and run:
If this is successful, the version of generative.server
will be printed.
If you’re not using a virtual environment (venv), this installs Generative packages globally - so you’d only need to do this once per machine. If you are using a venv then you will need to install generative server inside the venv.
Create an empty folder
If you are using an IDE (code editor), you can probably do this step there.
We recommend you do not create a venv, which some IDEs will do by default when making a new project, unless you’re already comfortable with virtual environments.
If you want to manage different Python packages per repository, we recommend you use a package manager - see the ‘Advanced’ track in the Setup guide for how to set one up.
Install the Generative packages
Install Generative packages generative-core
and generative-server
from pypi.generative.vision.
Open a terminal window, navigate to the folder you created, and run:
If this is successful, the version of generative.server
will be printed.
If you’re not using a virtual environment (venv), this installs Generative packages globally - so you’d only need to do this once per machine. If you are using a venv then you will need to install generative server inside the venv.
This initialisation method assumes you have a Python package manager set up - see the ‘Advanced’ track in the Setup guide for how to set one up.
The steps given are for UV or Poetry, but will be similar for whichever package manager you’re using.
Create an empty folder
If you are using an IDE (code editor), you can probably manage this step there.
Initialise package manager
In the same folder, run:
Follow the instructions to initialise an empty repository.
Add the Generative packages
Run the following to install the generative-core
and generative-server
Python packages as dependencies:
Writing a Generative Function
Create a Python file in your folder. We’ll call the file basic_function.py
, but it can be anything you like.
In the file, define a function which describes the engineering system you want to explore over,
and add the @generative_function
decorator to make it accessible in the app.
For example, copy the below code to define a simple function which divides two numbers.
Connecting to the app
Now you have finished creating your first Generative Function, the next step is to connect to the app to start generating designs.
Start up a local function server
Run the following command from a terminal at the root of your repository or in the folder your Generative Function is in:
When you make changes to your function, manually stop the server (e.g. Ctrl-C in Powershell) and run the above command again.
If you want the server to automatically restart when you make changes to your function, you can remove the --no-reload
option or use --reload
,
but on Windows this is known to not work as expected so we recommend using --no-reload
.
To learn more, see the concepts section.
Login to the app
Account is required to proceed. If you haven’t already, sign up at generative.vision.
Open app
Create an empty project
Create and navigate to an empty project. Under the ‘Experiment’ tab, your local function server will be automatically detected if it’s running on port 3000.
If your function server is not detected, check the logs in your terminal where you’re running the server. If the server started correctly, you should see a link, which will take you the server’s API docs page.
Generating your first designs
You should now have a project open in the app connected to your new Generative Function.
If you haven’t got the Generative Function running on a Function Server, you can go to the app and open a copy of the tutorial project ''.
From here you can use the Generative Function running in our cloud to continue with the rest of the tutorial.
Set up an experiment
Before you start generating designs, you need to constrain the parameters exposed by your Generative Function by giving them values.
For example, set numerator
and denominator
parameters to vary between 0 and 4.
Experiment is set up and ready to generate designs
Click 'Generate' to start
Once you have some values set, you can start generating data for all parameters specified in your Generative Function.
The algorithm will try to work within the constraints you set and generate data that you can visualise next.
Visualising generated data
Navigate to the ‘Discover’ tab. This is where you can visualise the generated data and curate it to find new insights.
You can follow the instructions to create a visualisation of the latest experiment across numerator
, denominator
and output
parameters.
View results on the Discover page
This is a very simple function, but you can already see that the output increases strongly as the denominator approaches 0.
Finished project
Congratulations, you finished the tutorial!
To see the finished project:
- Go to the app
- Open a copy of the tutorial project ''
- Navigate to the ‘Discover’ tab to view generated designs
More learning
Now you’ve run your first experiment, if you want to learn more, check out the key concepts or try a more complex tutorial like exploring tradeoffs of an airfoil design.