Merge branch 'main' of github.com:google/or-tools
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "ortools/algorithms/bin_packing.h"
|
||||
#include "ortools/set_cover/samples/bin_packing.h"
|
||||
|
||||
#include <absl/algorithm/container.h>
|
||||
#include <absl/container/flat_hash_set.h>
|
||||
@@ -37,10 +37,10 @@ void BinPackingModel::set_bin_capacity(Cost capacity) {
|
||||
LOG(WARNING) << "Bin capacity must be positive.";
|
||||
return;
|
||||
}
|
||||
bin_capcaity_ = capacity;
|
||||
bin_capacity_ = capacity;
|
||||
}
|
||||
void BinPackingModel::AddItem(Cost weight) {
|
||||
if (weight > bin_capcaity_) {
|
||||
if (weight > bin_capacity_) {
|
||||
LOG(WARNING) << "Element weight exceeds bin capacity.";
|
||||
return;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ void AddRandomizedBins(const BinPackingModel& model, BaseInt num_bins,
|
||||
items.push_back(n);
|
||||
|
||||
if (unique_bin_num == scp_model.full_model().num_subsets()) {
|
||||
VLOG(1) << "No new bins generated.";
|
||||
LOG(INFO) << "No new bins generated.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef OR_TOOLS_ORTOOLS_ALGORITHMS_BIN_PACKING_H
|
||||
#define OR_TOOLS_ORTOOLS_ALGORITHMS_BIN_PACKING_H
|
||||
#ifndef OR_TOOLS_ORTOOLS_SET_COVER_SAMPLES_BIN_PACKING_H
|
||||
#define OR_TOOLS_ORTOOLS_SET_COVER_SAMPLES_BIN_PACKING_H
|
||||
|
||||
#include <absl/algorithm/container.h>
|
||||
#include <absl/container/flat_hash_set.h>
|
||||
@@ -33,7 +33,7 @@ class BinPackingModel {
|
||||
public:
|
||||
BinPackingModel() = default;
|
||||
BaseInt num_items() const { return weigths_.size(); }
|
||||
Cost bin_capacity() const { return bin_capcaity_; }
|
||||
Cost bin_capacity() const { return bin_capacity_; }
|
||||
void set_bin_capacity(Cost capacity);
|
||||
const ElementCostVector& weights() const { return weigths_; }
|
||||
void AddItem(Cost weight);
|
||||
@@ -44,7 +44,7 @@ class BinPackingModel {
|
||||
|
||||
private:
|
||||
bool is_sorted_ = false;
|
||||
Cost bin_capcaity_ = .0;
|
||||
Cost bin_capacity_ = .0;
|
||||
ElementCostVector weigths_ = {};
|
||||
};
|
||||
|
||||
@@ -177,4 +177,4 @@ void AddRandomizedBins(const BinPackingModel& model, BaseInt num_bins,
|
||||
BinPackingSetCoverModel& scp_model, std::mt19937& rnd);
|
||||
|
||||
} // namespace operations_research
|
||||
#endif /* OR_TOOLS_ORTOOLS_ALGORITHMS_BIN_PACKING_H */
|
||||
#endif /* OR_TOOLS_ORTOOLS_SET_COVER_SAMPLES_BIN_PACKING_H */
|
||||
@@ -18,10 +18,10 @@
|
||||
#include <cstdlib>
|
||||
#include <random>
|
||||
|
||||
#include "ortools/algorithms/bin_packing.h"
|
||||
#include "ortools/base/init_google.h"
|
||||
#include "ortools/set_cover/base_types.h"
|
||||
#include "ortools/set_cover/set_cover_cft.h"
|
||||
#include "ortools/set_cover/samples/bin_packing.h"
|
||||
|
||||
using namespace operations_research;
|
||||
ABSL_FLAG(std::string, instance, "", "BPP instance int RAIL format.");
|
||||
@@ -95,7 +95,7 @@ void KnapsackTest() {
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
InitGoogle(argv[0], &argc, &argv, true);
|
||||
|
||||
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
|
||||
// KnapsackTest();
|
||||
// return 0;
|
||||
|
||||
@@ -141,4 +141,4 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user