Esempio n. 1
0
 def test_get_data(self, export_swarm):
     states_attr = ray.get(export_swarm.get.remote("cum_rewards"))
     assert isinstance(states_attr, numpy.ndarray)
     env_attr = ray.get(export_swarm.get.remote("observs"))
     assert isinstance(env_attr, numpy.ndarray)
     model_attr = ray.get(export_swarm.get.remote("actions"))
     assert isinstance(model_attr, numpy.ndarray)
     walkers_attr = ray.get(export_swarm.get.remote("minimize"))
     assert isinstance(walkers_attr, bool)
     swarm_attr = ray.get(export_swarm.get.remote("n_import"))
     assert isinstance(swarm_attr, int)
Esempio n. 2
0
    def test_get_data(self, export_swarm):
        states_attr = ray.get(export_swarm.get.remote("cum_rewards"))

        assert dtype.is_tensor(states_attr), (type(states_attr), states_attr)
        env_attr = ray.get(export_swarm.get.remote("observs"))
        assert dtype.is_tensor(env_attr)
        model_attr = ray.get(export_swarm.get.remote("actions"))
        assert dtype.is_tensor(model_attr)
        walkers_attr = ray.get(export_swarm.get.remote("minimize"))
        assert dtype.is_bool(walkers_attr)
        swarm_attr = ray.get(export_swarm.get.remote("n_import"))
        assert dtype.is_int(swarm_attr)
Esempio n. 3
0
    def test_run_exchange_step(self, export_swarm):
        empty_walkers = ray.get(export_swarm.get_empty_export_walkers.remote())
        ray.get(export_swarm.run_exchange_step.remote(empty_walkers))

        walkers = ExportedWalkers(3)
        walkers.rewards = numpy.array([999, 777, 333])
        walkers.states = numpy.array([[999, 999, 999,
                                       999], [777, 777, 777, 777],
                                      [333, 333, 333, 333]])
        walkers.id_walkers = numpy.array([999, 777, 333])
        walkers.observs = numpy.array([[999, 999, 999, 999],
                                       [777, 777, 777, 777],
                                       [333, 333, 333, 333]])
        ray.get(export_swarm.reset.remote())
        exported = ray.get(export_swarm.run_exchange_step.remote(walkers))
        best_found = ray.get(export_swarm.get.remote("best_reward"))
        assert len(exported) == ray.get(export_swarm.get.remote("n_export"))
        assert best_found == 999
Esempio n. 4
0
 def test_get_empty_walkers(self, export_swarm):
     walkers = ray.get(export_swarm.get_empty_export_walkers.remote())
     assert isinstance(walkers, ExportedWalkers)
     assert len(walkers) == 0
Esempio n. 5
0
 def test_reset(self, export_swarm):
     reset = ray.get(export_swarm.reset.remote())
     assert reset is None