Data-Mining for Lawrence Livermore Labs Group 5 Laura Palmer, Scott Paniccia, Donna Parker, Jordan...
-
Upload
pierce-morris -
Category
Documents
-
view
212 -
download
0
Transcript of Data-Mining for Lawrence Livermore Labs Group 5 Laura Palmer, Scott Paniccia, Donna Parker, Jordan...
Data-Mining for Lawrence Livermore Labs
Group 5Laura Palmer, Scott Paniccia, Donna Parker, Jordan
Rayburn, and Aurelio Rico
The Task:
Calculate average power consumption and time of each operation performed by
an automatic milling machine.
Phase 0: Optional Output File NamingFunction Output_Name:● Prompt user for output file
nameo a variety of filetypes can be
chosen● Continue to program
void Output_Name (){
cout << "What would you like the output file to be named?" << endl;cout << "Be sure to include the file extension type at the end of the file name." << endl;cout << " Text document, '.txt'. Spreadsheet, '.xls'. Data file, '.dat'." << endl << endl;cout << "Example: 'example.txt' would produce a text file named 'example'." << endl << endl;cin >> output_file;cout << endl;
cout << "The analysis of 'OperationActive' for electric_61-66 is as follows:" << endl;}
Phase 1: Extract Data into Data File
Sequence:
Open and Read file
Search for String
Extract lines containing power
values
Output to Datafile
Phase 1 AlgorithmFunction Data_Grab:● Opens source file● Using a for loop, cycle through
line by lineo assign each line to workspace1o mark specific lines that contain
timestamp information
● Search for the phrase ‘timestamp=’
● Combine into one string● Output string to ‘Timestamp.txt’
void Data_Grab(){
ifstream inData;ofstream outData;
string workspace1;string workspace2;
int ind;
int i;int j;
ind=0; i=0; j=0;
inData.open("OperationActive.xml");outData.open("Timestamp.txt");
for (i==0; i<88; i++){getline(inData,workspace1);if (i==71 || i==74 || i==77 || i==80 || i==83 || i==86 ){ind=workspace1.find("timestamp=");workspace1=workspace1.substr(ind+11,workspace1.length(workspace2=workspace1.substr(0,23);outData << endl << workspace2 << ":";}
if (i==72 || i==75 || i==78 || i==81 || i==84 || i==87){outData << '\n' << workspace1;}}
}
Phase 2: Ready Data
Sequence:
Read Input String
Store in temporary
Phase 2 Algorithm
Main function:● Open file ‘Timestamp.txt’● Initiate while loop to read
through new data in ‘Timestamp’
● Outputs data in pairs, first the time, then the power
● Use str_temp to find average value of str_rawdata
inData.open("Timestamp.txt");outData.open(output_file);
getline(inData,trash);
while (inData.good()){
getline(inData,str_timestamp);getline(inData,str_rawdata);str_temp=str_rawdata;
Phase 3: Display and Write to Output
Sequence:
Read from Integer
Find Elapsed Time
Output Averages and Elapsed Time
to Output File
Phase 3 Algorithm
Main function continued:● Use for loop to calculate
average of each of 25 data lineso Find empty spaceo Add data value into total
‘k’o Shorten data line to next
data input● Divide total by 25 for average
power
for(j==0; j<25; j++){
index=str_temp.find(" ");workspace1=str_temp.substr(0,index);
k = k + stoi(workspace1);str_temp=str_temp.substr(index+1,str_temp.length());}avg=(k/25);
Phase 3 Algorithm
Main function continued:● Output the average
timestamp to screen● Output power average to
screen● Clear loop counters
● Convey thanks and cheer, programs have feelings too.
cout << str_timestamp << " Average Output: " << avg << endl;
cout << str_rawdata << endl << endl;
outData << str_timestamp << " Average Output: " << avg << '\n' << str_rawdata
<< '\n' << '\n';
j=0;k=0;
}cout << "Thank you for making a simple program happy."
<< endl << "Have a wonderful day!" << endl;
cout << “ The End “ << endl;