void LpSub::loadBasis(Array<LPVARSTAT::STATUS> &lpVarStat, Array<SlackStat::STATUS> &slackStat) { Array<LPVARSTAT::STATUS> colStat(trueNCol()); int n = 0; const int nVar = sub_->nVar(); for (int i = 0; i < nVar; i++) if (!eliminated(i)) colStat[n++] = lpVarStat[i]; LP::loadBasis(colStat, slackStat); }
void LpSub::addCons(ArrayBuffer<Constraint*> &newCons) { // LpSub::addCons(): local variables ArrayBuffer<Row*> newRows(newCons.size(),false); //!< the new constraints in row format ArrayBuffer<int> delVar(sub_->nVar(),false); //!< buffer of deletable components of row format double rhsDelta; //!< correction of right hand side InfeasCon::INFEAS infeas; //!< infeasibility mode (TooLarge, TooSmall) Row *nr; constraint2row(newCons, newRows); // eliminate variables in added constraints /* Also the elimination of variables in an added constraint might * cause a void left hand side (interpreted as 0) violated the right hand * side of the constraint. These infeasible constraints are recognized, * but the resolution is currently not implemented. */ const int nNewRows = newRows.size(); for (int c = 0; c < nNewRows; c++) { //! eliminate variables in constraint \a c delVar.clear(); rhsDelta = 0.0; nr = newRows[c]; const int nrNnz = nr->nnz(); for(int i = 0; i < nrNnz; i++) if(eliminated(nr->support(i))) { delVar.push(i); rhsDelta += nr->coeff(i)*elimVal(nr->support(i)); } nr->delInd(delVar,rhsDelta); nr->rename(orig2lp_); // check if constraint \a c has become infeasible if(nr->nnz() == 0) { infeas = newCons[c]->voidLhsViolated(nr->rhs()); if (infeas != InfeasCon::Feasible) { infeasCons_.push(new InfeasCon(master_, newCons[c], infeas)); Logger::ifout() << "LpSub::addCons(): infeasible constraint added.\nAll variables with nonzero coefficients are eliminated and constraint is violated.\nSorry, resolution not implemented yet.\n"; OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::afcLpSub); } } } LP::addRows(newRows); for (int i = 0; i < newRows.size(); i++) delete newRows[i]; }
bool KateSearch::doSearch( const TQString& text ) { /* rodda: Still Working on this... :) bool result = false; if (m_searchResults.count()) { m_resultIndex++; if (m_resultIndex < (int)m_searchResults.count()) { s = m_searchResults[m_resultIndex]; result = true; } } else { int temp = 0; do {*/ #if 0 static int oldLine = -1; static int oldCol = -1; #endif uint line = s.cursor.line(); uint col = s.cursor.col();// + (result ? s.matchedLength : 0); bool backward = s.flags.backward; bool caseSensitive = s.flags.caseSensitive; bool regExp = s.flags.regExp; bool wholeWords = s.flags.wholeWords; uint foundLine, foundCol, matchLen; bool found = false; //kdDebug() << "Searching at " << line << ", " << col << endl; // kdDebug()<<"KateSearch::doSearch: "<<line<<", "<<col<<", "<<backward<<endl; if (backward) { KateDocCursor docCursor(line, col, doc()); // If we're at the top of the document, we're not gonna find anything, so bail. if (docCursor.line() == 0 && docCursor.col() == 0) return false; // Move one step backward before searching, if this is a "find again", we don't // want to find the same match. docCursor.moveBackward(1); line = docCursor.line(); col = docCursor.col(); } do { if( regExp ) { m_re = TQRegExp( text, caseSensitive ); found = doc()->searchText( line, col, m_re, &foundLine, &foundCol, &matchLen, backward ); } else if ( wholeWords ) { bool maybefound = false; do { maybefound = doc()->searchText( line, col, text, &foundLine, &foundCol, &matchLen, caseSensitive, backward ); if ( maybefound ) { found = ( ( foundCol == 0 || ! doc()->highlight()->isInWord( doc()->textLine( foundLine ).at( foundCol - 1 ) ) ) && ( foundCol + matchLen == doc()->lineLength( foundLine ) || ! doc()->highlight()->isInWord( doc()->textLine( foundLine ).at( foundCol + matchLen ) ) ) ); if ( found ) { break; } else if ( backward && foundCol == 0 ) // we are done on this line and want to avoid endless loops like in #137312 { if ( line == 0 ) // we are completely done... break; else line--; } else { line = foundLine; col = foundCol + 1; } } } while ( maybefound ); } else { found = doc()->searchText( line, col, text, &foundLine, &foundCol, &matchLen, caseSensitive, backward ); } if ( found && s.flags.selected ) { KateTextCursor start (s.selBegin); KateTextCursor end (s.selEnd); // recalc for block sel, to have start with lowest col, end with highest if (m_view->blockSelectionMode()) { start.setCol (kMin(s.selBegin.col(), s.selEnd.col())); end.setCol (kMax(s.selBegin.col(), s.selEnd.col())); } if ( !s.flags.backward && KateTextCursor( foundLine, foundCol ) >= end || s.flags.backward && KateTextCursor( foundLine, foundCol ) < start ) { found = false; } else if (m_view->blockSelectionMode()) { if ((int)foundCol >= start.col() && (int)foundCol < end.col()) break; } } line = foundLine; col = foundCol+1; } while (s.flags.selected && m_view->blockSelectionMode() && found); // in the case we want to search in selection + blockselection we need to loop if( !found ) return false; // save the search result s.cursor.setPos(foundLine, foundCol); s.matchedLength = matchLen; // we allready wrapped around one time if (s.wrapped) { if (s.flags.backward) { if ( (s.cursor.line() < s.wrappedEnd.line()) || ( (s.cursor.line() == s.wrappedEnd.line()) && ((s.cursor.col()+matchLen) <= uint(s.wrappedEnd.col())) ) ) return false; } else { if ( (s.cursor.line() > s.wrappedEnd.line()) || ( (s.cursor.line() == s.wrappedEnd.line()) && (s.cursor.col() > s.wrappedEnd.col()) ) ) return false; } } // kdDebug() << "Found at " << s.cursor.line() << ", " << s.cursor.col() << endl; //m_searchResults.append(s); if (arbitraryHLExample) { KateArbitraryHighlightRange* hl = new KateArbitraryHighlightRange(new KateSuperCursor(m_doc, true, s.cursor), new KateSuperCursor(m_doc, true, s.cursor.line(), s.cursor.col() + s.matchedLength), this); hl->setBold(); hl->setTextColor(Qt::white); hl->setBGColor(Qt::black); // destroy the highlight upon change connect(hl, TQT_SIGNAL(contentsChanged()), hl, TQT_SIGNAL(eliminated())); m_arbitraryHLList->append(hl); } return true; /* rodda: more of my search highlighting work } while (++temp < 100); if (result) { s = m_searchResults.first(); m_resultIndex = 0; } } return result;*/ }