Skip to content

Commit

Permalink
perf(jssp)?!: do not store scheduled operations (#449)
Browse files Browse the repository at this point in the history
## Description

The only thing we need is number of currently scheduled operations -> we
do not need to store operation ids.
This should redice allocations (memory footprint) & peformance (to the
very very limited extent)
  • Loading branch information
kkafar authored Oct 22, 2023
1 parent c1ad4a9 commit cd3522a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions examples/jssp/problem/fitness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ use crate::problem::{Edge, EdgeKind};
use super::individual::JsspIndividual;

pub struct JsspFitness {
// All operations that have been sheduled up to iteration g
scheduled: HashSet<usize>,

// Delay feasible operations are those operations that:
// 1. have not yet been scheduled up to iteration g (counter defined below),
// 2. all their predecesors have finished / will have been finished in time window t_g +
Expand All @@ -22,7 +19,6 @@ pub struct JsspFitness {
impl JsspFitness {
pub fn new() -> Self {
Self {
scheduled: HashSet::new(),
delay_feasibles: Vec::new(),
}
}
Expand All @@ -43,7 +39,7 @@ impl JsspFitness {
let mut finish_times = vec![usize::MAX; n + 2];

// Schedule the dummy zero operation
self.scheduled.insert(0);
let mut scheduled_count = 1;
finish_times[0] = 0;
indv.operations[0].finish_time = Some(0);

Expand All @@ -65,7 +61,7 @@ impl JsspFitness {
let mut j: usize;

let mut last_finish_time = 0;
while self.scheduled.len() < n + 1 {
while scheduled_count < n + 1 {
// Calculate the delay. The formula is taken straight from the paper.
// TODO: Parameterize this & conduct experiments
let mut delay = self.delay_for_g(indv, n, g, maxdur);
Expand Down Expand Up @@ -97,7 +93,7 @@ impl JsspFitness {
+ op_j_duration;

// Update state
self.scheduled.insert(op_j.id);
scheduled_count += 1;
finish_times[op_j.id] = finish_time_j;
g += 1;

Expand Down Expand Up @@ -345,7 +341,6 @@ impl JsspFitness {
#[inline]
fn reset(&mut self) {
self.delay_feasibles.clear();
self.scheduled.clear();
}
}

Expand Down

0 comments on commit cd3522a

Please sign in to comment.