#include "StdAfx.h" #include "cOptManager.h" #include "cProbModel.h" #include "cUpdateAngle.h" #include "cEigenValsOptimise.h" cOptManager::cOptManager( cOccuranceData const& Data, cProbs& BackgroundProbs, tOptParams Params ) : _params( Params ), _data( Data ), _initModel( BackgroundProbs ) { } cOptManager::cOptManager( cOccuranceData const& Data, cProbModel const& Model, tOptParams Params ) : _params( Params ), _data( Data ), _initModel( Model ) { } cOptManager::~cOptManager() { } void cOptManager::IterationAngleParallel(cDataProbModel& DM) { cUpdateAngle Update(DM); cAngles NewA = Update.ComputeNewPhi(); cout << "IterationAngleParallel" << endl; cout << " Old = "; DM.ProbModel().Angles().print(); // reset all frozen angles... for( size_t k = 0; k < First_Angle(); k++ ) NewA.set( k, DM.ProbModel().Angles().get( k ) ); DM.ProbModel().setAngles( NewA ); cout << " New = "; NewA.print(); cout << " New Angle LL = " << DM.LL() << endl; } double EmpiricalDerivAngle(cDataProbModel& DM, int k) { double eps = 0.00000001; double origPhi=DM.ProbModel().Angles().get(k); DM.ProbModel().setAngle( k, origPhi-eps ); double llMinus = DM.LL(); DM.ProbModel().setAngle( k, origPhi+eps ); double llPlus = DM.LL(); DM.ProbModel().setAngle( k, origPhi ); return (llPlus-llMinus)/(2*eps); } void cOptManager::IterationAngleSequential(cDataProbModel& DM) { cout << "IterationAngleSequential" << endl; // right now determinist round robin algorithm for( size_t k = First_Angle(); k < DM.ProbModel().Angles().NDims(); k++ ) { double OldLL=DM.LL(); double NewLL=OldLL; int IterNum=0; // do { // IterNum++; OldLL=NewLL; cUpdateAngle Update(DM); cAngles const& A = DM.ProbModel().Angles(); double phi = A.get(k); cout << "Emp Dphi "<