Nelder-Mead Generator¶
NelderMeadGenerator
¶
Bases: SequentialGenerator
Nelder-Mead algorithm from SciPy in Xopt's Generator form. Converted to use a state machine to resume in exactly the last state.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the generator. |
initial_point |
Optional[Dict[str, float]]
|
Initial point for the optimization. |
initial_simplex |
Optional[Dict[str, Union[List[float], ndarray]]]
|
Initial simplex for the optimization. |
adaptive |
bool
|
Change hyperparameters based on dimensionality. |
current_state |
SimplexState
|
Current state of the simplex. |
future_state |
Optional[SimplexState]
|
Future state of the simplex. |
x |
Optional[ndarray]
|
Current x value. |
y |
Optional[float]
|
Current y value. |
Methods:
| Name | Description |
|---|---|
add_data |
Add new data to the generator. |
generate |
Generate a specified number of candidate samples. |
_call_algorithm |
Call the Nelder-Mead algorithm. |
simplex |
Returns the simplex in the current state. |
Source code in xopt/generators/sequential/neldermead.py
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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
simplex
property
¶
Returns the simplex in the current state.
Returns:
| Type | Description |
|---|---|
Dict[str, ndarray]
|
The simplex in the current state. |
x0
property
¶
Raw internal initial point for convenience. If initial_point is set, it will be used. Otherwise, if data is set, the last point will be used.
Returns:
| Type | Description |
|---|---|
ndarray
|
The initial point as a NumPy array. |
add_data(new_data)
¶
Add new data to the generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_data
|
DataFrame
|
The new data to add. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the generator is active but no candidate was generated, or if the new data does not contain the last candidate. |
Source code in xopt/generators/sequential/sequential_generator.py
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 | |
generate(n_candidates=1)
¶
Generate a new candidate point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_candidates
|
int
|
Number of candidates to generate, by default 1. |
1
|
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary representing the candidate point. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If more than one candidate is requested. |
Source code in xopt/generators/sequential/sequential_generator.py
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 | |
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 | |
reset()
¶
Reset the generator.
Source code in xopt/generators/sequential/sequential_generator.py
167 168 169 170 171 172 173 | |
set_data(data)
¶
Set the full dataset for the generator. Typically only used when loading from a save file. This skips active generator lockout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
The data to set. |
required |
Source code in xopt/generators/sequential/sequential_generator.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
validate_point(point)
¶
determine if an input point was generated by the generator
Source code in xopt/generators/sequential/sequential_generator.py
60 61 62 63 64 65 66 67 68 69 70 71 72 | |
yaml(**kwargs)
¶
serialize first then dump to yaml string
Source code in xopt/pydantic.py
231 232 233 234 235 236 237 238 | |
SimplexState
¶
Bases: XoptBaseModel
Container model for all simplex parameters
Source code in xopt/generators/sequential/neldermead.py
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 | |
yaml(**kwargs)
¶
serialize first then dump to yaml string
Source code in xopt/pydantic.py
231 232 233 234 235 236 237 238 | |