[−][src]Struct vrp_core::solver::Builder
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; // create your VRP problem let problem: Arc<Problem> = create_example_problem(); // build solver using builder with overridden parameters let solver = Builder::new(problem) .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.
cost_variation: Option<(usize, f64)>
A cost variation parameters for termination criteria.
seed: Option<u64>
A randomization seed
config: EvolutionConfig
An evolution configuration..
Implementations
impl Builder
[src]
impl Builder
[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]
Sets max generations to be run by evolution. Default is 3000.
pub fn with_cost_variation(self, variation: Option<(usize, f64)>) -> Self
[src]
Sets cost variation termination criteria. Default is None.
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,
size: Option<usize>,
initial_methods: Option<Vec<(Box<dyn Recreate + Send + Sync>, usize)>>
) -> Self
[src]
self,
size: Option<usize>,
initial_methods: Option<Vec<(Box<dyn Recreate + Send + Sync>, usize)>>
) -> Self
Sets initial parameters used to construct initial population.
pub fn with_init_solutions(self, solutions: Vec<Solution>) -> Self
[src]
Sets initial solutions in population. Default is no solutions in population.
pub fn with_population_size(self, size: usize) -> Self
[src]
Sets max population size. Default is 4.
pub fn with_selection(self, selection: Arc<dyn Selection + Send + Sync>) -> Self
[src]
Sets selection algorithm. Default is naive selection.
pub fn with_mutation(self, mutation: Arc<dyn Mutation + Send + Sync>) -> Self
[src]
Sets mutation algorithm. Default is ruin and recreate.
pub fn with_termination(self, termination: Arc<dyn Termination>) -> Self
[src]
Sets termination algorithm. Default is max time and max generations.
pub fn with_seed(self, seed: Option<u64>) -> Self
[src]
Sets randomization seed.
pub fn build(self) -> Result<Solver, String>
[src]
Builds Solver
instance.
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,