Skip to content

Commit

Permalink
modify src/solver/restart.rs (this will be used in 0.18.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
shnarazk committed Aug 1, 2024
1 parent 6331a94 commit 45fbd21
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/solver/restart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ pub trait RestartIF: Instantiate {
fn set_segment_parameters(&mut self, segment_scale: usize);
}

const FUEL: f64 = 2.0;
const SCALE: f64 = 64.0;
const FUEL: f64 = 1.0;

/// `RestartManager` provides restart API and holds data about restart conditions.
#[derive(Clone, Debug, Default)]
pub struct RestartManager {
penetration_energy: f64,
pub penetration_energy_charged: f64,
penetration_energy_unit: f64,
field_scale: f64,
}

impl Instantiate for RestartManager {
Expand All @@ -29,7 +27,6 @@ impl Instantiate for RestartManager {
penetration_energy: FUEL,
penetration_energy_charged: FUEL,
penetration_energy_unit: FUEL,
field_scale: 1.0 / SCALE,
}
}
fn handle(&mut self, e: SolverEvent) {
Expand All @@ -41,14 +38,11 @@ impl Instantiate for RestartManager {

impl RestartIF for RestartManager {
fn restart(&mut self, lbd: &EmaView, ent: &EmaView) -> bool {
let gscale = |x: f64| self.field_scale * (x - 1.0) + 1.0;
self.penetration_energy -= (lbd.trend() + gscale(ent.trend())) - 2.0;
self.penetration_energy -= 0.125 * (lbd.trend() / ent.trend());
self.penetration_energy < 0.0
}
fn set_segment_parameters(&mut self, segment_scale: usize) {
let factor = 0.5 * (segment_scale.trailing_zeros() + 1) as f64;
self.field_scale = 1.0 / (SCALE - factor);
self.penetration_energy_unit *= 10.0_f64.powf(-0.1);
fn set_segment_parameters(&mut self, _segment_scale: usize) {
// self.penetration_energy_unit *= 10.0_f64.powf(-0.1);
}
fn set_stage_parameters(&mut self, stage_scale: usize) {
let e = self.penetration_energy_unit * (stage_scale as f64);
Expand Down

0 comments on commit 45fbd21

Please sign in to comment.