Giter VIP home page Giter VIP logo

batch-metaheuristics's Introduction

batchopt

license:MIT

This is a repository of black-box-optimization using meta-heuristics.

Usage

Quick Start:

git clone [email protected]:pfnet-research/batch_metaheuristics.git
cd batch_metaheuristics
pip install ./batchopt
python example.py

Output (Black box optimization involves random elements, so the results will be different each time):

> Epoch: 1, Best fit: 884.7695325180321
> Epoch: 2, Best fit: -63.122234265670585
> Epoch: 3, Best fit: -85.04995732445039
> Epoch: 4, Best fit: -85.04995732445039
> Epoch: 5, Best fit: -111.70023680346456
> Epoch: 6, Best fit: -127.10859058276085
> Epoch: 7, Best fit: -131.96113684754317
> Epoch: 8, Best fit: -135.051712626202
> Epoch: 9, Best fit: -137.46424504437974
> Epoch: 10, Best fit: -138.53373567844406

Entire code of example.py is like this:

from batchopt.benchfunctions import batch_styblinski_tang
from batchopt.optimizers.whale_optimization_algorithm import WhaleOptimizationAlgorithm

opt = WhaleOptimizationAlgorithm(
    domain_range=[(-20, 20), (-20, 20), (-20, 20), (-20, 20)],
    pop_size=50,
    epoch=10,
    log=True,
)
objective_function = batch_styblinski_tang
# must be function 2-dimension-array to 1 dimension array

opt.optimize(objective_function)

This example uses WhaleOptimizationAlgorithm as optimizer. You can use other 20+ algorithms. Optimization algorithms are initialized with the following arguments:

  • domain_range: List of domain of the objective function.
  • pop_size: Number of candidate points to generate at one time.
  • epoch: Number of times to repeat the optimization process.
  • log: Whether to display logs.

Once you have created an instance of Optimizer, optimize with the optimize method. The argument of the optimize method is the objective function. The Objective function needs to be a mapping from a 2D-array to a 1D-array.

Reference:

Reference implementation: https://github.com/thieu1995/mealpy

batch-metaheuristics's People

Contributors

mist714 avatar

Stargazers

 avatar

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.