6#ifndef CoinWarmStartVector_H
7#define CoinWarmStartVector_H
11#pragma warning(disable : 4786)
24template <
typename T >
31 inline void gutsOfCopy(
const CoinWarmStartVector< T > &rhs)
163template <
typename T >
216 const T *
const diffVals);
249template <
typename T,
typename U >
252 CoinWarmStartVector< T >
t_;
256 inline int size0()
const {
return t_.size(); }
257 inline int size1()
const {
return u_.size(); }
312template <
typename T,
typename U >
371template <
typename T >
378 const CoinWarmStartVector< T > *oldVector =
dynamic_cast< const CoinWarmStartVector< T > *
>(oldCWS);
380 throw CoinError(
"Old warm start not derived from CoinWarmStartVector.",
381 "generateDiff",
"CoinWarmStartVector");
383 const CoinWarmStartVector< T > *newVector =
this;
388 const int oldCnt = oldVector->size();
389 const int newCnt = newVector->size();
391 assert(newCnt >= oldCnt);
393 unsigned int *diffNdx =
new unsigned int[newCnt];
394 T *diffVal =
new T[newCnt];
399 const T *oldVal = oldVector->values();
400 const T *newVal = newVector->values();
401 int numberChanged = 0;
403 for (i = 0; i < oldCnt; i++) {
404 if (oldVal[i] != newVal[i]) {
405 diffNdx[numberChanged] = i;
406 diffVal[numberChanged++] = newVal[i];
409 for (; i < newCnt; i++) {
410 diffNdx[numberChanged] = i;
411 diffVal[numberChanged++] = newVal[i];
416 CoinWarmStartVectorDiff< T > *diff =
new CoinWarmStartVectorDiff< T >(numberChanged, diffNdx, diffVal);
434template <
typename T >
440 const CoinWarmStartVectorDiff< T > *diff =
dynamic_cast< const CoinWarmStartVectorDiff< T > *
>(cwsdDiff);
442 throw CoinError(
"Diff not derived from CoinWarmStartVectorDiff.",
443 "applyDiff",
"CoinWarmStartVector");
448 const int numberChanges = diff->sze_;
449 const unsigned int *diffNdxs = diff->diffNdxs_;
450 const T *diffVals = diff->diffVals_;
453 for (
int i = 0; i < numberChanges; i++) {
454 unsigned int diffNdx = diffNdxs[i];
455 T diffVal = diffVals[i];
456 vals[diffNdx] = diffVal;
464template <
typename T >
465CoinWarmStartVectorDiff< T > &
476 memcpy(
diffNdxs_, rhs.diffNdxs_,
sze_ *
sizeof(
unsigned int));
490template <
typename T >
498 memcpy(
diffNdxs_, rhs.diffNdxs_,
sze_ *
sizeof(
unsigned int));
506template <
typename T >
514 memcpy(
diffNdxs_, diffNdxs, sze *
sizeof(
unsigned int));
516 memcpy(
diffVals_, diffVals, sze *
sizeof(T));
void CoinDisjointCopyN(const T *from, const CoinBigIndex size, T *to)
This helper function copies an array to another location.
\legal Copyright (C) 2000 – 2003, International Business Machines Corporation and others.
Error Class thrown by an exception.
Abstract base class for warm start ‘diff’ objects.
A ‘diff’ between two CoinWarmStartVector objects.
CoinWarmStartVectorDiff(const CoinWarmStartVectorDiff< T > &rhs)
Copy constructor.
virtual CoinWarmStartVectorDiff & operator=(const CoinWarmStartVectorDiff< T > &rhs)
Assignment.
void clear()
Clear the data.
int sze_
Number of entries (and allocated capacity), in units of T.
T * diffVals_
Array of diff values.
CoinWarmStartVectorDiff()
Default constructor.
virtual ~CoinWarmStartVectorDiff()
Destructor.
unsigned int * diffNdxs_
Array of diff indices.
CoinWarmStartVectorDiff(int sze, const unsigned int *const diffNdxs, const T *const diffVals)
Standard constructor.
void swap(CoinWarmStartVectorDiff &rhs)
virtual CoinWarmStartDiff * clone() const
‘Virtual constructor’
virtual ~CoinWarmStartVectorPairDiff()
virtual CoinWarmStartVectorPairDiff & operator=(const CoinWarmStartVectorPairDiff< T, U > &rhs)
virtual CoinWarmStartDiff * clone() const
‘Virtual constructor’
CoinWarmStartVectorPairDiff(const CoinWarmStartVectorPairDiff< T, U > &rhs)
CoinWarmStartVectorDiff< T > tdiff_
CoinWarmStartVectorDiff< U > udiff_
CoinWarmStartVectorPairDiff()
void swap(CoinWarmStartVectorPairDiff< T, U > &rhs)
void swap(CoinWarmStartVectorPair< T, U > &rhs)
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
void assignVector1(int size, U *&vec)
CoinWarmStartVector< T > t_
virtual CoinWarmStart * clone() const
‘Virtual constructor’
CoinWarmStartVectorPair & operator=(const CoinWarmStartVectorPair< T, U > &rhs)
const T * values0() const
CoinWarmStartVectorPair()
const U * values1() const
CoinWarmStartVector< U > u_
CoinWarmStartVectorPair(const CoinWarmStartVectorPair< T, U > &rhs)
virtual ~CoinWarmStartVectorPair()
CoinWarmStartVectorPair(int s0, const T *v0, int s1, const U *v1)
void assignVector0(int size, T *&vec)
virtual CoinWarmStartDiff * generateDiff(const CoinWarmStart *const oldCWS) const
void assignVector(int size, T *&vec)
Assign the vector to be the warmstart information.
CoinWarmStartVector(int size, const T *vec)
void swap(CoinWarmStartVector &rhs)
virtual ~CoinWarmStartVector()
CoinWarmStartVector & operator=(const CoinWarmStartVector &rhs)
const T * values() const
return a pointer to the array of vectors
void clear()
Clear the data.
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
Apply diff to this warm start.
int size() const
return the size of the vector
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...
int size_
the size of the vector
virtual CoinWarmStart * clone() const
‘Virtual constructor’
CoinWarmStartVector(const CoinWarmStartVector &rhs)
T * values_
the vector itself
void gutsOfCopy(const CoinWarmStartVector< T > &rhs)
Abstract base class for warm start information.