add node directly with default empty BnBNodeInfo#38
Conversation
Codecov Report
@@ Coverage Diff @@
## main #38 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 131 133 +2
=========================================
+ Hits 131 133 +2
Continue to review full report at Codecov.
|
Co-authored-by: Mathieu Besançon <mathieu.besancon@gmail.com>
| Creates a node of type `Node` with id `node_id` and the named tuple `node`. | ||
| For information on that see [`set_root!`](@ref). | ||
| """ | ||
| function create_node(Node, node_id::Int, parent::Union{AbstractNode, Nothing}, node_info::NamedTuple) | ||
| function create_node(Node, node_id::Int, parent::Union{AbstractNode, Nothing}, node::AbstractNode) |
There was a problem hiding this comment.
this is strange here, we have a function create node that already takes as input the created node?
There was a problem hiding this comment.
Yes that's the reason why I don't like this approach same with the mutable but I wasn't able to come up with something better which is most likely the reason why I used the named tuple approach 🤣
I wanted to avoid a node and an inner node as the user should have access to both but I also don't want to pass both around all the time. I could make a parametric type which includes both info and then one can dispatch on the inner later but accessing the variables of the inner then is a a bit tedious. Or one would need to create a get property and set property function to make it simpler....
Did you have a completely different approach in mind?
| node_nt = merge(bnb_nt, node_info) | ||
| return structfromnt(Node, node_nt) | ||
| bnb_node = BnBNodeInfo(node_id, lb, Inf) | ||
| node.std = bnb_node |
There was a problem hiding this comment.
the default here assumes the node is mutable?
Implements #37
I'm not sure whether this approach is a reasonable one. There is a default
BnBNodeInfonow which is used by a default constructor of an AbstractNode. The values of id, lb and ub are then updated when the node is actually added to the tree.All docstrings need fixes but maybe you (@matbesancon ) can already say whether this solves the flexibility problem you had in mind.