def test_initialize_countries(self): # given test_function = CostFunction(lambda x: tf.reduce_sum(tf.square(x), 1), 10.0, -10.0, 2) ica = ICA(test_function, 10, 3, 1, log=True, seed=42) # when countries = ica.initialize_countries() # then self.assertTrue(tf.reduce_all(tf.greater(countries, -10.0).numpy())) self.assertTrue(tf.reduce_all(tf.less(countries, 10.0).numpy()))
def test_create_empires(self): # given test_function = CostFunction(lambda x: tf.reduce_sum(tf.square(x), 1), 10.0, -10.0, 2) ica = ICA(test_function, 10, 3, 1, log=True, seed=42) countries = ica.initialize_countries() # when empires, colonies, empires_numbers = ica.create_empires(countries) # then unique, _ = tf.unique(empires_numbers) self.assertEqual(3, tf.size(unique)) self.assertEqual([7, 2], colonies.shape) self.assertEqual([7, 2], empires.shape)