MCPcopy Create free account
hub / github.com/Gecode/gecode / solve

Function solve

examples/job-shop.cpp:617–791  ·  view source on GitHub ↗

Solver

Source from the content-addressed store, hash-verified

615
616/// Solver
617void
618solve(const JobShopOptions& opt) {
619 Rnd rnd(opt.seed());
620
621 /*
622 * Invariant:
623 * - There is a solution with makespan u,
624 * - There is no solution with makespan l
625 */
626
627 int l, u;
628
629 {
630 Support::Timer t; t.start();
631 Search::Statistics stat;
632 JobShopProbe* master = new JobShopProbe(opt);
633
634 if (master->status() != SS_SOLVED) {
635 delete master;
636 std::cerr << "Error: has no solution..." << std::endl;
637 return;
638 }
639
640 l = master->cost().min();
641 u = master->cost().max();
642
643 FailTimeStop fts(opt.fail_probe(),opt.time_probe());
644 CommonOptions so(opt);
645 so.stop = &fts;
646 bool stopped = false;
647
648 std::cout << "\tProbing..." << std::endl;
649
650 std::cout << "\t\tBounds: [" << l << "," << u << "]"
651 << std::endl;
652
653 for (unsigned int p=0; p<opt.probes(); p++) {
654 JobShopProbe* jsp = static_cast<JobShopProbe*>(master->clone());
655 jsp->branch(p,rnd);
656 DFS<JobShopProbe> dfs(jsp,so);
657 JobShopProbe* s = dfs.next();
658 Search::Statistics statj = dfs.statistics();
659
660 if (s != nullptr) {
661 if (u > s->cost().val()) {
662 u = s->cost().val();
663 s->print(std::cout);
664 }
665 delete s;
666 } else if (fts.time(statj,so)) {
667 stopped = true;
668 break;
669 }
670 stat += statj;
671 }
672 delete master;
673
674 print(stat,false);

Callers 2

runMethod · 0.85
mainFunction · 0.85

Calls 15

stopFunction · 0.85
fail_probeMethod · 0.80
time_probeMethod · 0.80
probesMethod · 0.80
time_adjustMethod · 0.80
time_solveMethod · 0.80
printFunction · 0.70
relFunction · 0.50
seedMethod · 0.45
startMethod · 0.45
statusMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected