Skip to content

Commit

Permalink
Remove state key management
Browse files Browse the repository at this point in the history
  • Loading branch information
reinterpretcat committed Jun 24, 2024
1 parent 0453fa6 commit d24ddf1
Show file tree
Hide file tree
Showing 43 changed files with 535 additions and 967 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ are already published. So, I stick to it for now.
* experimental `async-evolution` feature
* NSGA-II implementation and its usage
* dependency on `hashbrown` crate
* state keys

### Fixed

Expand Down
9 changes: 1 addition & 8 deletions vrp-core/src/construction/enablers/feature_combinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use rosomaxa::evolution::objectives::dominance_order;
use rosomaxa::prelude::*;
use std::cmp::Ordering;
use std::ops::ControlFlow;
use std::slice::Iter;
use std::sync::Arc;

/// Specifies a type for injecting custom objective combination logic.
Expand Down Expand Up @@ -101,13 +100,11 @@ fn combine_features(

struct CombinedFeatureState {
states: Vec<Arc<dyn FeatureState>>,
state_keys: Vec<StateKey>,
}

impl CombinedFeatureState {
pub fn new(states: Vec<Arc<dyn FeatureState>>) -> Self {
let state_keys = states.iter().flat_map(|state| state.state_keys().cloned()).collect();
Self { states, state_keys }
Self { states }
}
}

Expand All @@ -123,10 +120,6 @@ impl FeatureState for CombinedFeatureState {
fn accept_solution_state(&self, solution_ctx: &mut SolutionContext) {
accept_solution_state_with_states(&self.states, solution_ctx)
}

fn state_keys(&self) -> Iter<StateKey> {
self.state_keys.iter()
}
}

struct CombinedFeatureConstraint {
Expand Down
8 changes: 1 addition & 7 deletions vrp-core/src/construction/enablers/multi_trip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::models::*;
use rosomaxa::prelude::*;
use std::collections::HashSet;
use std::iter::once;
use std::slice::Iter;
use std::sync::Arc;

/// Specifies multi trip extension behavior.
Expand Down Expand Up @@ -112,7 +111,6 @@ impl MultiTripConstraint {
struct MultiTripState {
multi_trip: Arc<dyn MultiTrip + Send + Sync>,
context_transition: Box<dyn JobContextTransition + Send + Sync>,
state_keys: Vec<StateKey>,
code: ViolationCode,
}

Expand All @@ -131,7 +129,7 @@ impl MultiTripState {
},
});

Self { multi_trip, context_transition, state_keys: vec![], code }
Self { multi_trip, context_transition, code }
}

fn filter_markers<'a>(&'a self, route: &'a Route, jobs: &'a [Job]) -> impl Iterator<Item = Job> + 'a + Send + Sync {
Expand Down Expand Up @@ -200,8 +198,4 @@ impl FeatureState for MultiTripState {

self.multi_trip.get_route_intervals().update_solution_intervals(solution_ctx);
}

fn state_keys(&self) -> Iter<StateKey> {
self.state_keys.iter()
}
}
Loading

0 comments on commit d24ddf1

Please sign in to comment.