Comments (17)
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.
Hi @jhmenke,
Thank you very much for a very interesting suggestion. We will try to add this
feature in the following days.
from niapy.
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.
i will monitor your repository, thanks!
from niapy.
May i ask what the status of the issue is?
I have seen promising commit messages: kb2623@bfee01b
from niapy.
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.
Will try asap! Thank you for your time!
from niapy.
@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.
@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.
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.
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.
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.
@jhmenke thanks for the feedback!
@kb2623 could you take a look at this?
from niapy.
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 initPopulation
method you can check other algorithms. For example I suggest that you check CamelAlgorithm
or FishSchoolSearch
algorithms.
from niapy.
@all-contributors please add @jhmenke for question
from niapy.
The example of custom initialization of population is available here.
from niapy.
I've put up a pull request to add @jhmenke! 🎉
from niapy.
Related Issues (20)
- Can not control the number of max_evals or max_iters HOT 11
- Whale Optimization Algorithm (WOA) and Sparrow Search Algorithm (SSA) implementation HOT 2
- jSO algorithm HOT 7
- L-SHADE algorithm
- Draft a new release HOT 2
- RUN Beyond the Metaphor An Efficient Optimization Algorithm Based on Runge Kutta Method
- Bump version to 2.0.3 HOT 6
- AttributeError: 'NoneType' object has no attribute 'copy' HOT 2
- Make problem HOT 4
- Dataframe to Excel -- not working HOT 2
- Program versions HOT 1
- Adding a "hook" for before and after each generation step HOT 2
- Switch to Poetry
- Bump version HOT 2
- Remove safety/pyup HOT 4
- Remove scrutinizer HOT 1
- Short tutorial for implementing a new algorithm in the framework HOT 1
- Statistical evaluation of the results HOT 2
- It is neither a bug report nor a feature request. But an inquiry into CS algorithm. HOT 5
- Test collection fails with KeyError 'runtest' for test_algorithm.py with pytest 8.2.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from niapy.