9个版本
0.1.9 | 2024年1月10日 |
---|---|
0.1.8 | 2023年3月2日 |
0.1.7 | 2022年12月14日 |
0.1.6 | 2022年11月28日 |
0.1.1 | 2022年9月23日 |
#327 in 算法
61 每月下载量
200KB
4K SLoC
Puan
定义线性不等式之间的逻辑关系并具有有效的降阶算法。
示例
这里定义了ID 0、1和2之间的关系,表示ID 0的值依赖于ID 1和2的值。
use puanrs::Theory;
use puanrs::Statement;
use puanrs::AtLeast;
use puanrs::Variable;
use puanrs::GeLineq;
let theory: Theory = Theory {
id : String::from("A"),
statements : vec![
Statement {
variable : Variable {
id : 0,
bounds : (0,1),
},
expression : Some(
AtLeast {
ids : vec![1,2],
bias : -1,
}
)
},
Statement {
variable : Variable {
id : 1,
bounds : (0,1),
},
expression : None
},
Statement {
variable : Variable {
id : 2,
bounds : (0,1),
},
expression : None
},
]
};
let actual: Vec<GeLineq> = theory.to_lineqs();
assert_eq!(actual.len(), 1);
assert_eq!(actual[0].bias, 0);
assert_eq!(actual[0].coeffs, vec![-1,1,1]);
assert_eq!(actual[0].indices, vec![0,1,2]);
如果A=0, x=1, y=2(这里的0、1、2是变量ID),我们可以将上述内容表示为
A=x+y>=1
。
依赖项
~425KB