6 #ifndef CoinWarmStartVector_H 7 #define CoinWarmStartVector_H 11 # pragma warning(disable:4786) 34 values_ =
new T[size_];
40 int size()
const {
return size_; }
42 const T*
values()
const {
return values_; }
75 std::swap(size_, rhs.size_);
76 std::swap(values_, rhs.values_);
150 template <
typename T>
177 std::swap(sze_, rhs.sze_);
178 std::swap(diffNdxs_, rhs.diffNdxs_);
179 std::swap(diffVals_, rhs.diffVals_);
197 const T*
const diffVals) ;
206 delete[] diffNdxs_; diffNdxs_ = NULL;
207 delete[] diffVals_; diffVals_ = NULL;
219 unsigned int* diffNdxs_ ;
228 template <
typename T,
typename U>
246 t_(s0, v0), u_(s1, v1) {}
249 t_(rhs.t_), u_(rhs.u_) {}
282 template <
typename T,
typename U>
297 tdiff_(rhs.tdiff_), udiff_(rhs.udiff_) {}
314 tdiff_.
swap(rhs.tdiff_);
315 udiff_.
swap(rhs.udiff_);
344 {
throw CoinError(
"Old warm start not derived from CoinWarmStartVector.",
345 "generateDiff",
"CoinWarmStartVector") ; }
351 const int oldCnt = oldVector->
size() ;
352 const int newCnt = newVector->
size() ;
354 assert(newCnt >= oldCnt) ;
356 unsigned int *diffNdx =
new unsigned int [newCnt];
357 T* diffVal =
new T[newCnt];
362 const T*oldVal = oldVector->
values() ;
363 const T*newVal = newVector->
values() ;
364 int numberChanged = 0 ;
366 for (i = 0 ; i < oldCnt ; i++) {
367 if (oldVal[i] != newVal[i]) {
368 diffNdx[numberChanged] = i ;
369 diffVal[numberChanged++] = newVal[i] ;
372 for ( ; i < newCnt ; i++) {
373 diffNdx[numberChanged] = i ;
374 diffVal[numberChanged++] = newVal[i] ;
399 template <
typename T>
void 408 throw CoinError(
"Diff not derived from CoinWarmStartVectorDiff.",
409 "applyDiff",
"CoinWarmStartVector") ;
414 const int numberChanges = diff->sze_ ;
415 const unsigned int *diffNdxs = diff->diffNdxs_ ;
416 const T* diffVals = diff->diffVals_ ;
417 T* vals = this->values_ ;
419 for (
int i = 0 ; i < numberChanges ; i++) {
420 unsigned int diffNdx = diffNdxs[i] ;
421 T diffVal = diffVals[i] ;
422 vals[diffNdx] = diffVal ;
441 diffNdxs_ =
new unsigned int[sze_] ;
442 memcpy(diffNdxs_,rhs.diffNdxs_,sze_*
sizeof(
unsigned int)) ;
443 diffVals_ =
new T[sze_] ;
444 memcpy(diffVals_,rhs.diffVals_,sze_*
sizeof(T)) ;
457 template <
typename T>
464 diffNdxs_ =
new unsigned int[sze_] ;
465 memcpy(diffNdxs_,rhs.diffNdxs_,sze_*
sizeof(
unsigned int)) ;
466 diffVals_ =
new T[sze_] ;
467 memcpy(diffVals_,rhs.diffVals_,sze_*
sizeof(T)) ;
473 template <
typename T>
475 (
int sze,
const unsigned int *
const diffNdxs,
const T *
const diffVals)
481 diffNdxs_ =
new unsigned int[sze] ;
482 memcpy(diffNdxs_,diffNdxs,sze*
sizeof(
unsigned int)) ;
483 diffVals_ =
new T[sze] ;
484 memcpy(diffVals_,diffVals,sze*
sizeof(T)) ;
Error Class thrown by an exception.
const T * values() const
return a pointer to the array of vectors
A ‘diff’ between two CoinWarmStartVector objects.
void CoinDisjointCopyN(register const T *from, const int size, register T *to)
This helper function copies an array to another location.
virtual ~CoinWarmStartVector()
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...
virtual CoinWarmStartVectorDiff & operator=(const CoinWarmStartVectorDiff< T > &rhs)
Assignment.
virtual ~CoinWarmStartVectorPair()
void assignVector(int size, T *&vec)
Assign the vector to be the warmstart information.
void clear()
Clear the data.
const U * values1() const
CoinWarmStartVectorPairDiff(const CoinWarmStartVectorPairDiff< T, U > &rhs)
int size() const
return the size of the vector
virtual CoinWarmStart * clone() const
‘Virtual constructor’
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
void assignVector0(int size, T *&vec)
const T * values0() const
CoinWarmStartVector & operator=(const CoinWarmStartVector &rhs)
void gutsOfCopy(const CoinWarmStartVector< T > &rhs)
CoinWarmStartVector(int size, const T *vec)
virtual CoinWarmStartVectorPairDiff & operator=(const CoinWarmStartVectorPairDiff< T, U > &rhs)
virtual ~CoinWarmStartVectorPairDiff()
virtual CoinWarmStartDiff * clone() const
‘Virtual constructor’
CoinWarmStartVectorPairDiff()
CoinWarmStartVectorPair & operator=(const CoinWarmStartVectorPair< T, U > &rhs)
CoinWarmStartVector(const CoinWarmStartVector &rhs)
CoinWarmStartVectorPair(int s0, const T *v0, int s1, const U *v1)
Copyright (C) 2000 – 2003, International Business Machines Corporation and others.
void swap(CoinWarmStartVectorDiff &rhs)
void swap(CoinWarmStartVectorPair< T, U > &rhs)
void assignVector1(int size, U *&vec)
void clear()
Clear the data.
Abstract base class for warm start ‘diff’ objects.
CoinWarmStartVectorPair(const CoinWarmStartVectorPair< T, U > &rhs)
virtual CoinWarmStartDiff * generateDiff(const CoinWarmStart *const oldCWS) const
WarmStart information that is only a vector.
virtual CoinWarmStart * clone() const
‘Virtual constructor’
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
Apply diff to this warm start.
virtual ~CoinWarmStartVectorDiff()
Destructor.
void swap(CoinWarmStartVector &rhs)
CoinWarmStartVectorPair()
virtual CoinWarmStartDiff * clone() const
‘Virtual constructor’
void swap(CoinWarmStartVectorPairDiff< T, U > &rhs)
Abstract base class for warm start information.
CoinWarmStartVectorDiff()
Default constructor.