@@ -234,3 +234,54 @@ impl BddSet for GraphColoredVertices {
234
234
u16:: try_from ( self . state_variables . len ( ) + self . parameter_variables . len ( ) ) . unwrap ( )
235
235
}
236
236
}
237
+
238
+ #[ cfg( test) ]
239
+ mod tests {
240
+ use crate :: biodivine_std:: traits:: Set ;
241
+ use crate :: symbolic_async_graph:: SymbolicAsyncGraph ;
242
+ use crate :: BooleanNetwork ;
243
+ use num_bigint:: BigInt ;
244
+ use num_traits:: One ;
245
+
246
+ #[ test]
247
+ fn basic_colored_spaces_set_test ( ) {
248
+ let bn = BooleanNetwork :: try_from_file ( "aeon_models/005.aeon" ) . unwrap ( ) ;
249
+ let stg = SymbolicAsyncGraph :: new ( bn. clone ( ) ) . unwrap ( ) ;
250
+
251
+ let unit = stg. mk_unit_colored_vertices ( ) ;
252
+ assert ! ( !unit. is_singleton( ) ) ;
253
+ assert_eq ! ( unit, unit. copy( unit. clone( ) . into_bdd( ) ) ) ;
254
+
255
+ let singleton = unit. pick_singleton ( ) ;
256
+ assert_eq ! ( 1.0 , singleton. approx_cardinality( ) ) ;
257
+ assert_eq ! ( BigInt :: one( ) , singleton. exact_cardinality( ) ) ;
258
+ let singleton_color = singleton. colors ( ) ;
259
+ let singleton_vertices = singleton. vertices ( ) ;
260
+ assert ! ( singleton_color. is_singleton( ) ) ;
261
+ assert ! ( singleton_vertices. is_singleton( ) ) ;
262
+ assert ! ( !unit. intersect_colors( & singleton_color) . is_singleton( ) ) ;
263
+ // There is only one color, hence this holds. Otherwise this should not hold.
264
+ assert ! ( unit. intersect_vertices( & singleton_vertices) . is_singleton( ) ) ;
265
+ assert ! ( unit. minus_colors( & singleton_color) . is_empty( ) ) ;
266
+ assert ! ( unit. minus_vertices( & singleton_vertices) . is_subset( & unit) ) ;
267
+
268
+ let var = bn. as_graph ( ) . find_variable ( "v_XPF" ) . unwrap ( ) ;
269
+ let selected = unit. fix_network_variable ( var, true ) ;
270
+ assert_eq ! (
271
+ unit. approx_cardinality( ) / 2.0 ,
272
+ selected. approx_cardinality( )
273
+ ) ;
274
+ let restricted = unit. restrict_network_variable ( var, true ) ;
275
+ assert_eq ! ( unit. approx_cardinality( ) , restricted. approx_cardinality( ) ) ;
276
+ let restricted = singleton. restrict_network_variable ( var, false ) ;
277
+ assert_eq ! (
278
+ singleton. approx_cardinality( ) * 2.0 ,
279
+ restricted. approx_cardinality( )
280
+ ) ;
281
+ assert ! ( singleton. restrict_network_variable( var, true ) . is_empty( ) ) ;
282
+
283
+ // There are 28 variables and we are eliminating 22 of them, so 6 should be left.
284
+ let project = unit. raw_projection ( & stg. symbolic_context ( ) . state_variables ( ) [ 0 ..22 ] ) ;
285
+ assert_eq ! ( project. iter( ) . count( ) , 2_usize . pow( 6 ) ) ;
286
+ }
287
+ }
0 commit comments