5 #ifndef CoinWarmStartVector_H
6 #define CoinWarmStartVector_H
10 # pragma warning(disable:4786)
149 template <
typename T>
196 const T*
const diffVals) ;
227 template <
typename T,
typename U>
235 inline int size0()
const {
return t_.size(); }
245 t_(s0, v0),
u_(s1, v1) {}
280 template <
typename T,
typename U>
339 {
throw CoinError(
"Old warm start not derived from CoinWarmStartVector.",
340 "generateDiff",
"CoinWarmStartVector") ; }
346 const int oldCnt = oldVector->
size() ;
347 const int newCnt = newVector->
size() ;
349 assert(newCnt >= oldCnt) ;
351 unsigned int *diffNdx =
new unsigned int [newCnt];
352 T* diffVal =
new T[newCnt];
357 const T*oldVal = oldVector->
values() ;
358 const T*newVal = newVector->
values() ;
359 int numberChanged = 0 ;
361 for (i = 0 ; i < oldCnt ; i++) {
362 if (oldVal[i] != newVal[i]) {
363 diffNdx[numberChanged] = i ;
364 diffVal[numberChanged++] = newVal[i] ;
367 for ( ; i < newCnt ; i++) {
368 diffNdx[numberChanged] = i ;
369 diffVal[numberChanged++] = newVal[i] ;
394 template <
typename T>
void
403 throw CoinError(
"Diff not derived from CoinWarmStartVectorDiff.",
404 "applyDiff",
"CoinWarmStartVector") ;
409 const int numberChanges = diff->
sze_ ;
410 const unsigned int *diffNdxs = diff->
diffNdxs_ ;
412 T* vals = this->values_ ;
414 for (
int i = 0 ; i < numberChanges ; i++) {
415 unsigned int diffNdx = diffNdxs[i] ;
416 T diffVal = diffVals[i] ;
417 vals[diffNdx] = diffVal ;
436 diffNdxs_ =
new unsigned int[sze_] ;
437 memcpy(diffNdxs_,rhs.
diffNdxs_,sze_*
sizeof(
unsigned int)) ;
438 diffVals_ =
new T[sze_] ;
439 memcpy(diffVals_,rhs.
diffVals_,sze_*
sizeof(T)) ;
452 template <
typename T>
468 template <
typename T>
470 (
int sze,
const unsigned int *
const diffNdxs,
const T *
const diffVals)
476 diffNdxs_ =
new unsigned int[sze] ;
477 memcpy(diffNdxs_,diffNdxs,sze*
sizeof(
unsigned int)) ;
478 diffVals_ =
new T[sze] ;
479 memcpy(diffVals_,diffVals,sze*
sizeof(T)) ;
CoinWarmStartVector & operator=(const CoinWarmStartVector &rhs)
void clear()
Clear the data.
T * diffVals_
Array of diff values.
CoinWarmStartVector(const CoinWarmStartVector &rhs)
void gutsOfCopy(const CoinWarmStartVector< T > &rhs)
int size() const
return the size of the vector
virtual ~CoinWarmStartVector()
virtual CoinWarmStartDiff * generateDiff(const CoinWarmStart *const oldCWS) const
void CoinDisjointCopyN(register const T *from, const int size, register T *to)
This helper function copies an array to another location.
const T * values() const
return a pointer to the array of vectors
Abstract base class for warm start `diff' objects.
CoinWarmStartVectorPair(const CoinWarmStartVectorPair< T, U > &rhs)
int sze_
Number of entries (and allocated capacity), in units of T.
const T * values0() const
virtual CoinWarmStart * clone() const
`Virtual constructor'
~CoinWarmStartVectorPairDiff()
const U * values1() const
virtual ~CoinWarmStartVectorDiff()
Destructor.
T * values_
the vector itself
int size_
the size of the vector
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
void swap(CoinWarmStartVector &rhs)
void assignVector0(int size, T *&vec)
virtual CoinWarmStartVectorPairDiff & operator=(const CoinWarmStartVectorPairDiff< T, U > &rhs)
CoinWarmStartVector< U > u_
CoinWarmStartVectorPairDiff(const CoinWarmStartVectorPairDiff< T, U > &rhs)
WarmStart information that is only a vector.
Declaration of the generic simplex (basis-oriented) warm start class. Also contains a basis diff clas...
CoinWarmStartVector(int size, const T *vec)
void swap(CoinWarmStartVectorDiff &rhs)
CoinWarmStartVectorDiff()
Default constructor.
CoinWarmStartVectorPair(int s0, const T *v0, int s1, const U *v1)
virtual CoinWarmStart * clone() const
`Virtual constructor'
void assignVector(int size, T *&vec)
Assign the vector to be the warmstart information.
virtual CoinWarmStartVectorDiff & operator=(const CoinWarmStartVectorDiff< T > &rhs)
Assignment.
void swap(CoinWarmStartVectorPairDiff< T, U > &rhs)
void assignVector1(int size, U *&vec)
virtual CoinWarmStartDiff * clone() const
`Virtual constructor'
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
Apply diff to this warm start.
virtual CoinWarmStartDiff * generateDiff(const CoinWarmStart *const oldCWS) const
Generate a `diff' that can convert the warm start passed as a parameter to the warm start specified b...
virtual CoinWarmStartDiff * clone() const
`Virtual constructor'
virtual ~CoinWarmStartVectorPair()
Abstract base class for warm start information.
CoinWarmStartVectorPairDiff()
Error Class thrown by an exception.
CoinWarmStartVectorPair()
CoinWarmStartVectorDiff< U > udiff_
CoinWarmStartVector< T > t_
A `diff' between two CoinWarmStartVector objects.
CoinWarmStartVectorDiff< T > tdiff_
CoinWarmStartVectorPair & operator=(const CoinWarmStartVectorPair< T, U > &rhs)
unsigned int * diffNdxs_
Array of diff indices.
void clear()
Clear the data.
void swap(CoinWarmStartVectorPair< T, U > &rhs)