Descriptors

Descriptors specify what kinds of values are valid for a parameter. There are currently, 2 variants: RangeDescriptor and CategoryDescriptor.
(Note that even though their names end with Parameter, they are actually descriptors, not parameters.)
from besos.parameters import (
    RangeDescriptor,
    CategoryDescriptor,
    Parameter,
)
from besos.problem import Problem
from besos import sampling
from besos.evaluator import EvaluatorGeneric

RangeDescriptors

\(min \leq x \leq max\)

zero_to_one_exclusive = RangeDescriptor(min_val=0.01, max_val=0.99)

CategoryDescriptors

A list of options.

text_example = CategoryDescriptor(options=["a", "b", "c", "other"])
single_digit_integers = CategoryDescriptor(options=range(10))

Sampling

These descriptors can be used to make Parameters. Then we can generate samples.

parameters = [
    Parameter(value_descriptors=zero_to_one_exclusive, name="0-1"),
    Parameter(value_descriptors=single_digit_integers, name="single digit"),
    Parameter(value_descriptors=text_example, name="text"),
]
problem = Problem(parameters, outputs=["output"])

samples = sampling.dist_sampler(sampling.lhs, problem, num_samples=10)
samples
0-1 single digit text
0 0.380019 9 a
1 0.586379 3 a
2 0.204224 7 b
3 0.616832 5 c
4 0.424950 1 c
5 0.029658 2 c
6 0.796134 8 other
7 0.913143 6 other
8 0.290977 4 b
9 0.758265 0 a

Evaluation

Since we did not specify selectors for the parameters, we cannot evaluate them using an EnergyPlus simulation. Instead, we will use a custom evaluation function.

def evaluation_function(values):
    x, y, z = values
    if z == "other":
        return (x,)
    else:
        return (x * y,)


evaluator = EvaluatorGeneric(evaluation_function, problem)
# The evaluator will use this objective by default
outputs = evaluator.df_apply(samples, keep_input=True)
# outputs is a pandas dataframe with one column since only one objective was requested
HBox(children=(FloatProgress(value=0.0, description='Executing', max=10.0, style=ProgressStyle(description_wid…
outputs
0-1 single digit text output
0 0.380019 9 a 3.420167
1 0.586379 3 a 1.759137
2 0.204224 7 b 1.429571
3 0.616832 5 c 3.084161
4 0.424950 1 c 0.424950
5 0.029658 2 c 0.059316
6 0.796134 8 other 0.796134
7 0.913143 6 other 0.913143
8 0.290977 4 b 1.163907
9 0.758265 0 a 0.000000