Swiftpack.co -  YutoMizutani/OperantKit as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
YutoMizutani/OperantKit
A tool for operant conditioning experiments for Swift.
.package(url: "https://github.com/YutoMizutani/OperantKit.git", from: "0.0.35")

OperantKit

Build Status Swift platform MIT License CocoaPods Carthage compatible Swift Package Manager compatible

OperantKit is a tool kit for operant conditioning (instrumental conditioning) experiments written in Swift.

日本語:jp:: README_JP.md

Usage

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())
}

Examples

Supporting schedules

Simple schedules

Fixed schedules

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.

Interval schedules

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.

Time schedules

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.

Other schedules

Name of schedule Code
Continuous reinforcement CRF()
Extinction schedule EXT()

Compound schedules

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)))

Installation

CocoaPods

Add this to your Podfile:

pod 'OperantKit'

and

$ pod install

Carthage

Add this to your Cartfile:

github "YutoMizutani/OperantKit"

and

$ carthage update

Swift Package Manager

Add this to your Package.swift:

dependencies: [
    .package(url: "https://github.com/YutoMizutani/OperantKit.git", "0.0.1" ..< "1.0.0"),
]

and

$ swift build

Dependencies

Documents

See https://yutomizutani.github.io/OperantKit/

Operant conditioning (Instrumental conditioning)

Clean architecture

Reactive programming

Development installation

Clone this repository,

$ git clone https://github.com/YutoMizutani/OperantKit.git

And use make command,

$ make deps-all
$ make open

References

Author

Yuto Mizutani, yuto.mizutani.dev@gmail.com

Donate

My "motivation" is fully controlled by continuous reinforcement (FR1) schedule :)

License

OperantKit is available under the MIT license.

GitHub

link
Stars: 6
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Dependencies

Release Notes

2 years ago
  • Add Time schedule

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API