MetaBox

Fit your own MetaBBO-RL into MetaBox

If you want to develop your own MetaBBO-RL approach, to fit into MetaBox running logic, you should meet with the following protocol about the Agent and Optimizer.

Agent is the same definition in RL area, taking the state from env as input and action as output. But to fit into MetaBox pre-defined Trainer and Tester calling logic, Agent should has train_episode interface which will be called in Trainer and rollout_episode interface which will be called in Tester.

Optimizer is a component of env in MetaBBO task. It’s controlled by Agent and take action from Agent to perfrom corresponding change like hyper-parameters adjusting or operators selection. But to fit into env calling logic. Interfaces namely init_population and update is needed.

By the way, if you are developing classic optimizer, please refer to example classic optimizer.

After that, you should put your own declaring files in directory src/agent/ and src/optimizer/ respectively. Then the file structure should be like:

src
│        
├─ agent
│   │
│   ├─ de_ddqn_agent.py
│   ├─ ...
│   ├─ rlepso_agent.py
│   └─ my_agent.py
└─ optimizer
    │
    ├─ dq_ddqn_optimizer.py
    ├─ ...
    ├─ rlepso_optimizer.py
    └─ my_optimizer.py

In addition, you should register you own agent and backbone optimizer in files src/agent/__init__.py and src/optimizer/__init__.py. For example, to register the previous class MyAgent, you should add one line into the src/agent/__init__.py file as below:

from .my_agent import *

Meanwhile, you should also import your own agent and backbone optimizer into src/trainer.py and src/tester.py. Take trainer as an example, you should add two lines into file src/trainer.py as follows:

...
# import your agent
from agent import{
     ...
     MyAgent
}
# import your optimizer
from optimizer import{
     ...
     MyOptimizer
}

The same action should be done also in src/tester.py.

As mentioned, four modes are available:

Notice that we record 21 checkpoint models during the whole training process. Rollout could help you pick the suitable or best model to test and calculate the metrics.