Closed ljvmiranda921 closed 6 years ago
I'll do Beale's Function!
Hey @Carl-K! Go ahead! Just leave a message in #6 if you ran into any problem/confusion 👍 😄
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.
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 AssertionError
s 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!
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.
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! 👍
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.
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!
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?
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!
OK, great, I will port it when I get some free time 😃.
Thank you for your responsiveness 😃
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
pyswarms.single.BPSO
) [1]pyswarms.multi.MOPSO
) [2]pyswarms.constrained.CPSO
) [3]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.