entity-neural-network / incubator

Collection of in-progress libraries for entity neural networks.
Apache License 2.0
29 stars 10 forks source link

Redesign Environment API #166

Closed cswinter closed 2 years ago

cswinter commented 2 years ago

This is a large refactor of the Environment API. It includes a new tutorial describing how to implement an Environment The main change is the way EnityIDs are handled:

Smaller changes:

cswinter commented 2 years ago

We split out the IDS into entity types... but why don't we just put the IDS along with the entities in the features? Having the same place for both things is more coherent and much easier to debug e.g:

I think we could do this, I actually started out combining all of "actions", "ids", and "features" into a single EntityObs so we have a single entities: Mapping[EntityType, EntityObs], but then changed back to the previous scheme since it made it harder to figure out all the algorithmic changes. I think it probably makes sense to still keep actions separate, since actions feel like a top-level object and often don't make sense to split across entity type, but joining ids and entities seems good. Maybe we could also have a constructor/function on Environment which you pass just the lists of ids and features, and it does the whole np.array(... thing and validates that the number of features match and the number of ids match the number of entities.

cswinter commented 2 years ago

@Bam4d made a bunch of fixes and also added a new Observation.from_entity_obs method that allows specifying ids and features side-by-side in the same dict.

cswinter commented 2 years ago

It's also completely optional to use np.array, so you don't need to think about the right shape for empty arrays or dtype.

Bam4d commented 2 years ago

Ill review this by doing the necessary Griddly changes and seeing if I run into any issues!

Bam4d commented 2 years ago

going to try get released today so we can build and test with poetry etc... https://github.com/Bam4d/Griddly/pull/165/files

cswinter commented 2 years ago

@Bam4d Thanks for the fixes!