首页 > 编程语言 >dragonfly 蜻蜓算法 学习笔记

dragonfly 蜻蜓算法 学习笔记

时间:2022-08-27 14:12:51浏览次数:74  
标签:蜻蜓 dragonfly -- py example 算法 config options

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} 训练一个新模型
(8条消息) Multi-fidelity DNNs : 多精度深度神经网络_waitingwinter的博客-CSDN博客_高精度神经网络
//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 version

6)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.txt

7)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.
$$

由以上显式创建(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])来指定

标签:蜻蜓,dragonfly,--,py,example,算法,config,options
From: https://www.cnblogs.com/kidragon/p/16630468.html

相关文章

  • 算法题python用法
    算法题python用法大写变小写往后移动一位chr(ord(v.lower())+1)大写、小写、数字i.isalpha():#英文i.isspace()#空格​ifitem.isupper():#大写     a......
  • 算法题
    回文字符串Manacher算法字符串aaabaLen数组有一个性质,那就是Len[i]-1就是以第i个字符为中心的回文子串在原字符串S中的长度。......
  • LeetCode 链表的中间结点算法题解 All In One
    LeetCode链表的中间结点算法题解AllInOnejs/ts实现重排链表链表的中间结点原理图解//快慢指针functionmiddleNode(head:ListNode|null):ListNode|n......
  • 有一个线性表,采用带头结点的单链表L来存储,设计一个算法将其逆置,且不能建立新节点,只能
    有一个线性表,采用带头结点的单链表L来存储,设计一个算法将其逆置,且不能建立新节点,只能通过表中已有的节点的重新组合来完成。分析:线性表中关于逆序的问题,就是用建立链表......
  • 【算法】二分
    y总二分模板y总模板链接boolcheck(intx){/*...*/}//检查x是否满足某种性质//区间[l,r]被划分成[l,mid]和[mid+1,r]时使用:intbsearch_1(intl,intr){......
  • java质数算法
    importjava.util.ArrayList;importjava.util.Iterator;importjava.util.List;importjava.stream.Collectors;importjava.stream.Stream;publicclassMain{publ......
  • Kruskal和Prim算法详解
    最小生成树概念(转载)假设一个国家有一些城市,这些城市可以互相连接起来,假设每两个城市之间的道路有很多条,那么一定存在这样的情况,可以用最少的路程连接各个城市。......
  • #前端算法救赎系列#LeetCode03.无重复字符的最长子串
    3.无重复字符的最长子串给定一个字符串s,请你找出其中不含有重复字符的最长子串的长度。示例1:输入:s="abcabcbb"输出:3解释:因为无重复字符的最长子串是......
  • [算法]区间归并
    问题分析有的时候,会遇到给定一系列的区间,求交集or并集,或者合并的题.这些题的解题方式比较通用个,做一个总结.会用到集合和归并排序的相关知识.两个区间的关系有六种......
  • 2022“杭电杯”中国大学生算法设计超级联赛(10) 题解
    C.WavyTree发现修改次数和相邻两数的相对大小有关,所以可先求出差分数组。分两种情况考虑:①奇数位置为波峰②偶数位置为波峰。以情况①为例,若奇数位置差分后值小......