1个不稳定版本
0.1.0 | 2023年12月15日 |
---|
#2138 在 算法 中
18KB
260 行
通用RCSP
使用动态规划标记算法解决资源受限最短路径问题的Rust库。是为解决分支定价的定价问题而开发的。
用法
实现UserProblem
特质。定义标签数据、资源扩展函数和支配函数。请参阅测试文件夹中的示例。
/// Main trait to implement that holds the user implementation of the problem.
///
/// Generics to implement:
/// - LabelMeta : Data to be stored in labels
/// - NodeWeight: Node attributes
/// - EdgeWeight: Edge attributes
/// - BranchFilter: Constraints made available during label extension
///
pub trait UserProblem<LabelMeta: Meta, NodeWeight,EdgeWeight : UserEdgeWeight, BranchFilter>
{
/// build your problem graph and return it
///
/// is called once during initialization of solver and then stored
fn create_graph(&mut self) -> ProblemGraph<NodeWeight, EdgeWeight>;
/// Dominance function called in labeling algorithm.
/// return true if label_a domiates label_b
fn is_dominating(label_a: &Label<LabelMeta>, label_b: &Label<LabelMeta>, active_filters : &[BranchFilter]) -> bool;
/// Label extension function
///
/// Receives previous label, edge, node weights, branching filters, and reference to the sink node
/// Return None if extension infeasible, otherwise return new Label.
fn extend_label<'arena>(
&self,
existing_label : &'arena Label<'arena, LabelMeta>,
edge : &EdgeReference<EdgeWeight>,
source : &NodeWeight,
target : &NodeWeight,
active_filters : &[BranchFilter],
sink : NodeIndex
) -> Option<Label<'arena,LabelMeta>>;
}
许可证
版权所有 (C) 2023 Gregor Godbersen 版权所有 (C) 2023 Gerhard Hiermann
此源代码形式受Mozilla公共许可证第2.0版的条款约束。如果没有与此文件一起分发MPL副本,您可以在http://mozilla.org/MPL/2.0/获得一份。
依赖项
~2.5MB
~40K SLoC