OperantKit is a tool kit for operant conditioning (instrumental conditioning) experiments written in Swift.
日本語:jp:: README_JP.md
import OperantKit
import RxSwift
func main() {
let schedule = FR(5) // Fixed ratio 5 schedule
let events: Observable<Void> = ... // Observable events
schedule.decision(events)
.filter({ $0.isReinforcement }) // Filtering responses of reinforcement
.subscribe(onNext: {
print("Reinforcement")
})
.disposed(by: DisposeBag())
}
Name of schedule | Code |
---|---|
Fixed ratio schedule | FR(5) |
Variable ratio schedule | VR(5) ※ |
Random ratio schedule | RR(5) |
※ The number of iterations of the variable schedule is "12" by default,
VR(10, iterations: 12)
It is also possible to change the number of iterations and so on.
Name of schedule | Code |
---|---|
Fixed interval schedule | FI(5) |
Variable interval schedule | VI(5) |
Random interval schedule | RI(5) |
The time interval defaults in .seconds
,
FI(5, unit: .minutes)
It is also possible to change the unit in such a way.
Name of schedule | Code |
---|---|
Fixed time schedule | FT(5) |
Variable time schedule | VT(5) |
Random time schedule | RT(5) |
The time interval defaults in .seconds
,
FI(5, unit: .minutes)
It is also possible to change the unit in such a way.
Name of schedule | Code |
---|---|
Continuous reinforcement | CRF() |
Extinction schedule | EXT() |
Name of schedule | Code |
---|---|
Concurrent schedule | Conc(FR(5), VI(10)) ※ |
※ When a common schedule applies to two or more types of operandam like the internal link in concurrent chained schedule, it can be handled by using Shared()
keyword. e.g. Conc(Shared(VI(10)))
Add this to your Podfile
:
pod 'OperantKit'
and
$ pod install
Add this to your Cartfile
:
github "YutoMizutani/OperantKit"
and
$ carthage update
Add this to your Package.swift
:
dependencies: [
.package(url: "https://github.com/YutoMizutani/OperantKit.git", "0.0.1" ..< "1.0.0"),
]
and
$ swift build
See docs/index.html
Clone this repository,
$ git clone https://github.com/YutoMizutani/OperantKit.git
And use make
command,
$ make deps-all
$ make open
Yuto Mizutani, yuto.mizutani.dev@gmail.com
My "motivation" is fully controlled by continuous reinforcement (FR1) schedule :)
OperantKit is available under the MIT license.