A lightweight stochastic optimizer based on slime mold (Slime Mold Algorithm)

Overview

Slime

This is a Swift implementation of a Slime Mold Algorithm - a stochastic optimizer - generally based on this paper

The only dependency required by Slime is SwiftNumerics

Visual Examples

Searching for the global maxima of -abs(x + 100000) - abs(y + 100000) + sin(10 * x)

Searching for the shortest path visiting 50 locations (traveling salesman)

Use the Slime

In a SwiftPM project:

Add the following line to the dependencies in your Package.swift file:

.package(url: "https://github.com/ejjonny/slime", from: "1.0.0"),

Add Slime as a dependency for your target:

.target(
    name: "MyTarget", 
    dependencies: [
        .product(name: "Slime", package: "Slime"),
    ]
),

Add import Slime to your swift file.

var slime = Slime(
                populationSize: 10,
                maxIterations: 100,
                lowerBound: [-1, -1],
                upperBound: [1, 1],
                method: .minimize, // Use .maximize if higher fitness values are better
                fitnessEvaluation: { vector in
                    let x = vector[0]
                    let y = vector[1]
                    // Return a fitness value Double using the proposed vector
                }
            )
slime.run() // This runs the fitness evaluation many times, among other busy work, & will usually be expensive

slime.bestCells // An array of the top 3 Cells. Use Cell.position for the associated vectors

This example is using a 2 dimensional solution space. The algorithm will work with any number of vector components if you're looking for a solution in hyperspace.

More Info

wikiversity

"Slime mold algorithm (SMA) is a population-based optimization technique which is proposed based on the oscillation style of slime mold in nature. The SMA has a unique mathematical model that simulates positive and negative feedbacks of the propagation wave of slime mold. It has a dynamic structure with a stable balance between global and local search drifts."

TODO:

  • Readme walkthrough of the math used in the algorithm
  • Explore some deterministic changes
You might also like...
swift-algorithm 눈물이 차올라서 고갤 들어..
swift-algorithm 눈물이 차올라서 고갤 들어..

swift-algorithm 눈물이 차올라서 고갤 들어.. 알고리즘 정리 Union Find Dynamic Programming 자주 사용되는 문법 1. for문 거꾸로 돌리기 0...n의 반대 for i in stride(from: n, to: 0, by: -1) {

Algorithm is a library of tools that is used to create intelligent applications.
Algorithm is a library of tools that is used to create intelligent applications.

Welcome to Algorithm Algorithm is a library of tools that is used to create intelligent applications. Features Probability Tools Expected Value Progra

💻 A fast and flexible O(n) difference algorithm framework for Swift collection.
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.

A fast and flexible O(n) difference algorithm framework for Swift collection. The algorithm is optimized based on the Paul Heckel's algorithm. Made wi

Simple macOS app that applies Apple's Person Segmentation algorithm to a video.
Simple macOS app that applies Apple's Person Segmentation algorithm to a video.

Simple macOS app that applies Apple's Person Segmentation algorithm to a video.

The Binary Search Algorithm in Swift 🤯 👨🏻‍💻
The Binary Search Algorithm in Swift 🤯 👨🏻‍💻

Binary Search in Swift Binary search is a simple algorithm that lets you search an array for a specific value. It’s trivial to implement in Swift, whi

Swift package wrapping the OpenWall BCrypt hashing algorithm

SwiftBCrypt A simple Swift Package wrapping the OpenWall BCrypt hashing algorithm. Generate Salt let bcryptSalt = try BCRypt.makeSalt() Hash Phrases

Debit/Credit card validation port of the Luhn Algorithm in Swift

SwiftLuhn Warning! This repository is no longer maintained. This is a port of the Luhn Algorithm, generally used for validating debit/credit card deta

Luhn Credit Card Validation Algorithm

Luhn Algorithm This is a port of the Luhn Algorithm, generally used for validating Credit Card details, to Objective-C (iOS). Swift port can be found

Simple and secure hashing in Swift with the SipHash algorithm

SipHash ⚠️ WARNING This package has been obsoleted by the Hasher type and the Hashable.hash(into:) requirement introduced in Swift 4.2. Using this pac

A mosaic collection view layout inspired by Lightbox's Algorithm, written in Swift 🔶
A mosaic collection view layout inspired by Lightbox's Algorithm, written in Swift 🔶

TRMosaicLayout A mosaic collection view layout inspired by Lightbox's Algorithm. This is a swift implementation/extension of @fmitech's FMMosaicLayout

Swift-cuckoo-collections - Cross-platform Swift dictionaries & sets that use a cuckoo hashing algorithm

CuckooCollections A Swift package for open-addressed sets and dictionaries that

Simplex-Swift - A basic implementation of the Simplex algorithm, written in Swift

Simplex-Swift - A basic implementation of the Simplex algorithm, written in Swift

Luhn Credit Card Validation Algorithm

Luhn Algorithm This is a port of the Luhn Algorithm, generally used for validating Credit Card details, to Objective-C (iOS). Swift port can be found

A native, lightweight and secure time-based (TOTP) & counter-based (HOTP) password client built for iOS
A native, lightweight and secure time-based (TOTP) & counter-based (HOTP) password client built for iOS

A native, lightweight and secure time-based (TOTP) & counter-based (HOTP) password client built for iOS Built by Tijme Gommers – Buy me a coffee via P

Super lightweight web framework in Swift based on SWSGI

Ambassador Super lightweight web framework in Swift based on SWSGI Features Super lightweight Easy to use, designed for UI automatic testing API mocki

CleanroomLogger provides an extensible Swift-based logging API that is simple, lightweight and performant
CleanroomLogger provides an extensible Swift-based logging API that is simple, lightweight and performant

CleanroomLogger CleanroomLogger provides an extensible Swift-based logging API that is simple, lightweight and performant. The API provided by Cleanro

Super lightweight web framework in Swift based on SWSGI

Ambassador Super lightweight web framework in Swift based on SWSGI Features Super lightweight Easy to use, designed for UI automatic testing API mocki

NotificationCenter based Lightweight UI / AnyObject binder.
NotificationCenter based Lightweight UI / AnyObject binder.

Continuum NotificationCenter based Lightweight UI / AnyObject binder. final class ViewController: UIViewController { @IBOutlet weak var label: UI

SwiftySideMenu is a lightweight and easy to use side menu controller to add left menu and center view controllers with scale animation based on Pop framework.
SwiftySideMenu is a lightweight and easy to use side menu controller to add left menu and center view controllers with scale animation based on Pop framework.

SwiftySideMenu SwiftySideMenu is a lightweight, fully customizable, and easy to use controller to add left menu and center view controllers with scale

Releases(2.0.1)
Owner
Ethan J
Ethan J
Swift package wrapping the OpenWall BCrypt hashing algorithm

SwiftBCrypt A simple Swift Package wrapping the OpenWall BCrypt hashing algorithm. Generate Salt let bcryptSalt = try BCRypt.makeSalt() Hash Phrases

Tanner Silva 1 Jul 8, 2022
Swift-cuckoo-collections - Cross-platform Swift dictionaries & sets that use a cuckoo hashing algorithm

CuckooCollections A Swift package for open-addressed sets and dictionaries that

Christopher Richez 0 Aug 2, 2022
PGPro can encrypt and decrypt messages as well as manage all your OpenPGP keys. It is free, simple and lightweight. Everything stays on your device. PGPro is made in Switzerland.

PGPro can encrypt and decrypt messages as well as manage all your OpenPGP keys. It is free, simple and lightweight. Everything stays on your device. P

Luca Näf 250 Jan 4, 2023
Swift-based fuzzing tools

The Mac is changing. We've long had a platform where out-of-the-box we were able to compile and run tools in a variety of languages.

Charles Edge 18 Jun 30, 2022
SuccessorCLI A CLI tool to restore iOS Devices on versions they're already on, based on the original Succession

A tool to restore iOS Devices on versions they're already on, based on the original Succession

Dabezt 11 Dec 26, 2022
Algorithm is a library of tools that is used to create intelligent applications.

Welcome to Algorithm Algorithm is a library of tools that is used to create intelligent applications. Features Probability Tools Expected Value Progra

Cosmicmind 821 Jan 9, 2023
Swift implementation of the longest common subsequence (LCS) algorithm.

SwiftLCS SwitLCS provides an extension of Collection that finds the indexes of the longest common subsequence with another collection. The longest com

Tommaso Madonia 212 Dec 29, 2022
Simple and secure hashing in Swift with the SipHash algorithm

SipHash ⚠️ WARNING This package has been obsoleted by the Hasher type and the Hashable.hash(into:) requirement introduced in Swift 4.2. Using this pac

null 262 Dec 19, 2022
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.

A fast and flexible O(n) difference algorithm framework for Swift collection. The algorithm is optimized based on the Paul Heckel's algorithm. Made wi

Ryo Aoyama 3.3k Jan 4, 2023
Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm

Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm. Creating a chan

Christoffer Winterkvist 127 Jun 3, 2022