Skip to content

Commit

Permalink
Merge pull request #33 from vcoppe/update-alp
Browse files Browse the repository at this point in the history
Block transitions when any aircraft cannot be scheduled
  • Loading branch information
xgillard committed Feb 2, 2024
2 parents e9aa3b7 + 4d6d671 commit dfa72ec
Show file tree
Hide file tree
Showing 722 changed files with 48,193 additions and 48,230 deletions.
11 changes: 10 additions & 1 deletion ddo/examples/alp/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ impl Problem for Alp {
fn for_each_in_domain(&self, variable: ddo::Variable, state: &Self::State, f: &mut dyn ddo::DecisionCallback) {
let mut tot_rem = 0;
let mut used = HashSet::new();
let mut decisions = vec![];

for (class, rem) in state.rem.iter().copied().enumerate() {
if rem > 0 {
let aircraft = self.next[class][rem];
Expand All @@ -182,17 +184,24 @@ impl Problem for Alp {

let arrival = self.get_arrival_time(&state.info, aircraft, runway);
if arrival <= self.instance.latest[aircraft] {
f.apply(Decision { variable, value: self.to_decision(&AlpDecision { class, runway }) });
decisions.push(self.to_decision(&AlpDecision { class, runway }));
used.insert(state.info[runway]);
}
}

if used.len() == 0 {

Check warning on line 192 in ddo/examples/alp/model.rs

View workflow job for this annotation

GitHub Actions / clippy

length comparison to zero

warning: length comparison to zero --> ddo/examples/alp/model.rs:192:20 | 192 | if used.len() == 0 { | ^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `used.is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero = note: `#[warn(clippy::len_zero)]` on by default
// This aircraft will never be able to land
return;
}
}

tot_rem += rem;
}

if tot_rem == 0 {
f.apply(Decision {variable, value: DUMMY });
} else {
decisions.iter().for_each(|d| f.apply(Decision { variable, value: *d }));
}
}
}
Expand Down
Loading

0 comments on commit dfa72ec

Please sign in to comment.