1、Getting Stated

1.1Command Line

使用方法:
在pycharm中:
cd example
python ..\ bin\ dragonfly-script.py --config xxx.json --option xxx.txt

1)Basic Use 全局优化

定义在.\ synthetic\ branin\ branin.py
//example: dragonfly-script.py --config synthetic/branin/config.json --options options_files/options_example.txt

2)Minimization

默认是maximization
//example:dragonfly-script.py --config synthetic/branin/config.json --options options_files/options_example_for_minimisation.txt

3)Multi-Fidelity 多精度优化

什么是多精度优化?

基本思想:一部分低精度数据{Xi,yi}N1i=1 ;一部分高精度{Xj,yj}N1+Nhj=N1+1
其中N1约为Nh的3~5倍甚至更多。分别用这两部分训练出两个模型,低精度模型由于有足够数据量所以得到一个相对精确的模型,高精度由于数据少,不准确。
令zi=NN1f(Xi) ,用{(Xi,zi),yi} 训练一个新模型
example:dragonfly-script.py --config synthetic/branin/config_mf.json --options options_files/options_example.txt

4)Specifying the domain

Euclidean, integral, discrete, and discrete numeric domains, or a domain which includes a combination of these variables.
//example:dragonfly-script.py --config synthetic/park2_3/config_mf.json --options options_files/options_example.txt
5)Optimization on a time budget
时间优化  。。。 看不太懂

example:从 Ia 型超新星数据中估计宇宙学参数:

dragonfly-script.py --config supernova/config.json --options options_files/options_example_realtime.txt

dragonfly-script.py --config supernova/config_mf.json --options options_files/options_example_realtime.txt ( For multi-fidelity version6)Other Method
BO是在计算难度大的情况下用的,在尽量少的运算中找到最优

如果 evaluation is cheap ,作者推荐使用DiRect或PDOO for 欧氏域

或者evolutionary算法for 非欧式域//example1:dragonfly-script.py --config synthetic/branin/config.json --options options_files/options_example_pdoo.txt

//example2:dragonfly-script.py --config synthetic/park2_3/config_mf.json --options options_files/options_example_ea.txt7)MultiObjective Optimization
多目标优化

//example:dragonfly-script.py --config demos_synthetic/multiobjective_hartmann/config.json --options demos_synthetic/multiobjective_options_example.txt

2.Code

1)API 的使用

/dragonfly/apis/moo.py&opt.py
/dragonfly/__init__.py

1.1)opt.py

1.1)maximize_function & minimize_function
1.2)maximize_multifidelity_function & minimize_multifidelity_function

1.2)moo.py

2.1)multiobjective_maximize_function & multiobjective_minimize_function

2)load config

dragonfly/exd/cp.domain_utils.py:load_config & load_config_file

3)各种各样的example

examples/synthetic/branin/in_code.demo.py
examples/synthetic/hartmann6_4/in_code.demo.py
examples/synthetic/harmann3_constrained/in_code.demo.py
examples/synthetic/discrete_euc/in_code.demo.py
examples/synthetic/park1_constrained/in_code.demo.py
examples/synthetic/borehole_constrained/in_code.demo.py
examples/tree_reg/in_code.demo.py
examples/nas/demo_nas.py

4)Neural Architectural Search(NAS)

dragonfly具有定义神经网络架构的API 定义了他们之间的距离 并实现了NASBOT
使用贝叶斯优化和最优传输进行神经架构搜索
Neural Architectural Search Bayesian Optimization and Optimal Transport

3.Ask Tell Mode

1)ask-tell接口

expose nextpoint to evaluated by BO
暴露一个由BO得出的下一个被探测的点
在代码的exd&opt里面可以看,用的时候需要设置ask_tell_mode=True

由两个组件组成:

一:caller 调用器

domain为欧式域的时候用EuclideanFunctionCaller

其余用CPFunctionCaller

对于笛卡尔乘积空间(cartesian product space),还需要对定于域的排序

用CPFunction中的domain_orderings参数

没有目标函数传递到caller中

二:optimizer 优化器

$$
+\left{
\begin{matrix}
GPBandit \
GAOptimizer \
RandomOptimizer
\end{matrix}
\right.
$$

蜻蜓优化算法 python 蜻蜓算法简介_蜻蜓优化算法 python

由以上显式创建(explicitly create)
domain是Euclidean或CP
最后通过.initialize()调用
要使函数最小化,只需去目标负值并执行上述程序
ask在一个numpy数组中返回下一个evaluate的点,通过调用目标函数evaluate后,将点返回给优化器。
tell需要一个参数(a tuple),这个参数囊括了(X,y) X:parameter y:target or objective

运行:python examples/detaild_use_cases/in_code_demo.ask_tell.py

2)Multifidelity Optimization

在上述基础上添加fidelity spacefidelity value 当目标函数在保真度坐标z和域坐标x上被评估时,保真度参数必须通过调用opt.tell([X,y,z])来指定