Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tabu_search

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tabu_search

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

TabuSearch

A simple Tabu Search framework

Installation

Add this line to your application's Gemfile:

gem 'tabu_search'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tabu_search

Usage

Require methods:

  • Class#genome Support dup
  • Class#genome=
  • Class#fitness Current unit fitness, the bigger than better
  • Class#search_neighbour(ts) Search some neighbour units
  • Class#step(ts, data) Update unit and TS context

Example:

class Unit
  include TabuSearch

  LEN = 5

  attr_accessor :genome

  def initialize(genome)
    @genome = genome.dup
  end

  def fitness
    val = genome.join.to_i(2)
    return 0 if val > 10
    10 * val - val * 3 + val ** 2
  end

  def step(ts, data)
    id, index, val, new_fitness = data
    genome[index] = val
    ts.update(id, genome, new_fitness)
  end

  def search_neighbour(ts)
    LEN.times.map do |i|
      origin = genome[i]
      new_val = 1 - origin
      genome[i] = new_val
      new_fitness = fitness
      genome[i] = origin
      ["#{i}-#{new_val}", i, new_val, new_fitness]
    end
  end
end

# Class.tabu_search(instance, times, tabu_size)
Unit.tabu_search(Unit.new([1,2,3]), 10, 10)
# or
Unit.new_ts_ctx(10).search(Unit.new([1,2,3]), 10)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/xjz19901211]/tabu_search.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 01 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc