Note

Go to the end to download the full example code.

# Sample several disciplines¶

The `DOEScenario`

class is used to solve trade-off studies,
based on a design space, an objective and optional constraints.
But for a simple need of sampling disciplines,
this class is not very appropriate
because the notions of objective, which is mandatory, and constraints do not make sense
and the same for the log including information related to an optimization problem.
Rather than using this class,
you can consider the `sample_disciplines()`

function
whose API has been designed fro sampling purposes.

```
from __future__ import annotations
from gemseo import sample_disciplines
from gemseo.algos.design_space import DesignSpace
from gemseo.disciplines.analytic import AnalyticDiscipline
```

First, create the disciplines:

```
disciplines = [
AnalyticDiscipline({"y1": "x0+x1+y2"}),
AnalyticDiscipline({"y2": "x0+x2+2*y1"}),
AnalyticDiscipline({"y0": "x0+y1+y2"}),
]
```

Then, create the input space:

```
input_space = DesignSpace()
input_space.add_variable("x0", l_b=0.0, u_b=1.0)
input_space.add_variable("x1", l_b=0.0, u_b=1.0)
input_space.add_variable("x2", l_b=0.0, u_b=1.0)
```

Lastly, sample these disciplines over the input space with the outputs of interest, the number of samples and the name of the DOE algorithm:

```
io_dataset = sample_disciplines(disciplines, input_space, ["y0", "y2"], 10, "fullfact")
io_dataset
```

Note that this function creates an `MDF`

formulation
and samples the top-level disciplines generated by this MDO formulation.
The `formulation`

and `formulation_options`

arguments
allow to customize the MDO formulation
and the options of the DOE algorithm can be passed as keyword arguments.

**Total running time of the script:** (0 minutes 0.111 seconds)