예제 #1
0
def make_config():
    global local_optimization
    global precision
    config = Config()
    config.precision = precision
    config.use_local_optimization = local_optimization
    return config
예제 #2
0
 def test_lorentz_cone(self):
     config = Config()
     config.use_local_optimization = True
     config.precision = 0.0001
     result = Minimize(
         x2,
         logical_and(-5 <= x0, x0 <= 5, -5 <= x1, x1 <= 5, 0 <= x2, x2 <= 5,
                     1 >= (x0 - 1)**2 + (x1 - 1)**2,
                     x2**2 >= x0**2 + x1**2), config)
     self.assertTrue(result)
     self.assertAlmostEqual(result[x2].mid(), 0.414212, places=3)
예제 #3
0
 def test_precision(self):
     c = Config()
     c.precision = 0.0001
     self.assertEqual(c.precision, 0.0001)
     c.precision = 0.01
     self.assertEqual(c.precision, 0.01)
예제 #4
0
 def test_use_local_optimization(self):
     c = Config()
     c.use_local_optimization = False
     self.assertFalse(c.use_local_optimization)
     c.use_local_optimization = True
     self.assertTrue(c.use_local_optimization)
예제 #5
0
 def test_use_worklist_fixpoint(self):
     c = Config()
     c.use_worklist_fixpoint = False
     self.assertFalse(c.use_worklist_fixpoint)
     c.use_worklist_fixpoint = True
     self.assertTrue(c.use_worklist_fixpoint)
예제 #6
0
 def test_use_polytope_in_forall(self):
     c = Config()
     c.use_polytope_in_forall = False
     self.assertFalse(c.use_polytope_in_forall)
     c.use_polytope_in_forall = True
     self.assertTrue(c.use_polytope_in_forall)
예제 #7
0
 def test_use_polytope(self):
     c = Config()
     c.use_polytope = False
     self.assertFalse(c.use_polytope)
     c.use_polytope = True
     self.assertTrue(c.use_polytope)