Main Page | Class Hierarchy | File List

AAP.cpp

00001 // $Id: AAP.cpp,v 1.2 2003/12/03 01:52:30 magh Exp $
00002 
00003 /*-------------------------------------------------------------------------
00004  Author: Matthew Galati (magh@lehigh.edu)
00005 
00006  (c) Copyright 2003 Lehigh University. All Rights Reserved.
00007 
00008  This software is licensed under the Common Public License. Please see 
00009  accompanying file for terms.    
00010 ---------------------------------------------------------------------------*/
00011 
00012 #include "AAP.hpp"
00013 
00014 #include <fstream>
00015 using namespace std;
00016 
00017 /*--------------------------------------------------------------------------*/
00018 AAP::AAP(const string & datafile) : dimension(0), assigncost(0) {
00019 
00020   //Read in the AAP instance from file
00021   ifstream is(datafile.c_str());
00022   if(!is){
00023     string err("AAP_tm : I/O Error - cannot open ");
00024     err += datafile;
00025     throw BCP_fatal_error(err.c_str());
00026   }
00027 
00028 
00029   string buffer;
00030   std::getline(is, buffer, '='); 
00031   is >> dimension;
00032   std::getline(is, buffer);
00033   std::getline(is, buffer);
00034     
00035   int n_cols = dimension * dimension * dimension;
00036   assigncost = new double[n_cols];
00037   for(int c = 0; c < n_cols; c++)
00038     is >> assigncost[c];
00039   
00040   is.close();
00041 }
00042 
00043 /*--------------------------------------------------------------------------*/
00044 AAP::AAP(BCP_buffer & buf){
00045   unpack(buf);
00046 }
00047 
00048 /*--------------------------------------------------------------------------*/
00049 void AAP::pack(BCP_buffer & buf) const{
00050   //Pack the AAP instance
00051   buf.pack(dimension);             //pack an int
00052   buf.pack(assigncost, n_cols());  //pack an array of doubles of length n_cols
00053 }
00054 
00055 /*--------------------------------------------------------------------------*/
00056 void AAP::unpack(BCP_buffer & buf){
00057   //Unpack the AAP instance
00058   buf.unpack(dimension);
00059   int num_cols = n_cols();  
00060   buf.unpack(assigncost, num_cols);
00061 }

Generated on Wed Dec 3 01:30:50 2003 for AAP_BP by doxygen 1.3.5