GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - jbytecode/mccga.py: Machine-coded compact genetic algorithm in Python

BranchesTags
Open more actions menu

Latest commit

 

History

20 Commits
20 Commits

Folders and files

NameName
Last commit message
Last commit date
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
__init__.py
__init__.py
 
 
byteworks.py
byteworks.py
 
 
genprobs.py
genprobs.py
 
 
hookejeeves.py
hookejeeves.py
 
 
optimizer.py
optimizer.py
 
 
utility.py
utility.py
 
 

Repository files navigation

mccga.py

Machine-coded compact genetic algorithm in Python

In-short

The package implements the Machine-coded compact genetic algorithm defined in

Satman, M. H. & Akadal, E. (2020). Machine Coded Compact Genetic Algorithms for Real Parameter Optimization Problems . Alphanumeric Journal , 8 (1) , 43-58 . DOI: 10.17093/alphanumeric.576919 Link

Usage

Suppose the optimization problem is

$$ \min f(x, y) = \text{abs}(x - 3.14159265) + \text{abs}(y - \exp{1}) $$

then the MCCGA searches for the minimum using

def f(xs: list[float]) -> float:
    return abs(xs[0] - 3.14159265) + abs(xs[1] - 2.71828)

rangemin = [-100.0, -100.0]
rangemax = [100.0, 100.0]
mutrate = 0.001
maxiter = 100000
result = optimizer.mccga(f, rangemin, rangemax, mutrate, maxiter)

Other implementations

  • Julia (https://github.com/jmejia8/Metaheuristics.jl)
  • Rust (https://crates.io/crates/mccga)
  • Java (https://github.com/jbytecode/mccga.java)

Calling mccga() from R

Thanks to the reticulate package, the Python function mccga() can be called into R. Here is the example:

# The package for R & Python integration
library(reticulate)

# Loading the mccga library
source_python("optimizer.py")

# Defining the objective function 
f <- function(xs){
    val <- (xs[1] - 3.14159265)^2 + (xs[2] - 2.71828)^2
    return(val)
}

result <- mccga(f, c(-100, -100), c(100, 100), 0.0001, 100000)

> result
[1] 3.141595 2.718276

About

Machine-coded compact genetic algorithm in Python

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

2 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.