Contact Graph Routing for time-varying satellite networks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

borealis, cgr: WIP changes

+26 -13
+26 -13
lib/cgr.ml
··· 161 161 let compare (t1, _) (t2, _) = Float.compare t1 t2 162 162 end) 163 163 164 - type node_state = { 165 - arrival_time : float; 166 - predecessor : Contact.t option; 167 - } 164 + type node_state = { arrival_time : float; predecessor : Contact.t option } 168 165 169 166 type state = { 170 167 plan : Contact_plan.t; ··· 192 189 Contact_plan.nodes plan 193 190 |> List.fold_left 194 191 (fun map node -> 195 - let arrival_time = if Node.equal node src then time else Float.infinity in 192 + let arrival_time = 193 + if Node.equal node src then time else Float.infinity 194 + in 196 195 H.add heap (arrival_time, node); 197 196 Node_map.add node { arrival_time; predecessor = None } map) 198 197 Node_map.empty ··· 200 199 let nodes = ref nodes in 201 200 (* Main loop with lazy deletion *) 202 201 while not (H.is_empty heap) do 203 - let (current_time, current) = H.pop_minimum heap in 204 - let current_state = get_node_state { plan; src; start_time = time; nodes = !nodes } current in 202 + let current_time, current = H.pop_minimum heap in 203 + let current_state = 204 + get_node_state { plan; src; start_time = time; nodes = !nodes } current 205 + in 205 206 (* Lazy deletion: skip if this entry is stale *) 206 - if Float.equal current_time current_state.arrival_time && Float.is_finite current_time then begin 207 + if 208 + Float.equal current_time current_state.arrival_time 209 + && Float.is_finite current_time 210 + then begin 207 211 (* Relax edges *) 208 212 List.iter 209 213 (fun contact -> 210 214 let neighbor = Contact.to_ contact in 211 215 let neighbor_state = 212 - get_node_state { plan; src; start_time = time; nodes = !nodes } neighbor 216 + get_node_state 217 + { plan; src; start_time = time; nodes = !nodes } 218 + neighbor 213 219 in 214 220 (* Can we use this contact? *) 215 221 if current_time < Contact.stop contact then begin ··· 229 235 done; 230 236 { plan; src; start_time = time; nodes = !nodes } 231 237 232 - let init plan ~src ~time = 233 - run plan ~src ~time 238 + let init plan ~src ~time = run plan ~src ~time 234 239 235 240 let extract_route state ~dst = 236 241 let ns = get_node_state state dst in ··· 244 249 | Some contact -> build_path (Contact.from contact) (contact :: acc) 245 250 in 246 251 let path = build_path dst [] in 247 - Some { Route.hops = path; src = state.src; dst; start_time = state.start_time } 252 + Some 253 + { 254 + Route.hops = path; 255 + src = state.src; 256 + dst; 257 + start_time = state.start_time; 258 + } 248 259 249 260 (* For API compatibility *) 250 261 let step state = Some state ··· 270 281 (* Remove the first contact to find alternative routes *) 271 282 let plan' = 272 283 Contact_plan.of_list 273 - (List.filter (fun c -> c != first_hop) (Contact_plan.contacts plan)) 284 + (List.filter 285 + (fun c -> c != first_hop) 286 + (Contact_plan.contacts plan)) 274 287 in 275 288 loop plan' (count + 1) (route :: acc)) 276 289 in