Internals
_blade(matrix: np.ndarray, *, max_min_dist_ratio: float | None = None, dimensions: tuple[int, ...] = (5, 4, 3, 2, 2, 2), starting_positions: np.ndarray | None = None, pca: bool = False, steps_per_round: int = 200, compute_weight_relative_threshold: Callable[[float], float] = lambda _: 0.1, compute_max_distance_to_walk: Callable[[float, float | None], float | tuple[float, float, float]] = default_compute_max_distance_to_walk, compute_regulation_cursor: Callable[[float], float] = lambda _: 0.1, compute_ratio_step_factors: Callable[[float], float] = default_compute_ratio_step_factors, ratio_rerun: int = 2, draw_steps: bool | list[int] = False, draw_weighted_graph: bool = False, draw_differences: bool = False) -> np.ndarray
Embed an interaction matrix or QUBO with the BLaDE algorithm.
Note
This function is private and not part of the public API. It is documented here for internal reference only.
BLaDE stands for Balanced Latently Dimensional Embedder. It compute positions for nodes so that their interactions approach the desired values. The interactions assume that the interaction coefficient of the device is set to 1. Its typical target is on interaction matrices or QUBOs, but it can also be used for MIS with limitations if the adjacency matrix is converted into a QUBO. The general principle is based on the Fruchterman-Reingold algorithm.
Parameters:
-
(matrixndarray) –An objective interaction matrix or QUBO between the nodes. It must be either symmetrical or triangular.
-
(max_min_dist_ratiofloat | None, default:None) –If present, set the maximum ratio between the maximum radial distance and the minimum pairwise distances.
-
(dimensionstuple[int, ...], default:(5, 4, 3, 2, 2, 2)) –List of numbers of dimensions to explore one after the other. A list with one value is equivalent to a list containing twice the same value. For a 2D embedding, the last value should be 2. Increasing the number of intermediate dimensions can help to escape from local minima.
-
(starting_positionsndarray | None, default:None) –If provided, initial positions to start from. Otherwise, random positions will be generated. The number of dimensions of the starting positions must be lower than or equal to the first dimension to explore. If it is lower, it is added dimensions filled with random values.
-
(pcabool, default:False) –Whether to apply Principal Component Analysis to prioritize dimensions to keep when transitioning from a space to a space with fewer dimensions. It is disabled by default because it can raise an error when there are too many dimensions compared to the number of nodes.
-
(steps_per_roundint, default:200) –Number of elementary steps to perform for each dimension transition, where at each step move vectors are computed and applied on the nodes.
-
(compute_weight_relative_thresholdCallable[[float], float], default:lambda _: 0.1) –Function that is called at each step. It takes a float number between 0 and 1 that represents the progress on the steps. It must return a float number between 0 and 1 that gives a threshold determining which weights are significant (see
update_positionsto learn more). -
(compute_max_distance_to_walkCallable[[float, float | None], float | tuple[float, float, float]], default:default_compute_max_distance_to_walk) –Function that is called at each step. It takes a float number between 0 and 1 that represents the progress on the steps, and takes another argument that is set to
Nonewhenmax_min_dist_ratiois not enabled, otherwise, it is set to the maximum radial distance for the current step. It must return a float number that limits the distances nodes can move at one step (seeupdate_positionsto learn more). -
(compute_regulation_cursorCallable[[float], float], default:lambda _: 0.1) –Function that is called at each step. It takes a float number between 0 and 1 that represents the progress on the steps. It must return a float number between 0 (no regulation) and 1 (full regulation) that uniformizes the ability for the forces to achieve their objectives at each step by changing priorities.
-
(ratio_rerunint, default:2) –When the distance ratio constraint is not met, it defines the maximum number of times the algorithm applies additional computation steps putting the priority on the constraint.
-
(compute_ratio_step_factorsCallable[[float], float], default:default_compute_ratio_step_factors) –Function that is called at the boundaries of the rounds. It defines the target ratio the enforce during the evolution. It acts as a multiplying factor on the target ratio.
-
(draw_stepsbool | list[int], default:False) –If it is a boolean, it defines whether to globally enable drawing and traces for nodes and forces (for all steps). If it is a list of integers, it defines a subset of steps to enable such drawing. Requires installing the seaborn library.
-
(draw_weighted_graphbool, default:False) –For each step with drawing enabled, defines whether to draw a weighted graph representing interactions.
-
(draw_differencesbool, default:False) –For each step with drawing enabled, defines whether to draw the differences between current and target interactions.
Source code in qoolqit/embedding/algorithms/blade/blade.py
387 388 389 390 391 392 393 394 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 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 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 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | |