File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,26 @@ fn test_maximum2satisfiability_to_maxcut_structure() {
5252 assert_eq ! ( target. evaluate( & target_solution) , Max ( Some ( 2 ) ) ) ;
5353}
5454
55+ #[ test]
56+ fn test_maximum2satisfiability_to_maxcut_issue_affine_relation_on_all_partitions ( ) {
57+ let source = make_issue_instance ( ) ;
58+ let reduction = ReduceTo :: < MaxCut < SimpleGraph , i32 > > :: reduce_to ( & source) ;
59+ let target = reduction. target_problem ( ) ;
60+
61+ // For this issue instance, every partition satisfies
62+ // 2 * satisfied_clauses = 8 + cut_weight.
63+ for mask in 0 ..( 1usize << target. num_vertices ( ) ) {
64+ let target_solution: Vec < usize > = ( 0 ..target. num_vertices ( ) )
65+ . map ( |bit| ( mask >> bit) & 1 )
66+ . collect ( ) ;
67+ let source_solution = reduction. extract_solution ( & target_solution) ;
68+ let satisfied = source. evaluate ( & source_solution) . unwrap ( ) as i32 ;
69+ let cut_weight = target. evaluate ( & target_solution) . unwrap ( ) ;
70+
71+ assert_eq ! ( 2 * satisfied, 8 + cut_weight, "target config {target_solution:?}" ) ;
72+ }
73+ }
74+
5575#[ test]
5676fn test_maximum2satisfiability_to_maxcut_extract_solution_uses_reference_vertex ( ) {
5777 let source = make_issue_instance ( ) ;
You can’t perform that action at this time.
0 commit comments