File tree Expand file tree Collapse file tree 4 files changed +55
-0
lines changed
python/ecole/src/ecole/core Expand file tree Collapse file tree 4 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ add_library(
2828 src/reward/lp-iterations.cpp
2929 src/reward/solving-time.cpp
3030 src/reward/n-nodes.cpp
31+ src/reward/tree -size-estimate.cpp
3132 src/reward/bound-integral.cpp
3233
3334 src/observation/node-bipartite.cpp
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < cstdint>
4+
5+ #include " ecole/export.hpp"
6+ #include " ecole/reward/abstract.hpp"
7+ #include " scip/event_estim.h"
8+ #include " scip/scip_event.h"
9+
10+ #define EVENTHDLR_NAME " estim"
11+
12+ namespace ecole ::reward {
13+
14+ class ECOLE_EXPORT TreeSizeEstimate {
15+ public:
16+ ECOLE_EXPORT auto before_reset (scip::Model& model) -> void;
17+ ECOLE_EXPORT auto extract (scip::Model& model, bool done = false ) -> Reward;
18+
19+ private:
20+ SCIP_Real tree_size_estimate = 0.0 ;
21+ };
22+
23+ } // namespace ecole::reward
Original file line number Diff line number Diff line change 1+ #include " ecole/reward/tree-size-estimate.hpp"
2+
3+ #include " ecole/scip/model.hpp"
4+ #include " scip/def.h"
5+
6+ namespace ecole ::reward {
7+
8+ void TreeSizeEstimate::before_reset (scip::Model& /* model */ ) {}
9+
10+ Reward TreeSizeEstimate::extract (scip::Model& model, bool /* done */ ) {
11+ // getTreeSizeEstimation returns -1 when no estimation has been made yet.
12+ tree_size_estimate = SCIPgetTreesizeEstimation (model.get_scip_ptr ());
13+ return tree_size_estimate;
14+ }
15+
16+ } // namespace ecole::reward
Original file line number Diff line number Diff line change 1111#include " ecole/reward/lp-iterations.hpp"
1212#include " ecole/reward/n-nodes.hpp"
1313#include " ecole/reward/solving-time.hpp"
14+ #include " ecole/reward/tree-size-estimate.hpp"
1415#include " ecole/scip/model.hpp"
1516
1617#include " core.hpp"
@@ -147,6 +148,20 @@ void bind_submodule(py::module_ const& m) {
147148 The difference in number of nodes is computed in between calls.
148149 )" );
149150
151+ auto treesizeestimate = py::class_<TreeSizeEstimate>(m, " TreeSizeEstimate" , R"(
152+ Estimate the size of a tree.
153+
154+ The reward is defined as the total number of nodes processed since the previous state.
155+ )" );
156+ treesizeestimate.def (py::init<>());
157+ def_operators (treesizeestimate);
158+ def_before_reset (treesizeestimate, " Reset the internal node count." );
159+ def_extract (treesizeestimate, R"(
160+ Update the internal node count and return the difference.
161+
162+ The difference in number of nodes is computed in between calls.
163+ )" );
164+
150165 auto solvingtime = py::class_<SolvingTime>(m, " SolvingTime" , R"(
151166 Solving time difference.
152167
You can’t perform that action at this time.
0 commit comments