def test_random_agent_loop(self): df = load_default_atf_data() n_seed = 200 # Starting sample size agent = RandomAgent(n_query=10) analyzer = StabilityAnalyzer(hull_distance=0.05, parallel=False) experiment = ATFSampler(dataframe=df) candidate_data = df new_loop = Campaign(candidate_data, agent, experiment, analyzer, create_seed=n_seed) new_loop.initialize() self.assertFalse(new_loop.create_seed) for _ in range(6): new_loop.run() self.assertTrue(True) # Testing the continuation new_loop = Campaign(candidate_data, agent, experiment, analyzer, create_seed=n_seed) self.assertTrue(new_loop.initialized) self.assertEqual(new_loop.iteration, 6) self.assertEqual(new_loop.loop_state, None) new_loop.run() self.assertTrue(True) self.assertEqual(new_loop.iteration, 7)
# Copyright Toyota Research Institute 2019 from camd.loop import Loop from sklearn.neural_network import MLPRegressor from camd.agent.agents import QBCStabilityAgent from camd.analysis import AnalyzeStability from camd.experiment.base import ATFSampler from camd.utils.data import load_default_atf_data ########################################################## # Load dataset and filter by n_species of 2 or less ########################################################## df = load_default_atf_data() ########################################################## # Binary stable material discovery QBC based agent recipe ########################################################## n_seed = 5000 # Starting sample size - a seed of this size will be randomly chosen. n_query = 200 # This many new candidates are "calculated with DFT" (i.e. requested from Oracle -- DFT) agent = QBCStabilityAgent agent_params = { 'ml_algorithm': MLPRegressor, 'ml_algorithm_params': { 'hidden_layer_sizes': (84, 50) }, 'n_query': n_query, 'n_members': 10, # Committee size in QBC 'hull_distance': 0.05, # Distance to hull to consider a finding as discovery (eV/atom) 'frac': 0.5 # Fraction of data to choose to form a committee member }