Main Page | Class Hierarchy | File List

AAP_var.hpp

00001 // $Id: AAP_var.hpp,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 #ifndef AAP_VAR_H
00013 #define AAP_VAR_H
00014 
00015 #include "BCP_var.hpp"
00016 #include "BCP_buffer.hpp"
00017 #include "AAP.hpp"
00018 #include "CoinHelperFunctions.hpp"
00019 
00020 #include <iostream>
00021 #include <vector>
00022 using namespace std;
00023 
00024 /*--------------------------------------------------------------------------*/
00025 /* Class for an AAP algorithmic variable (derived from a BCP_var_algo).
00026    A variable in this context is an point that satisfies the assignment
00027    constraints over J x K.
00028 */
00029 
00030 class AAP_var : public BCP_var_algo{
00031 public:
00032   vector<int> ap; //ijk indices that define the AP point (the J x K assignment)
00033   double cost;    //the cost of the assignment
00034 
00035 public:
00036   AAP_var() : 
00037     BCP_var_algo(BCP_BinaryVar, 0.0, 0.0, 1.0), ap(0), cost(0.0) {}
00038   
00039   AAP_var(const vector<int> & ap_, const double cost_) :
00040     BCP_var_algo(BCP_BinaryVar, cost_, 0.0, 1.0), ap(ap_), cost(cost_) {} 
00041 
00042   AAP_var(const AAP_var & x) :
00043     BCP_var_algo(BCP_BinaryVar, x.cost, 0.0, 1.0), ap(x.ap), cost(x.cost) {} 
00044 
00045   AAP_var(BCP_buffer & buf)
00046     : BCP_var_algo(BCP_BinaryVar, 0.0, 0.0, 1.0), ap(0), cost(0.0) {
00047     //Constructor given a buffer stream - unpacks the buffer stream 
00048     //into this's data members
00049     unpack(buf);
00050     set_obj(cost); //a method of BCP_var_algo
00051   }
00052 
00053   ~AAP_var() {};
00054 
00055 public:
00056   void pack(BCP_buffer & buf) const {
00057     //Pack the variable
00058     buf.pack(ap).pack(cost);
00059   }
00060 
00061   void unpack(BCP_buffer & buf){
00062     //Unpack the variable
00063     buf.unpack(ap).unpack(cost);
00064   } 
00065 
00066   void print(const int dimension, ostream * os = &cout) const {
00067     //Print the variable (AP point) for debugging
00068     (*os) << " AP Cost: " << cost << endl;
00069     for(unsigned int p = 0; p < ap.size(); p++){
00070       (*os) << " index : " << ap[p] << " : ";
00071       ijk_print(ap[p], dimension, os);
00072       (*os) << endl;
00073     }
00074   }
00075 
00076 };
00077 
00078 #endif

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