MetaBox

Testing

How to Test

In MetaBox, you can select the test mode by using the --test option. When conducting evaluations, we first instantiate a Tester object and load all agents and optimizers. Then, we build the test sets and, for each problem in the test set, we call each instantiated optimizer to test the problem and obtain a solution, recording 51 runs of optimization performance.

Currently, we have implemented 7 MetaBBO-RL optimizers, 1 MetaBBO-SL optimizer and 11 classic optimizers, which are listed in Baselines. You can also find their implementations in src/agent and src/optimizer. We have imported all of these agents and optimizers in tester.py for you to compare, and you are supposed to import your own agent and optimizer in it.

You can use the --agent_for_cp xxx option to select the agent(s) for comparison and --l_optimizer_for_cp xxx option to select the learnable optimizer(s) for comparison. Please note that the agent needs to support the corresponding learnable optimizer. Additionally, you can use --t_optimizer_for_cp xxx to select the traditional optimizer(s) for comparison. --agent_load_dir option specifies the directory that contains the .pkl model files of your own agent and all comparing agents, and make sure that the model files are named after the class name of corresponding agent, for example, DE_DDQN_Agent.pkl. --log_dir option specifies the directory where log files will be saved.

You can test your own agent MyAgent and optimizer MyOptimizer with DE_DDQN, LDE, DEAP_DE, JDE21, DEAP_CMAES, Random_search using the following command:

python main.py --test --agent_load_dir MyAgentLoadDir --agent_for_cp MyAgent DE_DDQN_Agent LDE_Agent --l_optimizer_for_cp MyOptimizer DE_DDQN_Optimizer LDE_Optimizer --t_optimizer_for_cp DEAP_DE JDE21 DEAP_CMAES Random_search --log_dir MyLogDir

For the above command, MetaBox will first load the trained model from MyAgentLoadDir, then initialize the agents and optimizers of yours, DE_DDQN and LDE and the selected traditional optimizers, and use the generated test set to optimize all the selected problems for testing.

Test Results

After testing, 3 types of data files will be generated in MyLogDir/test/runName or output/test/runName by default:

MGD Test

Meta Generalization Decay (MGD) metric is to assess the generalization performance of MetaBBO-RL for unseen tasks. Before running MGD test, you should prepare two agent models that have trained on two different problem sets respectively.

Run the following command to execute MGD test:

python main.py --mgd_test --problem_from bbob-noisy --difficulty_from easy --problem_to bbob --difficulty_to easy --agent MyAgent --optimizer MyOptimizer --model_from path_of_model_trained_on_problem_from --model_to path_of_model_trained_on_problem_to

Then, the program will print the MGD score when it ends.

MTE Test

Meta Transfer Efficiency (MTE) metric is to evaluate the transfer learning capacity of a MetaBBO-RL approach. Before running MTE test, two agent models need to be prepared. One is trained on –problem_to, and another one is pre-trained on –problem_from then is transferred to continue training on –problem_to. After that, rollout these two models on –problem_to respectively to obtain two rollout.pkl files.

Run the following command to execute MTE test:

python main.py --mte_test --problem_from bbob-noisy --difficulty_from easy --problem_to bbob --difficulty_to easy --agent MyAgent --pre_train_rollout path_of_pkl_result_file_of_pretrain_rollout --scratch_rollout path_of_pkl_result_file_of_scratch_rollout

When the test ends, it will print the MTE score and save a figure at directory src/output/mte_test/runName/.