ANIMA  4.0
animaNNLSOptimizerTest.cxx
Go to the documentation of this file.
1 #include <animaNNLSOptimizer.h>
2 #include <itkTimeProbe.h>
3 #include <iostream>
4 #include <fstream>
5 
6 int main()
7 {
8  typedef anima::NNLSOptimizer OptimizerType;
9 
10  itk::TimeProbe tmpTime;
11  tmpTime.Start();
12 
13  OptimizerType::Pointer optTest = OptimizerType::New();
14 
15  unsigned int dimX = 72;
16  unsigned int dimY = 2;
17  OptimizerType::MatrixType testData (dimX,dimY);
18  std::ifstream dataMat("/Users/ocommowi/Documents/Tmp2/dataMatrix.txt");
19 
20  for (unsigned int i = 0;i < dimX;++i)
21  {
22  for (unsigned int j = 0;j < dimY;++j)
23  dataMat >> testData(i,j);
24  }
25 
26  std::cout << "Test data " << testData << std::endl;
27 
28  OptimizerType::ParametersType testPoints(dimX);
29  std::ifstream bVector("/Users/ocommowi/Documents/Tmp2/bVector.txt");
30 
31  for (unsigned int i = 0;i < dimX;++i)
32  bVector >> testPoints[i];
33 
34  std::cout << "Test points " << testPoints << std::endl;
35 
36  optTest->SetDataMatrix(testData);
37  optTest->SetPoints(testPoints);
38  optTest->SetSquaredProblem(false);
39 
40  optTest->StartOptimization();
41 
42  tmpTime.Stop();
43 
44  std::cout << "Computation time: " << tmpTime.GetTotal() << std::endl;
45  std::cout << optTest->GetCurrentPosition() << std::endl;
46 
47  return EXIT_SUCCESS;
48 }
int main()
Non negative least squares optimizer. Implements Lawson et al method, of squared problem is activated...