Open schrum2 opened 5 years ago
I have a semi-working serializer and deserializer based on Jackson. However, the XML mapper was unable to handle multidimensional arrays for some weird reason. So, I switched to json instead. This mostly works, but cannot handle circular references, which is something that wox CAN do. I thought this would be ok, and it seems to mostly work, but I started seeing exceptions when running basic evolution in the pole-balancing problem, so I reverted those commits.
Either need a different serializer/deserializer or need to find a way to make Jackson handle the circular references correctly.
Gson is no good either: https://github.com/google/gson/blob/master/UserGuide.md
Here is a slightly tidied up version of wox: https://github.com/codelion/wox Is it actually different than what I already have? Might be worth checking.
Then again, the xml serialization is pretty verbose. If wox simply won't work (and maybe even if it does) I should consider making a custom serializer for certain classes at least, such as the TWEANNGenotype. However, should I customize them within the framework of some other serialization library, or just may my own save/load methods?
Apparently Java has some built-in serialization capabilities: https://www.baeldung.com/java-serialization
This seems to actually work. The file format is incomprehensible, but does that matter? Do a bit of research first, but then potentially commit to this new approach and finally get rid of those wox libraries.
I'm making progress here, but wox is used in a lot of places. Therefore, I added an option to choose between wox serialization or the new style so that nothing has to remain broken.
Also, there are actually a few saved xml files in the repo for things like the UT^2 controller and the winning Ms Pac-Man competition entry. If I want to keep using these, then I will need to load the classes in with wox and save new .ser files with Java serialization to be able to keep loading the information moving forward.
My code currently makes use of the wox serialization library to create xml files from neural networks. Unfortunately, this library relies on some sun packages that are not meant to be used, and are deprecated in some versions of Java.
A possible alternative that has been pointed out to me is Jackson: https://github.com/FasterXML/jackson
Here are usage examples: https://www.baeldung.com/jackson-xml-serialization-and-deserialization
I think it won't be too hard to switch over, but I worry about whether things will still work they way they are supposed to. Also, I'm not sure if this library handles circular references, which is something that wox does ... though I'm not sure this is relevant for any of my code.