@@ -127,11 +127,29 @@ class Trace(Generic[ASpecificScen, ASpecificKB]):
127127
128128 def __init__ (self , scen : ASpecificScen , knowledge_base : ASpecificKB | None = None ) -> None :
129129 self .scen : ASpecificScen = scen
130+
131+ # BEGIN: graph structure -------------------------
130132 self .hist : list [Trace .NodeType ] = (
131133 []
132134 ) # List of tuples containing experiments and their feedback, organized over time.
133135 self .dag_parent : list [tuple [int , ...]] = [] # List of tuples representing parent indices in the DAG structure.
134- # (,) represents no parent; (1,) presents one parent; (1, 2) represents two parents.
136+ # Definition:
137+ # - (,) represents no parent (root node in one tree);
138+ # - (1,) presents one parent;
139+ # - (1, 2) represents two parents (Multiple parent is not implemented yet).
140+ # Syntax sugar for the parent relationship:
141+ # - Only for selection:
142+ # - (-1,) indicates that select the last record node as parent.
143+
144+ # NOTE: the sequence of hist and dag_parent is organized by the order to record the experiment.
145+ # So it may be different from the order of the loop_id.
146+ # So we need an extra mapping to map the enqueue id back to the loop id.
147+ self .idx2loop_id : dict [int , int ] = {}
148+
149+ # Design discussion:
150+ # - If we unifiy the loop_id and the enqueue id, we will have less recognition burden.
151+ # - If we use different id for loop and enqueue, we don't have to handle the placeholder logic.
152+ # END: graph structure -------------------------
135153
136154 # TODO: self.hist is 2-tuple now, remove hypothesis from it, change old code for this later.
137155 self .knowledge_base : ASpecificKB | None = knowledge_base
@@ -227,9 +245,13 @@ def get_selection(self, trace: Trace) -> tuple[int, ...] | None:
227245 checkpoint_idx represents the place where we want to create a new node.
228246 the return value should be the idx of target node (the parent of the new generating node).
229247 - `(-1, )` represents starting from the latest trial in the trace - default value
248+
249+ - NOTE: we don't encourage to use this option; It is confusing when we have multiple traces.
250+
230251 - `(idx, )` represents starting from the `idx`-th trial in the trace.
231252 - `None` represents starting from scratch (start a new trace)
232253
254+
233255 - More advanced selection strategies in `select.py`
234256 """
235257
0 commit comments