Skip to content

Commit

Permalink
Change ruin limits
Browse files Browse the repository at this point in the history
  • Loading branch information
reinterpretcat committed May 9, 2024
1 parent fcdfec0 commit 911a383
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
22 changes: 13 additions & 9 deletions vrp-core/src/solver/heuristic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,20 +555,21 @@ mod dynamic {
problem: Arc<Problem>,
environment: Arc<Environment>,
limits: RemovalLimits,
prefix: &str,
) -> Vec<(Arc<dyn Ruin + Send + Sync>, String, f64)> {
vec![
(Arc::new(AdjustedStringRemoval::new_with_defaults(limits.clone())), "asr".to_string(), 2.),
(Arc::new(NeighbourRemoval::new(limits.clone())), "neighbour_removal".to_string(), 5.),
(Arc::new(AdjustedStringRemoval::new_with_defaults(limits.clone())), format!("{prefix}_asr"), 2.),
(Arc::new(NeighbourRemoval::new(limits.clone())), format!("{prefix}_neighbour_removal"), 5.),
(
Arc::new(ClusterRemoval::new_with_defaults(problem.clone(), environment)),
"cluster_removal".to_string(),
format!("{prefix}_cluster_removal"),
4.,
),
(Arc::new(WorstJobRemoval::new(4, limits.clone())), "worst_job".to_string(), 4.),
(Arc::new(RandomJobRemoval::new(limits.clone())), "random_job_removal".to_string(), 4.),
(Arc::new(RandomRouteRemoval::new(limits.clone())), "random_route_removal".to_string(), 2.),
(Arc::new(CloseRouteRemoval::new(limits.clone())), "close_route_removal".to_string(), 4.),
(Arc::new(WorstRouteRemoval::new(limits)), "worst_route_removal".to_string(), 5.),
(Arc::new(WorstJobRemoval::new(4, limits.clone())), format!("{prefix}_worst_job"), 4.),
(Arc::new(RandomJobRemoval::new(limits.clone())), format!("{prefix}_random_job_removal"), 4.),
(Arc::new(RandomRouteRemoval::new(limits.clone())), format!("{prefix}_random_route_removal"), 2.),
(Arc::new(CloseRouteRemoval::new(limits.clone())), format!("{prefix}_close_route_removal"), 4.),
(Arc::new(WorstRouteRemoval::new(limits)), format!("{prefix}_worst_route_removal"), 5.),
]
}

Expand Down Expand Up @@ -633,7 +634,10 @@ mod dynamic {
// NOTE: consider checking usage of names within heuristic filter before changing them

let recreates = get_recreates(problem.as_ref(), random.clone());
let ruins = get_ruins(problem.clone(), environment.clone(), normal_limits.clone());
let ruins = get_ruins(problem.clone(), environment.clone(), normal_limits.clone(), "normal")
.into_iter()
.chain(get_ruins(problem.clone(), environment.clone(), small_limits.clone(), "small").into_iter())
.collect::<Vec<_>>();

let extra_random_job = Arc::new(RandomJobRemoval::new(small_limits));

Expand Down
2 changes: 1 addition & 1 deletion vrp-core/src/solver/search/ruin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl RemovalLimits {
let jobs_size = problem.jobs.size() as f64;

let min_activities = ((jobs_size * 0.05) as usize).clamp(1, 8);
let max_activities = ((jobs_size * 0.5) as usize).clamp(8, 48);
let max_activities = ((jobs_size * 0.5) as usize).clamp(8, 32);

Self { removed_activities_range: min_activities..max_activities, affected_routes_range: 2..5 }
}
Expand Down
6 changes: 4 additions & 2 deletions vrp-core/src/solver/search/ruin/route_removal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ pub struct CloseRouteRemoval {

impl CloseRouteRemoval {
/// Creates a new instance of `CloseRouteRemoval`.
pub fn new(limits: RemovalLimits) -> Self {
assert!(limits.affected_routes_range.start > 1);
pub fn new(mut limits: RemovalLimits) -> Self {
limits.affected_routes_range.start = limits.affected_routes_range.start.max(2);
limits.affected_routes_range.end = limits.affected_routes_range.end.max(3);

Self { limits }
}
}
Expand Down

0 comments on commit 911a383

Please sign in to comment.