Bayesian generators
xopt.generators.bayesian.bayesian_generator.BayesianGenerator ¶
BayesianGenerator(**kwargs)
Bases: Generator
, ABC
Bayesian Generator for Bayesian Optimization.
Attributes:
name : str The name of the Bayesian Generator.
model : Optional[Model] The BoTorch model used by the generator to perform optimization.
n_monte_carlo_samples : int The number of Monte Carlo samples to use in the optimization process.
turbo_controller : SerializeAsAny[Optional[TurboController]] The Turbo Controller for trust-region Bayesian Optimization.
use_cuda : bool A flag to enable or disable CUDA usage if available.
gp_constructor : SerializeAsAny[ModelConstructor] The constructor used to generate the model for Bayesian Optimization.
numerical_optimizer : SerializeAsAny[NumericalOptimizer] The optimizer used to optimize the acquisition function in Bayesian Optimization.
max_travel_distances : Optional[List[float]] The limits for travel distances between points in normalized space.
fixed_features : Optional[Dict[str, float]] The fixed features used in Bayesian Optimization.
computation_time : Optional[pd.DataFrame] A data frame tracking computation time in seconds.
log_transform_acquisition_function: Optional[bool] Flag to determine if final acquisition function value should be log-transformed before optimization.
n_interpolate_samples: Optional[PositiveInt] Number of interpolation points to generate between last observation and next observation, requires n_candidates to be 1.
n_candidates : int The number of candidates to generate in each optimization step.
Methods:
generate(self, n_candidates: int) -> List[Dict]: Generate candidates for Bayesian Optimization.
add_data(self, new_data: pd.DataFrame): Add new data to the generator for Bayesian Optimization.
train_model(self, data: pd.DataFrame = None, update_internal=True) -> Module: Train a Bayesian model for Bayesian Optimization.
propose_candidates(self, model, n_candidates=1) -> Tensor: Propose candidates for Bayesian Optimization.
get_input_data(self, data: pd.DataFrame) -> torch.Tensor: Get input data in torch.Tensor format.
get_acquisition(self, model) -> AcquisitionFunction: Get the acquisition function for Bayesian Optimization.
Source code in xopt/generator.py
60 61 62 63 64 65 66 |
|
Attributes¶
xopt.generators.bayesian.bayesian_generator.BayesianGenerator.model_input_names
property
¶
model_input_names
variable names corresponding to trained model
Functions¶
xopt.generators.bayesian.bayesian_generator.BayesianGenerator.generate ¶
generate(n_candidates)
Generate candidates using Bayesian Optimization.
Parameters:
n_candidates : int The number of candidates to generate in each optimization step.
Returns:
List[Dict] A list of dictionaries containing the generated candidates.
Raises:
NotImplementedError If the number of candidates is greater than 1, and the generator does not support batch candidate generation.
RuntimeError If no data is contained in the generator, the 'add_data' method should be called to add data before generating candidates.
Notes:
This method generates candidates for Bayesian Optimization based on the provided number of candidates. It updates the internal model with the current data and calculates the candidates by optimizing the acquisition function. The method returns the generated candidates in the form of a list of dictionaries.
Source code in xopt/generators/bayesian/bayesian_generator.py
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 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
xopt.generators.bayesian.bayesian_generator.BayesianGenerator.get_acquisition ¶
get_acquisition(model)
Define the acquisition function based on the given GP model.
Parameters:
model : Model The BoTorch model to be used for generating the acquisition function.
Returns:
acqusition_function : AcqusitionFunction
Raises:
ValueError If the provided 'model' is None. A valid model is required to create the acquisition function.
Source code in xopt/generators/bayesian/bayesian_generator.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
|
xopt.generators.bayesian.bayesian_generator.BayesianGenerator.get_input_data ¶
get_input_data(data)
Convert input data to a torch tensor.
Parameters:
data : pd.DataFrame The input data in the form of a pandas DataFrame.
Returns:
torch.Tensor A torch tensor containing the input data.
Notes:
This method takes a pandas DataFrame as input data and converts it into a torch tensor. It specifically selects columns corresponding to the model's input names (variables), and the resulting tensor is configured with the data type and device settings from the generator.
Source code in xopt/generators/bayesian/bayesian_generator.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
xopt.generators.bayesian.bayesian_generator.BayesianGenerator.get_optimum ¶
get_optimum()
select the best point(s) given by the model using the Posterior mean
Source code in xopt/generators/bayesian/bayesian_generator.py
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
|
xopt.generators.bayesian.bayesian_generator.BayesianGenerator.get_training_data ¶
get_training_data(data)
Get training data used to train the GP model
If a turbo controller is specified with the flag restrict_model_data
this
will return a subset of data that is inside the trust region.
Parameters:
data : pd.DataFrame The data in the form of a pandas DataFrame.
Returns:
data : pd.DataFrame A subset of data used to train the model form of a pandas DataFrame.
Source code in xopt/generators/bayesian/bayesian_generator.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
|
xopt.generators.bayesian.bayesian_generator.BayesianGenerator.propose_candidates ¶
propose_candidates(model, n_candidates=1)
given a GP model, propose candidates by numerically optimizing the acquisition function
Source code in xopt/generators/bayesian/bayesian_generator.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
|
xopt.generators.bayesian.bayesian_generator.BayesianGenerator.train_model ¶
train_model(data=None, update_internal=True)
Returns a ModelListGP containing independent models for the objectives and constraints
Source code in xopt/generators/bayesian/bayesian_generator.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
|
xopt.generators.bayesian.bayesian_generator.BayesianGenerator.validate_turbo_controller ¶
validate_turbo_controller(value, info)
note default behavior is no use of turbo
Source code in xopt/generators/bayesian/bayesian_generator.py
225 226 227 228 229 230 231 232 233 234 |
|
xopt.generators.bayesian.bayesian_generator.BayesianGenerator.visualize_model ¶
visualize_model(**kwargs)
displays the GP models
Source code in xopt/generators/bayesian/bayesian_generator.py
546 547 548 |
|
xopt.generators.bayesian.bayesian_exploration.BayesianExplorationGenerator ¶
BayesianExplorationGenerator(**kwargs)
Bases: BayesianGenerator
Source code in xopt/generator.py
60 61 62 63 64 65 66 |
|
xopt.generators.bayesian.mobo.MOBOGenerator ¶
MOBOGenerator(**kwargs)
Bases: MultiObjectiveBayesianGenerator
Source code in xopt/generator.py
60 61 62 63 64 65 66 |
|
Functions¶
xopt.generators.bayesian.mobo.MOBOGenerator.get_acquisition ¶
get_acquisition(model)
Returns a function that can be used to evaluate the acquisition function
Source code in xopt/generators/bayesian/mobo.py
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 |
|
xopt.generators.bayesian.upper_confidence_bound.UpperConfidenceBoundGenerator ¶
UpperConfidenceBoundGenerator(**kwargs)
Bases: BayesianGenerator
Source code in xopt/generator.py
60 61 62 63 64 65 66 |
|