| 284 | } |
| 285 | |
| 286 | private static double stress(final List<Vec> X_views, final List<Double> X_rowCache, final Matrix delta, ExecutorService ex) |
| 287 | { |
| 288 | final AtomicDouble stress = new AtomicDouble(0); |
| 289 | final CountDownLatch latch = new CountDownLatch(SystemInfo.LogicalCores); |
| 290 | |
| 291 | for(int id = 0; id < SystemInfo.LogicalCores; id++) |
| 292 | { |
| 293 | final int ID= id; |
| 294 | ex.submit(new Runnable() |
| 295 | { |
| 296 | |
| 297 | @Override |
| 298 | public void run() |
| 299 | { |
| 300 | double localStress = 0; |
| 301 | for(int i = ID; i < delta.rows(); i+=SystemInfo.LogicalCores) |
| 302 | { |
| 303 | |
| 304 | for(int j = i+1; j < delta.rows(); j++) |
| 305 | { |
| 306 | double tmp = embedMetric.dist(i, j, X_views, X_rowCache)-delta.get(i, j); |
| 307 | localStress += tmp*tmp; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | stress.addAndGet(localStress); |
| 312 | latch.countDown(); |
| 313 | } |
| 314 | }); |
| 315 | |
| 316 | } |
| 317 | |
| 318 | try |
| 319 | { |
| 320 | latch.await(); |
| 321 | } |
| 322 | catch (InterruptedException ex1) |
| 323 | { |
| 324 | Logger.getLogger(MDS.class.getName()).log(Level.SEVERE, null, ex1); |
| 325 | } |
| 326 | |
| 327 | return stress.get(); |
| 328 | } |
| 329 | |
| 330 | @Override |
| 331 | public int getTargetDimension() |