本文整理汇总了C++中CoinError函数的典型用法代码示例。如果您正苦于以下问题:C++ CoinError函数的具体用法?C++ CoinError怎么用?C++ CoinError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CoinError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNumElements
std::set<int> *
CoinPackedVectorBase::indexSet(const char* methodName,
const char * className) const
{
testedDuplicateIndex_ = true;
if ( indexSetPtr_ == NULL ) {
// create a set of the indices
indexSetPtr_ = new std::set<int>;
const int s = getNumElements();
const int * inds = getIndices();
for (int j=0; j < s; ++j) {
if (!indexSetPtr_->insert(inds[j]).second) {
testedDuplicateIndex_ = false;
delete indexSetPtr_;
indexSetPtr_ = NULL;
if (methodName != NULL) {
throw CoinError("Duplicate index found", methodName, className);
} else {
throw CoinError("Duplicate index found",
"indexSet", "CoinPackedVectorBase");
}
}
}
}
return indexSetPtr_;
}
示例2: CoinError
void
CoinPackedVector::truncate( int n )
{
if ( n > nElements_ )
throw CoinError("n > size()","truncate","CoinPackedVector");
if ( n < 0 )
throw CoinError("n < 0","truncate","CoinPackedVector");
nElements_ = n;
clearBase();
}
示例3: overlap
/** This helper function copies an array to another location. The two arrays
must not overlap (otherwise an exception is thrown). For speed 8 entries
are copied at a time. The arrays are given by pointers to their first
entries and by the size of the source array.
Note JJF - the speed claim seems to be false on IA32 so I have added
CoinMemcpyN which can be used for atomic data */
template <class T> inline void
CoinDisjointCopyN(register const T* from, const int size, register T* to)
{
#ifndef _MSC_VER
if (size == 0 || from == to)
return;
#ifndef NDEBUG
if (size < 0)
throw CoinError("trying to copy negative number of entries",
"CoinDisjointCopyN", "");
#endif
#if 0
/* There is no point to do this test. If to and from are from different
blocks then dist is undefined, so this can crash correct code. It's
better to trust the user that the arrays are really disjoint. */
const long dist = to - from;
if (-size < dist && dist < size)
throw CoinError("overlapping arrays", "CoinDisjointCopyN", "");
#endif
for (register int n = size / 8; n > 0; --n, from += 8, to += 8) {
to[0] = from[0];
to[1] = from[1];
to[2] = from[2];
to[3] = from[3];
to[4] = from[4];
to[5] = from[5];
to[6] = from[6];
to[7] = from[7];
}
switch (size % 8) {
case 7:
to[6] = from[6];
case 6:
to[5] = from[5];
case 5:
to[4] = from[4];
case 4:
to[3] = from[3];
case 3:
to[2] = from[2];
case 2:
to[1] = from[1];
case 1:
to[0] = from[0];
case 0:
break;
}
#else
CoinCopyN(from, size, to);
#endif
}
示例4: CoinError
void
CoinIndexedVector::setElement(int index, double element)
{
#ifndef COIN_FAST_CODE
if ( index >= nElements_ )
throw CoinError("index >= size()", "setElement", "CoinIndexedVector");
if ( index < 0 )
throw CoinError("index < 0" , "setElement", "CoinIndexedVector");
#endif
elements_[indices_[index]] = element;
}
示例5: assert
/** Access the i'th element of the full storage vector. */
double &
CoinIndexedVector::operator[](int index) const
{
assert (!packedMode_);
#ifndef COIN_FAST_CODE
if ( index >= capacity_ )
throw CoinError("index >= capacity()", "[]", "CoinIndexedVector");
if ( index < 0 )
throw CoinError("index < 0" , "[]", "CoinIndexedVector");
#endif
double * where = elements_ + index;
return *where;
}
示例6: switch
CoinFileOutput *CoinFileOutput::create (const std::string &fileName,
Compression compression)
{
switch (compression)
{
case COMPRESS_NONE:
return new CoinPlainFileOutput (fileName);
case COMPRESS_GZIP:
#ifdef COIN_HAS_ZLIB
return new CoinGzipFileOutput (fileName);
#endif
break;
case COMPRESS_BZIP2:
#ifdef COIN_HAS_BZLIB
return new CoinBzip2FileOutput (fileName);
#endif
break;
default:
break;
}
throw CoinError ("Unsupported compression selected!",
"create",
"CoinFileOutput");
}
示例7: clear
void
CoinPackedVector::assignVector(int size, int*& inds, double*& elems,
bool testForDuplicateIndex)
{
clear();
// Allocate storage
if ( size != 0 ) {
//reserve(size); //This is a BUG!!!
nElements_ = size;
if (indices_ != NULL) delete[] indices_;
indices_ = inds; inds = NULL;
if (elements_ != NULL) delete[] elements_;
elements_ = elems; elems = NULL;
if (origIndices_ != NULL) delete[] origIndices_;
origIndices_ = new int[size];
CoinIotaN(origIndices_, size, 0);
capacity_ = size;
}
if (testForDuplicateIndex) {
try {
CoinPackedVectorBase::setTestForDuplicateIndex(testForDuplicateIndex);
}
catch (CoinError e) {
throw CoinError("duplicate index", "assignVector",
"CoinPackedVector");
}
} else {
setTestsOff();
}
}
示例8: indexSet
void
CoinPackedVector::append(const CoinPackedVectorBase & caboose)
{
const int cs = caboose.getNumElements();
if (cs == 0) {
return;
}
if (testForDuplicateIndex()) {
// Just to initialize the index heap
indexSet("append (1st call)", "CoinPackedVector");
}
const int s = nElements_;
// Make sure there is enough room for the caboose
if ( capacity_ < s + cs)
reserve(CoinMax(s + cs, 2 * capacity_));
const int * cind = caboose.getIndices();
const double * celem = caboose.getElements();
CoinDisjointCopyN(cind, cs, indices_ + s);
CoinDisjointCopyN(celem, cs, elements_ + s);
CoinIotaN(origIndices_ + s, cs, s);
nElements_ += cs;
if (testForDuplicateIndex()) {
std::set<int>& is = *indexSet("append (2nd call)", "CoinPackedVector");
for (int i = 0; i < cs; ++i) {
if (!is.insert(cind[i]).second)
throw CoinError("duplicate index", "append", "CoinPackedVector");
}
}
}
示例9: getVectorLast
/** The position of the last element (well, one entry <em>past</em> the
last) in the i'th major-dimension vector. */
CoinBigIndex getVectorLast(const int i) const {
#ifndef COIN_FAST_CODE
if (i < 0 || i >= majorDim_)
throw CoinError("bad index", "vectorLast", "CoinPackedMatrix");
#endif
return start_[i] + length_[i];
}
示例10: UtilAlpsDecodeWarmStart
//===========================================================================//
CoinWarmStartBasis* UtilAlpsDecodeWarmStart(AlpsEncoded& encoded,
AlpsReturnStatus* rc)
{
//rc not used? not checked?
int numCols;
int numRows;
encoded.readRep(numCols);
encoded.readRep(numRows);
int tempInt;
// Structural
int nint = (numCols + 15) >> 4;
char* structuralStatus = new char[4 * nint];
encoded.readRep(structuralStatus, tempInt);
assert(tempInt == nint * 4);
// Artificial
nint = (numRows + 15) >> 4;
char* artificialStatus = new char[4 * nint];
encoded.readRep(artificialStatus, tempInt);
assert(tempInt == nint * 4);
CoinWarmStartBasis* ws = new CoinWarmStartBasis();
if (!ws) {
throw CoinError("Out of memory", "UtilAlpsDecodeWarmStart", "HELP");
}
ws->assignBasisStatus(numCols, numRows,
structuralStatus, artificialStatus);
return ws;
}
示例11: CoinError
void
OaDecompositionBase::solverManip::restore()
{
if (initialNumberRows_ >= 0) {
int nRowsToDelete = si_->getNumRows() - initialNumberRows_;
int * rowsToDelete = new int[nRowsToDelete];
for (int i = 0 ; i < nRowsToDelete ; i++) {
rowsToDelete[i] = i + initialNumberRows_;
}
si_->deleteRows(nRowsToDelete, rowsToDelete);
delete [] rowsToDelete;
numrows_ = si_->getNumRows() ;
}
if (colLower_) {
si_->setColLower(colLower_);
}
if (colUpper_) {
si_->setColUpper(colUpper_);
}
if (cutoff_<COIN_DBL_MAX) {
si_->setDblParam(OsiDualObjectiveLimit, cutoff_);
}
if (warm_) {
if (si_->setWarmStart(warm_)==false) {
throw CoinError("Fail restoring the warm start at the end of procedure",
"restore","OaDecompositionBase::SaveSolverState") ;
}
}
getCached();
}
示例12: optionExists
/** throw if option does not exists.*/
inline void optionExists(const std::string & option){
if(!IsValid(GetOption(option))){
std::string msg = "Try to access option: "+option;
msg += "\n Option is not registered.\n";
throw CoinError("Bonmin::RegisteredOption","optionExists",msg);
}
}
示例13: chooseOptions
void
RegisteredOptions::fillAmplOptionList(ExtraCategoriesInfo which, Ipopt::AmplOptionsList * amplOptList){
std::list<int> test;
std::list< Ipopt::RegisteredOption * > options;
chooseOptions(which, options);
for(std::list< Ipopt::RegisteredOption * >::iterator i = options.begin();
i != options.end() ; i++)
{
std::string name = "bonmin.";
name += (*i)->Name();
Ipopt::RegisteredOptionType T = (*i)->Type();
Ipopt::AmplOptionsList::AmplOptionType type;
switch(T){
case Ipopt::OT_Number: type = Ipopt::AmplOptionsList::Number_Option;
break;
case Ipopt::OT_Integer: type = Ipopt::AmplOptionsList::Integer_Option;
break;
case Ipopt::OT_String: type = Ipopt::AmplOptionsList::String_Option;
break;
case Ipopt::OT_Unknown:
default:
throw CoinError("RegisteredOptions","fillAmplOptionList","Unknown option type");
}
amplOptList->AddAmplOption(name, name, type, (*i)->ShortDescription());
}
}
示例14: CoinError
//------------------------------------------------------------------
std::vector<double*> OsiTestSolverInterface::getPrimalRays(int /*maxNumRays*/) const
{
// *FIXME* : must write the method -LL
throw CoinError("method is not yet written", "getPrimalRays",
"OsiTestSolverInterface");
return std::vector<double*>();
}
示例15: getVectorSize
/** The length of i'th vector. */
inline int getVectorSize(const int i) const {
#ifndef COIN_FAST_CODE
if (i < 0 || i >= majorDim_)
throw CoinError("bad index", "vectorSize", "CoinPackedMatrix");
#endif
return length_[i];
}