Class AbstractClimber
- java.lang.Object
-
- com.github.benmanes.caffeine.cache.simulator.policy.sketch.climbing.AbstractClimber
-
- All Implemented Interfaces:
HillClimber
- Direct Known Subclasses:
Adam,AmsGrad,Nadam,SimpleClimber,SimulatedAnnealingClimber,Stochastic
public abstract class AbstractClimber extends Object implements HillClimber
A skeleton for hill climbers that walk using the hit rate.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.github.benmanes.caffeine.cache.simulator.policy.sketch.climbing.HillClimber
HillClimber.Adaptation, HillClimber.QueueType
-
-
Field Summary
Fields Modifier and Type Field Description protected inthitsInMainprotected inthitsInSampleprotected inthitsInWindowprotected intmissesInSampleprotected doublepreviousHitRateprotected intsampleSize
-
Constructor Summary
Constructors Constructor Description AbstractClimber()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description HillClimber.Adaptationadapt(double windowSize, double probationSize, double protectedSize, boolean isFull)Determines how to adapt the segment sizes.protected abstract doubleadjust(double hitRate)Returns the amount to adapt by.voidonHit(long key, HillClimber.QueueType queueType, boolean isFull)Records that a hit occurred with a full cache.voidonMiss(long key, boolean isFull)Records that a miss occurred with a full cache.protected voidresetSample(double hitRate)Starts the next sample period.
-
-
-
Method Detail
-
onMiss
public void onMiss(long key, boolean isFull)Description copied from interface:HillClimberRecords that a miss occurred with a full cache.- Specified by:
onMissin interfaceHillClimber- Parameters:
key- the key accessedisFull- if the cache is fully populated and had to evict
-
onHit
public void onHit(long key, HillClimber.QueueType queueType, boolean isFull)Description copied from interface:HillClimberRecords that a hit occurred with a full cache.- Specified by:
onHitin interfaceHillClimber- Parameters:
key- the key accessedqueueType- the queue the entry was found inisFull- if the cache is fully populated
-
adapt
public HillClimber.Adaptation adapt(double windowSize, double probationSize, double protectedSize, boolean isFull)
Description copied from interface:HillClimberDetermines how to adapt the segment sizes.- Specified by:
adaptin interfaceHillClimber- Parameters:
windowSize- the current window sizeprobationSize- the current probation sizeprotectedSize- the current protected sizeisFull- if the cache is fully populated- Returns:
- the adjustment to the segments
-
adjust
protected abstract double adjust(double hitRate)
Returns the amount to adapt by.
-
resetSample
protected void resetSample(double hitRate)
Starts the next sample period.
-
-