Node difference for abscissa in Primal/Dual Integrals#268
Node difference for abscissa in Primal/Dual Integrals#268jdumouchelle wants to merge 2 commits intolatestfrom
Conversation
|
Thanks @jdumouchelle. The code looks good to me, however I'm wondering if we should make this future-proof. Meta levelAt a more abstract level, I believe |
|
Yes I agree. It did come across my mind, but it will likely require a decent amount of time. Perhaps we can merge this for now so it can be used by Aaron, open an issue for a more general integral reward, and discuss it in there. After that, I will work on when I have more time. |
AntoinePrv
left a comment
There was a problem hiding this comment.
Let's change the use_bool parameter for an enumeration, it will make it easier to add more possibilities without breaking API.
@jdumouchelle, do you want to add #198 in here or make a separate one? I feel the changes could be related.
| using BoundFunction = std::function<std::tuple<Reward, Reward>(scip::Model& model)>; | ||
|
|
||
| ECOLE_EXPORT BoundIntegral(bool wall_ = false, const BoundFunction& bound_function_ = {}); | ||
| ECOLE_EXPORT BoundIntegral(bool wall_ = false, bool use_nnodes_ = false, const BoundFunction& bound_function_ = {}); |
There was a problem hiding this comment.
Let's change use_nnodes from a boolean to an enumeration like abscissa:
enum struct Abscissa { wall_time, n_nodes };And
BoundIntegral(bool wall_ = false, Abscissa abscissa = Abscissa::wall_time, const BoundFunction& bound_function_ = {});| std::vector<std::chrono::nanoseconds> times; | ||
| std::vector<SCIP_Longint> nodes; |
There was a problem hiding this comment.
Then what about having a single vector here like std::vector<double> abscissa instead?
Also related to #198 ?
| times.push_back(time_now(wall)); | ||
| if (use_nnodes) { | ||
| nodes.push_back(get_nnodes(scip)); | ||
| } else { | ||
| times.push_back(time_now(wall)); | ||
| } |
There was a problem hiding this comment.
Let's abstract that in a function/method, something like get_abscissa.
And elsewhere...
| )"); | ||
| primalintegral.def( | ||
| py::init<bool, PrimalIntegral::BoundFunction>(), | ||
| py::init<bool, bool, PrimalIntegral::BoundFunction>(), |
There was a problem hiding this comment.
For the enum, we have a binding function that will make it implicitly convertible from strings.
It will need to be moved inside the extension-helper library (and you might need to rebase first), and be renamed in something more sensible. Let me know if you need help with it.
Pull request checklist
Proposed implementation
Implementation of primal, dual, and primal dual integrals with respect to number of nodes.
From the perspective of the user, one can simply pass
use_nnodes=Trueinto the constructor of any of the integral reward functions.