Skip to content

Base generator class

xopt.generator

Classes

xopt.generator.Generator
Generator(**kwargs)

Bases: XoptBaseModel, ABC

Initialize the generator.

Source code in xopt/generator.py
60
61
62
63
64
65
66
def __init__(self, **kwargs):
    """
    Initialize the generator.

    """
    super().__init__(**kwargs)
    logger.info(f"Initialized generator {self.name}")
Functions
xopt.generator.Generator.add_data
add_data(new_data)

update dataframe with results from new evaluations.

This is intended for generators that maintain their own data.

Source code in xopt/generator.py
76
77
78
79
80
81
82
83
84
85
86
def add_data(self, new_data: pd.DataFrame):
    """
    update dataframe with results from new evaluations.

    This is intended for generators that maintain their own data.

    """
    if self.data is not None:
        self.data = pd.concat([self.data, new_data], axis=0)
    else:
        self.data = new_data
xopt.generator.Generator.model_dump
model_dump(*args, **kwargs)

overwrite model dump to remove faux class attrs

Source code in xopt/generator.py
88
89
90
91
92
93
94
95
96
def model_dump(self, *args, **kwargs) -> dict[str, Any]:
    """overwrite model dump to remove faux class attrs"""

    res = super().model_dump(*args, **kwargs)

    res.pop("supports_batch_generation", None)
    res.pop("supports_multi_objective", None)

    return res