DIgging
DIgging -- Decision Intelligence for digging better parameters in target function/environments.
Introduction
DIgging is a heuristic searching and optimization platform with various Decision Intelligence methods such as Genetic Algorithm, Bayesian Optimization and Reinforcement Learning etc. It can be used to digging better candidates to handle combinatorial optimization problems and non-gradient search problems.
DIgging is a fundamental platform under OpenDILab and it uses DI-engine to build RL searching pipelines.
Outlines
Installation
You can simply install DIgging with pip
command line from the official PyPI site.
pip install --user digging
python -c 'import digging'
Or you can simply install it from the source code.
git clone git clone https://github.com/opendilab/DIgging.git
cd DIgging
pip install --user .
python -c 'import digging'
It will automatically install DI-engine together with its requirement packages i.e. PyTorch.
Quick start
DIgging defines core algorithm and searching methods as Digger
. You can define a Digger
with a searching Space
,
and can be modified by a config dict.
DIgging provides two kinds of searching pipeline for a target function. Thet are listed as follow.
- Interactive Procedure
It is done by calling Digger
's propose
and update_score
method, in which you can flexibly define the searching
procedures. You can call the provide_best
method at any time to see the currently best candidate sample and its score.
Here's an simple example:
def target_func(x):
...
return score
space = YourSpace(shape=(...))
digger = YourDigger(config, space)
for i in range(max_iterations):
samples = digger.propose(sample_num)
scores = [target_func(x) for x in samples]
digger.update_score(samples, scores)
print(digger.provide_best())
- Functional Procedure
It is done by calling the search
method of Digger
, with target function provided as input. The digger will
automatically search the best samples of the target according to the config. Here's an example:
def target_func(x):
...
return score
space = YourSpace(shape=(...))
digger = YourDigger(config, space)
digger.search(target_func)
print(digger.provide_best())
- Reinforcement Learning Procedure
When using a Reinforcement Learning Digger
, users need to provide an RL Policy
defined in DI-engine form,
and some other RL workers in DI-engine such as Collector
, Learner
, ReplayBuffer
are supposed to be used
in the Digger
. In the searching procedure, a target Env
is used instead of a function. So we suggest to use
the search
method to if the user is not familiar with the RL pipeline of DI-engine. Here's an example.
def target_func(x):
...
return score
rl_config = EasyDict(dict(...))
space = YourSearchSpace(shape=(...))
policy = YourPolicy(rl_config.policy, ...)
digger = RLDigger(rl_cfg, space, policy)
digger.search(target_func)
print(digger.provide_best())
Digging Method Zoo
- Genetic Algorithm
- Bayesian Optimization
- RL
Join and Contribute
We appreciate all contributions to improve DIgging, both algorithms and system designs. Welcome to OpenDILab community! Scan the QR code and add us on Wechat:
Or you can contact us with slack or email ([email protected]).
License
DIgging is released under the Apache 2.0 license.