About the inspyred.ec.emo.Pareto()

103 views
Skip to first unread message

uqzcpo

unread,
Jul 16, 2012, 2:07:16 AM7/16/12
to insp...@googlegroups.com
I suddenly found a problem with the inspyred.ec.emo.Pareto(), i have two objects, they are all calculated from the CFD solver result file, but when i open the ga_individuals.csv file, i found that the fitness value is not equal to what it shoud be.
i used this line to append the fitness value:
fitness.append(inspyred.ec.emo.Pareto([Pt_loss/Pt_loss_design, mass_con]))
in the
ga_individuals.csv file:
object 1 = 0.8517391087085469
object 2 = 0.04852634712712112
but actully, they shoud be:
object 1 = 0.882692184074
object 2 = 0.0278852833184
I checked the code to calculate the objects, and there is no problem, is there a built in transformation?
I also used
archive_observer, my pop-size is 28, why it only print 6 individuals to screen?

Aaron Garrett

unread,
Jul 16, 2012, 2:29:17 AM7/16/12
to insp...@googlegroups.com

The Pareto class doesn't do any calculation. I suspect that the difference is in your calculation somewhere. How do you know what the actual values should be? Are you running the individuals back through your solver to double-check their fitness values? That would be my first step. Take the individuals.csv file and pass a few of them into the solver to see if you get the same values back as their fitnesses. If you don't, then I'd check your evaluation function to make sure that you're calculating the fitness the same way as your spot-check procedure. There are not many places in the library for things to go wrong in the case you're describing.

As for the archive, it will not necessarily be the same size as your population. They are not the same. The archive only holds the non-dominated solutions found so far, in the case of NSGA, for example.

-- Aaron Garrett

--
You received this message because you are subscribed to the Google Groups "Inspyred" group.
To view this discussion on the web visit https://groups.google.com/d/msg/inspyred/-/FNya0elvZtcJ.
To post to this group, send email to insp...@googlegroups.com.
To unsubscribe from this group, send email to inspyred+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/inspyred?hl=en.

uqzcpo

unread,
Jul 16, 2012, 6:02:08 AM7/16/12
to insp...@googlegroups.com
I add a line 'print emo.Pareto([f1, f2])' in the benchmarks.py->class Kursawe(Benchmark) in order to compare the print out results and results in the ga_individuals.csv file.
Then i run the nsga_example.py with the file_observer, i just set the pop_size=10.
In the print out results generation0:
[-11.003257255844874, 0.9273927686012078]
[-10.677773337603771, 5.095688245239632]
[-9.821625459206496, 2.764901808702323]
[-10.244283083533272, 10.078823492404464]
[-14.478268557227548, 3.976218759821066]
[-13.819455573408893, 5.977186461914271]
[-16.69693426619406, -2.813425373271362]
[-13.084924296209268, -2.267625811100122]
[-14.170748304381114, 12.916165790480118]
[-8.321106190546386, 11.503825977312356]
in the
ga_individuals.csv file gneration0:
 [-16.69693426619406  -2.813425373271362]
 [-11.003257255844874  0.9273927686012078]
 [-14.478268557227548  3.976218759821066]
 [-13.819455573408893  5.977186461914271]
 [-13.084924296209268  -2.267625811100122]
 [-10.677773337603771  5.095688245239632]
 [-9.821625459206496  2.764901808702323]
 [-10.244283083533272  10.078823492404464]
 [-14.170748304381114  12.916165790480118]
 [-8.321106190546386  11.503825977312356]
you can found out that the only different is the order.
In the print out results generation1:
[-13.44076450355643, -6.845242104849904]
[-14.850367892809949, -3.586092030408952]
[-15.848295268700621, 0.551880533330031]
[-16.11674428877094, -0.6027572840874829]
[-11.918571542426175, 5.242708356878806]
[-11.781454273747658, 6.899804529558446]
[-15.079665777258908, 1.2289895951590837]
[-14.663893061659136, 2.7252440084940743]
[-12.378612739768538, -1.2850129359004525]
[-12.836282903055567, -2.040089362559654]
in the ga_individuals.csv file gneration1:
 [-16.69693426619406  -2.813425373271362]
 [-13.44076450355643  -6.845242104849904]
 [-14.850367892809949  -3.586092030408952]
 [-13.084924296209268  -2.267625811100122]
 [-16.11674428877094  -0.6027572840874829]
 [-15.848295268700621  0.551880533330031]
 [-12.836282903055567  -2.040089362559654]
 [-15.079665777258908  1.2289895951590837]
 [-12.378612739768538  -1.2850129359004525]
 [-11.003257255844874  0.9273927686012078]
i found that the results in red is not in the ga_individuals.csv file.
i don't know why?

Aaron Garrett

unread,
Jul 16, 2012, 9:14:55 AM7/16/12
to insp...@googlegroups.com
OK. I ran multiple tests before I really realized what you were doing. What you're seeing is correct. The problem is that my documentation is misleading (which I will correct). The "individuals" file doesn't necessarily contain every CREATED individual, which is what you're printing out. It contains every individual that makes it into a population. There's no single place to plug in to ensure that you print every created individual. You can do it in the evaluator, like you're doing, or maybe a custom variator if you don't care about the individual's fitness. An observer only sees a fully formed population. 

So, in your case, individuals are being created but immediately replaced before they make it into a final population. 


Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
Jacksonville State University
Jacksonville, AL  36265
agar...@jsu.edu
256-782-5364
http://mcis.jsu.edu/faculty/agarrett


--
You received this message because you are subscribed to the Google Groups "Inspyred" group.
To view this discussion on the web visit https://groups.google.com/d/msg/inspyred/-/M4O14AXiqaAJ.

uqzcpo

unread,
Jul 16, 2012, 9:13:35 PM7/16/12
to insp...@googlegroups.com
Sorry, i know my english sucks, but believe me that i have tried hard to express what i want to say.
 I was confused, if I have run an optimization, during the evolving process, i saved every individual in every generation that was evaluated, and when it finished I want to find out the best individual through the file_observer output file, but the best individual in the file_observer output file is not correspond to what I saved during the evolving process. Because in my case, every individual's fitness is calculated through the CFD solver output file, then I find the best individual in the file_observer output fle, but there is no CFD solver output file corresponding to it. I want to know how did the individual in the file_observer output file get its fitness, if it was calculated through the CFD solver, then the CFD solver output file must be saved, but i can't finf it out.For example the best individual in the file_observer output file is the generation23, individual2 and has a fitness value6.5323, but in the CFD solver reasults i saved during the evolving process there is no such a individual.
In my mind, the generator gnerates the generation0, then every individual is evaluated, then generation1 is generated through selector, variator, crossover, then generatio1 is evaluated, and so on. During the process every generation is saved in the file_observer output file. So i think every evaluated individual must be in the file_observer output file.
 

Aaron Garrett

unread,
Jul 16, 2012, 11:23:32 PM7/16/12
to insp...@googlegroups.com

OK. So you have an individual in the output file whose fitness isn't in your calculation files. I don't see how that can happen. It IS possible to have an individual in your calculation files that doesn't exist in the output file for the generations, because he may have been replaced before he ever made it into the population. (The "individuals" file is a snapshot of all of the individuals in the population at the end of a generation. Some guys might never have made it that far.) But the other way shouldn't happen. Your fellow's fitness came from somewhere. The library doesn't do any math on the fitness values. My guess would be that either you just missed it in your set of calculation files or your evaluation function isn't recording the fitness the same way your calculation files are. I'm not saying that the library is error free. (It certainly isn't.) But I have used it myself for at least two years on lots of projects, and I've never seen the error you're describing. So I'm betting that there's something in the code that uses the library that's causing the problem.

If you send your code, I'm happy to look through it to see if I can spot any issues. I can't run it because I don't have your solver program, but maybe another pair of eyes can help find the problem. And if it does turn out to be a bug in the library, I'd like to track it down and fix it.

-- Aaron Garrett

--
You received this message because you are subscribed to the Google Groups "Inspyred" group.
To view this discussion on the web visit https://groups.google.com/d/msg/inspyred/-/zIu-piVA_a8J.

uqzcpo

unread,
Jul 17, 2012, 4:57:34 AM7/17/12
to insp...@googlegroups.com
I just sent the source code to your gmail, thanks for your help.
I'am not major in the Evolutionary algorithm, I want to know how to choose the selector, crossover operator, variator, the muatation rate, the crossover rate and so on.
I need to make the EC best fit my problem, but I don't know how. So
I want you to recommend me some books about this topic, most important is easy to understand.

uqzcpo

unread,
Jul 17, 2012, 9:38:06 AM7/17/12
to insp...@googlegroups.com
I have read a book about NSGA_II, it said in the NSGA-II, an initial population P0 with size N is randomly generated, then a new population named Q0 with size N is generated from the P0 through evolution operators, the P0 and Q0 merge into a big population R0, then individuals in R0 is evaluated through the evaluator, after that the Non-dominated sorting is conducted, finally a new population P1 with size N is selected from R0. So the number of the evaluated individuals are 2*N, but in the code I found that the number of the individuals in the candidates equals to pop_size, not 2*pop_size.

Aaron Garrett

unread,
Jul 17, 2012, 2:16:03 PM7/17/12
to insp...@googlegroups.com
The N parents have already been evaluated, so only the N children need to be evaluated each generation.



Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
Jacksonville State University
Jacksonville, AL  36265
agar...@jsu.edu
256-782-5364
http://mcis.jsu.edu/faculty/agarrett


On Tue, Jul 17, 2012 at 8:38 AM, uqzcpo <shuai.s...@gmail.com> wrote:
I have read a book about NSGA_II, it said in the NSGA-II, an initial population P0 with size N is randomly generated, then a new population named Q0 with size N is generated from the P0 through evolution operators, the P0 and Q0 merge into a big population R0, then individuals in R0 is evaluated through the evaluator, after that the Non-dominated sorting is conducted, finally a new population P1 with size N is selected from R0. So the number of the evaluated individuals are 2*N, but in the code I found that the number of the individuals in the candidates equals to pop_size, not 2*pop_size.

--
You received this message because you are subscribed to the Google Groups "Inspyred" group.
To view this discussion on the web visit https://groups.google.com/d/msg/inspyred/-/eGE26VWt1icJ.

uqzcpo

unread,
Aug 1, 2012, 4:43:59 AM8/1/12
to insp...@googlegroups.com
Hi Aaron Garrett, I just finished an optimization, and the results are fine, there is nothing wrong with your code, it's my misunderstanding. Thanks for your work.

Aaron Garrett

unread,
Aug 1, 2012, 11:31:51 AM8/1/12
to insp...@googlegroups.com
That is excellent to hear. If you have any feedback about the library, or any additional needs, please let me know.



Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
Jacksonville State University
Jacksonville, AL  36265
agar...@jsu.edu
256-782-5364
http://mcis.jsu.edu/faculty/agarrett


On Wed, Aug 1, 2012 at 3:43 AM, uqzcpo <shuai.s...@gmail.com> wrote:
Hi Aaron Garrett, I just finished an optimization, and the results are fine, there is nothing wrong with your code, it's my misunderstanding. Thanks for your work.

--
You received this message because you are subscribed to the Google Groups "Inspyred" group.
To view this discussion on the web visit https://groups.google.com/d/msg/inspyred/-/G8nwgCHV85QJ.
Reply all
Reply to author
Forward
0 new messages