@@ -278,6 +278,54 @@ def test_error_handling(self):
278278 with self .assertRaises (TypeError ):
279279 oj .SQASampler (trotter = 10 )
280280
281+ def test_simple_two_variable_cases (self ):
282+ # Test case 1: (0,0): 1, (1,1): 1 with expected result [0,0]
283+ qubo1 = {(0 , 0 ): 1 , (1 , 1 ): 1 }
284+
285+ sampler = oj .SASampler ()
286+ res = sampler .sample_qubo (qubo1 , seed = 1 )
287+ self .assertEqual (len (res .states ), 1 )
288+ self .assertListEqual ([0 , 0 ], list (res .states [0 ]))
289+
290+ # Test case 2: (0,0): -1, (1,1): -1 with expected result [1,1]
291+ qubo2 = {(0 , 0 ): - 1 , (1 , 1 ): - 1 }
292+
293+ sampler = oj .SASampler ()
294+ res = sampler .sample_qubo (qubo2 , seed = 1 )
295+ self .assertEqual (len (res .states ), 1 )
296+ self .assertListEqual ([1 , 1 ], list (res .states [0 ]))
297+
298+ def test_simple_two_variable_cases_with_small_interaction (self ):
299+ # Test case 1: (0,0): 1, (1,1): 1 with expected result [0,0]
300+ qubo1 = {(0 , 0 ): 1 , (1 , 1 ): 1 , (0 , 1 ): 1e-7 }
301+
302+ sampler = oj .SASampler ()
303+ res = sampler .sample_qubo (qubo1 , seed = 1 )
304+ self .assertEqual (len (res .states ), 1 )
305+ self .assertListEqual ([0 , 0 ], list (res .states [0 ]))
306+
307+ # Test case 2: (0,0): -1, (1,1): -1 with expected result [1,1]
308+ qubo2 = {(0 , 0 ): - 1 , (1 , 1 ): - 1 , (0 , 1 ): 1e-7 }
309+
310+ sampler = oj .SASampler ()
311+ res = sampler .sample_qubo (qubo2 , seed = 1 )
312+ self .assertEqual (len (res .states ), 1 )
313+ self .assertListEqual ([1 , 1 ], list (res .states [0 ]))
314+
315+ def test_qubo_with_null_interaction (self ):
316+ # Test case with zero interaction
317+ qubo = {}
318+
319+ sampler = oj .SASampler ()
320+ _ = sampler .sample_qubo (qubo , seed = 1 )
321+
322+ def test_qubo_with_zero_interaction (self ):
323+ # Test case with zero interaction
324+ qubo = {(0 , 0 ): 0 , (1 , 1 ): 0 }
325+
326+ sampler = oj .SASampler ()
327+ _ = sampler .sample_qubo (qubo , seed = 1 )
328+
281329
282330if __name__ == '__main__' :
283331 unittest .main ()
0 commit comments