@Override public double[] getLogLikelihoods(List<Beacon> beacons, State[] locations) { List<Beacon> beaconsCleansed = Beacon.filterBeacons(beacons, minRssi, maxRssi); beaconsCleansed = beaconFilter.setBLEBeacon(bleBeacons).filter(beaconsCleansed, locations); BLEBeacon.setBLEBeaconIdsToMeasuredBeacons(bleBeacons, beaconsCleansed); int[] activeBeaconList = ModelAdaptUtils.beaconsToActiveBeaconArray(beaconsCleansed); final double[] ySub = ModelAdaptUtils.beaconsToVecSubset(beaconsCleansed); final double[][] X = ModelAdaptUtils.locationsToMat(locations); // Adjust bias by average bias final double[] rssiBiases = ModelAdaptUtils.biasesToVec(locations); double logLLs[] = null; try { Class<?> cls = gpLDPL.getClass(); Constructor<?> cst = cls.getConstructor(gpLDPL.getClass()); final GaussianProcessLDPLMean gpLDPLtmp = (GaussianProcessLDPLMean) cst.newInstance(gpLDPL); gpLDPLtmp.updateByActiveBeaconList(activeBeaconList); int n = X.length; final double logpro[] = new double[n]; Future<?>[] futures = new Future<?>[n]; for (int i = 0; i < n; i++) { final int idx = i; futures[idx] = ExecutorServiceHolder.getExecutorService() .submit( new Runnable() { public void run() { // Subtract bias from an observation vector. double[] ySubAdjusted = ArrayUtils.addScalar(ySub, -rssiBiases[idx]); logpro[idx] = gpLDPLtmp.logProbaygivenx(X[idx], ySubAdjusted); } }); } for (int i = 0; i < n; i++) { futures[i].get(); } logLLs = logpro; } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { e.printStackTrace(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } return logLLs; }