/home/coin/SVN-release/OS-2.4.2/Bcp/examples/MCF-3/Member/MCF3_var.cpp

Go to the documentation of this file.
00001 #include "MCF3_var.hpp"
00002 
00003 //#############################################################################
00004 
00005 void MCF3_var::pack(BCP_buffer& buf) const
00006 {
00007   buf.pack(commodity);
00008   int numarcs = flow.getNumElements();
00009   buf.pack(flow.getIndices(), numarcs);
00010   buf.pack(flow.getElements(), numarcs);
00011   buf.pack(weight);
00012 }
00013 
00014 /*---------------------------------------------------------------------------*/
00015 
00016 MCF3_var::MCF3_var(BCP_buffer& buf) :
00017   // we don't know the onj coeff (weight) yet, so temporarily set it to 0
00018   BCP_var_algo(BCP_ContinuousVar, 0, 0, 2)
00019 {
00020   buf.unpack(commodity);
00021   int numarcs;
00022   int* ind;
00023   double* val;
00024   buf.unpack(ind, numarcs);
00025   buf.unpack(val, numarcs);
00026   flow.assignVector(numarcs, ind, val, false /*don't test for duplicates*/);
00027   buf.unpack(weight);
00028   set_obj(weight);
00029 }
00030 
00031 /*===========================================================================*/
00032 
00033 void MCF3_pack_var(const BCP_var_algo* var, BCP_buffer& buf)
00034 {
00035   const MCF3_var* v = dynamic_cast<const MCF3_var*>(var);
00036   if (v) {
00037     v->pack(buf);
00038   }
00039 }
00040 
00041 /*---------------------------------------------------------------------------*/
00042 
00043 BCP_var_algo* MCF3_unpack_var(BCP_buffer& buf)
00044 {
00045   return new MCF3_var(buf);
00046 }

Generated on Wed Nov 30 03:03:47 2011 by  doxygen 1.4.7