MCPcopy Create free account
hub / github.com/argumentcomputer/ix / fm_gain

Function fm_gain

crates/kernel/src/shard.rs:810–828  ·  view source on GitHub ↗

FM gain of moving local vertex `v` from its side to the other. `+w` for each net where `v`'s side has exactly one pin (the move uncuts it); `−w` for each net fully on `v`'s side with ≥2 pins (the move newly cuts it).

(lv: Level<'_>, ns: &NetState, side: &[u8], v: usize)

Source from the content-addressed store, hash-verified

808 cnt[i][side[v as usize] as usize] += 1;
809 }
810 if cnt[i][0] > 0 && cnt[i][1] > 0 {
811 cut += u128::from(*w);
812 }
813 }
814 (NetState { cnt }, cut)
815 }
816}
817
818/// FM gain of moving local vertex `v` from its side to the other.
819/// `+w` for each net where `v`'s side has exactly one pin (the move uncuts it);
820/// `−w` for each net fully on `v`'s side with ≥2 pins (the move newly cuts it).
821fn fm_gain(lv: Level<'_>, ns: &NetState, side: &[u8], v: usize) -> i128 {
822 let a = side[v] as usize;
823 let b = 1 - a;
824 let mut g: i128 = 0;
825 for &ni in &lv.vnets[v] {
826 let (w, pins) = &lv.nets[ni as usize];
827 if pins.len() > FM_NET_CAP {
828 continue; // hub net: ignored by FM
829 }
830 let ca = ns.cnt[ni as usize][a];
831 let cb = ns.cnt[ni as usize][b];

Callers 1

fm_refineFunction · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected