Skip to main content

cmtool_core/model/
balance.rs

1// SPDX-License-Identifier: GPL-3.0-or-later
2
3///Knobs of the balancing pass, `Default` is what the CLI uses unless it is told otherwise
4#[derive(Debug, Clone, Copy)]
5pub struct BalanceSettings {
6    ///Iterations the balancing may spend before giving up
7    pub max_iterations: usize,
8    ///Divergence it aims for, convergence is linear so asking for much less costs iterations
9    pub tolerance: f64,
10    ///Divergence above which the resulting flow map is rejected
11    pub max_divergence: f64,
12}
13
14impl Default for BalanceSettings {
15    fn default() -> Self {
16        Self {
17            max_iterations: 1000,
18            tolerance: 1e-6,
19            max_divergence: 1e-2,
20        }
21    }
22}
23
24///What the balancing pass achieved, so that a caller can tell a converged map from a giving up one
25pub struct BalanceReport {
26    pub iterations: usize,
27    pub residual: f64,
28}