Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-direct

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-direct

Direct - DIviding RECTangles optimization algorithm

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
increased by19.65%
Maintainers
1
Weekly downloads
 
Created
Source

ml-direct

NPM version build status npm download

Direct - DIviding RECTangles algorithm.

The algorithm is intended to minimize real valued multivariate scalar fields over a hyper-rectangular region of N, theoretically the only prerequisite to achieve convergence is that the function must be continuous in the domain or at least continuous over a neighborhood of the global minimum.

Advanced example

import direct from 'ml-direct';

const options = {
  iterations: 50,
};

const lowerBoundaries = [-1, -1.5];
const upperBoundaries = [2, 6];

const predicted = direct(griewank, lowerBoundaries, upperBoundaries, options);

function griewank(x) {
  let d = x.length;
  let s = 0;
  let p = 1;
  for (let i = 0; i < d; i++) {
    s += Math.pow(x[i], 2) / Math.sqrt(4000);
    p *= Math.cos(x[i] / Math.sqrt(i + 1));
  }
  let result = s - p + 1;
  return result;
}

// predicted.minFunctionValue = 0;
// predicted.optima[0] = [0, 0]; This are the points where the function has minimum value

A tool for global optimization of real valued functions .

Installation

$ npm i ml-direct

Usage

import direct from 'ml-direct';

const options = {
  iterations: 25,
};

// for x we explore values between -5 and 4
// for y we explore values between -2 and 3

const lowerBoundaries = [-5, -2];
const upperBoundaries = [4, 3];

const quadratic = function (parameters) {
  let [x, y] = parameters;
  return Math.pow(x, 2) + Math.pow(y, 2);
};

const predicted = direct(quadratic, lowerBoundaries, upperBoundaries, options);

// predicted.minFunctionValue = 0;
// predicted.optima[0] = [0, 0];

API Documentation

References

  • Jones, D. R., Perttunen, C. D., & Stuckman, B. E. (1993). Lipschitzian optimization without the Lipschitz constant. Journal of optimization Theory and Applications, 79(1), 157-181.

  • Björkman, M., & Holmström, K. (1999). Global optimization using the DIRECT algorithm in Matlab.

  • Preparata, F. P., & Shamos, M. I. (2012). Computational geometry: an introduction. Springer Science & Business Media.

License

MIT

FAQs

Package last updated on 07 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc