Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

SloppyDataMinimizableDirector.cpp

Go to the documentation of this file.
00001 #include "SloppyDataMinimizableDirector.h"
00002 
00003 CSloppyDataMinimizableDirector::CSloppyDataMinimizableDirector(void)
00004 {
00005 }
00006 
00007 CSloppyDataMinimizableDirector::~CSloppyDataMinimizableDirector(void)
00008 {
00009         int i;
00010         for(i = 0; i < m_vpRelationList.size(); i++)
00011         {
00012                 delete m_vpRelationList[i];
00013         }
00014 }
00015 
00016 double CSloppyDataMinimizableDirector::ObjectiveFunction(double *parameters)
00017 {
00018         double totalC = 0.0;
00019         return totalC;
00020 }
00021 
00022 void CSloppyDataMinimizableDirector::ParseDataFile(std::string fileName)
00023 {
00024         int i = 0;
00025         bool isEqual;
00026         // used for reading in the data
00027         char lineBuf[1000];
00028         char rname1[100],rname2[100],cname1[100],cname2[100];
00029         char type;
00030         double time1,time2;
00031 //      ifstream dataFile;
00032 
00033         int r1,r2,q1,q2;
00034 
00035         // open the file for reading
00036         ifstream dataFile(fileName.c_str());
00037 //      dataFile.open(fileName.c_str());
00038         assert(dataFile);
00039         
00040         // put the data line by line into the linebuffer and then parse it
00041         while(dataFile.getline(lineBuf,sizeof(lineBuf)))
00042         {
00043                 if(lineBuf[0] == '%') {continue;}
00044                 std::istringstream dataStream(lineBuf);
00045                 dataStream >> rname1 >> cname1 >> time1 >> rname2 >> cname2 >> time2 >> type;
00046 
00047                 // find where network one goes
00048                 std::string n1(rname1);
00049                 for(i = 0; i < m_vpRunnables.size(); i++)
00050                 {
00051                         isEqual = (n1 == m_vpRunnables[i]->GetRunnableName());
00052                         if(isEqual) {break;}
00053                 }
00054                 r1 = i;
00055                 // find where the first quantity is present in that runnable
00056                 std::string c1(cname1);
00057                 for(i = 0; i < m_vpRunnables[r1]->GetReactionNetwork()->GetNumberOfChemicals(); i++)
00058                 {
00059                         isEqual = (c1 == m_vpRunnables[i]->GetReactionNetwork()->GetChemical(i)->GetName());
00060                         if(isEqual) {break;}
00061                 }
00062                 q1 = i;
00063 
00064                 // now repeat for the second half of the line
00065 
00066                 // find where network two goes
00067                 std::string n2(rname2);
00068                 for(i = 0; i < m_vpRunnables.size(); i++)
00069                 {
00070                         isEqual = (n2 == m_vpRunnables[i]->GetRunnableName());
00071                         if(isEqual) {break;}
00072                 }
00073                 r2 = i;
00074                 // find where the second quantity is present in that runnable
00075                 std::string c2(cname2);
00076                 for(i = 0; i < m_vpRunnables[r2]->GetReactionNetwork()->GetNumberOfChemicals(); i++)
00077                 {
00078                         isEqual = (c2 == m_vpRunnables[i]->GetReactionNetwork()->GetChemical(i)->GetName());
00079                         if(isEqual) {break;}
00080                 }
00081                 q2 = i;
00082                 
00083                 // create a binary relation and put it in the right place
00084                 m_vpRelationList.push_back(new CBinaryNetworkDataRelation(r1,q1,(int)time1,r2,q2,(int)time2,type));
00085         }
00086 
00087         
00088         return;
00089 }

Generated on Mon Nov 3 09:38:15 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002