@@ -690,9 +690,41 @@ crate::declare_variants! {
690690 ILP <i64 , f64 > => "num_vars^num_vars" ,
691691}
692692
693+ impl crate :: solvers:: BruteForceProblem for ILP < bool > {
694+ fn dimensions ( & self ) -> Vec < usize > {
695+ vec ! [ 2 ; self . num_vars( ) ]
696+ }
697+ }
698+
699+ crate :: decision_problem_meta!( ILP <bool >, "DecisionILP" ) ;
700+ crate :: register_decision_variant!( without_turing;
701+ ILP <bool >, "DecisionILP" , "2^num_vars" , & [ ] ,
702+ "Does a binary ILP have a feasible solution meeting its objective bound?" ,
703+ category: crate :: registry:: ProblemCategory :: Algebraic ,
704+ dims: [
705+ VariantDimension :: new( "variable" , "bool" , & [ "bool" ] ) ,
706+ VariantDimension :: new( "coefficient" , "i64" , & [ "i64" ] ) ,
707+ VariantDimension :: new( "bounds" , "general" , & [ "general" ] ) ,
708+ ] ,
709+ fields: [
710+ FieldInfo { name: "variables" , type_name: "Vec<IntegerVariable>" , description: "Binary variable bounds [0, 1]" } ,
711+ FieldInfo { name: "constraints" , type_name: "Vec<LinearConstraint<i64>>" , description: "Sparse integer linear constraints" } ,
712+ FieldInfo { name: "objective" , type_name: "Vec<(usize, i64)>" , description: "Sparse integer objective coefficients" } ,
713+ FieldInfo { name: "sense" , type_name: "ObjectiveSense" , description: "Optimization direction" } ,
714+ FieldInfo { name: "bound" , type_name: "i64" , description: "Upper bound for minimization, lower bound for maximization" } ,
715+ ] ,
716+ decode: |_, indices: Vec <usize >| indices. into_iter( ) . map( |bit| i64 :: try_from( bit) . expect( "binary coordinate fits i64" ) ) . collect:: <Vec <_>>( )
717+ ) ;
718+
693719#[ cfg( feature = "example-db" ) ]
694720pub ( crate ) fn canonical_model_example_specs ( ) -> Vec < crate :: example_db:: specs:: ModelExampleSpec > {
695721 vec ! [
722+ crate :: example_db:: specs:: ModelExampleSpec {
723+ id: "decision_ilp" ,
724+ instance: Box :: new( canonical_decision_example( ) ) ,
725+ optimal_config: serde_json:: json!( [ 0 , 0 , 1 ] ) ,
726+ optimal_value: serde_json:: json!( true ) ,
727+ } ,
696728 crate :: example_db:: specs:: ModelExampleSpec {
697729 id: "ilp" ,
698730 instance: Box :: new(
@@ -733,3 +765,17 @@ pub(crate) fn canonical_model_example_specs() -> Vec<crate::example_db::specs::M
733765#[ cfg( test) ]
734766#[ path = "../../unit_tests/models/algebraic/ilp.rs" ]
735767mod tests;
768+
769+ #[ cfg( feature = "example-db" ) ]
770+ pub ( crate ) fn canonical_decision_example ( ) -> crate :: models:: Decision < ILP < bool > > {
771+ crate :: models:: Decision :: new (
772+ ILP :: new (
773+ 3 ,
774+ vec ! [ LinearConstraint :: eq( vec![ ( 0 , 1 ) , ( 1 , 1 ) , ( 2 , 1 ) ] , 1 ) ] ,
775+ vec ! [ ( 0 , 3 ) , ( 1 , 2 ) , ( 2 , 1 ) ] ,
776+ ObjectiveSense :: Minimize ,
777+ )
778+ . unwrap ( ) ,
779+ 1 ,
780+ )
781+ }
0 commit comments