File tree 4 files changed +55
-0
lines changed
python/ecole/src/ecole/core
4 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ add_library(
28
28
src/reward/lp-iterations.cpp
29
29
src/reward/solving-time.cpp
30
30
src/reward/n-nodes.cpp
31
+ src/reward/tree -size-estimate.cpp
31
32
src/reward/bound-integral.cpp
32
33
33
34
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 11
11
#include " ecole/reward/lp-iterations.hpp"
12
12
#include " ecole/reward/n-nodes.hpp"
13
13
#include " ecole/reward/solving-time.hpp"
14
+ #include " ecole/reward/tree-size-estimate.hpp"
14
15
#include " ecole/scip/model.hpp"
15
16
16
17
#include " core.hpp"
@@ -147,6 +148,20 @@ void bind_submodule(py::module_ const& m) {
147
148
The difference in number of nodes is computed in between calls.
148
149
)" );
149
150
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
+
150
165
auto solvingtime = py::class_<SolvingTime>(m, " SolvingTime" , R"(
151
166
Solving time difference.
152
167
You can’t perform that action at this time.
0 commit comments