Skip to content

Commit

Permalink
Add conditional dependencies API
Browse files Browse the repository at this point in the history
Signed-off-by: Arjo Chakravarty <[email protected]>
  • Loading branch information
arjo129 committed Nov 13, 2024
1 parent 54992f4 commit 527d81a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/discrete_vs_nodiscrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn main() {
FixedTimeSATSolver::without_optimality_check(soln.clone());
let optimality_proof_dur = timer.elapsed();

let sat_flexible_time_problem = sat_flexible_time_model::Problem { requests };
let sat_flexible_time_problem = sat_flexible_time_model::Problem { requests, dependencies: vec![] , one_of_dependencies: vec![]};

let stop = Arc::new(AtomicBool::new(false));

Expand Down
14 changes: 12 additions & 2 deletions src/algorithms/sat_flexible_time_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ pub struct Problem {
/// A vector of requests. A solved problem will satisfy at least one "alternative"
/// within a request.
pub requests: Vec<Vec<ReservationRequestAlternative>>,

/// Dependency one of the
pub one_of_dependencies: Vec<Vec<(usize, usize)>>,

/// Dependency of the form (a, b) where a is the request id and b is the alternative id.
pub dependencies: Vec<((usize, usize), (usize, usize))>
}

impl Problem {
Expand Down Expand Up @@ -959,6 +965,8 @@ fn test_flexible_one_item_sat_solver() {

let problem = Problem {
requests: vec![req1],
one_of_dependencies: vec![],
dependencies: vec![]
};

let stop = Arc::new(AtomicBool::new(false));
Expand Down Expand Up @@ -1022,6 +1030,8 @@ fn test_flexible_two_items_sat_solver() {

let problem = Problem {
requests: vec![req1, req2],
one_of_dependencies: vec![],
dependencies: vec![]
};

let stop = Arc::new(AtomicBool::new(false));
Expand Down Expand Up @@ -1067,7 +1077,7 @@ fn test_flexible_n_items_sat_solver() {
}]);
}

let problem = Problem { requests };
let problem = Problem { requests, dependencies: vec![], one_of_dependencies: vec![] };

let stop = Arc::new(AtomicBool::new(false));
let model = SATFlexibleTimeModel {
Expand Down Expand Up @@ -1112,7 +1122,7 @@ fn test_flexible_no_soln_sat_solver() {
}]);
}

let problem = Problem { requests };
let problem = Problem { requests, one_of_dependencies: vec![], dependencies: vec![] };

let stop = Arc::new(AtomicBool::new(false));
let model = SATFlexibleTimeModel {
Expand Down
5 changes: 4 additions & 1 deletion src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ impl<ClockType: ClockSource + Clone + std::marker::Send + std::marker::Sync + 's
}
}

let problem = super::algorithms::sat_flexible_time_model::Problem { requests };
let problem = super::algorithms::sat_flexible_time_model::Problem { requests,
one_of_dependencies: vec![],
dependencies: vec![]
};

Snapshot {
problem,
Expand Down

0 comments on commit 527d81a

Please sign in to comment.