OsiSolverInterface* OsiIF::switchInterfaces(SOLVERTYPE newMethod) { OsiSolverInterface *s2 = nullptr; if( newMethod == Exact ) { s2 = getDefaultInterface(); } else { #ifdef OSI_VOL // TODO switchInterfaces // s2 = getApproxInterface() s2 = new OsiVolSolverInterface; #else Logger::ifout() << "ABACUS has not been compiled with support for the Volume Algorithm, cannot switch to approximate solver.\n"; OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::afcOsiIf); #endif } s2->setHintParam(OsiDoReducePrint, true, OsiHintDo); s2->messageHandler()->setLogLevel(0); master_->setSolverParameters(s2, currentSolverType() == Approx); if (currentSolverType() == Exact && numRows_ == 0 && master_->defaultLpSolver() == Master::CPLEX) { loadDummyRow(s2, osiLP_->getColLower(), osiLP_->getColUpper(), osiLP_->getObjCoefficients()); } else { s2->loadProblem(*osiLP_->getMatrixByCol(), osiLP_->getColLower(), osiLP_->getColUpper(), osiLP_->getObjCoefficients(), osiLP_->getRowLower(), osiLP_->getRowUpper()); } s2->setObjSense(osiLP_->getObjSense()); delete osiLP_; // get the pointers to the solution, reduced costs etc. rhs_ = s2->getRightHandSide(); rowsense_ = s2->getRowSense(); colupper_ = s2->getColUpper(); collower_ = s2->getColLower(); objcoeff_ = s2->getObjCoefficients(); if( ws_ != nullptr ) delete ws_; ws_ = dynamic_cast<CoinWarmStartBasis* >(s2->getWarmStart()); xValStatus_ = recoStatus_= yValStatus_ = slackStatus_ = basisStatus_ = Missing; return s2; }
/** *@var bWITHIPV6ONLY *@brief only use IPv6 *@brief bWITHIPV6 = true means, running only with IPv6 *@brief bWITHIPV6 = false means, running with IPv6 and IPv4 *@brief initializes value of bWITHIPV6ONLY 'false' */ bool bWITHIPV6ONLY=false; /** *@var sINTERFACE *@brief choose the INTERFACE, which will be used *@brief default use the DefaultInterface */ std::string sINTERFACE = getDefaultInterface(); /** *@var iLostTime *@brief the records which more than iLostTime hours can not be connected, will be deleted */ int iLostTime = 3; /** *@var iServerSidePortIPv4 *@brief Server Port by ipv4 */ int iServerSidePortIPv4 = 5000; /** *@var iServerSidePortIPv6
void OsiIF::_initialize( OptSense sense, int nRow, int maxRow, int nCol, int maxCol, Array<double> &obj, Array<double> &lBound, Array<double> &uBound, Array<Row*> &rows) { osiLP_ = getDefaultInterface(); currentSolverType_ = Exact; // switch off output from the solver // can be reset in setSolverParameters osiLP_->setHintParam(OsiDoReducePrint, true, OsiHintDo); osiLP_->messageHandler()->setLogLevel(0); master_->setSolverParameters(osiLP_, currentSolverType() == Approx); numRows_ = nRow; numCols_ = nCol; double *lbounds = new double[numCols_]; double *ubounds = new double[numCols_]; double *objectives = new double[numCols_]; CoinPackedVector *coinrow = new CoinPackedVector(); CoinPackedMatrix *matrix = new CoinPackedMatrix(false,0,0); matrix->setDimensions(0, numCols_); for (int i = 0; i < numCols_; i++){ lbounds[i] = lBound[i]; ubounds[i] = uBound[i]; objectives[i] = obj[i]; } if (currentSolverType() == Exact && numRows_ == 0 && master_->defaultLpSolver() == Master::CPLEX) { loadDummyRow(osiLP_, lbounds, ubounds, objectives); } else { char *senses = new char[numRows_]; double *rhs = new double[numRows_]; double *ranges = new double[numRows_]; for (int i = 0; i < numRows_; i++){ coinrow->clear(); for (int j = 0; j < rows[i]->nnz(); j++){ coinrow->insert(rows[i]->support(j), rows[i]->coeff(j)); } matrix->appendRow(*coinrow); senses[i] = csense2osi(rows[i]->sense()); rhs[i] = rows[i]->rhs(); ranges[i] = 0.0; } lpSolverTime_.start(); osiLP_->loadProblem(*matrix, lbounds, ubounds, objectives, senses, rhs, ranges); lpSolverTime_.stop(); freeChar(senses); freeDouble(rhs); freeDouble(ranges); } // set the sense of the optimization _sense(sense); // get the pointers to the solution, reduced costs etc. lpSolverTime_.start(); numRows_ = osiLP_->getNumRows(); numCols_ = osiLP_->getNumCols(); rhs_ = osiLP_->getRightHandSide(); rowsense_ = osiLP_->getRowSense(); colupper_ = osiLP_->getColUpper(); collower_ = osiLP_->getColLower(); objcoeff_ = osiLP_->getObjCoefficients(); if( ws_ != nullptr ) delete ws_; //ws_ = dynamic_cast<CoinWarmStartBasis *>(osiLP_->getWarmStart()); ws_=nullptr; xValStatus_ = recoStatus_ = yValStatus_ = slackStatus_ = basisStatus_ = Missing; lpSolverTime_.stop(); delete coinrow; delete matrix; freeDouble(lbounds); freeDouble(ubounds); freeDouble(objectives); }