Struct vrp_core::solver::Builder [−][src]
pub struct Builder {
pub max_generations: Option<usize>,
pub max_time: Option<usize>,
pub min_cv: Option<(String, usize, f64, bool)>,
pub config: EvolutionConfig,
}Expand description
Provides configurable way to build Vehile Routing Problem Solver instance using fluent
interface style.
A newly created builder instance is pre-configured with some reasonable defaults for mid-size problems (~200), so there is no need to call any of its methods.
Examples
This example shows how to override some of default metaheuristic parameters using fluent interface methods:
use vrp_core::solver::Builder;
use vrp_core::models::Problem;
use vrp_core::utils::Environment;
// create your VRP problem
let problem: Arc<Problem> = create_example_problem();
let environment = Arc::new(Environment::default());
// build solver using builder with overridden parameters
let solver = Builder::new(problem, environment)
.with_max_time(Some(60))
.with_max_generations(Some(100))
.build()?;
// run solver and get the best known solution within its cost.
let (solution, cost, _) = solver.solve()?;
assert_eq!(cost, 42.);
assert_eq!(solution.routes.len(), 1);
assert_eq!(solution.unassigned.len(), 0);Fields
max_generations: Option<usize>A max amount generations in evolution.
max_time: Option<usize>A max seconds to run evolution.
min_cv: Option<(String, usize, f64, bool)>A variation coefficient parameters for termination criteria.
config: EvolutionConfigAn evolution configuration..
Implementations
Sets telemetry. Default telemetry is set to do nothing.
Sets max generations to be run by evolution. Default is 3000.
Sets variation coefficient termination criteria. Default is None.
Sets max running time limit for evolution. Default is 300 seconds.
Sets initial parameters used to construct initial population.
Sets initial solutions in population. Default is no solutions in population.
Sets population algorithm. Default is rosomaxa.
Sets hyper heuristic algorithm. Default is simple selective.
Sets termination algorithm. Default is max time and max generations.
pub fn with_pre_processing(
self,
pre_processing: Option<Arc<dyn PreProcessing + Send + Sync>>
) -> Self
pub fn with_pre_processing(
self,
pre_processing: Option<Arc<dyn PreProcessing + Send + Sync>>
) -> Self
Sets problem pre processing logic.
pub fn with_post_processing(
self,
post_processing: Option<Arc<dyn PostProcessing + Send + Sync>>
) -> Self
pub fn with_post_processing(
self,
post_processing: Option<Arc<dyn PostProcessing + Send + Sync>>
) -> Self
Sets solution post processing logic.