|
128 | 128 | % This function estimates the gradient and the hessian of the |
129 | 129 | % field at the current agent location. |
130 | 130 |
|
131 | | - field_estimate = obj.position'*obj.QuadModelEst.Q_id*obj.position+obj.QuadModelEst.b_id'*obj.position+obj.QuadModelEst.c_id; |
132 | | - field_data_self = field_data.values(1); |
133 | | - |
134 | | - % We use the following heuristic for identifying the underlying |
135 | | - % field which has been observed to work for an inverted gaussian field: |
136 | | - % 1. If we have less than three data points, we assume a zero |
137 | | - % model since the identfied model wouldn\t be reliable |
138 | | - % 2. If we have three to ten data points, we try to identify a |
139 | | - % linear model which has three model parameters (grad and bias) |
140 | | - % 3. If we have more than ten data points, we identify a |
141 | | - % quadratic model which has 6 model parameters (hess, grad and bias) |
142 | | - data_size=size(field_data.values,2); |
143 | | - if abs(field_estimate-field_data_self) >= obj.field_sensor.noise_bound |
144 | | - if (data_size>=3) && (data_size<10) |
145 | | - obj.QuadModelEst=obj.field_sensor.linear_regression(field_data); |
146 | | - elseif (data_size>=10) |
147 | | - obj.QuadModelEst=obj.field_sensor.quadratic_regression(field_data); |
148 | | - else |
149 | | - obj.QuadModelEst.Q_id = zeros(obj.dim); |
150 | | - obj.QuadModelEst.b_id = zeros(obj.dim,1); |
151 | | - obj.QuadModelEst.c_id = 0; |
152 | | - end |
153 | | - end |
154 | | - grad = 2*obj.QuadModelEst.Q_id*obj.position+obj.QuadModelEst.b_id; |
155 | | - hess = 2*obj.QuadModelEst.Q_id; |
| 131 | +% field_estimate = obj.position'*obj.QuadModelEst.Q_id*obj.position+obj.QuadModelEst.b_id'*obj.position+obj.QuadModelEst.c_id; |
| 132 | +% field_data_self = field_data.values(1); |
| 133 | +% |
| 134 | +% % We use the following heuristic for identifying the underlying |
| 135 | +% % field which has been observed to work for an inverted gaussian field: |
| 136 | +% % 1. If we have less than three data points, we assume a zero |
| 137 | +% % model since the identfied model wouldn\t be reliable |
| 138 | +% % 2. If we have three to ten data points, we try to identify a |
| 139 | +% % linear model which has three model parameters (grad and bias) |
| 140 | +% % 3. If we have more than ten data points, we identify a |
| 141 | +% % quadratic model which has 6 model parameters (hess, grad and bias) |
| 142 | +% data_size=size(field_data.values,2); |
| 143 | +% if abs(field_estimate-field_data_self) >= obj.field_sensor.noise_bound |
| 144 | +% if (data_size>=3) && (data_size<10) |
| 145 | +% obj.QuadModelEst=obj.field_sensor.linear_regression(field_data); |
| 146 | +% elseif (data_size>=10) |
| 147 | +% obj.QuadModelEst=obj.field_sensor.quadratic_regression(field_data); |
| 148 | +% else |
| 149 | +% obj.QuadModelEst.Q_id = zeros(obj.dim); |
| 150 | +% obj.QuadModelEst.b_id = zeros(obj.dim,1); |
| 151 | +% obj.QuadModelEst.c_id = 0; |
| 152 | +% end |
| 153 | +% end |
| 154 | +% grad = 2*obj.QuadModelEst.Q_id*obj.position+obj.QuadModelEst.b_id; |
| 155 | +% hess = 2*obj.QuadModelEst.Q_id; |
156 | 156 |
|
157 | 157 | % Can get the true gradient and hessians at obj.position |
158 | 158 | % for a posterior analysis |
159 | 159 | grad=obj.conc_field.get_true_gradient(obj.position); |
| 160 | + hess=0; |
160 | 161 | %hess=obj.conc_field.get_true_hessian(obj.position); |
161 | 162 | end |
162 | 163 |
|
|
0 commit comments