Lines Matching refs:tao

9     def __call__(self, tao, x):  argument
14 def __call__(self, tao, x, g): argument
28 def create(self, tao): argument
32 def destroy(self, tao): argument
36 def setFromOptions(self, tao): argument
39 def setUp(self, tao): argument
41 self.testvec = tao.getSolution().duplicate()
43 def solve(self, tao): argument
46 def step(self, tao, x, g, s): argument
48 tao.computeGradient(x, g)
52 def preStep(self, tao): argument
55 def postStep(self, tao): argument
58 def monitor(self, tao): argument
64 self.tao = PETSc.TAO()
65 self.tao.createPython(MyTao(), comm=PETSc.COMM_SELF)
74 self.tao.destroy()
75 self.tao = None
80 ctx = self.tao.getPythonContext()
82 self.assertTrue(self.tao.getPythonType() == pytype)
85 tao = self.tao
86 ctx = tao.getPythonContext()
87 x = PETSc.Vec().create(tao.getComm())
92 tao.setObjective(Objective())
93 tao.setGradient(Gradient(), None)
94 tao.setMonitor(ctx.monitor)
95 tao.setFromOptions()
96 tao.setMaximumIterations(3)
98 def _update(tao, it, cnt): argument
102 tao.setUpdate(_update, (cnt_up,))
103 tao.setSolution(x)
107 tao.solve()
108 n = tao.getIterationNumber()
114 tao.solve()
115 n = tao.getIterationNumber()
116 self.assertGreater(tao.getConvergedReason(), 0)
124 tao.solve()
125 n = tao.getIterationNumber()
126 self.assertGreater(tao.getConvergedReason(), 0)
140 tao.cancelMonitor()
143 return self.tao.getPythonContext()
150 def create(self, tao): argument
152 self._ls.useTAORoutine(tao)
156 def destroy(self, tao): argument
159 def setUp(self, tao): argument
162 def solve(self, tao): argument
163 x = tao.getSolution()
164 gradient = tao.getGradient()[0]
166 for it in range(tao.getMaximumIterations()):
167 tao.setIterationNumber(it)
170 tao.computeGradient(x, gradient)
177 tao.monitor(f=f, res=gradient.norm())
182 if tao.checkConverged() > 0:
185 def step(self, tao, x, g, s): argument
188 def preStep(self, tao): argument
191 def postStep(self, tao): argument
197 self.tao = PETSc.TAO()
198 self.tao.createPython(MyGradientDescent(), comm=PETSc.COMM_SELF)
201 self.tao.destroy()
202 self.tao = None
205 tao = self.tao
211 tao.setOptionsPrefix('test_tao_python_optimiser_')
212 tao.setFromOptions()
214 x = PETSc.Vec().createSeq(2, comm=tao.getComm())
217 tao.setSolution(x)
218 tao.setObjective(Objective())
219 tao.setGradient(Gradient(), x.copy())
221 tao.solve()
223 self.assertEqual(tao.getMaximumIterations(), 100)
224 self.assertAlmostEqual(tao.getTolerances()[0], 1e-6)
225 self.assertGreater(tao.getIterationNumber(), 0)
226 self.assertGreater(tao.getConvergedReason(), 0)
229 self.assertGreater(tao.getObjectiveValue(), 0)
230 self.assertAlmostEqual(tao.getObjectiveValue(), 0, places=5)