Skip to content

Commit

Permalink
updated masking for compatibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
jdumouchelle authored and AntoinePrv committed Jan 26, 2022
1 parent b59e8ea commit 5662678
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
2 changes: 1 addition & 1 deletion libecole/include/ecole/instance/combinatorial-auction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ECOLE_EXPORT CombinatorialAuctionGenerator : public InstanceGenerator {
unsigned int min_value = 1; // NOLINT(readability-magic-numbers)
unsigned int max_value = 100; // NOLINT(readability-magic-numbers)
double value_deviation = 0.5; // NOLINT(readability-magic-numbers)
double add_item_prob = 0.7; // NOLINT(readability-magic-numbers)
double add_item_prob = 0.65; // NOLINT(readability-magic-numbers)
std::size_t max_n_sub_bids = 5; // NOLINT(readability-magic-numbers)
double additivity = 0.2; // NOLINT(readability-magic-numbers)
double budget_factor = 1.5; // NOLINT(readability-magic-numbers)
Expand Down
21 changes: 2 additions & 19 deletions libecole/src/instance/combinatorial-auction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,32 +86,15 @@ auto arg_choice_without_replacement(std::size_t n_samples, xvector<double> weigh
return indices;
}

/** Gets compats indexed by bundle_masked. */
auto get_compats_masked(xvector<std::size_t> const& bundle_mask, xmatrix<double> const& compats) {

auto c0 = xt::eval(xt::row(compats, 0));
auto c1 = xt::eval(xt::row(compats, 1));
auto compats_masked = xt::eval(compats);
for (std::size_t i = 0; i < bundle_mask.size(); ++i) {
auto c = xt::row(compats_masked, static_cast<long int>(i));
if (bundle_mask[i] == 0) {
c = c0;
} else {
c = c1;
}
}
return compats_masked;
}

/** Choose the next item to be added to the bundle/sub-bundle. */
auto choose_next_item(
xvector<std::size_t> const& bundle_mask,
xvector<double> const& interests,
xmatrix<double> const& compats,
RandomGenerator& rng) {

auto const compats_masked = get_compats_masked(bundle_mask, compats);
auto const compats_masked_mean = xt::mean(compats_masked, 0);
auto const compats_masked = compats * bundle_mask;
auto const compats_masked_mean = xt::mean(compats_masked, 1);
auto const probs = xt::eval((1 - bundle_mask) * interests * compats_masked_mean);
return arg_choice_without_replacement(1, probs, rng)(0);
}
Expand Down

0 comments on commit 5662678

Please sign in to comment.