Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework logic and data structures involved in multi threaded computation #69

Merged
merged 37 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
73e8b8b
Refactor MtspResult
sebrockm Aug 6, 2023
809cb25
Use private members only
sebrockm Aug 6, 2023
0d0fe5e
Appears to be working when no timeout occurs
sebrockm Aug 7, 2023
b173a06
Cleanup
sebrockm Aug 7, 2023
b17e09f
Measure wait times
sebrockm Aug 13, 2023
8f5869d
Reduce waiting time in PopToModel
sebrockm Aug 13, 2023
50fe2f1
Bench
sebrockm Aug 14, 2023
6d6fe7e
Bench
sebrockm Sep 1, 2023
764cdf3
Simplify result interface
sebrockm Sep 1, 2023
61429fb
Try 2s timeout in tests
sebrockm Sep 2, 2023
0064a42
Format
sebrockm Sep 2, 2023
462e02a
Add debug printing
sebrockm Sep 2, 2023
2528690
print test names
sebrockm Sep 2, 2023
1e3e244
log bounds
sebrockm Sep 3, 2023
062f0d8
More logging
sebrockm Sep 3, 2023
e78f7dd
Treat infeasible solution as infinite LB
sebrockm Sep 3, 2023
dcd6731
WIP: Make sure global LB is up to date when continuing loop
sebrockm Sep 6, 2023
c19f7ed
Fix return value
sebrockm Sep 7, 2023
5e2e012
Automatically notify node done
sebrockm Sep 8, 2023
ddc50bb
Tests for BranchAndCutQueue
sebrockm Sep 15, 2023
684c6cf
WIP...
sebrockm Sep 26, 2023
c56ee85
Undo debug printing
sebrockm Sep 26, 2023
c196e8f
BnCQ tests pass
sebrockm Sep 26, 2023
58edfeb
Make c'tor explicit
sebrockm Sep 26, 2023
c01ef93
linter
sebrockm Sep 26, 2023
7d1bd64
Small changes
sebrockm Sep 28, 2023
b298e01
Rework BnCQ
sebrockm Oct 5, 2023
60055c8
TMP: printing
sebrockm Oct 8, 2023
db71451
TMP: run tests 10k times
sebrockm Oct 10, 2023
d17606d
TMP: better logging
sebrockm Oct 10, 2023
8a78cbc
TMP: better logging
sebrockm Oct 14, 2023
529400a
TMP: log skipping
sebrockm Oct 14, 2023
44bce02
Fix missing LB update
sebrockm Oct 14, 2023
3c29d86
Push finished LBs back for reevaluation
sebrockm Oct 14, 2023
0e1153a
Remove logging
sebrockm Oct 15, 2023
2f3f5e4
Add more tests
sebrockm Oct 15, 2023
3174ce9
New bench
sebrockm Oct 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions mtsp-vrp-c/src/mtsp-vrp-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,35 @@ int solve_mtsp_vrp(
assert(tensor.shape() == (std::array{numberOfAgents, numberOfNodes, numberOfNodes}));
fractional_callback(tensor.data()); }
: std::function<void(const xt::xtensor<double, 3>&)> {};
const auto result = model.BranchAndCutSolve(numberOfThreads, callback);
model.BranchAndCutSolve(numberOfThreads, callback);

*lowerBound = result.LowerBound;
*upperBound = result.UpperBound;
const auto& result = model.GetResult();
const auto [lb, ub] = result.GetBounds();
*lowerBound = lb;
*upperBound = ub;

if (!result.IsTimeoutHit && result.UpperBound == std::numeric_limits<double>::max())
if (!result.IsTimeoutHit() && ub == std::numeric_limits<double>::max())
return MTSP_VRP_C_NO_RESULT_INFEASIBLE;

if (result.IsTimeoutHit && result.UpperBound == std::numeric_limits<double>::max())
if (result.IsTimeoutHit() && ub == std::numeric_limits<double>::max())
return MTSP_VRP_C_NO_RESULT_TIMEOUT;

size_t offset = 0;
for (size_t a = 0; a < numberOfAgents; ++a)
{
pathOffsets[a] = offset; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
auto length = result.Paths[a].size();
auto length = result.GetPaths()[a].size();
if (startPositions[a] == endPositions[a])
--length; // don't copy unneeded (duplicate) last entry
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
std::copy_n(result.Paths[a].begin(), length, paths + offset);
std::copy_n(result.GetPaths()[a].begin(), length, paths + offset);
offset += length;
}

if (result.LowerBound >= result.UpperBound)
if (lb >= ub)
return MTSP_VRP_C_RESULT_SOLVED;

assert(result.IsTimeoutHit);
assert(result.IsTimeoutHit());
return MTSP_VRP_C_RESULT_TIMEOUT;
}
catch (const tsplp::CyclicDependenciesException&)
Expand Down
Loading
Loading