Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Swiper

Carthage compatible

A series of bandit algorithms in Swift, built with functional programing and immutable data structures. Inspired by johnmyleswhite/BanditsBook.

Swiper

Swift Build System Instructions

To run on the command line:

  1. $ swift build // requires you to be in the ./Swiper directory
  2. $ ./build/debug/Swiper // builds a results_swift.tsv file in your ~/Documents/ directory

Epsilon-Greedy

The epsilon in the Epsilon-greedy strategy controls the proportion of explorations vs exploitations.

Example usage:

letepsilonGreedy=EpsilonGreedy(epsilon:0.1, nArms:2)letselectedArm= epsilonGreedy.selectArm()somethingWithCallback(color: selectedArm){(reward)inletupdatedEpsilonGreedy= epsilonGreedy.update(selectedArm, reward: reward)}

Softmax (Annealing)

The Annealing Softmax object selects arms based on a softmax function. This object does not require a temperature—the algorithm automatically manages it via simulated annealing.

Example usage:

letsoftmax=Softmax(nArms:4)letselectedArm= softmax.selectArm()somethingWithCallback(copy: selectedArm){(reward)inletupdatedSoftmax= softmax.update(selectedArm, reward: reward)}

UCB1 (Upper Confidence Bound)

The UCB strategy uses context to select its next arm. The UCB1 assumes that your max reward is a value of 1.

Example useage:

letucb=UCB1(nArms:3)letselectedArm= ucb.selectArm()somethingWithCallback(displayPopup: selectedArm){(reward)inletupdatedUcb= ucb.update(selectedArm, reward: reward)}

About

🦊 A series of bandit algorithms in Swift

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages