use super::*;
#[test]
fn round_trip_weighted_non_dyadic() {
let rt = round_trip(
"wmc",
"c t wmc\n\
p cnf 4 4\n\
c p weight 1 1/3 0\n\
c p weight -1 2/3 0\n\
c p weight 2 5/7 0\n\
c p weight -2 3/11 0\n\
c p weight 3 2 0\n\
c p weight -3 1/5 0\n\
1 2 0\n\
-1 3 0\n\
-2 -3 4 0\n\
2 3 -4 0\n",
);
rt.assert_sound();
}
#[test]
fn round_trip_weighted_backbone_and_free() {
let rt = round_trip(
"wmc-backbone",
"c t wmc\n\
p cnf 5 4\n\
c p weight 1 3/5 0\n\
c p weight -1 7/5 0\n\
c p weight 4 1/3 0\n\
c p weight -4 1/7 0\n\
c p weight 2 2/9 0\n\
c p weight -2 5/9 0\n\
1 0\n\
-1 2 3 0\n\
-2 3 0\n\
2 -3 0\n",
);
rt.assert_sound();
assert_ne!(
rt.record.weight_lift, "1/1",
"a forced literal and a free variable both owe a weighted factor",
);
}
#[test]
fn weighted_without_arjun_keeps_the_original_weights() {
let rt = round_trip_with(
"pwmc-no-arjun",
"c t pwmc\n\
p cnf 5 5\n\
c p show 2 4 5 0\n\
c p weight 2 5/7 0\n\
c p weight -2 3/11 0\n\
c p weight 4 2 0\n\
c p weight -4 1/5 0\n\
1 2 0\n\
-1 3 0\n\
-2 -3 4 0\n\
2 3 -4 0\n\
4 5 0\n",
&RunConfig {
mode: Some(Mode::Pwmc),
stages: crate::config::PreprocessStages {
arjun: false,
..Default::default()
},
..Default::default()
},
);
rt.assert_sound();
assert_eq!(
rt.reduced_weights(),
rt.original_weights.clone().assume_reduced_identity(),
"with no renumbering stage the emitted table is the declared one; record = {}",
rt.record.to_json_string(),
);
}
#[test]
fn round_trip_projected_weighted() {
let rt = round_trip(
"pwmc",
"c t pwmc\n\
p cnf 5 5\n\
c p show 1 2 3 0\n\
c p weight 1 1/3 0\n\
c p weight -1 2/3 0\n\
c p weight 2 5/7 0\n\
c p weight -2 3/11 0\n\
c p weight 3 2 0\n\
c p weight -3 1/5 0\n\
1 2 0\n\
-1 4 0\n\
-2 -4 5 0\n\
2 4 -5 0\n\
3 5 0\n",
);
rt.assert_sound();
}
#[test]
fn round_trip_projected_weighted_arjun_only_checkpoint() {
let rt = round_trip_with(
"pwmc-arjun-only",
"c t pwmc\n\
p cnf 5 5\n\
c p show 1 2 3 0\n\
c p weight 1 1/3 0\n\
c p weight -1 2/3 0\n\
c p weight 2 5/7 0\n\
c p weight -2 3/11 0\n\
c p weight 3 2 0\n\
c p weight -3 1/5 0\n\
1 2 0\n\
-1 4 0\n\
-2 -4 5 0\n\
2 4 -5 0\n\
3 5 0\n",
&RunConfig {
mode: Some(Mode::Pwmc),
projection_policy: crate::config::ProjectionPolicy::ArjunOnly(
crate::config::ProjectionNoGain::KeepSound,
),
..RunConfig::default()
},
);
rt.assert_sound();
}
#[test]
fn round_trip_weighted_unsat() {
let rt = round_trip(
"wmc-unsat",
"c t wmc\n\
p cnf 3 4\n\
c p weight 1 1/3 0\n\
c p weight -1 2/3 0\n\
1 0\n\
-1 0\n\
2 3 0\n\
-2 -3 0\n",
);
rt.assert_sound();
}