ljvmiranda921 / pyswarms

A research toolkit for particle swarm optimization in Python
https://pyswarms.readthedocs.io/en/latest/
MIT License
1.29k stars 333 forks source link

Development Roadmap #5

Closed ljvmiranda921 closed 6 years ago

ljvmiranda921 commented 7 years ago

Development Roadmap

Here is the feature list needed for the major release. We will be implementing different PSO variants, more test functions, and a hyperparameter search utility.

Optimizers

Test Functions

Most of the good test functions can be found here. If you want to implement a single function, just make a pull request, and then implement it. In fact, even Wikipedia (I know, I know) has a good resource for test functions.

Single-objective pyswarms.utils.single_obj

Multi-Objective pyswarms.utils.multi_obj

Constrained Problems pyswarms.utils.constrained_obj

Utilities

Examples

We need various examples or use-cases to help a user use PySwarms. For now, these things are much better written in a Jupyter Notebook.

No. Reference
[1] J. Kennedy and R.C. Eberhart, "A discrete binary version of the particle swarm algorithm," in IEEE International Conference on Systems, Man, and Cybernetics, 1997.
[2] M.R. Sierra and C.A. Coello, "Multi-Objective Particle Swarm Optimizers: A Survey of the State-of-the-Art," International Journal of Computational Intelligence Research, 2006.
[3] Parsopoulos, Konstantinos E., and Michael N. Vrahatis. "Particle swarm optimization method for constrained optimization problems," Intelligent Technologies–Theory and Application: New Trends in Intelligent Technologies pp. 214-220, 2006.
Carl-K commented 7 years ago

I'll do Beale's Function!

ljvmiranda921 commented 7 years ago

Hey @Carl-K! Go ahead! Just leave a message in #6 if you ran into any problem/confusion 👍 😄

Carl-K commented 7 years ago

Hello again @ljvmiranda921, I can take care of the rest of the functions (goldstein, booth, bukin6, matyas, levi, schaffer2) and also add extra tests for correct input dimensions (Beale, Goldstein, Booth, etc.) if needed.

ljvmiranda921 commented 7 years ago

Hey @Carl-K , wow, that would be really helpful! You can implement the rest of the functions in single_obj.py for now.

I forgot to mention, it would be really nice if we follow PEP8 standards in writing equations. So for the Beale's function, we can write something like this:

# Line breaks before the operator, notice the parenthesis enveloping 
# our equation.
j = ((1.5 - x_ + x_ * y_)**2.0 
    + (2.25 - x_ + x_ * y_**2.0)**2.0 
    + (2.625 - x_ + x_ * y_**3.0)**2.0)

With regard to the extra tests, I believe I have updated them already in the InputDimFail class (check this commit). Right now we're still in Pre-Alpha. Once we do a release, we'll start refactoring all our AssertionErrors into raised Exceptions. But it's still a long way but I'm taking notes on what to change so far so we won't refactor a lot of error-handling in the future. So yeah, just take the assertions and unit tests as it is for now. 👍

Anyways, good job and I hope you're enjoying! Just drop any questions here if needed!

Carl-K commented 7 years ago

Hello @ljvmiranda921 thank you for the guidance it is much helpful. I would just like to bring something to your attention about the tests you have written regarding

with self.assertRaises(AssertionError):

consider

def test_beale_bound_fail(self):
    x = np.array([[-5, 5]])
    x_ = np.array([[3, 0.5]])

    with self.assertRaises(AssertionError):
        fx.beale_func(x)
        fx.beale_func(x_)

vs

def test_beale_bound_fail(self):
    x = np.array([[-5, 5]])
    x_ = np.array([[3, 0.5]])

    with self.assertRaises(AssertionError):
        fx.beale_func(x)

    with self.assertRaises(AssertionError):
        fx.beale_func(x_)

for Beale's function. The array [3, 0.5] does not raise an assertion error within beale_func(x) because it is valid input, so the test for bounds should fail. In the first example the test does not fail even though it should because I am assuming "with self.assertRaises(AssertionError):" catches an assertion thrown from any line, not all of them, which is what the test currently is. In the second example the test does fail, which I believe is what you want. I hope this is not nitpicky it is just something that caught my eye.

ljvmiranda921 commented 7 years ago

Hmmm... interesting. Turns out that context managers (with self.assertRaises(AssertionError)) work in an any perspective. Already fixed it (and the others) in the latest commit.

Thanks for catching it! 👍

SioKCronin commented 7 years ago

Hi @ljvmiranda921 I'm a CS grad student just beginning to use PSO in my work, and can help out with documentation and the Jupyter examples notebook.

ljvmiranda921 commented 7 years ago

Hi @SioKCronin! That's awesome!

Just fork this repo and do a pull request once you're done. The steps can be seen in this link

Also, if you have questions, need help, or found some bugs, please don't hesitate to contact/raise an issue!

Thank you so much!

abougouffa commented 7 years ago

Hi @ljvmiranda921, I'm working on a project in which I implemented another PSO variant named GLIR-PSO and I can port it to work with pyswarms.

I don't know if you are interested in implementing existing PSO variants or just implement a generic framework?

ljvmiranda921 commented 7 years ago

Hi @abougouffa, sure please do port it here in PySwarms! The idea is that we can pool different variants in the library to ease benchmarking for researchers. 👍

However, please do check if the base classes can support GLIR-PSO. Hopefully it does, if there's a need to create a new base class, or improve the existing base classes, just write a message here!

abougouffa commented 7 years ago

OK, great, I will port it when I get some free time 😃.

Thank you for your responsiveness 😃