diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index b9df0a9..9a3078a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,6 +26,13 @@ enum Embedder { Content, } +#[derive(Debug, Clone, Copy, clap::ValueEnum)] +enum TspAlg { + MstDfs, + Christofides, + ChristofidesRefined, +} + #[derive(Debug, Parser)] struct Args { /// Characteristic to sort by @@ -52,6 +59,10 @@ struct Args { #[arg(short = 'b', long)] benchmark: bool, + /// Algorithm for TSP approximation. Leave as default if unsure. + #[arg(long, default_value = "christofides")] + tsp_approx: TspAlg, + images: Vec<PathBuf>, } @@ -109,12 +120,16 @@ where .collect(); // TODO only run e.embeds if !missing_embeds_indices.is_empty(); this allows // for optimizations in the ai embedde (move pip to ::embeds() instead of ::new()) - let missing_embeds = e.embeds( - &missing_embeds_indices - .iter() - .map(|i| args.images[*i].clone()) - .collect::<Vec<_>>(), - )?; + let missing_embeds = if missing_embeds_indices.is_empty() { + Vec::new() + } else { + e.embeds( + &missing_embeds_indices + .iter() + .map(|i| args.images[*i].clone()) + .collect::<Vec<_>>(), + )? + }; for (idx, emb) in missing_embeds_indices .into_iter() @@ -125,7 +140,7 @@ where } let embeds: Vec<_> = embeds.into_iter().map(|e| e.unwrap()).collect(); - let (tsp_path, total_dist) = tsp(&embeds); + let (tsp_path, total_dist) = tsp(&embeds, &args.tsp_approx); Ok(( tsp_path.iter().map(|i| args.images[*i].clone()).collect(), |