Fix all warnings

This commit is contained in:
hal8174 2025-03-30 22:03:50 +02:00
parent 34ff825ff0
commit 721e83006d
11 changed files with 57 additions and 71 deletions

View file

@ -4,7 +4,7 @@ use factorio_blueprint_generator::factory::{FactoryGraph, generate_factory};
use factorio_core::{prelude::*, visualize::Visualize}; use factorio_core::{prelude::*, visualize::Visualize};
use factorio_graph::{ use factorio_graph::{
priority_queue::{ priority_queue::{
ByKey, PriorityQueue, ByKey,
binary_heap::{BinaryHeap, FastBinaryHeap}, binary_heap::{BinaryHeap, FastBinaryHeap},
bucket_queue::BucketQueue, bucket_queue::BucketQueue,
}, },

View file

@ -1,9 +1,5 @@
use std::ops::Index;
use factorio_core::visualize::Visualize;
use factorio_graph::{ use factorio_graph::{
graph::Graph, priority_queue::bucket_queue::BucketQueue,
priority_queue::binary_heap::FastBinaryHeap,
wheighted_graph::{WheightedGraph, shortest_path::dijkstra, steiner_tree}, wheighted_graph::{WheightedGraph, shortest_path::dijkstra, steiner_tree},
}; };
use tracing::trace_span; use tracing::trace_span;
@ -196,7 +192,7 @@ impl Blueprint {
// ]; // ];
if let Some(res) = if let Some(res) =
steiner_tree::takaheshi_matsuyama::<_, FastBinaryHeap<_>>(&graph, &pole_positions) steiner_tree::takaheshi_matsuyama::<_, BucketQueue<_>>(&graph, &pole_positions)
{ {
for path in res { for path in res {
let path_iter = path.iter().filter_map( let path_iter = path.iter().filter_map(
@ -252,7 +248,7 @@ impl Blueprint {
let mut roboportmap = self let mut roboportmap = self
.entities .entities
.iter() .iter()
.filter_map(|(k, e)| match e.entity { .filter_map(|(_k, e)| match e.entity {
EntityType::Roboport => Some(e.position), EntityType::Roboport => Some(e.position),
_ => None, _ => None,
}) })
@ -380,7 +376,7 @@ impl Blueprint {
start_nodes: start_nodes.clone(), start_nodes: start_nodes.clone(),
}; };
let p = dijkstra::<_, FastBinaryHeap<_>, _>(&multistart_graph, None, |p| { let p = dijkstra::<_, BucketQueue<_>, _>(&multistart_graph, None, |p| {
if let Some(n) = p { if let Some(n) = p {
match n.node_type { match n.node_type {
NodeType::In => false, NodeType::In => false,

View file

@ -1,17 +1,12 @@
use std::collections::HashMap; use super::Blueprint;
use crate::abstraction::Entity;
use factorio_core::{misc::PositionMap, prelude::Position}; use factorio_core::prelude::Position;
use factorio_graph::{ use factorio_graph::{
graph::Graph, graph::Graph, priority_queue::binary_heap::FastBinaryHeap,
priority_queue::binary_heap::FastBinaryHeap, set_cover::greedy_connected_set_cover_priority_queue,
set_cover::{greedy_connected_set_cover_priority_queue, greedy_set_cover_priority_queue},
}; };
use tracing::trace_span; use tracing::trace_span;
use crate::abstraction::Entity;
use super::{Blueprint, EntityType};
struct RoboportGraph<'a> { struct RoboportGraph<'a> {
roboports: &'a [Position], roboports: &'a [Position],
} }

View file

@ -1,7 +1,6 @@
use super::PriorityQueueByKey;
use std::collections::{HashMap, VecDeque}; use std::collections::{HashMap, VecDeque};
use super::{PriorityQueue, PriorityQueueByKey};
pub struct BucketQueue<Item> { pub struct BucketQueue<Item> {
min: i64, min: i64,
data: VecDeque<Vec<(usize, Item)>>, data: VecDeque<Vec<(usize, Item)>>,

View file

@ -6,20 +6,20 @@ use crate::{graph::Graph, priority_queue::PriorityQueue};
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct SetUncovered { pub struct SetUncovered {
setIndex: usize, set_index: usize,
uncoveredElements: usize, uncovered_elements: usize,
} }
impl PartialEq for SetUncovered { impl PartialEq for SetUncovered {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
self.uncoveredElements.eq(&other.uncoveredElements) self.uncovered_elements.eq(&other.uncovered_elements)
} }
} }
impl PartialOrd for SetUncovered { impl PartialOrd for SetUncovered {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.uncoveredElements self.uncovered_elements
.partial_cmp(&other.uncoveredElements) .partial_cmp(&other.uncovered_elements)
.map(|o| o.reverse()) .map(|o| o.reverse())
} }
} }
@ -72,8 +72,8 @@ where
.enumerate() .enumerate()
.map(|(i, s)| { .map(|(i, s)| {
Some(p.insert(SetUncovered { Some(p.insert(SetUncovered {
setIndex: i, set_index: i,
uncoveredElements: s.len(), uncovered_elements: s.len(),
})) }))
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -82,8 +82,8 @@ where
while covered_count < universe { while covered_count < universe {
let SetUncovered { let SetUncovered {
setIndex: i, set_index: i,
uncoveredElements: _, uncovered_elements: _,
} = p.pop_min().unwrap(); } = p.pop_min().unwrap();
r.push(i); r.push(i);
@ -102,7 +102,7 @@ where
} }
// dbg!(decrease, i, s.deref()); // dbg!(decrease, i, s.deref());
p.increase_key(h, |e| e.uncoveredElements -= decrease); p.increase_key(h, |e| e.uncovered_elements -= decrease);
} }
for &e in sets[i].deref() { for &e in sets[i].deref() {
@ -161,15 +161,15 @@ where
} }
for e in graph.edge_iter(&i) { for e in graph.edge_iter(&i) {
handles[e] = HandleOption::Seen(p.insert(SetUncovered { handles[e] = HandleOption::Seen(p.insert(SetUncovered {
setIndex: e, set_index: e,
uncoveredElements: sets[e].iter().filter(|&&v| !covered[v]).count(), uncovered_elements: sets[e].iter().filter(|&&v| !covered[v]).count(),
})); }));
} }
while covered_count < universe { while covered_count < universe {
let SetUncovered { let SetUncovered {
setIndex: i, set_index: i,
uncoveredElements: _, uncovered_elements: _,
} = p.pop_min().unwrap(); } = p.pop_min().unwrap();
r.push(i); r.push(i);
@ -192,7 +192,7 @@ where
} }
// dbg!(decrease, i, s.deref()); // dbg!(decrease, i, s.deref());
p.increase_key(h, |e| e.uncoveredElements -= decrease); p.increase_key(h, |e| e.uncovered_elements -= decrease);
} }
for &e in sets[i].deref() { for &e in sets[i].deref() {
@ -204,8 +204,8 @@ where
for e in graph.edge_iter(&i) { for e in graph.edge_iter(&i) {
if matches!(handles[e], HandleOption::Unknown) { if matches!(handles[e], HandleOption::Unknown) {
handles[e] = HandleOption::Seen(p.insert(SetUncovered { handles[e] = HandleOption::Seen(p.insert(SetUncovered {
setIndex: e, set_index: e,
uncoveredElements: sets[e].iter().filter(|&&v| !covered[v]).count(), uncovered_elements: sets[e].iter().filter(|&&v| !covered[v]).count(),
})); }));
} }
} }

View file

@ -1,10 +1,7 @@
use std::{collections::HashMap, fmt::Debug, hash::Hash, hash::Hasher};
use tracing::{field::Empty, trace_span};
use crate::priority_queue::{PriorityQueue, PriorityQueueByKey};
use super::WheightedGraph; use super::WheightedGraph;
use crate::priority_queue::PriorityQueueByKey;
use std::{collections::HashMap, fmt::Debug, hash::Hash, hash::Hasher};
use tracing::{field::Empty, trace_span};
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct QueueObject<N> { pub struct QueueObject<N> {

View file

@ -1,11 +1,9 @@
use tracing::trace_span;
use crate::priority_queue::{PriorityQueue, PriorityQueueByKey};
use std::hash::Hash;
use std::{collections::HashSet, fmt::Debug};
use super::shortest_path::dijkstra; use super::shortest_path::dijkstra;
use super::{WheightedGraph, shortest_path::QueueObject}; use super::{WheightedGraph, shortest_path::QueueObject};
use crate::priority_queue::PriorityQueueByKey;
use std::collections::HashSet;
use std::hash::Hash;
use tracing::trace_span;
struct MultistartWrapper<'a, 'b, G> struct MultistartWrapper<'a, 'b, G>
where where

View file

@ -1,21 +1,21 @@
use factorio_pathfinding::Pathfinder; // use factorio_pathfinding::Pathfinder;
use rand::Rng; // use rand::Rng;
use crate::Layouter; // use crate::Layouter;
pub struct GeneticAlgorithmV2 { // pub struct GeneticAlgorithmV2 {
pub new_layouts: usize, // pub new_layouts: usize,
pub mutation_timeout: usize, // pub mutation_timeout: usize,
pub max_mutations: usize, // pub max_mutations: usize,
} // }
impl Layouter for GeneticAlgorithmV2 { // impl Layouter for GeneticAlgorithmV2 {
fn layout<R: Rng, P: Pathfinder>( // fn layout<R: Rng, P: Pathfinder>(
&self, // &self,
input: &crate::LayoutInput, // input: &crate::LayoutInput,
pathfinder: &P, // pathfinder: &P,
rng: &mut R, // rng: &mut R,
) -> Option<crate::LayoutResult> { // ) -> Option<crate::LayoutResult> {
todo!() // todo!()
} // }
} // }

View file

@ -7,7 +7,6 @@ use crate::SinglePathfinder;
use crate::examples::HashMapMap; use crate::examples::HashMapMap;
use factorio_core::misc::Map; use factorio_core::misc::Map;
use factorio_core::{prelude::*, visualize::Visualize}; use factorio_core::{prelude::*, visualize::Visualize};
use factorio_graph::priority_queue::PriorityQueue;
use factorio_graph::priority_queue::PriorityQueueByKey; use factorio_graph::priority_queue::PriorityQueueByKey;
use factorio_graph::wheighted_graph::WheightedGraph; use factorio_graph::wheighted_graph::WheightedGraph;
use factorio_graph::wheighted_graph::shortest_path::QueueObject; use factorio_graph::wheighted_graph::shortest_path::QueueObject;

View file

@ -63,13 +63,14 @@ fn main() {
match args.input { match args.input {
PathfindingInputArg::EmptyDiagonal => { PathfindingInputArg::EmptyDiagonal => {
let lanes = 5;
let connections = vec![Connection { let connections = vec![Connection {
start_pos: Position::new(0, -1), start_pos: Position::new(lanes - 1, -1),
start_dir: Direction::Down, start_dir: Direction::Down,
end_pos: Position::new(args.size - 1, args.size), end_pos: Position::new(args.size - 1, args.size),
end_dir: Direction::Down, end_dir: Direction::Down,
beltspeed: factorio_core::beltoptions::Beltspeed::Normal, beltspeed: factorio_core::beltoptions::Beltspeed::Normal,
lanes: 1, lanes: lanes as usize,
}]; }];
let map = EmptyMap { let map = EmptyMap {
area: AABB::new( area: AABB::new(

View file

@ -38,6 +38,7 @@ struct SingleConnection {
pub start_dir: Direction, pub start_dir: Direction,
pub end_pos: Position, pub end_pos: Position,
pub end_dir: Direction, pub end_dir: Direction,
#[allow(dead_code)]
pub beltspeed: Beltspeed, pub beltspeed: Beltspeed,
} }