freConjugateGradientOptimizerController.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freConjugateGradientOptimizerController.cxx,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 
00023 #include "freConjugateGradientOptimizerController.h"
00024 #include "freExceptions.h"
00025 #include "freTransformSetupAdaptor.h"
00026 
00027 namespace FREE
00028 {
00029 
00033 
00034 
00035 ConjugateGradientOptimizerController::
00036 ConjugateGradientOptimizerController()
00037 {
00038   //Profile settings
00039   this->UpdateControllerID(ControllerID::ConjugateGradientOptimizerController);
00040   this->m_Description = "Optimizes by a conjugate gradient optimizer approach.";
00041         
00042 
00043 };
00044 
00045 ConjugateGradientOptimizerController::
00046 ~ConjugateGradientOptimizerController()
00047 {
00048 };
00049 
00050 void 
00051 ConjugateGradientOptimizerController::
00052 ActualizeMainComponent(ComponentType* pMainComponent,
00053                        SessionComponentCache* pComponentCache, SessionInfo* pSessionInfo,
00054                                                                                          const unsigned int& iActLevel) const
00055 {
00056   ComponentSetup* pTransformSetup = pComponentCache->Setup()->GetComponentByIDPath("../"+ComponentID(cComp_MainTransform));
00057   if (!pTransformSetup) throwCtrlExceptionMacro("","Error; no main transform found to actualize the optimizer.");
00058   TransformSetupAdaptor adaptor(pTransformSetup);
00059 
00060   pMainComponent->SetScales(adaptor.GetScales(iActLevel));
00061 
00062   Parameter::Pointer smpDirection = pComponentCache->GetParentCache()->Controller()->GetParameter(pComponentCache->GetParentCache(),OptimizerOwnerControllerInterface::cParam_MinimizeToOptimize);
00063   if (smpDirection.IsNull()) throwCtrlExceptionMacro("","Cannot retrieve optimization direction via optimizer owner. Parameter \"MinimizeToOptimize\" is unknown. Please ensure valid session and setup");
00064   bool bMinimize;
00065   smpDirection->GetParameterValue(bMinimize);
00066   pMainComponent->SetMaximize( !bMinimize);
00067 };
00068 
00069 void
00070 ConjugateGradientOptimizerController::
00071 SetStatisticEntryMainComponent(StatisticEntry& rStatisticEntry,
00072                                              ComponentType* pMainComponent,
00073                                              SessionComponentCache* pMainComponentCache,
00074                                              SessionInfo* pSessionInfo,
00075                                              StatisticDictionary& rDictionary) const
00076 {
00077   ParameterArrayType parameters = pMainComponent->GetCachedCurrentPosition();
00078   std::string sName = "Position #";
00079   std::string sIDPath = pMainComponentCache->GetIDPath();
00080   std::string sCommment = "Optimizer position. Meaning depends on chosen transformation";
00081   StatisticValueDefinition* pEntry = rDictionary.GetValueDefinitionByName(sIDPath,sName+"0");
00082     
00083   if (!pEntry) //Entry is not recorded yet, so do so.
00084   {
00085     pEntry = rDictionary.AddValueDefinition(sIDPath,sName+"0", sCommment);
00086     for (unsigned int i = 1; i<parameters.Size(); i++)
00087     {
00088       rDictionary.AddValueDefinition(sIDPath,sName+Convert::ToStr(i),sCommment);
00089     }
00090                 rDictionary.AddValueDefinition(sIDPath,"OptimizerValue", "Value of the optimizer");
00091   }
00092   
00093   for (unsigned int i = 0; i<parameters.Size(); i++)
00094   {
00095     rStatisticEntry.AddValue(Convert::ToStr(parameters.GetElement(i)),pEntry->GetRefID()+i);
00096   }
00097 
00098   rStatisticEntry.AddValue(Convert::ToStr(pMainComponent->GetCachedValue()),pEntry->GetRefID()+parameters.Size());
00099 };
00100 
00101 } //end of namespace free

Generated at Sat Oct 13 15:39:20 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000