Skip to content

Commit b38251a

Browse files
committed
fix an important bug
1 parent 21015e8 commit b38251a

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

include/sched/shop/helper/JobShopStates.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#include <cassert>
77

88
#include <algorithm>
9-
#include <vector>
9+
#include <ranges>
1010
#include <tuple>
11+
#include <vector>
1112

1213
#include <sched/Ids.h>
1314
#include <sched/support/Range.h>
@@ -47,16 +48,21 @@ namespace sched::shop {
4748
bool has_pending_operations(const MachineOperations& machine_operations) const
4849
{
4950
assert(machine_operations.size() == machines.size());
50-
return std::ranges::any_of(machines, [&](std::size_t index) { return index < machine_operations[index].size(); }, &MachineState::index);
51+
52+
for (auto [ machine_index, machine_state ] : std::views::enumerate(machines)) {
53+
if (machine_state.index < machine_operations[machine_index].size()) {
54+
return true;
55+
}
56+
}
57+
58+
return false;
5159
}
5260

5361
void update_pending_operations(const MachineOperations& machine_operations)
5462
{
5563
assert(machine_operations.size() == machines.size());
5664

57-
for (std::size_t machine_index : over(machines)) {
58-
MachineState& machine_state = machines[machine_index];
59-
65+
for (auto [ machine_index, machine_state ] : std::views::enumerate(machines)) {
6066
for (;;) {
6167
if (machine_state.index >= machine_operations[machine_index].size()) {
6268
break;
@@ -89,13 +95,11 @@ namespace sched::shop {
8995

9096
std::vector<std::tuple<OperationId, MachineId>> schedulable_operations;
9197

92-
for (std::size_t machine_index : over(machines)) {
93-
const MachineState& machine_state = machines[machine_index];
94-
98+
for (auto [ machine_index, machine_state ] : std::views::enumerate(machines)) {
9599
// check if the next operation is schedulable
96100

97101
if (machine_state.index >= machine_operations[machine_index].size()) {
98-
break;
102+
continue;
99103
}
100104

101105
const OperationId machine_operation = machine_operations[machine_index][machine_state.index];

0 commit comments

Comments
 (0)