Code Monkey home page Code Monkey logo

mpopt's Introduction

MPOPT: Multi-Population based Optimization

standard-readme compliant

mpopt is a flexible framework for complex optimization tasks by managing multiple populations.

Note: We only consider Bound-Constrained, Continuous, Black-Box, Minimization optimization problems.

This repository is a generalized framework of Fireworks Algorithm and traditional EAs and SIOAs. It is inspired from the research of (FWA) and presently mainly used in FWA-related research and applications.

The repository contains:

  1. Basic operators used in EAs and SIOAs.

  2. Methods and examples for designing populations.

  3. Methods and examples for designing optimization algorithms with population.

  4. A new objective function interface and some pre-compiled benchmarks.

  5. Analysis tools for optimization results.

Table of Contents

Background

mpopt is motivated by the research of FWA, in which multiple population called fireworks are maintained for optimization. This optimization framework is of great significance in future research and application. The aim of this repository is to provide a complete set of toolkits for designing, benchmarking and applying those methods.

The latest information on FWA can be found at here.

Install

To install 'mpopt', run the following commands:

git clone [email protected]:CavalloneChen/mpopt.git
cd mpopt
python3 setup.py install

If you do not have the super authority, run python3 setup.py install --user instead.

Note: 'numpy' is required for this repository.

Usage

Here, we illustrate how to optimize using mpopt. First of all, numpy is needed in most parts of the package.

import numpy as np

Objective Function

If you want to provide a handcraft objective, a callable function is needed first. For example:

def my_func(X):
    return np.sum(X**2)

Then, an ObjFunction instance should be created using the callable function with some additional infomation, which illustrate how the function should be called:

from mpopt.tools.objective import ObjFunction
obj = ObjFunction(my_func, dim=2, lb=-1, ub=1)

ObjFunction instance can be called directly, but it is better to create a Evaluator instance for each run of optimization.

from mpopt.tools.objective import Evaluator
evaluator = Evaluator(obj, max_eval = 100)

You can also get a evaluator from provided benchmark easily:

from mpopt.benchmarks.benchmark import Benchmark
# get CEC20 benchmark in 10 dimension.
benchmark = Benchmark('CEC20', 10)
# get a evaluator for the first function
func_id = 0
evaluator = benchmark.generate(func_id)

The evaluator holds the setting of optimization task and record states during the optimization. For example, a random search can simply be completed by following code:

lb = evaluator.obj.lb
ub = evaluator.obj.ub
dim = evaluator.obj.dim
sample_num = 10
while not evaluator.terminate():
    rand_samples = np.random.uniform(lb, ub, [sample_num, dim])
    fitness = evaluator(rand_samples)
print("Optimal: {}, Value: {}.".format(evaluator.best_x, evaluator.best_y))

Algorithm

Currently, mpopt provie some classic population based algorithms which can be used directly. We are planning on providing a lot more algorithms. For example, you can optimize a evaluator using following code:

from mpopt.algorithms.LoTFWA import LoTFWA
alg = LoTFWA()
opt_val = alg.optimize(evaluator)

You can also get and adjust the default params of the algorithm:

params = alg.default_params()
alg.set_params(params)

Contributing

Please follow the README.md in each module for requirements to contirbutes.

If you have any question, contact Yifeng Li ([email protected]).

License

This source code is licensed under GPL v3. License is avaliable here.

Definitions

  • EA: Evolutionary Algorithm.

  • SIOA: Swarm Intelligence Optimization Algorithm.

mpopt's People

Contributors

aor-li avatar cavallonechen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

cil-lab

mpopt's Issues

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.