Deduplicated Generator Base¶
DeduplicatedGeneratorBase
¶
Bases: Generator
Base class for generators that avoid producing duplicate candidates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deduplicate_output
|
bool
|
Whether to perform deduplication on generated candidates. |
True
|
decision_vars_seen
|
ndarray
|
Array of previously seen decision variables, shape (n_seen, n_variables). If None, will be initialized on first generation. |
required |
Notes
Subclasses must implement the _generate method which produces
candidate solutions. The base class handles the deduplication logic.
Deduplication is performed using numpy's unique function to identify
and filter out duplicate decision vectors. The class maintains a history
of all previously seen decision variables to ensure global uniqueness
across multiple generate calls.
Source code in xopt/generators/deduplicated.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
__init__(**kwargs)
¶
Initialize the generator.
Source code in xopt/generator.py
119 120 121 122 123 124 | |
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
140 141 142 143 144 145 146 147 148 149 150 | |
generate(n_candidates)
¶
Generate the unique candidates.
If deduplication is enabled, ensures all returned candidates have unique decision variables that have not been seen before.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_candidates
|
int
|
Number of unique candidates to generate. |
required |
Returns:
| Type | Description |
|---|---|
list of dict
|
List of candidate solutions. |
Notes
When deduplication is enabled, the method may make multiple calls
to the underlying _generate method if duplicates are found, until
the requested number of unique candidates is obtained.
Source code in xopt/generators/deduplicated.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
model_dump(*args, **kwargs)
¶
overwrite model dump to remove faux class attrs
Source code in xopt/generator.py
152 153 154 155 156 157 158 159 160 | |
yaml(**kwargs)
¶
serialize first then dump to yaml string
Source code in xopt/pydantic.py
231 232 233 234 235 236 237 238 | |