MCPcopy Create free account
hub / github.com/dds-bridge/dds / SortSolve

Method SortSolve

library/src/system/scheduler.cpp:476–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

474};
475
476void Scheduler::SortSolve()
477{
478 listType * lp;
479 handType * hp;
480 int strain, key, index;
481
482 for (int g = 0; g < numGroups; g++)
483 {
484 strain = group[g].strain;
485 key = group[g].hash;
486 lp = &list[strain][key];
487 index = lp->first;
488 hp = &hands[index];
489
490 // Taking into account repeat times saves 1-2%.
491
492 int repeatNo = 0;
493 int firstPrev = -1;
494 group[g].pred = 0;
495 do
496 {
497 // Skip complete duplicates, as we won't solve them again.
498 if (hands[index].first != firstPrev)
499 {
500 group[g].pred += SORT_SOLVE_TIMES[hp->NTflag][repeatNo];
501 if (repeatNo < 7)
502 repeatNo++;
503 firstPrev = hands[index].first;
504 }
505
506 index = hands[index].next;
507 }
508 while (index != -1);
509
510 // Taking into account fanout saves 4-6%.
511
512 int fanout = hp->fanout;
513 double * slist = SORT_SOLVE_FANOUT[hp->NTflag];
514 double fanoutFactor;
515
516 if (fanout < slist[0])
517 fanoutFactor = 0.; // A bit extreme...
518 else if (fanout < slist[1])
519 fanoutFactor = slist[2] * (fanout - slist[0]);
520 else
521 fanoutFactor = slist[3] * exp( (fanout - slist[1]) / slist[4] );
522
523 group[g].pred = static_cast<int>(
524 (fanoutFactor * static_cast<double>(group[g].pred)));
525 }
526
527 // Sort groups using merge sort.
528 groupType gp;
529 for (int g = 0; g < numGroups; g++)
530 {
531 gp = group[g];
532 int j = g;
533 for (; j && gp.pred > group[j - 1].pred; --j)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected