Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

CoinWarmStartDual Class Reference

#include <CoinWarmStartDual.hpp>

Inheritance diagram for CoinWarmStartDual:

CoinWarmStart List of all members.

Public Member Functions

int size () const
 return the size of the dual vector

const double * dual () const
 return a pointer to the array of duals

void assignDual (int size, double *&dual)
 CoinWarmStartDual (int size, const double *dual)
 CoinWarmStartDual (const CoinWarmStartDual &rhs)
CoinWarmStartDualoperator= (const CoinWarmStartDual &rhs)
virtual CoinWarmStartclone () const
Dual warm start `diff' methods
virtual CoinWarmStartDiffgenerateDiff (const CoinWarmStart *const oldCWS) const
 Generate a `diff' that can convert the warm start passed as a parameter to the warm start specified by this.

virtual void applyDiff (const CoinWarmStartDiff *const cwsdDiff)
 Apply diff to this warm start.


Protected Member Functions

void gutsOfDestructor ()
void gutsOfCopy (const CoinWarmStartDual &rhs)

Private Attributes

Private data members
int dualSize_
 the size of the dual vector

double * dualVector_
 the dual vector itself


Detailed Description

WarmStart information that is only a dual vector

Definition at line 15 of file CoinWarmStartDual.hpp.


Member Function Documentation

void CoinWarmStartDual::applyDiff const CoinWarmStartDiff *const  cwsdDiff  )  [virtual]
 

Apply diff to this warm start.

Update this warm start by applying diff. It's assumed that the allocated capacity of the warm start is sufficiently large.

Definition at line 82 of file CoinWarmStartDual.cpp.

References CoinWarmStartDualDiff::diffNdxs_, CoinWarmStartDualDiff::diffVals_, dualVector_, and CoinWarmStartDualDiff::sze_.

00083 {
00084 /*
00085   Make sure we have a CoinWarmStartDualDiff
00086 */
00087   const CoinWarmStartDualDiff *diff =
00088     dynamic_cast<const CoinWarmStartDualDiff *>(cwsdDiff) ;
00089   if (!diff)
00090   { throw CoinError("Diff not derived from CoinWarmStartDualDiff.",
00091                     "applyDiff","CoinWarmStartDual") ; }
00092 /*
00093   Application is by straighforward replacement of words in the dual vector.
00094 */
00095   const int numberChanges = diff->sze_ ;
00096   const unsigned int *diffNdxs = diff->diffNdxs_ ;
00097   const double *diffVals = diff->diffVals_ ;
00098   double *vals = this->dualVector_ ;
00099 
00100   for (int i = 0 ; i < numberChanges ; i++)
00101   { unsigned int diffNdx = diffNdxs[i] ;
00102     double diffVal = diffVals[i] ;
00103     vals[diffNdx] = diffVal ; }
00104 
00105   return ; }

void CoinWarmStartDual::assignDual int  size,
double *&  dual
[inline]
 

Assign the dual vector to be the warmstart information. In this method the object assumes ownership of the pointer and upon return "dual" will be a NULL pointer. If copying is desirable use the constructor.

Definition at line 35 of file CoinWarmStartDual.hpp.

References dualSize_, and dualVector_.

00035                                              {
00036       dualSize_ = size;
00037       delete[] dualVector_;
00038       dualVector_ = dual;
00039       dual = NULL;
00040    }

virtual CoinWarmStart* CoinWarmStartDual::clone  )  const [inline, virtual]
 

`Virtual constructor'

Implements CoinWarmStart.

Definition at line 62 of file CoinWarmStartDual.hpp.

00062                                         {
00063       return new CoinWarmStartDual(*this);
00064    }

CoinWarmStartDiff * CoinWarmStartDual::generateDiff const CoinWarmStart *const  oldCWS  )  const [virtual]
 

Generate a `diff' that can convert the warm start passed as a parameter to the warm start specified by this.

The capabilities are limited: the basis passed as a parameter can be no larger than the basis pointed to by this.

Definition at line 24 of file CoinWarmStartDual.cpp.

References dual(), and size().

00025 { 
00026 /*
00027   Make sure the parameter is CoinWarmStartDual or derived class.
00028 */
00029   const CoinWarmStartDual *oldDual =
00030       dynamic_cast<const CoinWarmStartDual *>(oldCWS) ;
00031   if (!oldDual)
00032   { throw CoinError("Old warm start not derived from CoinWarmStartDual.",
00033                     "generateDiff","CoinWarmStartDual") ; }
00034   const CoinWarmStartDual *newDual = this ;
00035 /*
00036   Make sure newDual is equal or bigger than oldDual. Calculate the worst
00037   case number of diffs and allocate vectors to hold them.
00038 */
00039   const int oldCnt = oldDual->size() ;
00040   const int newCnt = newDual->size() ;
00041 
00042   assert(newCnt >= oldCnt) ;
00043 
00044   unsigned int *diffNdx = new unsigned int [newCnt]; 
00045   double *diffVal = new double [newCnt]; 
00046 /*
00047   Scan the dual vectors.  For the portion of the vectors which overlap,
00048   create diffs. Then add any additional entries from newDual.
00049 */
00050   const double *oldVal = oldDual->dual() ;
00051   const double *newVal = newDual->dual() ;
00052   int numberChanged = 0 ;
00053   int i ;
00054   for (i = 0 ; i < oldCnt ; i++)
00055   { if (oldVal[i] != newVal[i])
00056     { diffNdx[numberChanged] = i ;
00057       diffVal[numberChanged++] = newVal[i] ; } }
00058   for ( ; i < newCnt ; i++)
00059   { diffNdx[numberChanged] = i ;
00060     diffVal[numberChanged++] = newVal[i] ; }
00061 /*
00062   Create the object of our desire.
00063 */
00064   CoinWarmStartDualDiff *diff =
00065     new CoinWarmStartDualDiff(numberChanged,diffNdx,diffVal) ;
00066 /*
00067   Clean up and return.
00068 */
00069   delete[] diffNdx ;
00070   delete[] diffVal ;
00071 
00072   return (dynamic_cast<CoinWarmStartDiff *>(diff)) ; }


The documentation for this class was generated from the following files:
Generated on Wed Dec 3 14:34:30 2003 for Coin by doxygen 1.3.5