@@ -272,6 +272,7 @@ inventory::submit! {
272272 }
273273}
274274
275+ // Decision<MDS<SG, One>> → MDS<SG, One>: both witness (identity config) and aggregate (solve + compare)
275276inventory:: submit! {
276277 crate :: rules:: ReductionEntry {
277278 source_name: "DecisionMinimumDominatingSet" ,
@@ -280,7 +281,16 @@ inventory::submit! {
280281 target_variant_fn: <MinimumDominatingSet <SimpleGraph , One > as Problem >:: variant,
281282 overhead_fn: || crate :: rules:: ReductionOverhead :: identity( & [ "num_vertices" , "num_edges" ] ) ,
282283 module_path: module_path!( ) ,
283- reduce_fn: None ,
284+ reduce_fn: Some ( |any| {
285+ let source = any
286+ . downcast_ref:: <Decision <MinimumDominatingSet <SimpleGraph , One >>>( )
287+ . expect( "DecisionMinimumDominatingSet witness reduction source type mismatch" ) ;
288+ Box :: new(
289+ <Decision <MinimumDominatingSet <SimpleGraph , One >> as crate :: rules:: ReduceTo <
290+ MinimumDominatingSet <SimpleGraph , One >,
291+ >>:: reduce_to( source) ,
292+ )
293+ } ) ,
284294 reduce_aggregate_fn: Some ( |any| {
285295 let source = any
286296 . downcast_ref:: <Decision <MinimumDominatingSet <SimpleGraph , One >>>( )
@@ -291,7 +301,7 @@ inventory::submit! {
291301 >>:: reduce_to_aggregate( source) ,
292302 )
293303 } ) ,
294- capabilities: crate :: rules:: EdgeCapabilities :: aggregate_only ( ) ,
304+ capabilities: crate :: rules:: EdgeCapabilities :: both ( ) ,
295305 overhead_eval_fn: |any| {
296306 let source = any
297307 . downcast_ref:: <Decision <MinimumDominatingSet <SimpleGraph , One >>>( )
@@ -314,6 +324,7 @@ inventory::submit! {
314324 }
315325}
316326
327+ // Reverse edge: MDS<SG, One> → Decision<MDS<SG, One>> (Turing)
317328inventory:: submit! {
318329 crate :: rules:: ReductionEntry {
319330 source_name: "MinimumDominatingSet" ,
@@ -396,33 +407,63 @@ pub(crate) fn decision_canonical_model_example_specs(
396407#[ cfg( feature = "example-db" ) ]
397408pub ( crate ) fn decision_canonical_rule_example_specs (
398409) -> Vec < crate :: example_db:: specs:: RuleExampleSpec > {
399- vec ! [ crate :: example_db:: specs:: RuleExampleSpec {
400- id: "decision_minimum_dominating_set_to_minimum_dominating_set" ,
401- build: || {
402- use crate :: example_db:: specs:: assemble_rule_example;
403- use crate :: export:: SolutionPair ;
404- use crate :: rules:: { AggregateReductionResult , ReduceToAggregate } ;
405-
406- let source = crate :: models:: decision:: Decision :: new(
407- MinimumDominatingSet :: new(
408- SimpleGraph :: new( 5 , vec![ ( 0 , 1 ) , ( 0 , 2 ) , ( 1 , 3 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 4 ) ] ) ,
409- vec![ 1i32 ; 5 ] ,
410- ) ,
411- 2 ,
412- ) ;
413- let result = source. reduce_to_aggregate( ) ;
414- let target = result. target_problem( ) ;
415- let config = vec![ 0 , 0 , 1 , 1 , 0 ] ;
416- assemble_rule_example(
417- & source,
418- target,
419- vec![ SolutionPair {
420- source_config: config. clone( ) ,
421- target_config: config,
422- } ] ,
423- )
410+ vec ! [
411+ crate :: example_db:: specs:: RuleExampleSpec {
412+ id: "decision_minimum_dominating_set_to_minimum_dominating_set" ,
413+ build: || {
414+ use crate :: example_db:: specs:: assemble_rule_example;
415+ use crate :: export:: SolutionPair ;
416+ use crate :: rules:: { AggregateReductionResult , ReduceToAggregate } ;
417+
418+ let source = crate :: models:: decision:: Decision :: new(
419+ MinimumDominatingSet :: new(
420+ SimpleGraph :: new( 5 , vec![ ( 0 , 1 ) , ( 0 , 2 ) , ( 1 , 3 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 4 ) ] ) ,
421+ vec![ 1i32 ; 5 ] ,
422+ ) ,
423+ 2 ,
424+ ) ;
425+ let result = source. reduce_to_aggregate( ) ;
426+ let target = result. target_problem( ) ;
427+ let config = vec![ 0 , 0 , 1 , 1 , 0 ] ;
428+ assemble_rule_example(
429+ & source,
430+ target,
431+ vec![ SolutionPair {
432+ source_config: config. clone( ) ,
433+ target_config: config,
434+ } ] ,
435+ )
436+ } ,
424437 } ,
425- } ]
438+ // One-weight variant: Decision<MDS<SG, One>> → MDS<SG, One> (aggregate)
439+ crate :: example_db:: specs:: RuleExampleSpec {
440+ id: "decision_minimum_dominating_set_one_to_minimum_dominating_set_one" ,
441+ build: || {
442+ use crate :: example_db:: specs:: assemble_rule_example;
443+ use crate :: export:: SolutionPair ;
444+ use crate :: rules:: { AggregateReductionResult , ReduceToAggregate } ;
445+
446+ let source = crate :: models:: decision:: Decision :: new(
447+ MinimumDominatingSet :: new(
448+ SimpleGraph :: new( 5 , vec![ ( 0 , 1 ) , ( 0 , 2 ) , ( 1 , 3 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 4 ) ] ) ,
449+ vec![ One ; 5 ] ,
450+ ) ,
451+ 2 ,
452+ ) ;
453+ let result = source. reduce_to_aggregate( ) ;
454+ let target = result. target_problem( ) ;
455+ let config = vec![ 0 , 0 , 1 , 1 , 0 ] ;
456+ assemble_rule_example(
457+ & source,
458+ target,
459+ vec![ SolutionPair {
460+ source_config: config. clone( ) ,
461+ target_config: config,
462+ } ] ,
463+ )
464+ } ,
465+ } ,
466+ ]
426467}
427468
428469/// Check if a set of vertices is a dominating set.
0 commit comments