onclave / nsga-ii Goto Github PK
View Code? Open in Web Editor NEWan implementation of NSGA-II in java
License: MIT License
an implementation of NSGA-II in java
License: MIT License
private static Chromosome binaryTournamentSelection(Population population) {
Chromosome individual1 = population.getPopulace().get(LOCAL_RANDOM.nextInt(population.getPopulace().size()));
Chromosome individual2 = population.getPopulace().get(LOCAL_RANDOM.nextInt(population.getPopulace().size()));
if(individual1.getFitness() > individual2.getFitness())
return individual1;
else return individual2;
}
after the first generation,it should use crowded-comparison operator,
As says in the Article in SectionIII part C: It is important to note that we use a binary tournament selection operator but the selection criterion is now based on the crowded-comparison operator.
Hi, Your code is really good but Can i adapt your code for Multi-objective NSGA - 2 for solving feature selection problem, if it does how do i go about it
Where do i add the dataset in the code, Its a ddos attack dataset used to conduct feature selection. And also i have an "Exception in thread "main" java.lang.NoClassDefFoundError: org/jfree/data/xy/XYDataset" even though i have added the jfree and jcommon jars to the project.
I should optimize my own problem.
I do not how to data structure it correctly.
plz, help me.
my problem has 10 different decision variables. each one has different attributes.
for example, x1 has the upper bound, lower bound, specific name, decision variable type, decision function type, decision function type parameters.
x1 variable name,upper bound, lower bound : ("quantity_A", 200, 750)
decision variable type : "quantity_A", "Real"
decision function type : triangle
decision function type parameters :{ 24, 380, 528 }
or
x2 variable name,upper bound, lower bound : ("quantity_B", 200, 650)
decision variable type : "quantity_B", "Real"
decision function type : Normal
decision function type parameters :{ ,'mu',330,'sigma', 96.6 }
I think hash table is good option?
what do you think?
I had decision variable class. I feel that It is better to define inner class for defining decision function class.
I am confused.
thanks.
Can you provide more information on how to provide my own objective function and fitness function. I read the content on get started doc but can you make it more clear or give an example to explain it further as i was struggling to understand when trying to extend AbstractObjectiveFunction class to implement the functions? I want to add fitness function to maximise relevance and minimise redundancy when performing feature selection using NSGA2 on a dataset.
HI, @onclave. I previously read the query that you commented on for someone recently regarding generating population of n chromosome and using the genetic code for each i.e allele 1 or 0 to use as reference to dataset columns (attributes) to either select them or discrad them for feature selection.
My project is focusing on NSGA-2 to perform feature selection aswell and I am using symmetric uncertainty as objective function to calculate the fitness of each column from dataset based on the chromsome generated as solution. My objective function is a maximisation function that looks to maximise relevance and also another function to reduce redundancy. I have created a popluatiion out of my dataset that i am using. However, the issue i am facing currently is that i am not able to integrate my SU function with your NSGA-2 package objective provider in generating binary encoded chromosomes (Default binary encoder provided in ur library) and using the chromosome index to refer to my dataset in order to produce subset of the dataset based on chromosome solution and evalute using objective function. I am using 2d datase with n columns and m rows.
Objective function details (SU):
Symmetric uncertainty can be used to calculate the fitness of features for feature selection by calculating between feature and the target class. The feature which has high value of SU gets high importance. Symmetric uncertainty defined as
Formula = SU(X,Y)=(2*MI(X,Y))/(H(X)+H(Y))
So, basically i am trying to achieve a filter based solution-using multi-objective algorithm (NSGA-2) to my problem - where i will test the generated subset on a classifier.
I had a look at the comment you made on someones issue and guidance you provided in documentation section but i am not sure on how to go about doing that. So, can you provide a pseudocode kind off explaination or step i can follow to acheive this?
Thanks - A Dj
Hi,
I checked your code and got the following question:
In your class [Chromosome](https://github.com/onclave/NSGA-II/blob/master/src/main/java/com/debacharya/nsgaii/datastructure/Chromosome.java)
you instantiate an object with the Rank = -1
.
But in your method reset()
you set the rank to Integer.MAX_VALUE
.
Is there a specific reason for that?
Because when I have a look at the call of reset()
in class [NSGA2.java](https://github.com/onclave/NSGA-II/blob/master/src/main/java/com/debacharya/nsgaii/NSGA2.java)
this seems to be "wrong" because there you increase the rank value by one to the already max Integer value.
Integer.MAX_VALUE = 2147483647
Integer.MAX_VALUE + 1 = -2147483648
In the end this new value has still the lowest rank value but isn't it easier and more intuitive to reset the rank to -1
or 0
? (also for readability)
Hello , i download the latest JFreeChart .It is the jcommon-1.0.23 and jfreechart-1.0.19. Most of the import is working well, but the
"import org.jfree.chart.ui.ApplicationFrame;" keeps saying that "the import cannot be resolved",when i repalce it to"import org.jfree.ui.ApplicationFrame;",it can work well , so i do not know what is the problem.
Hi @onclave,
we are doing a roster optimization project using GA for our lecture. We have found your project, which is very interesting. But we would like to add some hard and soft constraints to influence the fitness results, unfortunately, we haven't found that concept in the code (but is stated in the research paper).
Where would you add these Constraints, in Service.calculateFitness or Service.decodeGeneticCode or do you have a more enlightened idea with your eventual knowledge of the C code base?
If you want we will do a Pull request with our changes on your codebase.
Thanks for the response.
Hello , i download the JFreeChart .It is the jcommon-1.0.24 and jfreechart-1.5.2. and 5.1 and 5.0 but still i get error for
"import org.jfree.chart.ui.ApplicationFrame;" and it syas caused by class not found, so i don't know what is the problem. I am using eclipse ide and i also get another issue which is with XYDataset saying class not found similar to application frame error
Hi @onclave,
I've got a question on how you generate the Pareto front diagram. It seems the last child generation is used to generate the Pareto Front diagram.
But as I understand it, the Pareto front should be composed of "optimal" solutions that dominate all the others on at least one axis. (This video explains well how I see it: https://www.youtube.com/watch?v=SL-u_7hIqjA&).
Is there an option that I didn't see? Did you understand it differently?
Thanks for your answer.
Simon
hello everyone
i would like to know how to adapt a new problem with this code
like the new objective functions the new operators new variables
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.