Skip to content

Commit

Permalink
Refactor enablers in pragmatic crate
Browse files Browse the repository at this point in the history
  • Loading branch information
reinterpretcat committed Jun 10, 2024
1 parent 4690d33 commit 9216e4d
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 35 deletions.
5 changes: 4 additions & 1 deletion vrp-core/src/construction/enablers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ pub use self::departure_time::*;
mod feature_combinator;
pub use self::feature_combinator::*;

pub mod multi_trip;
mod multi_trip;
pub use self::multi_trip::*;

mod only_vehicle_activity_cost;
pub use self::only_vehicle_activity_cost::*;

mod route_intervals;
pub use self::route_intervals::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::core::models::solution::Route;
use vrp_core::models::common::{Cost, Timestamp};
use vrp_core::models::problem::{ActivityCost, SimpleActivityCost};
use vrp_core::models::solution::Activity;
use crate::models::common::{Cost, Timestamp};
use crate::models::problem::{ActivityCost, SimpleActivityCost};
use crate::models::solution::Activity;
use crate::models::solution::Route;

/// Uses costs only for a vehicle ignoring costs of a driver.
#[derive(Default)]
Expand Down
8 changes: 0 additions & 8 deletions vrp-pragmatic/src/format/enablers/mod.rs

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use vrp_core::models::common::{Distance, Duration, Location, Profile};
use vrp_core::models::problem::TransportFallback;

/// A transport fallback for only custom unknown location type.
/// A transport fallback for only a custom unknown location type.
/// Returns zero distance/duration for unknown type locations.
pub struct UnknownLocationFallback {
coord_index: Arc<CoordIndex>,
Expand Down
8 changes: 6 additions & 2 deletions vrp-pragmatic/src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ use vrp_core::prelude::GenericError;
mod coord_index;
pub use self::coord_index::CoordIndex;

mod entities;
pub use self::entities::*;

mod location_fallback;
pub use self::location_fallback::*;

pub mod problem;
pub mod solution;

pub(crate) mod enablers;

/// Represents a location type.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
Expand Down
7 changes: 2 additions & 5 deletions vrp-pragmatic/src/format/problem/aspects.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use crate::format::enablers::{BreakTie, JobTie, VehicleTie};
use crate::format::{BreakTie, JobTie, VehicleTie};
use hashbrown::HashSet;
use std::marker::PhantomData;
use vrp_core::construction::features::{
BreakAspects, BreakCandidate, BreakPolicy, CompatibilityAspects, GroupAspects, JobSkills, JobSkillsAspects,
RechargeAspects, RechargeDistanceLimitFn, RechargeKeys, ReloadAspects,
};
use vrp_core::construction::features::*;
use vrp_core::construction::heuristics::{RouteContext, StateKey};
use vrp_core::models::common::{CapacityDimension, Demand, DemandDimension, IdDimension, LoadOps};
use vrp_core::models::problem::{Job, Single, Vehicle};
Expand Down
2 changes: 1 addition & 1 deletion vrp-pragmatic/src/format/problem/clustering_reader.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use crate::format::enablers::JobTie;
use crate::format::problem::fleet_reader::get_profile_index_map;
use crate::format::JobTie;
use hashbrown::HashSet;
use std::cmp::Ordering;
use vrp_core::construction::clustering::vicinity::*;
Expand Down
2 changes: 1 addition & 1 deletion vrp-pragmatic/src/format/problem/fleet_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
mod fleet_reader_test;

use super::*;
use crate::format::enablers::{UnknownLocationFallback, VehicleTie};
use crate::format::{UnknownLocationFallback, VehicleTie};
use crate::get_unique_locations;
use crate::utils::get_approx_transportation;
use crate::Location as ApiLocation;
Expand Down
2 changes: 1 addition & 1 deletion vrp-pragmatic/src/format/problem/goal_reader.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use crate::format::enablers::{JobTie, VehicleTie};
use crate::format::problem::aspects::*;
use crate::format::{JobTie, VehicleTie};
use hashbrown::HashSet;
use vrp_core::construction::clustering::vicinity::ClusterDimension;
use vrp_core::construction::enablers::{FeatureCombinator, RouteIntervals, ScheduleKeys};
Expand Down
3 changes: 1 addition & 2 deletions vrp-pragmatic/src/format/problem/job_reader.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::format::coord_index::CoordIndex;
use crate::format::enablers::{BreakTie, JobTie, VehicleTie};
use crate::format::problem::JobSkills as ApiJobSkills;
use crate::format::problem::*;
use crate::format::{JobIndex, Location};
use crate::format::{BreakTie, JobIndex, JobTie, Location, VehicleTie};
use crate::utils::VariableJobPermutation;
use hashbrown::HashMap;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion vrp-pragmatic/src/format/problem/problem_reader.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::*;
use crate::format::enablers::{OnlyVehicleActivityCost, VehicleTie};
use crate::format::problem::clustering_reader::create_cluster_config;
use crate::format::problem::fleet_reader::*;
use crate::format::problem::goal_reader::create_goal_context;
use crate::format::problem::job_reader::{read_jobs_with_extra_locks, read_locks};
use crate::format::VehicleTie;
use crate::format::{FormatError, JobIndex};
use crate::validation::ValidationContext;
use crate::{parse_time, CoordIndex};
Expand Down
3 changes: 1 addition & 2 deletions vrp-pragmatic/src/format/solution/activity_matcher.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::format::enablers::JobTie;
use crate::format::problem::VehicleBreak;
use crate::format::problem::{Problem as FormatProblem, VehicleRequiredBreakTime};
use crate::format::solution::{Activity as FormatActivity, Schedule as FormatSchedule, Tour as FormatTour};
use crate::format::solution::{PointStop, TransitStop};
use crate::format::{CoordIndex, JobIndex};
use crate::format::{CoordIndex, JobIndex, JobTie};
use crate::parse_time;
use hashbrown::HashSet;
use std::cmp::Ordering;
Expand Down
3 changes: 1 addition & 2 deletions vrp-pragmatic/src/format/solution/initial_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
#[path = "../../../tests/unit/format/solution/initial_reader_test.rs"]
mod initial_reader_test;

use crate::format::enablers::{JobTie, VehicleTie};
use crate::format::solution::activity_matcher::{try_match_point_job, JobInfo};
use crate::format::solution::Activity as FormatActivity;
use crate::format::solution::Stop as FormatStop;
use crate::format::solution::Tour as FormatTour;
use crate::format::solution::{deserialize_solution, map_reason_code};
use crate::format::{get_indices, CoordIndex, JobIndex};
use crate::format::{get_indices, CoordIndex, JobIndex, JobTie, VehicleTie};
use crate::parse_time;
use hashbrown::{HashMap, HashSet};
use std::io::{BufReader, Read};
Expand Down
4 changes: 2 additions & 2 deletions vrp-pragmatic/src/format/solution/solution_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#[path = "../../../tests/unit/format/solution/writer_test.rs"]
mod writer_test;

use crate::format::coord_index::CoordIndex;
use crate::format::enablers::{JobTie, VehicleTie};
use crate::format::solution::activity_matcher::get_job_tag;
use crate::format::solution::model::Timing;
use crate::format::solution::*;
use crate::format::CoordIndex;
use crate::format::{JobTie, VehicleTie};
use vrp_core::construction::enablers::{get_route_intervals, ReservedTimesIndex};
use vrp_core::construction::heuristics::UnassignmentInfo;
use vrp_core::models::common::*;
Expand Down
2 changes: 1 addition & 1 deletion vrp-pragmatic/tests/helpers/core.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::format::enablers::{JobTie, VehicleTie};
use crate::format::{JobTie, VehicleTie};
use std::sync::Arc;
use vrp_core::construction::enablers::create_typed_actor_groups;
use vrp_core::models::common::*;
Expand Down
2 changes: 1 addition & 1 deletion vrp-pragmatic/tests/unit/format/problem/reader_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::format::enablers::{JobTie, VehicleTie};
use crate::format::problem::*;
use crate::format::{JobTie, VehicleTie};
use crate::helpers::*;
use hashbrown::HashSet;
use std::iter::FromIterator;
Expand Down

0 comments on commit 9216e4d

Please sign in to comment.