Skip to content

Commit

Permalink
Reduce quality upper bound clamp range
Browse files Browse the repository at this point in the history
  • Loading branch information
KonaeAkira committed Aug 11, 2024
1 parent 56bafd0 commit 311b2c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions solvers/src/macro_solver/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ impl<'a> MacroSolver<'a> {
if popped % (1 << 16) == 0 {
(self.progress_callback)(search_queue.progress_estimate());
}
let mut search_actions = match backload_progress && state.progress != 0 {

let search_actions = match state.get_quality() >= self.settings.max_quality
|| (backload_progress && state.progress != 0)
{
true => PROGRESS_SEARCH_ACTIONS.intersection(self.settings.allowed_actions),
false => FULL_SEARCH_ACTIONS.intersection(self.settings.allowed_actions),
};
if state.get_quality() >= self.settings.max_quality {
search_actions = search_actions.minus(QUALITY_ACTIONS);
}

let current_steps = search_queue.steps(backtrack_id);

Expand Down
6 changes: 3 additions & 3 deletions solvers/src/quality_upper_bound_solver/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ impl QualityUpperBoundSolver {
solved_states: HashMap::default(),
pareto_front_builder: ParetoFrontBuilder::new(
settings.max_progress,
settings.max_quality.saturating_mul(2),
settings.max_quality + 9 * settings.base_quality,
),
waste_not_1_min_cp: waste_not_min_cp(Action::WasteNot.cp_cost(), 4, durability_cost),
waste_not_2_min_cp: waste_not_min_cp(Action::WasteNot2.cp_cost(), 8, durability_cost),
}
}

/// Returns an upper-bound on the maximum Quality achievable from this state while also maxing out Progress.
/// The returned upper-bound is clamped to 2 times settings.max_quality.
/// There is no guarantee on the tightness of the upper-bound.
pub fn quality_upper_bound(&mut self, mut state: SimulationState) -> u16 {
let current_quality = state.get_quality();
Expand Down Expand Up @@ -92,8 +91,9 @@ impl QualityUpperBoundSolver {
Ok(i) => i,
Err(i) => i,
};

std::cmp::min(
self.settings.max_quality.saturating_mul(2),
self.settings.max_quality + 9 * self.settings.base_quality,
pareto_front[index].second.saturating_add(current_quality),
)
}
Expand Down

0 comments on commit 311b2c7

Please sign in to comment.