Real-time plot

57 views
Skip to first unread message

Fabio Brigidi

unread,
Oct 16, 2014, 1:27:17 PM10/16/14
to insp...@googlegroups.com
Hi Aaron and all,

First of all I would like to thank for having shared such an interesting library and for the very nice documentation that comes with it, which I've found very useful.

I'm currently trying to use Inspyred evolutionary algorithm to fit some experimental data to a simulation I'm performing with some code of my own. I'm still trying some dummy system to test the functionality and get the result I'm looking for, but I've already encountered some problem.

I would like to display the result of the fit at each iteration but I'm currently failing.

I wrote some code showing how I'm currently trying to implement the algorithm. I've substituted the real experimental and the real simulation with some silly calculation but the structure is the same. I'm trying to fit 2 variables that has to be confined in certain boundaries and i would like to plot the result of the simulation compared at each iteration. Here's the link to the code:

https://gist.github.com/anonymous/0ddf2d6d083e6fdda3c3

The reason why I would like to see how the fitting is progressing at each iteration is that in my final application I will have to fit many parameters at the same time and there's no way I can estimate how many iteration are enough to reach a good result. Ideally I would like to continue the optimization until I'm happy with the result.

Thanks in advance for the help.

Best regards,
Fabio

Aaron Garrett

unread,
Oct 16, 2014, 3:28:39 PM10/16/14
to insp...@googlegroups.com
In what way is it failing to do that for you? Can you explain the error you're getting and what you expect/want to see?



Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
131 Ayers Hall
Jacksonville State University
Jacksonville, AL  36265
agar...@jsu.edu
256-782-5364

--
You received this message because you are subscribed to the Google Groups "Inspyred" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inspyred+u...@googlegroups.com.
To post to this group, send email to insp...@googlegroups.com.
Visit this group at http://groups.google.com/group/inspyred.
For more options, visit https://groups.google.com/d/optout.

Fabio Brigidi

unread,
Oct 17, 2014, 4:44:07 AM10/17/14
to insp...@googlegroups.com

I'm sorry for the vagueness of the previous post. I'll try to explain my issue a little bit better.

The minimization algorithm seems to work correctly. If I simply try to plot the simulation obtained with the values returned by the minimization algorithm, the result looks very convincing.
My problem arises when I try to get a runtime visualization of the result of the simulation at the end of each iteration.
Written the way I posted the code is creating a tkinter window as expected, but it's empty and immediately close after the end of the execution. I've also tried not to use Tkinter, sticking to the only use of  matplotlib. The code looks pretty much like this (just noticed in the last code there's a comment about '3 different sets of experimental data' that has no sense but comes from a wrong copy and paste):

https://gist.github.com/anonymous/4bc727d68872fb70a680

In this case the line is not updated and remains as it is initialized. (I tryed also other combinations including the use of .draw() instead of .plot() but still nothing solved my problem).

A solution including Tkinter would be preferred since this way it will be easier in the future to move the implementation inside a GUI, but any other solution to my problem is fine.

Thanks again for the help.

Best Regards,
Fabio

Aaron Garrett

unread,
Oct 17, 2014, 4:19:39 PM10/17/14
to insp...@googlegroups.com
OK. So my initial guess would be that you'll need to put the evolution into its own thread and update the GUI plot from there at every observer callback. I will try to put together a "simple" example for this, but I won't have time to do that before Monday.



Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
131 Ayers Hall
Jacksonville State University
Jacksonville, AL  36265
agar...@jsu.edu
256-782-5364

Aaron Garrett

unread,
Oct 20, 2014, 1:04:21 AM10/20/14
to insp...@googlegroups.com
Here's a minimal working example of what you're trying to do, as best I understand it. In this code, I'm just trying to "evolve" the point (0.5, 0.5). It's a silly example, but hopefully it will show you what you need to do for your work.



Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
131 Ayers Hall
Jacksonville State University
Jacksonville, AL  36265
agar...@jsu.edu
256-782-5364

plots.py

Fabio Brigidi

unread,
Oct 20, 2014, 9:24:54 AM10/20/14
to insp...@googlegroups.com
Thanks a lot for the support Aaron. I'm currently trying to combine the structure you showed with the simulating software of mine, but I've encountered some problem of threading with the SQL database I've to use for my simulations. I'll let you know if I'll find a way to make it work.
Thanks again for your time and availability.
Best regards,
Fabio
Reply all
Reply to author
Forward
0 new messages