-
Notifications
You must be signed in to change notification settings - Fork 0
Fix: Tune SA performance to avoid slowdown #9
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -89,7 +89,7 @@ public static State getHillClimbSA(State state, int maxAge) { | |||||
|
|
||||||
| // Estimate initial temperature from sample mutations | ||||||
| float temperature = estimateTemperature(state); | ||||||
| int totalIterations = maxAge * 10; | ||||||
| int totalIterations = maxAge * 3; // 3x hill climb iterations balances exploration vs speed | ||||||
| float coolingRate = computeCoolingRate(temperature, maxAge); | ||||||
|
|
||||||
| State undo = state.getCopy(); | ||||||
|
|
@@ -145,7 +145,7 @@ static float estimateTemperature(State state) { | |||||
| State probe = state.getCopy(); | ||||||
| State undo = probe.getCopy(); | ||||||
| float totalDelta = 0; | ||||||
| int samples = 30; | ||||||
| int samples = 10; // fewer probes for faster temperature estimation | ||||||
|
|
||||||
| for (int i = 0; i < samples; i++) { | ||||||
| float before = probe.getEnergy(); | ||||||
|
|
@@ -167,7 +167,7 @@ static float estimateTemperature(State state) { | |||||
| * {@code initialTemp} to near-zero (0.001) over {@code maxAge * 10} iterations. | ||||||
|
||||||
| * {@code initialTemp} to near-zero (0.001) over {@code maxAge * 10} iterations. | |
| * {@code initialTemp} to near-zero (0.001) over {@code maxAge * 3} iterations. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,7 +98,7 @@ Worker getWorker() { | |
|
|
||
| private static final int max_random_states = 1000; | ||
| private static final int age = 100; | ||
| private static final int times = Math.max(1, Runtime.getRuntime().availableProcessors() / 2); | ||
| private static final int times = 1; // SA explores well enough without multiple chains; keeps speed comparable to original | ||
|
|
||
|
Comment on lines
99
to
102
|
||
| private List<State> randomStates; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totalIterationsis computed here asmaxAge * 3, butcomputeCoolingRate(temperature, maxAge)recomputes its owntotalIterationsinternally. This duplication is easy to let drift (e.g., future tuning changes one but not the other). Consider passingtotalIterationsintocomputeCoolingRate(or defining a shared constant/multiplier) so the loop count and cooling schedule can’t diverge.