Giter VIP home page Giter VIP logo

ccssmnn / hego Goto Github PK

View Code? Open in Web Editor NEW
51.0 4.0 6.0 258 KB

Metaheuristics / Blackbox Optimization Algorithms for Go: Simulated Annealing, Genetic Algorithm, Ant Colony Optimization, Tabu Search, Particle Swarm Optimization ...

License: MIT License

Go 100.00%
optimization-algorithms optimization genetic-algorithm evolutionary-algorithm simulated-annealing ant-colony-optimization go tabu-search particle-swarm-optimization

hego's People

Contributors

ccssmnn avatar hchargois avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hego's Issues

Don't keep every iteration candidate

Large problems need many iterations. The current implementation keeps a solution for every iteration in memory which leads to problems for large problems.

Only store best and current candidate.

Example different results

There is a Rastrigin example on this package README file. The example output for that example is reported on the README file as:

Screen Shot 2023-01-22 at 12 35 18

Try the same example

I run the same example on the README file, three times. Each time I get a different result.

1st try

finished Simulated Annealing in: 227.100175ms
finished Simulated Annealing, Final Result/State: [0.0029467658259519063 -0.0019141863449331415
finished Simulated Annealing, Final Value/Energy: 0.0024495962011314987

2nd try

finished Simulated Annealing in: 240.450095ms
finished Simulated Annealing, Final Result/State: [-0.0005143562820309873 -0.0024060189297087885
finished Simulated Annealing, Final Value/Energy: 0.0012009426091914577

3rd try

finished Simulated Annealing in: 190.875726ms
finished Simulated Annealing, Final Result/State: [0.0009942218440814055 0.0001947203504867579
finished Simulated Annealing, Final Value/Energy: 0.00020362763283543472

Question

Is it expected to get different results? Is such a difference acceptable? Am I missing something? Thanks.

Add binary search based weighted choice

GA and ACO use the weightedChoice method. Currently it uses a linear search strategy with O(N) performance. However a binary search with O(log(N)) could be used whenever multiple selections from the same weights are made.

I found a python implementation here

def prepare_binary_search(weights):
    # Computing the running totals takes O(N) time
    running_totals = list(itertools.accumulate(weights))
        
    def weighted_random():
        target_distance = random()*running_totals[-1]
        low, high = 0, len(weights)
        while low < high:
            mid = int((low + high) / 2)
            distance = running_totals[mid]
            if distance < target_distance:
                low = mid + 1
            elif distance > target_distance:
                high = mid
            else:
                return mid
        return low

    return weighted_random

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.