Skip to content

Commit

Permalink
Adjust get_bit_size_for_range() to account for domain-abstracted tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jendrikseipp committed Jan 10, 2024
1 parent 61f8d80 commit a829dcf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/search/algorithms/int_packer.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "int_packer.h"

#include <algorithm>
#include <cassert>

using namespace std;
Expand All @@ -24,6 +23,11 @@ static IntPacker::Bin get_bit_mask(int from, int to) {
}

static int get_bit_size_for_range(int range) {
assert(range >= 1);
// Domains in domain-abstracted tasks may have size one.
if (range == 1) {
return 1;
}
int num_bits = 0;
while ((1U << num_bits) < static_cast<unsigned int>(range))
++num_bits;
Expand Down Expand Up @@ -84,8 +88,6 @@ void IntPacker::set(Bin *buffer, int var, int value) const {

void IntPacker::pack_bins(const vector<int> &ranges) {
assert(var_infos.empty());
assert(all_of(ranges.begin(), ranges.end(),
[](int range) {return range > 1;}));

int num_vars = ranges.size();
var_infos.resize(num_vars);
Expand Down
8 changes: 3 additions & 5 deletions src/search/task_utils/task_properties.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,9 @@ PerTaskInformation<int_packer::IntPacker> g_state_packers(
vector<int> variable_ranges;
variable_ranges.reserve(variables.size());
for (VariableProxy var : variables) {
/* IntPacker expects all variables to have at least a domain size of
two. This is not the case for some domain-abstracted tasks. */
int domain_size = max(2, var.get_domain_size());
variable_ranges.push_back(domain_size);
variable_ranges.push_back(var.get_domain_size());
}
return utils::make_unique_ptr<int_packer::IntPacker>(variable_ranges);
});
}
);
}

0 comments on commit a829dcf

Please sign in to comment.