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

Adding Vehicle Routing and Bin Packing Problems as well as TreeSizeEstimate as a reward function. #352

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions libecole/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ add_library(
src/instance/independent-set.cpp
src/instance/combinatorial-auction.cpp
src/instance/capacitated-facility-location.cpp
src/instance/capacitated-vehicle-routing.cpp
src/instance/bin-packing.cpp

src/reward/is-done.cpp
src/reward/lp-iterations.cpp
src/reward/solving-time.cpp
src/reward/n-nodes.cpp
src/reward/tree-size-estimate.cpp
src/reward/bound-integral.cpp

src/observation/node-bipartite.cpp
Expand Down
42 changes: 42 additions & 0 deletions libecole/include/ecole/instance/bin-packing.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef BIN_PACKING_HPP
#define BIN_PACKING_HPP
#pragma once

#include <cstddef>
#include <string>
#include <utility>
#include <vector>

#include "ecole/export.hpp"
#include "ecole/instance/abstract.hpp"
#include "ecole/random.hpp"

namespace ecole::instance {

class ECOLE_EXPORT Binpacking : public InstanceGenerator {
public:
struct ECOLE_EXPORT Parameters {
std::string filename; // NOLINT(readability-magic-numbers)
std::size_t n_bins; // NOLINT(readability-magic-numbers)
};

ECOLE_EXPORT static scip::Model generate_instance(Parameters parameters, RandomGenerator& rng);

ECOLE_EXPORT Binpacking(Parameters parameters, RandomGenerator rng);
ECOLE_EXPORT Binpacking(Parameters parameters);
ECOLE_EXPORT Binpacking();

ECOLE_EXPORT scip::Model next() override;
ECOLE_EXPORT void seed(Seed seed) override;
[[nodiscard]] ECOLE_EXPORT bool done() const override { return false; }

[[nodiscard]] ECOLE_EXPORT Parameters const& get_parameters() const noexcept { return parameters; }

private:
RandomGenerator rng;
Parameters parameters;
};

} // namespace ecole::instance

#endif
38 changes: 38 additions & 0 deletions libecole/include/ecole/instance/capacitated-vehicle-routing.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include <cstddef>
#include <string>
#include <utility>
#include <vector>

#include "ecole/export.hpp"
#include "ecole/instance/abstract.hpp"
#include "ecole/random.hpp"

namespace ecole::instance {

class ECOLE_EXPORT CapacitatedVehicleRoutingLoader : public InstanceGenerator {
public:
struct ECOLE_EXPORT Parameters {
std::string filename; // NOLINT(readability-magic-numbers)
std::size_t n_vehicles; // NOLINT(readability-magic-numbers)
};

ECOLE_EXPORT static scip::Model generate_instance(Parameters parameters, RandomGenerator& rng);

ECOLE_EXPORT CapacitatedVehicleRoutingLoader(Parameters parameters, RandomGenerator rng);
ECOLE_EXPORT CapacitatedVehicleRoutingLoader(Parameters parameters);
ECOLE_EXPORT CapacitatedVehicleRoutingLoader();

ECOLE_EXPORT scip::Model next() override;
ECOLE_EXPORT void seed(Seed seed) override;
[[nodiscard]] ECOLE_EXPORT bool done() const override { return false; }

[[nodiscard]] ECOLE_EXPORT Parameters const& get_parameters() const noexcept { return parameters; }

private:
RandomGenerator rng;
Parameters parameters;
};

} // namespace ecole::instance
23 changes: 23 additions & 0 deletions libecole/include/ecole/reward/tree-size-estimate.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include <cstdint>

#include "ecole/export.hpp"
#include "ecole/reward/abstract.hpp"
#include "scip/event_estim.h"
#include "scip/scip_event.h"

#define EVENTHDLR_NAME "estim"

namespace ecole::reward {

class ECOLE_EXPORT TreeSizeEstimate {
public:
ECOLE_EXPORT auto before_reset(scip::Model& model) -> void;
ECOLE_EXPORT auto extract(scip::Model& model, bool done = false) -> Reward;

private:
SCIP_Real tree_size_estimate = 0.0;
};

} // namespace ecole::reward
Loading