MCPcopy Create free account
hub / github.com/davisking/dlib / bsp_job_node_0

Function bsp_job_node_0

dlib/test/bsp.cpp:432–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430
431
432 void bsp_job_node_0 (
433 bsp_context& context,
434 double& min_value,
435 double& optimal_x
436 )
437 {
438 double left = -100;
439 double right = 100;
440
441 min_value = std::numeric_limits<double>::infinity();
442 double interval_width = std::abs(right-left);
443
444 // This is doing a BSP based grid search for the minimum of f(). Here we
445 // do 100 iterations where we keep shrinking the grid size.
446 for (int i = 0; i < 100; ++i)
447 {
448 context.broadcast(left);
449 context.broadcast(right);
450
451 for (unsigned int k = 1; k < context.number_of_nodes(); ++k)
452 {
453 std::pair<double,double> val;
454 context.receive(val);
455 if (val.second < min_value)
456 {
457 min_value = val.second;
458 optimal_x = val.first;
459 }
460 }
461
462 interval_width *= 0.5;
463 left = optimal_x - interval_width/2;
464 right = optimal_x + interval_width/2;
465 }
466 }
467
468
469 void bsp_job_other_nodes (

Callers

nothing calls this directly

Calls 4

absFunction · 0.85
broadcastMethod · 0.45
number_of_nodesMethod · 0.45
receiveMethod · 0.45

Tested by

no test coverage detected