9 个版本
0.4.3 | 2021 年 10 月 24 日 |
---|---|
0.4.2 | 2020 年 10 月 12 日 |
0.4.1 | 2019 年 12 月 9 日 |
0.3.0 | 2019 年 11 月 15 日 |
0.1.2 | 2019 年 7 月 31 日 |
在 算法 中排名第 874
每月下载 90 次
32KB
341 行
Simple(x) 全局优化
Simple(x) 黑盒全局优化算法的 Rust 实现。
此算法(不应与单纯形算法混淆)最接近贝叶斯优化。与贝叶斯优化相比,其优势在于能够有效地处理大量样本和高维数据。
使用方法
可以使用两种方式使用该算法,一种是使用 Optimizer::minimize
/ Optimizer::maximize
函数之一
let f = |v:&[f64]| v[0] + v[1] * v[2];
let input_interval = vec![(-10., 10.), (-20., 20.), (0, 5.)];
let nb_iterations = 100;
let (max_value, coordinates) = Optimizer::maximize(&f, &input_interval, nb_iterations);
println!("max value: {} found in [{}, {}, {}]", max_value, coordinates[0], coordinates[1], coordinates[2]);
或者如果您想将 exploration_depth
设置为某个特殊值,或者想对停止条件有更精细的控制,可以使用迭代器
let f = |v:&[f64]| v[0] * v[1];
let input_interval = vec![(-10., 10.), (-20., 20.)];
let should_minimize = true;
// sets `exploration_depth` to be greedy
// runs the search for 30 iterations
// then waits until we find a point good enough
// finally stores the best value so far
let (min_value, coordinates) = Optimizer::new(&f, &input_interval, should_minimize)
.set_exploration_depth(10)
.skip(30)
.skip_while(|(value,coordinates)| value > 1. )
.next().unwrap();
println!("min value: {} found in [{}, {}]", min_value, coordinates[0], coordinates[1]);
与参考实现的不同之处
-
用户将搜索空间定义为超立方体(然后使用此方法将其映射到单纯形)。
-
exploration_preference
(浮点数)参数已被替换为exploration_depth
(无符号整数)参数。它表示算法在需要更高层次探索之前可以搜索多少层(0 表示类似于网格搜索的探索,5 是一个好的默认值,而大值(10+)则非常注重探索/贪婪)。 -
调用算法有两种方式,一种是调用单个函数,另一种是通过迭代器,这使用户可以完全控制停止条件。
潜在的未来发展
请不要犹豫,提出改进意见。以下是可以做但可能不会主动完成的事项列表,除非有要求包括:
-
允许用户提出一些点以加速搜索(需要能够检查点是否在单纯形或三角化算法中)。
-
允许用户并行探索多个点。
-
允许用户离线进行搜索。
-
我们可以将该项目集成到argmin 优化框架中(使算法更易于访问、面向未来,并更容易与现有技术进行比较)。
依赖关系
~1.5MB
~23K SLoC