-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding B&B tree size as a reward function
- Loading branch information
1 parent
353a450
commit e6ebddf
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "ecole/reward/tree-size-estimate.hpp" | ||
|
||
#include "ecole/scip/model.hpp" | ||
#include "scip/def.h" | ||
|
||
namespace ecole::reward { | ||
|
||
void TreeSizeEstimate::before_reset(scip::Model& /* model */) {} | ||
|
||
Reward TreeSizeEstimate::extract(scip::Model& model, bool /* done */) { | ||
// getTreeSizeEstimation returns -1 when no estimation has been made yet. | ||
tree_size_estimate = SCIPgetTreesizeEstimation(model.get_scip_ptr()); | ||
return tree_size_estimate; | ||
} | ||
|
||
} // namespace ecole::reward |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters