DifferentiableObjective¶
sgptools.methods.DifferentiableObjective
¶
Bases: Method
Implements informative sensor placement/path planning optimization by directly differentiating through the objective function.
This method leverages TensorFlow's automatic differentiation capabilities to optimize the sensing locations (or path waypoints) by treating them as trainable variables and minimizing a given objective function (e.g., Mutual Information). This approach can be more efficient than black-box methods like Bayesian Optimization or CMA-ES, especially when the objective function is smooth. However, the method is also more prone to getting stuck in local minima.
Attributes:
Name | Type | Description |
---|---|---|
transform |
Optional[Transform]
|
Transform object to apply to the solution. |
X_sol |
Variable
|
The solution (e.g., sensor locations) being optimized. |
objective |
Objective
|
The objective function to be optimized. |
Source code in sgptools/methods.py
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 |
|
__init__(num_sensing, X_objective, kernel, noise_variance, transform=None, num_robots=1, X_candidates=None, num_dim=None, objective='SLogMI', X_init=None, X_time=None, orientation=False, **kwargs)
¶
Initializes the DifferentiableObjective optimizer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_sensing
|
int
|
Number of sensing locations to optimize. |
required |
X_objective
|
ndarray
|
(n, d); Data points used to define the objective function. |
required |
kernel
|
Kernel
|
GPflow kernel function. |
required |
noise_variance
|
float
|
Data noise variance. |
required |
transform
|
Optional[Transform]
|
Transform object to apply to inducing points. Defaults to None. |
None
|
num_robots
|
int
|
Number of robots/agents. Defaults to 1. |
1
|
X_candidates
|
Optional[ndarray]
|
(c, d); Discrete set of candidate locations for sensor placement. Defaults to None. |
None
|
num_dim
|
Optional[int]
|
Dimensionality of the sensing locations. Defaults to dimensonality of X_objective. |
None
|
objective
|
Union[str, Objective]
|
The objective function to use. Can be a string (e.g., 'SLogMI', 'MI') or an instance of an objective class. Defaults to 'SLogMI'. |
'SLogMI'
|
X_init
|
Optional[ndarray]
|
(num_sensing * num_robots, d); Initial solution. If None, initial points are randomly selected from X_objective. |
None
|
X_time
|
Optional[ndarray]
|
(m, d); Temporal dimensions of the inducing points, used when modeling spatio-temporal IPP. Defaults to None. |
None
|
orientation
|
bool
|
If True, adds an additional dimension to model sensor FoV rotation angle when selecting initial inducing points. Defaults to False. |
False
|
**kwargs
|
Any
|
Additional keyword arguments passed to the objective function. |
{}
|
Source code in sgptools/methods.py
get_hyperparameters()
¶
Retrieves the current kernel and noise variance hyperparameters from the objective.
Returns:
Type | Description |
---|---|
Tuple[Kernel, float]
|
Tuple[gpflow.kernels.Kernel, float]: A tuple containing a deep copy of the kernel and the noise variance. |
Source code in sgptools/methods.py
optimize(max_steps=500, optimizer='scipy.L-BFGS-B', verbose=False, **kwargs)
¶
Optimizes the sensor placement/path by differentiating through the objective function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_steps
|
int
|
Maximum number of optimization steps. Defaults to 500. |
500
|
optimizer
|
str
|
Optimizer " |
'scipy.L-BFGS-B'
|
verbose
|
bool
|
Verbosity, if True additional details will by reported. Defaults to False. |
False
|
**kwargs
|
Any
|
Additional keyword arguments for the optimizer. |
{}
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: (num_robots, num_sensing, num_dim); Optimized sensing locations. |
Usage
# Assuming X_train, candidates, kernel_opt, noise_variance_opt are defined
diff_obj_method = DifferentiableObjective(
num_sensing=10,
X_objective=X_train,
kernel=kernel_opt,
noise_variance=noise_variance_opt,
transform=IPPTransform(num_robots=1), # Example transform
X_candidates=candidates
)
optimized_solution = diff_obj_method.optimize(max_steps=500, optimizer='scipy.L-BFGS-B')
Source code in sgptools/methods.py
update(kernel, noise_variance)
¶
Updates the kernel and noise variance parameters of the objective function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kernel
|
Kernel
|
Updated GPflow kernel function. |
required |
noise_variance
|
float
|
Updated data noise variance. |
required |