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>Expand description
A max amount generations in evolution.
max_time: Option<usize>Expand description
A max seconds to run evolution.
min_cv: Option<(String, usize, f64, bool)>Expand description
A variation coefficient parameters for termination criteria.
config: EvolutionConfigExpand description
An evolution configuration..
Implementations
impl Builder[src]
impl Builder[src]pub fn with_telemetry(self, telemetry: Telemetry) -> Self[src]
pub fn with_telemetry(self, telemetry: Telemetry) -> Self[src]Sets telemetry. Default telemetry is set to do nothing.
pub fn with_max_generations(self, limit: Option<usize>) -> Self[src]
pub fn with_max_generations(self, limit: Option<usize>) -> Self[src]Sets max generations to be run by evolution. Default is 3000.
pub fn with_min_cv(self, min_cv: Option<(String, usize, f64, bool)>) -> Self[src]
pub fn with_min_cv(self, min_cv: Option<(String, usize, f64, bool)>) -> Self[src]Sets variation coefficient termination criteria. Default is None.
pub fn with_max_time(self, limit: Option<usize>) -> Self[src]
pub fn with_max_time(self, limit: Option<usize>) -> Self[src]Sets max running time limit for evolution. Default is 300 seconds.
pub fn with_init_params(
self,
max_size: usize,
quota: f64,
methods: Vec<(Arc<dyn Recreate + Send + Sync>, usize)>
) -> Self[src]
pub fn with_init_params(
self,
max_size: usize,
quota: f64,
methods: Vec<(Arc<dyn Recreate + Send + Sync>, usize)>
) -> Self[src]Sets initial parameters used to construct initial population.
pub fn with_init_solutions(
self,
solutions: Vec<Solution>,
max_init_size: Option<usize>
) -> Self[src]
pub fn with_init_solutions(
self,
solutions: Vec<Solution>,
max_init_size: Option<usize>
) -> Self[src]Sets initial solutions in population. Default is no solutions in population.
pub fn with_population(
self,
population: Box<dyn Population + Send + Sync>
) -> Self[src]
pub fn with_population(
self,
population: Box<dyn Population + Send + Sync>
) -> Self[src]Sets population algorithm. Default is rosomaxa.
pub fn with_hyper(self, hyper: Box<dyn HyperHeuristic + Send + Sync>) -> Self[src]
pub fn with_hyper(self, hyper: Box<dyn HyperHeuristic + Send + Sync>) -> Self[src]Sets hyper heuristic algorithm. Default is simple selective.
pub fn with_termination(
self,
termination: Arc<dyn Termination + Send + Sync>
) -> Self[src]
pub fn with_termination(
self,
termination: Arc<dyn Termination + Send + Sync>
) -> Self[src]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[src]
pub fn with_pre_processing(
self,
pre_processing: Option<Arc<dyn PreProcessing + Send + Sync>>
) -> Self[src]Sets problem pre processing logic.
pub fn with_post_processing(
self,
post_processing: Option<Arc<dyn PostProcessing + Send + Sync>>
) -> Self[src]
pub fn with_post_processing(
self,
post_processing: Option<Arc<dyn PostProcessing + Send + Sync>>
) -> Self[src]Sets solution post processing logic.
Auto Trait Implementations
impl !RefUnwindSafe for Builder
impl !Send for Builder
impl !Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for Timpl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,