Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] simulated anneal always accepts first iter #153

Merged
merged 3 commits into from
Dec 2, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[fix] simulated anneal always accepts first iter
  • Loading branch information
dariogoetz committed Dec 1, 2021
commit 7fcc5fb4b0e725b81cd6a2499e43d0e3dadb1a0a
26 changes: 16 additions & 10 deletions src/solver/simulatedannealing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,23 @@ where
const NAME: &'static str = "Simulated Annealing";
fn init(
&mut self,
_op: &mut OpWrapper<O>,
_state: &IterState<O>,
op: &mut OpWrapper<O>,
state: &IterState<O>,
) -> Result<Option<ArgminIterData<O>>, Error> {
Ok(Some(ArgminIterData::new().kv(make_kv!(
"initial_temperature" => self.init_temp;
"stall_iter_accepted_limit" => self.stall_iter_accepted_limit;
"stall_iter_best_limit" => self.stall_iter_best_limit;
"reanneal_fixed" => self.reanneal_fixed;
"reanneal_accepted" => self.reanneal_accepted;
"reanneal_best" => self.reanneal_best;
))))
let cost = op.apply(&state.get_param())?;
Ok(Some(
ArgminIterData::new()
.param(state.get_param())
.cost(cost)
.kv(make_kv!(
"initial_temperature" => self.init_temp;
"stall_iter_accepted_limit" => self.stall_iter_accepted_limit;
"stall_iter_best_limit" => self.stall_iter_best_limit;
"reanneal_fixed" => self.reanneal_fixed;
"reanneal_accepted" => self.reanneal_accepted;
"reanneal_best" => self.reanneal_best;
)),
))
}

/// Perform one iteration of SA algorithm
Expand Down