# cuckoo-search

> An cuckoo search JavaScript library.

Latest version **1.0.0** (published 2018-12-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install cuckoo-search
pnpm add cuckoo-search
yarn add cuckoo-search
bun add cuckoo-search
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-12-08 |
| First published | 2018-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Luyu Liu |
| Maintainers | sarchivorist |
| Keywords | optimization-algorithms, visualization, metaheuristics |

## Links

- npm: https://www.npmjs.com/package/cuckoo-search
- Repository: https://github.com/luyuliu/cuckoo.js
- Homepage: https://github.com/luyuliu/cuckoo.js#readme
- Issues: https://github.com/luyuliu/cuckoo.js/issues
- npm.io page: https://npm.io/package/cuckoo-search

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-12-08

## README

# cuckoo.js

A cuckoo search JavaScript library. Read more about [Cuckoo Search Algorithm](https://ieeexplore.ieee.org/abstract/document/5393690).

## Feature
 * Implement basic cuckoo search algorithm.
 * Support integer and real number optimization.
 * Support upperBound and lowerBound array.
 * Support WebWorker, node.js, and browser.
 
## Import
Please be aware that this library depends on [underscore.js](https://underscorejs.org/). Make sure install underscore.js before using.

Web browser environment: 
```HTML
<script src="cuckoo.js"></script>
<script src="underscore.js"></script>
```

Node.js environment:
```bash
$ npm install cuckoo-search
$ npm install underscore
```
and

```js
Cuckoo = require("cuckoo-search"); // Add to the first line.
```

## API usage
```js
var cuckoo = new Cuckoo(objectiveFunction, // Objective Function to be **minimized**.
    nestCount, // The number of nests.
    dimension, // The dimension of the optimization problem.
    Pa, // The rate of nests replacement. Default to 0.25.
    lowerBound, // The lower bound array. The demension of this array should be equal to dimension.
    upperBound, // The upper bound array. The demension of this array should be equal to dimension.
    intFlag, // True if the problem is an integer problem; False otherwise.
    uniqueFlag // True if each dimension's value should be different; False otherwise. e.g.: If true, the solution [0, 0, 0, 0] here is not allowed.
);

// Initialization
cuckoo.init(); // Init the cuckoo search process.

// Next iteration
cuckoo.next(); // Proceed to the next iteration.

// Output
cuckoo.output(outputFlag); // Output the result. Print the result after this iteration if outputFlag is true.

// The output is a JSON object:
//{ 
//  solution: [ 0, 0, 0, 0 ], 
//  objective: 0 
//}
```

## Example
### Live demo: 
https://luyuliu.github.io/cuckoo.js/example/graph/

### Node.js example
```js
Cuckoo = require("cuckoo-research");

var objectiveFunction = function (x) {
    var result = 0;
    for (var i in x) {
        result += (x[i])
    }
    return result;
}

var upperBound = [99, 99, 99, 99];
var lowerBound = [0, 0, 0, 0];
var cuckoo = new Cuckoo(objectiveFunction, 10, 4, 0.25, lowerBound, upperBound, true, false);
cuckoo.init();
var maxgen = 100;

for (var i = 0; i < maxgen; i++) {
    cuckoo.next(false);
    console.log(cuckoo.output());
}
```
## Acknowledgement
 * The basic CS algorithm is based on [@Xin-She Yang](https://www.mathworks.com/matlabcentral/fileexchange/29809-cuckoo-search-cs-algorithm)'s Matlab script. 
 * I also referred to [@Ningchuan Xiao](https://github.com/ncxiao)'s Python script. 
 * This is a final project for OSU GEOG8200.

---
_Source: https://npm.io/package/cuckoo-search · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
