Correct ways to save evaluation informations to a self defined file

20 views
Skip to first unread message

Will Tsing

unread,
Nov 14, 2017, 3:26:09 AM11/14/17
to Inspyred
Hi there,

Thanks for this lovely algorithm code and I was a little bit struggle on a naive problem: saving each evaluation informations(ie. evaluation, best , worst) to my self defined file.

I've found the file_observer in the observers. I tried to pass a self defined(name and path) opening file to it like this:
statistics_file = open('/'.join(path, filename), 'w')
inspyred
.ec.observers.file_observer(population, num_generations, num_evaluations, statistics_file)

so that it could write to it.
However I get the following TypeError:
TypeError: '_io.TextIOWrapper' object is not subscriptable

Any hints for this?

Aaron Garrett

unread,
Nov 14, 2017, 7:52:38 AM11/14/17
to insp...@googlegroups.com
Look at the Lunar Explorer example (http://pythonhosted.org/inspyred/tutorial.html#id11) to see how the file_observer should be used. Let me know if that doesn't clear it up for you.

--
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 https://groups.google.com/group/inspyred.
For more options, visit https://groups.google.com/d/optout.
--
Aaron Garrett, Ph.D.
Assistant Professor
Computer Science
Wofford College
429 North Church Street
Spartanburg, SC 29303
Reply all
Reply to author
Forward
0 new messages