Languages
[Edit]
EN

JavaScript - async loop based scattered Particle Swarm Optimization (PSO) algorithm example

4 points
Created by:
Root-ssh
178180

In this article, we're going to have a look at how to implement PSO (Particle Swarm Optimization) algorithm that shedules tasks in groups to indicated servers in JavaScript.

This article is combination of following articles:

  1. JavaScript - Particle Swarm Optimization (PSO) algorithm example
  2. JavaScript - how to make buffered async loop class with next iteration confirmation?

Main idea of presented below aproach is to send requests for computation to backend/server, waint until it will be finished and do not let to make more than set number (threadsCount parameter) of computations in same time. When some computation is completed implementation shedules next one untill all will be completed and next epoch occurs.

Practical implementation example

Edit

In below code, backend/server computations are simulated by fake $.ajax() method that waits random time and retunrs infomration about completed job. Fake methos can be replaced by real AJAX method, WebSocket, or other technology if needed.

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join