| 871 // be consumed by `t` below by suitably large choice of `tolerance_mult`. |
871 // be consumed by `t` below by suitably large choice of `tolerance_mult`. |
| 872 // Hence, we simply implicitly adapt the `tolerance_mult` be commenting out |
872 // Hence, we simply implicitly adapt the `tolerance_mult` be commenting out |
| 873 // the `ε` here. That way, `d` is in its entirely multiplied by τ, as is `t`, |
873 // the `ε` here. That way, `d` is in its entirely multiplied by τ, as is `t`, |
| 874 // making all factors independent of τ. |
874 // making all factors independent of τ. |
| 875 let maybe_excess = match ρ.α_γ.total_cmp(&0.0) { |
875 let maybe_excess = match ρ.α_γ.total_cmp(&0.0) { |
| 876 Greater => (δ.α >= 0.0).then(|| { |
876 // Note, the δ.α > 0 (and < 0) restriction will cause the transport to be reset, |
| |
877 // if no spike was left at the target point after weight optimisation. |
| |
878 Greater => (δ.α > 0.0).then(|| { |
| 877 let gvx = v.differential(&ρ.x); |
879 let gvx = v.differential(&ρ.x); |
| 878 let d = if tconfig.alt_remainder_control { |
880 let d = if tconfig.alt_remainder_control { |
| 879 let τv̆y = τv̆.apply(&ρ.y); |
881 let τv̆y = τv̆.apply(&ρ.y); |
| 880 (/*ε +*/τ * α_upper + ω(&ρ.x, ρ.α_γ.total_cmp(&ρ.α_μ_orig), false)) |
882 (/*ε +*/τ * α_upper + ω(&ρ.x, ρ.α_γ.total_cmp(&ρ.α_μ_orig), false)) |
| 881 + (τv̆y + τ * gvx.dot(&ρ.x - &ρ.y)) |
883 + (τv̆y + τ * gvx.dot(&ρ.x - &ρ.y)) |
| 886 + τ * gvx.dot(&ρ.x - &ρ.y) |
888 + τ * gvx.dot(&ρ.x - &ρ.y) |
| 887 - τℓ_gradv2 * ρ.y.dist2_squared(&ρ.x) |
889 - τℓ_gradv2 * ρ.y.dist2_squared(&ρ.x) |
| 888 }; |
890 }; |
| 889 d * ρ.α_γ |
891 d * ρ.α_γ |
| 890 }), |
892 }), |
| 891 Less => (δ.α <= 0.0).then(|| { |
893 Less => (δ.α < 0.0).then(|| { |
| 892 let gvx = v.differential(&ρ.x); |
894 let gvx = v.differential(&ρ.x); |
| 893 let d = if tconfig.alt_remainder_control { |
895 let d = if tconfig.alt_remainder_control { |
| 894 let τv̆y = τv̆.apply(&ρ.y); |
896 let τv̆y = τv̆.apply(&ρ.y); |
| 895 (/*ε*/-τ * α_lower - ω(&ρ.x, ρ.α_γ.total_cmp(&ρ.α_μ_orig), true)) |
897 (/*ε*/-τ * α_lower - ω(&ρ.x, ρ.α_γ.total_cmp(&ρ.α_μ_orig), true)) |
| 896 - (τv̆y + τ * gvx.dot(&ρ.x - &ρ.y)) |
898 - (τv̆y + τ * gvx.dot(&ρ.x - &ρ.y)) |