20个版本 (11个破坏性更新)
0.12.1 | 2022年2月15日 |
---|---|
0.11.1 | 2022年2月14日 |
0.11.0 | 2021年11月16日 |
0.9.0 |
|
#1858 在 算法
每月247次下载
61KB
1K SLoC
simple_optimization
一些简单的多线程优化器。
你可以进行类似以下随机的搜索
use std::sync::Arc;
use simple_optimization::{random_search, Polling};
// Our evaluation function takes 3 `f64`s and no additional data `()`.
fn simple_function(list: &[f64; 3], _: Option<Arc::<()>>) -> f64 { list.iter().sum() }
let best = random_search!(
(0f64..10f64, 5u32..15u32, 10i16..20i16), // Value ranges.
simple_function, // Evaluation function.
None, // No additional evaluation data.
// Every `10ms` we print progress and exit early if `simple_function` return a value less than `19.`.
Some(Polling::new(true,Some(19.))),
None, // We don't specify the number of threads to run.
1000, // Take `1000` samples.
);
assert!(simple_function(&best, None) < 19.);
在执行过程中将给出如下输出
1000
500 (50.00%) 00:00:11 / 00:00:47 [25.600657363049734]
表示
<Total number of samples>
<Current number of samples> (<Percentage of samples taken>) <Time running> / <ETA> [<Current best value>]
支持
优化器 | 状态 |
---|---|
随机搜索 | ✅ |
网格搜索 | ✅ |
模拟退火 | ✅ |
贝叶斯优化 | 进行中 |
梯度下降 | 请参阅我的笔记 |
遗传算法 | 没有计划 |
蚁群优化 | 没有计划 |
线性规划 | 没有计划 |
由于我找到的现有库感觉不太舒服,所以我制作了这个。
依赖项
~2MB
~38K SLoC