Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/contact_manager/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,13 @@ macro_rules! generate_prio_volume_manager {
at_time: crate::types::Date,
bundle: &crate::bundle::Bundle,
) -> Option<crate::contact_manager::ContactManagerTxData> {
if let Some(data) = self.dry_run_tx(contact_data, at_time, bundle) {
// Conditionally update queue size based on $auto_update
// Can overflow with overbooking
if $auto_update {
self.enqueue(bundle);
}
return Some(data);
let data = self.dry_run_tx(contact_data, at_time, bundle)?;
// Conditionally update queue size based on $auto_update
// Can overflow with overbooking
if $auto_update {
self.enqueue(bundle);
}
None
return Some(data);
}

/// Initializes the segmentation manager by checking that rate and delay intervals have no gaps.
Expand Down
41 changes: 18 additions & 23 deletions src/contact_plan/from_asabr_lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,18 @@ impl ASABRContactPlan {
return Err(msg);
}
ParsingState::Finished((info, manager)) => {
if let Some(contact) = Contact::try_new(info, manager) {
Self::add_contact(
contact,
&mut contacts,
&mut max_node_id_in_contacts,
);
} else {
let Some(contact) = Contact::try_new(info, manager) else {
return Err(format!(
"Malformed contact ({})",
lexer.get_current_position()
));
}
};

Self::add_contact(
contact,
&mut contacts,
&mut max_node_id_in_contacts,
);
}
}
}
Expand All @@ -164,25 +164,20 @@ impl ASABRContactPlan {
return Err(msg);
}
ParsingState::Finished((info, manager)) => {
if let Some(node) = Node::try_new(info, manager) {
match Self::add_node(
node,
&mut nodes,
&mut max_node_in_in_nodes,
&mut known_node_ids,
&mut known_node_names,
) {
Ok(_) => {}
Err(msg) => {
return Err(msg);
}
}
} else {
let Some(node) = Node::try_new(info, manager) else {
return Err(format!(
"Malformed node ({})",
lexer.get_current_position()
));
}
};

Self::add_node(
node,
&mut nodes,
&mut max_node_in_in_nodes,
&mut known_node_ids,
&mut known_node_names,
)?;
}
}
}
Expand Down
22 changes: 12 additions & 10 deletions src/contact_plan/from_ion_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,18 @@ impl IONContactPlan {
}

for range in &ranges {
if let Some(tx_map) = contact_info_map.get_mut(&range.tx_node) {
if let Some(contact_vec) = tx_map.get_mut(&range.rx_node) {
for contact in contact_vec.iter_mut() {
if range.tx_start <= contact.tx_start && contact.tx_end <= range.tx_end {
contact.delay = range.delay;
contacts.push(CM::ion_convert(contact).unwrap());
} else {
panic!("This parser only supports one range per contact");
}
}
let Some(tx_map) = contact_info_map.get_mut(&range.tx_node) else {
continue;
};
let Some(contact_vec) = tx_map.get_mut(&range.rx_node) else {
continue;
};
for contact in contact_vec.iter_mut() {
if range.tx_start <= contact.tx_start && contact.tx_end <= range.tx_end {
contact.delay = range.delay;
contacts.push(CM::ion_convert(contact).unwrap());
} else {
panic!("This parser only supports one range per contact");
}
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,21 @@ macro_rules! implement_manager {
ParsingState::EOF => ParsingState::EOF,
ParsingState::Error(msg) => ParsingState::Error(msg),
ParsingState::Finished(marker) => {
if let Some(marker_map) = marker_map_opt {
if let Some(parse_fn) = marker_map.get(marker.as_str()) {
parse_fn(lexer)
} else {
ParsingState::Error(format!(
"Unrecognized marker ({})",
lexer.get_current_position()
))
}
} else {
ParsingState::Error(format!(
let Some(marker_map) = marker_map_opt else {
return ParsingState::Error(format!(
"Dynamic parsing requires a map ({})",
lexer.get_current_position()
))
}
));
};

let Some(parse_fn) = marker_map.get(marker.as_str()) else {
return ParsingState::Error(format!(
"Unrecognized marker ({})",
lexer.get_current_position()
));
};

parse_fn(lexer)
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/pathfinding/contact_parenting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ macro_rules! define_contact_graph {
let rx_node_id = receiver.node.borrow().info.id;

if let Some(hop) = &route_proposition.via {
let route_proposition_ref =
Rc::new(RefCell::new(route_proposition.clone_work_area()));
let route_proposition_ref = Rc::new(RefCell::new(
route_proposition.clone_work_area(),
));
priority_queue.push(Reverse(DistanceWrapper::new(
route_proposition_ref.clone(),
)));
Expand Down
42 changes: 23 additions & 19 deletions src/pathfinding/hybrid_parenting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,26 +332,30 @@ macro_rules! define_mpt {
}
}

if let Some(first_contact_index) =
let Some(first_contact_index) =
receiver.lazy_prune_and_get_first_idx(current_time)
{
if let Some(route_proposition) = try_make_hop(
first_contact_index,
&from_route,
bundle,
&receiver.contacts_to_receiver,
&sender.node,
&receiver.node,
) {
// This transforms a prop in the stack to a prop in the heap
if let Some(new_route) =
try_insert::<NM, CM, D>(route_proposition, &mut tree)
{
priority_queue
.push(Reverse(DistanceWrapper::new(new_route.clone())));
}
}
}
else {
continue;
};

let Some(route_proposition) = try_make_hop(
first_contact_index,
&from_route,
bundle,
&receiver.contacts_to_receiver,
&sender.node,
&receiver.node,
) else {
continue;
};

// This transforms a prop in the stack to a prop in the heap
let Some(new_route) = try_insert::<NM, CM, D>(route_proposition, &mut tree)
else {
continue;
};

priority_queue.push(Reverse(DistanceWrapper::new(new_route.clone())));
}
}

Expand Down
58 changes: 31 additions & 27 deletions src/pathfinding/node_parenting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,37 +126,41 @@ macro_rules! define_node_graph {
}
}

if let Some(first_contact_index) =
let Some(first_contact_index) =
receiver.lazy_prune_and_get_first_idx(current_time)
{
if let Some(route_proposition) = try_make_hop(
first_contact_index,
&from_route,
bundle,
&receiver.contacts_to_receiver,
&sender.node,
&receiver.node,
) {
let mut push = false;
if let Some(know_route_ref) = tree.by_destination
[receiver.node.borrow().info.id as usize]
.clone()
{
let mut known_route = know_route_ref.borrow_mut();
if D::cmp(&route_proposition, &known_route) == Ordering::Less {
known_route.is_disabled = true;
push = true;
}
else {
continue;
};

let Some(route_proposition) = try_make_hop(
first_contact_index,
&from_route,
bundle,
&receiver.contacts_to_receiver,
&sender.node,
&receiver.node,
) else {
continue;
};

let idx = receiver.node.borrow().info.id as usize;
let push = match tree.by_destination[idx].as_ref() {
Some(known_route_ref) => {
let mut known_route = known_route_ref.borrow_mut();
if D::cmp(&route_proposition, &known_route) == Ordering::Less {
known_route.is_disabled = true;
true
} else {
push = true;
}
if push {
let route_ref = Rc::new(RefCell::new(route_proposition));
tree.by_destination[receiver.node.borrow().info.id as usize] =
Some(route_ref.clone());
priority_queue.push(Reverse(DistanceWrapper::new(route_ref)));
false
}
}
None => true,
};

if push {
let route_ref = Rc::new(RefCell::new(route_proposition));
tree.by_destination[idx] = Some(route_ref.clone());
priority_queue.push(Reverse(DistanceWrapper::new(route_ref)));
}
}
}
Expand Down
Loading