def print_minim_info(self, x0, found_minimum): print "x0: " print x0 print "cost x0: " print self.reg.cost_fun(x0) print "found_minimum: " print found_minimum print "cost found_minimum: " print KernelCorrelation.cost_fun(self.reg, found_minimum)
def test_minimum_better_than_random(self): """Test if for a random transform, the cost that is found after a few iterations is lower than the initial cost""" numpy.random.seed(0) scalefactor = 2 model = self.normed_rand(self.num_vectors, self.mdim*scalefactor) scene = self.normed_rand(self.num_vectors, self.mdim*scalefactor) self.reg = RigidKernelCorrelation(model, scene) x0=numpy.random.rand(self.reg.transform_dof) found_minimum = self.reg.find_minimum(x0=x0) self.print_minim_info(x0, found_minimum) self.assertTrue(KernelCorrelation.cost_fun(self.reg, found_minimum) < self.reg.cost_fun(x0))