Ejemplo n.º 1
0
void
BCP_lp_relax::pack(BCP_buffer& buf) const {
   const int major = getMajorDim();
   const int minor = getMinorDim();
   buf.pack(colOrdered_)
      .pack(extraGap_)
      .pack(extraMajor_)
      .pack(major)
      .pack(minor)
      .pack(size_)
      .pack(maxMajorDim_)
      .pack(maxSize_);

   const int * length = getVectorLengths();
   const int * start = getVectorStarts();
   const int * ind = getIndices();
   const double * elem = getElements();
   if (major > 0) {
     buf.pack(length, major);
     buf.pack(start, major+1);
     for (int i = 0; i < major; ++i)
       buf.pack(ind + start[i], length[i]);
     for (int i = 0; i < major; ++i)
       buf.pack(elem + start[i], length[i]);
   }

   buf.pack(_Objective).pack(_ColLowerBound).pack(_ColUpperBound)
      .pack(_RowLowerBound).pack(_RowUpperBound);
}
Ejemplo n.º 2
0
   /** Equivalence.
       Two matrices are equivalent if they are both by rows or both by columns,
       they have the same dimensions, and each vector is equivalent. 
       In this method the FloatEqual function operator can be specified. 
   */
   template <class FloatEqual> bool 
   isEquivalent(const CoinPackedMatrix& rhs, const FloatEqual& eq) const
   {
      // Both must be column order or both row ordered and must be of same size
      if ((isColOrdered() ^ rhs.isColOrdered()) ||
	  (getNumCols() != rhs.getNumCols()) ||
	  (getNumRows() != rhs.getNumRows()) ||
	  (getNumElements() != rhs.getNumElements()))
	 return false;
     
      for (int i=getMajorDim()-1; i >= 0; --i) {
        CoinShallowPackedVector pv = getVector(i);
        CoinShallowPackedVector rhsPv = rhs.getVector(i);
        if ( !pv.isEquivalent(rhsPv,eq) )
          return false;
      }
      return true;
   }