Giter Site home page Giter Site logo

Comments (17)

kb2623 avatar kb2623 commented on June 13, 2024 2

Hi @jhmenke

I am working on update that will have your requested functionality. You can have a look at my repository of NiaPy. There is still a lot of work to be done on old algorithms. So the fix won't reach release so soon.

from niapy.

firefly-cpp avatar firefly-cpp commented on June 13, 2024 1

Hi @jhmenke,

Thank you very much for a very interesting suggestion. We will try to add this
feature in the following days.

from niapy.

GregaVrbancic avatar GregaVrbancic commented on June 13, 2024 1

Hi @jhmenke, thank you again for showing the interest in our micro-framework. @kb2623 is working actively on this functionality. As soon as we reach the release phase, we will let you know.

from niapy.

jhmenke avatar jhmenke commented on June 13, 2024

i will monitor your repository, thanks!

from niapy.

jhmenke avatar jhmenke commented on June 13, 2024

May i ask what the status of the issue is?
I have seen promising commit messages: kb2623@bfee01b

from niapy.

kb2623 avatar kb2623 commented on June 13, 2024

Now you can pass a function for population initialization to all algorithms. You have to pass InitPopFunc parameter to setParameters function or to algorithms constructor. Parameter should be a function that takes int, Task and mtrand.RandomState as parameters. In Algorithm class you can see the example of two predefined functions for population initialization for additional help.

from niapy.

jhmenke avatar jhmenke commented on June 13, 2024

Will try asap! Thank you for your time!

from niapy.

GregaVrbancic avatar GregaVrbancic commented on June 13, 2024

@jhmenke the pull request addressing the issues is now merged into the master branch.

Please, try it out and give us some feedback.

from niapy.

FlorianShepherd avatar FlorianShepherd commented on June 13, 2024

@jhmenke the pull request addressing the issues is now merged into the master branch.

Please, try it out and give us some feedback.

Dear @GregaVrbancic,
I tested the code in behalf of @jhmenke . Thank you so much for adding this feature. It seems to work great :)

However, I wondered why some algorithms didn't support the initPopFunc. Either I did something wrong when creating the task and calling algorithm.run(task) or it is really not supported (yet). I noticed this for PSO and MFO for example. Maybe others as well.

I fixed this for the PSO here:
FlorianShepherd@9cbe071

All I had to do was to add "InitPopFunc" to "setParameters".

Also I added the option "binary" for the PSO, which rounds the velocity V to integers. This way I can use the PSO as a binary PSO like here: https://pyswarms.readthedocs.io/en/latest/examples/feature_subset_selection.html#using-binary-pso

from niapy.

GregaVrbancic avatar GregaVrbancic commented on June 13, 2024

Dear @FlorianShepherd,

thank you very much for taking an effort and testing out the new feature 😃 Regarding the problem with some algorithms, we will take a look at it as soon as possible.

The "binary" option for the PSO also looks promising, we might also integrate it into NiaPy.

from niapy.

FlorianShepherd avatar FlorianShepherd commented on June 13, 2024

Probably it is just my mistake. I (have to) run the optimization like this, otherwise my initFunc() is not called:

from NiaPy.algorithms.basic.pso import ParticleSwarmAlgorithm

    task = Mytask(max_evals=max_evals, D=D, NP=NP, nGEN=nGEN,
                  benchmark=benchmark_class(), InitPopFunc=initfunc, binary=True)
    alg = ParticleSwarmAlgorithm(max_evals=max_evals, D=D, NP=NP, nGEN=nGEN,
                  benchmark=benchmark_class(), InitPopFunc=initfunc, binary=True)
    alg.setParameters(max_evals=max_evals, D=D, NP=NP, nGEN=nGEN,
                  benchmark=benchmark_class(), InitPopFunc=initfunc, binary=True)
    result, _ = alg.run(task=task)

It seems like I have to call each function with the same parameters, otherwise an inconsistent default value is used.

from niapy.

jhmenke avatar jhmenke commented on June 13, 2024

thanks for the updates! i have tried PSO and it works well with the initlization!

there are some problems with other algorithms with the new initialization, e.g. the artificial bee colony. due to the Foods now being a numpy array, the algorithm is broken.

newSolution.x[param2change] = Foods[i].x[param2change] + (-1 + 2 * self.rand()) * (Foods[i].x[param2change] - Foods[neighbor].x[param2change])

from niapy.

GregaVrbancic avatar GregaVrbancic commented on June 13, 2024

@jhmenke thanks for the feedback!

@kb2623 could you take a look at this?

from niapy.

kb2623 avatar kb2623 commented on June 13, 2024

Hi.

I have added missing code to algorithms that where not using passed function for population initialization.

If you want to write a problem specific algorithm, you can rewrite initPopulation method form algorithm you are trying to solve a specific problem. For examples on how to rewrite initPopulationmethod you can check other algorithms. For example I suggest that you check CamelAlgorithm or FishSchoolSearch algorithms.

from niapy.

GregaVrbancic avatar GregaVrbancic commented on June 13, 2024

@all-contributors please add @jhmenke for question

from niapy.

GregaVrbancic avatar GregaVrbancic commented on June 13, 2024

The example of custom initialization of population is available here.

from niapy.

allcontributors avatar allcontributors commented on June 13, 2024

@GregaVrbancic

I've put up a pull request to add @jhmenke! 🎉

from niapy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.