Transformations¶
sgptools.core.transformations.Transform
¶
Base class for transformations applied to inducing points in sparse Gaussian process models. This class defines common interfaces for expanding inducing points (e.g., to model sensor fields of view or continuous paths) and aggregating kernel matrices. It also provides a base for adding constraint terms to the optimization objective.
Refer to the following papers for more details
- Efficient Sensor Placement from Regression with Sparse Gaussian Processes in Continuous and Discrete Spaces [Jakkala and Akella, 2023]
- Multi-Robot Informative Path Planning from Regression with Sparse Gaussian Processes [Jakkala and Akella, 2024]
Source code in sgptools/core/transformations.py
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 |
|
__init__(aggregation_size=None, constraint_weight=1.0, **kwargs)
¶
Initializes the base Transform class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
aggregation_size
|
Optional[int]
|
Number of consecutive inducing points to aggregate when transforming kernel matrices. If None, no aggregation is performed. Defaults to None. |
None
|
constraint_weight
|
float
|
A scalar weight that controls the importance of the constraint terms in the SGP's optimization objective function. A higher weight means stronger enforcement of constraints. Defaults to 1.0. |
1.0
|
**kwargs
|
Any
|
Additional keyword arguments to be passed to the constructor. |
{}
|
Source code in sgptools/core/transformations.py
aggregate(k)
¶
Applies an aggregation transform to kernel matrices. This is typically used
to reduce the size of kernel matrices after expansion, by averaging or summing
over groups of expanded points. This can reduce computational cost for
matrix inversions (e.g., in Kuu
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
k
|
Tensor
|
The input kernel matrix.
Can be (mp, mp) for |
required |
Returns:
Type | Description |
---|---|
Tensor
|
tf.Tensor: The aggregated kernel matrix. Shape: (m, m) if input was (mp, mp), or (m, n) if input was (mp, n). |
Source code in sgptools/core/transformations.py
constraints(Xu)
¶
Computes constraint terms that are added to the SGP's optimization function (ELBO). This base implementation returns a zero tensor, implying no constraints by default. Subclasses should override this to implement specific constraints (e.g., path length budget).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Xu
|
Tensor
|
The inducing points, from which to compute the constraints. Shape: (m, d). |
required |
Returns:
Type | Description |
---|---|
Tensor
|
tf.Tensor: A scalar tensor representing the constraint penalty. Defaults to 0.0. |
Source code in sgptools/core/transformations.py
expand(Xu)
¶
Applies an expansion transform to the inducing points. In this base class, it simply returns the input inducing points unchanged. Subclasses should override this method to implement specific expansion logic.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Xu
|
Union[ndarray, Tensor]
|
The input inducing points.
Shape: (m, d) where |
required |
Returns:
Type | Description |
---|---|
Union[ndarray, Tensor]
|
Union[np.ndarray, tf.Tensor]: The expanded inducing points. |
Source code in sgptools/core/transformations.py
sgptools.core.transformations.IPPTransform
¶
Bases: Transform
Transform to model Informative Path Planning (IPP) problems for single or multiple robots. It handles continuous sensing, non-point fields of view (FoV), and distance constraints.
- For point sensing (discrete waypoints), set
sampling_rate = 2
. - For continuous sensing along paths, set
sampling_rate > 2
to interpolate additional points between waypoints for information gathering. - For continuous sensing with aggregation for computational efficiency,
set
sampling_rate > 2
andaggregate_fov = True
. This averages covariances from interpolated points, potentially diminishing solution quality slightly. - If using a non-point FoV model (e.g.,
SquareTransform
) with continuous sampling, only the FoV inducing points are aggregated. - For multi-robot scenarios, set
num_robots > 1
. - For online IPP where some visited waypoints are fixed, use
update_Xu_fixed
to freeze these waypoints from further optimization.
Source code in sgptools/core/transformations.py
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 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 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 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
|
__init__(sampling_rate=2, distance_budget=None, num_robots=1, Xu_fixed=None, num_dim=2, sensor_model=None, aggregate_fov=False, **kwargs)
¶
Initializes the IPPTransform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sampling_rate
|
int
|
Number of points to sample along each segment between two
consecutive inducing points. |
2
|
distance_budget
|
Optional[float]
|
The maximum allowable total path length for each robot. If None, no distance constraint is applied. Defaults to None. |
None
|
num_robots
|
int
|
The number of robots or agents involved in the IPP problem. Defaults to 1. |
1
|
Xu_fixed
|
Optional[ndarray]
|
(num_robots, num_visited, num_dim); An array of pre-defined, fixed waypoints that should not be optimized (e.g., already visited locations in online IPP). If None, all waypoints are optimizable. Defaults to None. |
None
|
num_dim
|
int
|
The dimensionality of the inducing points (e.g., 2 for (x,y), 3 for (x,y,angle)). Defaults to 2. |
2
|
sensor_model
|
Optional[Transform]
|
A |
None
|
aggregate_fov
|
bool
|
If True, and |
False
|
**kwargs
|
Any
|
Additional keyword arguments passed to the base |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If |
Usage
# Single robot, point sensing
transform_point = IPPTransform(num_robots=1, num_dim=2, sampling_rate=2)
# Single robot, continuous sensing
transform_continuous = IPPTransform(num_robots=1, num_dim=2, sampling_rate=10)
# Multi-robot, continuous sensing with distance budget
transform_multi_budget = IPPTransform(num_robots=2, num_dim=2, sampling_rate=5, distance_budget=50.0, constraint_weight=100.0)
Source code in sgptools/core/transformations.py
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 |
|
aggregate(k)
¶
Applies the aggregation transform to kernel matrices.
If a sensor_model
is defined, it delegates aggregation to the sensor model.
Otherwise, it uses the base class's aggregation logic (which depends on self.aggregation_size
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
k
|
Tensor
|
The input kernel matrix (e.g., K_expanded_expanded, K_expanded_training). |
required |
Returns:
Type | Description |
---|---|
Tensor
|
tf.Tensor: The aggregated kernel matrix. |
Source code in sgptools/core/transformations.py
constraints(Xu)
¶
Computes the distance constraint term that is added to the SGP's optimization function.
Each robot's path length is constrained by distance_budget
. A penalty is applied
if the path length exceeds the budget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Xu
|
Tensor
|
The inducing points (waypoints) from which to compute path lengths. Shape: (num_robots * num_waypoints, num_dim). |
required |
Returns:
Type | Description |
---|---|
Tensor
|
tf.Tensor: A scalar tensor representing the total distance constraint penalty. This value is negative, and its magnitude increases with constraint violation. |
Source code in sgptools/core/transformations.py
distance(Xu)
¶
Computes the total path length(s) incurred by sequentially visiting the inducing points. For multiple robots, returns a tensor of individual path lengths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Xu
|
Tensor
|
The inducing points (waypoints) from which to compute the path lengths.
Shape: (total_waypoints, num_dim). This input is typically already
expanded to include fixed points if |
required |
Returns:
Type | Description |
---|---|
Tensor
|
tf.Tensor: A scalar tensor if |
Source code in sgptools/core/transformations.py
expand(Xu, expand_sensor_model=True)
¶
Applies the expansion transform to the inducing points based on the IPP settings.
This can involve:
1. Adding fixed (already visited) waypoints.
2. Interpolating points between waypoints for continuous sensing.
3. Expanding each point into a sensor's Field of View (FoV) if a sensor_model
is present.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Xu
|
Tensor
|
The current set of optimizable inducing points.
Shape: (num_robots * num_optimizable_waypoints, num_dim).
Note: |
required |
expand_sensor_model
|
bool
|
If True, applies the |
True
|
Returns:
Type | Description |
---|---|
Tensor
|
tf.Tensor: The expanded inducing points, ready for kernel computations.
Shape: (total_expanded_points, d_output), where |
Source code in sgptools/core/transformations.py
update_Xu_fixed(Xu_fixed)
¶
Updates the set of visited (fixed) waypoints for online IPP scenarios. These waypoints will not be optimized in subsequent steps.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Xu_fixed
|
ndarray
|
A NumPy array of shape (num_robots, num_visited_waypoints, num_dim) representing the new set of fixed waypoints. |
required |
Source code in sgptools/core/transformations.py
sgptools.core.transformations.SquareTransform
¶
Bases: Transform
Non-point Transform to model a square Field of View (FoV) for a sensor.
This transform expands each inducing point (waypoint with position and orientation)
into a grid of points approximating a square area, which is then used in kernel computations.
This typically applies to single-robot cases as part of an IPPTransform
.
Source code in sgptools/core/transformations.py
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 |
|
__init__(side_length, pts_per_side, aggregate_fov=False, **kwargs)
¶
Initializes the SquareTransform for a square FoV.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
side_length
|
float
|
The side length of the square FoV. |
required |
pts_per_side
|
int
|
The number of points to sample along each side of the square.
A |
required |
aggregate_fov
|
bool
|
If True, aggregation will be enabled for the expanded FoV points. This averages covariances from the FoV points to reduce computational cost. Defaults to False. |
False
|
**kwargs
|
Any
|
Additional keyword arguments passed to the base |
{}
|
Usage
Source code in sgptools/core/transformations.py
distance(Xu)
¶
Computes the Euclidean distance incurred by sequentially visiting the inducing points. For a Square FoV, the distance is typically only based on the (x,y) movement, ignoring the angle.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Xu
|
Tensor
|
Inducing points.
Shape: (m, 3) where |
required |
Returns:
Type | Description |
---|---|
Tensor
|
tf.Tensor: A scalar tensor representing the total path length. |
Source code in sgptools/core/transformations.py
enable_aggregation(size=None)
¶
Enables FoV covariance aggregation. This reduces the covariance matrix inversion cost by effectively reducing the covariance matrix size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
Optional[int]
|
If None, all the interpolated inducing points within the FoV
(i.e., |
None
|
Source code in sgptools/core/transformations.py
expand(Xu)
¶
Applies the expansion transformation to the inducing points, modeling a square FoV.
Each input inducing point, which includes position (x, y) and orientation (theta),
is expanded into a grid of pts_per_side
x pts_per_side
points representing the FoV.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Xu
|
Tensor
|
Inducing points in the position and orientation space.
Shape: (m, 3) where |
required |
Returns:
Type | Description |
---|---|
Tensor
|
tf.Tensor: The expanded inducing points in 2D input space (x,y).
Shape: (m * pts_per_side * pts_per_side, 2).
|
Source code in sgptools/core/transformations.py
sgptools.core.transformations.SquareHeightTransform
¶
Bases: Transform
Non-point Transform to model a height-dependent square Field of View (FoV). The size of the square FoV changes with the 'height' (z-dimension) of the sensor. This transform expands each inducing point (waypoint with x, y, z coordinates) into a grid of points approximating a square area whose size depends on 'z'.
Source code in sgptools/core/transformations.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 |
|
__init__(pts_per_side, aggregate_fov=False, **kwargs)
¶
Initializes the SquareHeightTransform for a height-dependent square FoV.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pts_per_side
|
int
|
The number of points to sample along each side of the square FoV.
A |
required |
aggregate_fov
|
bool
|
If True, aggregation will be enabled for the expanded FoV points. This averages covariances from the FoV points to reduce computational cost. Defaults to False. |
False
|
**kwargs
|
Any
|
Additional keyword arguments passed to the base |
{}
|
Usage
Source code in sgptools/core/transformations.py
distance(Xu)
¶
Computes the Euclidean distance incurred by sequentially visiting the inducing points. For a height-dependent Square FoV, the distance is typically only based on the (x,y,z) movement.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Xu
|
Tensor
|
Inducing points.
Shape: (m, 3) where |
required |
Returns:
Type | Description |
---|---|
Tensor
|
tf.Tensor: A scalar tensor representing the total path length. |
Source code in sgptools/core/transformations.py
enable_aggregation(size=None)
¶
Enables FoV covariance aggregation, which reduces the covariance matrix inversion cost by effectively reducing the covariance matrix size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
Optional[int]
|
If None, all the interpolated inducing points within the FoV
(i.e., |
None
|
Source code in sgptools/core/transformations.py
expand(Xu)
¶
Applies the expansion transform to the inducing points
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Xu
|
ndarray
|
(m, 3); Inducing points in the 3D position space.
|
required |
Returns:
Name | Type | Description |
---|---|---|
Xu |
ndarray
|
(mp, 2); Inducing points in input space.
|