/** Assignment operator.*/ TMat& TMat::operator=(const TMat &rhs){ if(this != &rhs){ freeSpace(); nnz_ = rhs.nnz_; capacity_ = rhs.capacity_; iRow_ = CoinCopyOfArray(rhs.iRow_, rhs.nnz_); jCol_ = CoinCopyOfArray(rhs.jCol_, rhs.nnz_); value_ = CoinCopyOfArray(rhs.value_, rhs.nnz_); columnOrdering_ = rhs.columnOrdering_; rowOrdering_ = rhs.rowOrdering_; nonEmptyCols_.clear(); nonEmptyRows_.clear(); } return (*this); }
/* Useful constructor - passed set of variables */ CbcBranchAllDifferent::CbcBranchAllDifferent (CbcModel * model, int numberInSet, const int * members) : CbcBranchCut(model) { numberInSet_ = numberInSet; which_ = CoinCopyOfArray(members, numberInSet_); }
//------------------------------------------------------------------- // Copy constructor //------------------------------------------------------------------- CglStored::CglStored (const CglStored & source) : CglCutGenerator(source), requiredViolation_(source.requiredViolation_), probingInfo_(NULL), cuts_(source.cuts_), numberColumns_(source.numberColumns_), bestSolution_(NULL), bounds_(NULL) { if (source.probingInfo_) probingInfo_ = new CglTreeProbingInfo(*source.probingInfo_); if (numberColumns_) { bestSolution_ = CoinCopyOfArray(source.bestSolution_,numberColumns_+1); bounds_ = CoinCopyOfArray(source.bounds_,2*numberColumns_); } }
//------------------------------------------------------------------- // Useful Constructor //------------------------------------------------------------------- CglAllDifferent::CglAllDifferent (int numberSets, const int * starts, const int * which) : CglCutGenerator(), numberSets_(numberSets), maxLook_(2), logLevel_(0), start_(NULL), which_(NULL), originalWhich_(NULL) { if (numberSets_>0) { int n = starts[numberSets_]; start_ = CoinCopyOfArray(starts,numberSets_+1); originalWhich_ = CoinCopyOfArray(which,n); which_ = new int[n]; int i; int maxValue=-1; for (i=0;i<n;i++) { int iColumn = which[i]; assert (iColumn>=0); maxValue = CoinMax(iColumn,maxValue); } maxValue++; int * translate = new int[maxValue]; for (i=0;i<maxValue;i++) translate[i]=-1; for (i=0;i<n;i++) { int iColumn = which[i]; translate[iColumn]=0; } numberDifferent_=0; for (i=0;i<maxValue;i++) { if (!translate[i]) translate[i]=numberDifferent_++; } // Now translate for (i=0;i<n;i++) { int iColumn = which[i]; iColumn = translate[iColumn]; assert (iColumn>=0); which_[i]=iColumn; } delete [] translate; } }
//------------------------------------------------------------------- // Useful Constructor //------------------------------------------------------------------- ClpLinearObjective::ClpLinearObjective (const double * objective , int numberColumns) : ClpObjective() { type_ = 1; numberColumns_ = numberColumns; objective_ = CoinCopyOfArray(objective, numberColumns_, 0.0); }
// Copy constructor CbcFollowOn::CbcFollowOn ( const CbcFollowOn & rhs) : CbcObject(rhs), matrix_(rhs.matrix_), matrixByRow_(rhs.matrixByRow_) { int numberRows = matrix_.getNumRows(); rhs_ = CoinCopyOfArray(rhs.rhs_, numberRows); }
//---------------------------------------------------------------- // Assignment operator //------------------------------------------------------------------- ClpConstraintQuadratic & ClpConstraintQuadratic::operator=(const ClpConstraintQuadratic& rhs) { if (this != &rhs) { delete [] start_; delete [] column_; delete [] coefficient_; numberColumns_ = rhs.numberColumns_; numberCoefficients_ = rhs.numberCoefficients_; numberQuadraticColumns_ = rhs.numberQuadraticColumns_; start_ = CoinCopyOfArray(rhs.start_, numberQuadraticColumns_ + 1); int numberElements = start_[numberQuadraticColumns_]; column_ = CoinCopyOfArray(rhs.column_, numberElements); coefficient_ = CoinCopyOfArray(rhs.coefficient_, numberElements); } return *this; }
//---------------------------------------------------------------- // Assignment operator //------------------------------------------------------------------- OsiSolverBranch & OsiSolverBranch::operator=(const OsiSolverBranch &rhs) { if (this != &rhs) { delete[] indices_; delete[] bound_; memcpy(start_, rhs.start_, sizeof(start_)); int size = start_[4]; if (size) { indices_ = CoinCopyOfArray(rhs.indices_, size); bound_ = CoinCopyOfArray(rhs.bound_, size); } else { indices_ = NULL; bound_ = NULL; } } return *this; }
// Copy constructor CbcFixVariable::CbcFixVariable ( const CbcFixVariable & rhs) : CbcConsequence(rhs) { numberStates_ = rhs.numberStates_; states_ = NULL; startLower_ = NULL; startUpper_ = NULL; newBound_ = NULL; variable_ = NULL; if (numberStates_) { states_ = CoinCopyOfArray(rhs.states_, numberStates_); startLower_ = CoinCopyOfArray(rhs.startLower_, numberStates_ + 1); startUpper_ = CoinCopyOfArray(rhs.startUpper_, numberStates_ + 1); int n = startLower_[numberStates_]; newBound_ = CoinCopyOfArray(rhs.newBound_, n); variable_ = CoinCopyOfArray(rhs.variable_, n); } }
// Copy constructor CbcSubProblem::CbcSubProblem ( const CbcSubProblem & rhs) : objectiveValue_(rhs.objectiveValue_), sumInfeasibilities_(rhs.sumInfeasibilities_), variables_(NULL), newBounds_(NULL), status_(NULL), depth_(rhs.depth_), numberChangedBounds_(rhs.numberChangedBounds_), numberInfeasibilities_(rhs.numberInfeasibilities_) { if (numberChangedBounds_) { variables_ = CoinCopyOfArray(rhs.variables_, numberChangedBounds_); newBounds_ = CoinCopyOfArray(rhs.newBounds_, numberChangedBounds_); } if (rhs.status_) { status_ = new CoinWarmStartBasis(*rhs.status_); } }
//------------------------------------------------------------------- // Assignment operator //------------------------------------------------------------------- CbcSolver2 & CbcSolver2::operator=(const CbcSolver2& rhs) { if (this != &rhs) { OsiClpSolverInterface::operator=(rhs); delete [] node_; delete [] howMany_; model_ = rhs.model_; int numberColumns = modelPtr_->numberColumns(); node_=CoinCopyOfArray(rhs.node_,numberColumns); howMany_=CoinCopyOfArray(rhs.howMany_,numberColumns); count_=rhs.count_; memory_=rhs.memory_; algorithm_=rhs.algorithm_; strategy_=rhs.strategy_; } return *this; }
//------------------------------------------------------------------- // Assignment operator //------------------------------------------------------------------- CbcSolverLongThin & CbcSolverLongThin::operator=(const CbcSolverLongThin& rhs) { if (this != &rhs) { OsiClpSolverInterface::operator=(rhs); delete [] node_; delete [] howMany_; model_ = rhs.model_; int numberColumns = modelPtr_->numberColumns(); node_=CoinCopyOfArray(rhs.node_,numberColumns); howMany_=CoinCopyOfArray(rhs.howMany_,numberColumns); count_=rhs.count_; memory_=rhs.memory_; believeInfeasible_ = rhs.believeInfeasible_; nestedSearch_ = rhs.nestedSearch_; algorithm_=rhs.algorithm_; } return *this; }
//------------------------------------------------------------------- // Copy constructor //------------------------------------------------------------------- CglAllDifferent::CglAllDifferent ( const CglAllDifferent & rhs) : CglCutGenerator(rhs), numberSets_(rhs.numberSets_), numberDifferent_(rhs.numberDifferent_), maxLook_(rhs.maxLook_), logLevel_(rhs.logLevel_) { if (numberSets_) { int n = rhs.start_[numberSets_]; start_ = CoinCopyOfArray(rhs.start_,numberSets_+1); which_ = CoinCopyOfArray(rhs.which_,n); originalWhich_ = CoinCopyOfArray(rhs.originalWhich_,n); } else { start_=NULL; which_=NULL; originalWhich_=NULL; } }
void AmplTMINLP::read_sos() { ASL_pfgh* asl = ampl_tnlp_->AmplSolverObject(); int i = 0;//ASL_suf_sos_explict_free; int copri[2], **p_sospri; copri[0] = 0; copri[1] = 0; int * starts = NULL; int * indices = NULL; char * types = NULL; double * weights = NULL; int * priorities = NULL; p_sospri = &priorities; sos_.gutsOfDestructor(); int m = n_con; sos_.num = suf_sos(i, &sos_.numNz, &types, p_sospri, copri, &starts, &indices, &weights); if(m != n_con){ throw CoinError("number of constraints changed by suf_sos. Not supported.", "read_sos","Bonmin::AmplTMINLP"); } if (sos_.num) { //Copy sos information sos_.priorities = CoinCopyOfArray(priorities,sos_.num); sos_.starts = CoinCopyOfArray(starts, sos_.num + 1); sos_.indices = CoinCopyOfArray(indices, sos_.numNz); sos_.types = CoinCopyOfArray(types, sos_.num); sos_.weights = CoinCopyOfArray(weights, sos_.numNz); ampl_utils::sos_kludge(sos_.num, sos_.starts, sos_.weights); for (int ii=0;ii<sos_.num;ii++) { int ichar = sos_.types[ii] - '0'; if (ichar != 1 && ichar != 2) { std::cerr<<"Unsuported type of sos constraint: "<<sos_.types[ii]<<std::endl; throw; } sos_.types[ii]= static_cast<char>(ichar); } } }
// Assignment operator CbcLink & CbcLink::operator=( const CbcLink& rhs) { if (this!=&rhs) { CbcObject::operator=(rhs); delete [] weights_; delete [] which_; numberMembers_ = rhs.numberMembers_; numberLinks_ = rhs.numberLinks_; sosType_ = rhs.sosType_; if (numberMembers_) { weights_ = CoinCopyOfArray(rhs.weights_,numberMembers_); which_ = CoinCopyOfArray(rhs.which_,numberMembers_*numberLinks_); } else { weights_ = NULL; which_ = NULL; } } return *this; }
// Assignment operator CbcTree & CbcTree::operator=(const CbcTree & rhs) { if (this != &rhs) { nodes_ = rhs.nodes_; maximumNodeNumber_ = rhs.maximumNodeNumber_; delete [] branched_; delete [] newBound_; numberBranching_ = rhs.numberBranching_; maximumBranching_ = rhs.maximumBranching_; if (maximumBranching_ > 0) { branched_ = CoinCopyOfArray(rhs.branched_, maximumBranching_); newBound_ = CoinCopyOfArray(rhs.newBound_, maximumBranching_); } else { branched_ = NULL; newBound_ = NULL; } } return *this; }
// Assignment operator CbcBranchAllDifferent & CbcBranchAllDifferent::operator=( const CbcBranchAllDifferent & rhs) { if (this != &rhs) { CbcBranchCut::operator=(rhs); delete [] which_; numberInSet_ = rhs.numberInSet_; which_ = CoinCopyOfArray(rhs.which_, numberInSet_); } return *this; }
//---------------------------------------------------------------- // Assignment operator //------------------------------------------------------------------- ClpLinearObjective & ClpLinearObjective::operator=(const ClpLinearObjective& rhs) { if (this != &rhs) { ClpObjective::operator=(rhs); numberColumns_ = rhs.numberColumns_; delete [] objective_; objective_ = CoinCopyOfArray(rhs.objective_, numberColumns_); } return *this; }
//---------------------------------------------------------------- // Assignment operator //------------------------------------------------------------------- OsiSolverResult & OsiSolverResult::operator=(const OsiSolverResult &rhs) { if (this != &rhs) { delete[] primalSolution_; delete[] dualSolution_; objectiveValue_ = rhs.objectiveValue_; basis_ = rhs.basis_; fixed_ = rhs.fixed_; int numberRows = basis_.getNumArtificial(); int numberColumns = basis_.getNumStructural(); if (numberColumns) { primalSolution_ = CoinCopyOfArray(rhs.primalSolution_, numberColumns); dualSolution_ = CoinCopyOfArray(rhs.dualSolution_, numberRows); } else { primalSolution_ = NULL; dualSolution_ = NULL; } } return *this; }
// Copy constructor CbcBranchToFixLots::CbcBranchToFixLots ( const CbcBranchToFixLots & rhs) : CbcBranchCut(rhs) { djTolerance_ = rhs.djTolerance_; fractionFixed_ = rhs.fractionFixed_; int numberColumns = model_->getNumCols(); mark_ = CoinCopyOfArray(rhs.mark_, numberColumns); matrixByRow_ = rhs.matrixByRow_; depth_ = rhs.depth_; numberClean_ = rhs.numberClean_; alwaysCreate_ = rhs.alwaysCreate_; }
void AmplTMINLP::read_priorities() { int numcols, m, dummy1, dummy2; TNLP::IndexStyleEnum index_style; ampl_tnlp_->get_nlp_info(numcols, m, dummy1, dummy2, index_style); const AmplSuffixHandler * suffix_handler = GetRawPtr(suffix_handler_); const Index* pri = suffix_handler->GetIntegerSuffixValues("priority", AmplSuffixHandler::Variable_Source); const Index* brac = suffix_handler->GetIntegerSuffixValues("direction", AmplSuffixHandler::Variable_Source); const Number* upPs = suffix_handler->GetNumberSuffixValues("upPseudocost", AmplSuffixHandler::Variable_Source); const Number* dwPs = suffix_handler->GetNumberSuffixValues("downPseudocost", AmplSuffixHandler::Variable_Source); branch_.gutsOfDestructor(); branch_.size = numcols; if (pri) { branch_.priorities = new int[numcols]; for (int i = 0 ; i < numcols ; i++) { branch_.priorities [i] = -pri[i] + 9999; } } if (brac) { branch_.branchingDirections = CoinCopyOfArray(brac,numcols); } if (upPs && !dwPs) dwPs = upPs; else if (dwPs && !upPs) upPs = dwPs; if (upPs) { branch_.upPsCosts = CoinCopyOfArray(upPs,numcols); } if (dwPs) { branch_.downPsCosts = CoinCopyOfArray(dwPs,numcols); } const double* perturb_radius = suffix_handler->GetNumberSuffixValues("perturb_radius", AmplSuffixHandler::Variable_Source); perturb_info_.SetPerturbationArray(numcols, perturb_radius); }
// Copy constructor CbcHeuristicDive::CbcHeuristicDive(const CbcHeuristicDive & rhs) : CbcHeuristic(rhs), matrix_(rhs.matrix_), matrixByRow_(rhs.matrixByRow_), percentageToFix_(rhs.percentageToFix_), maxIterations_(rhs.maxIterations_), maxSimplexIterations_(rhs.maxSimplexIterations_), maxSimplexIterationsAtRoot_(rhs.maxSimplexIterationsAtRoot_), maxTime_(rhs.maxTime_) { downArray_ = NULL; upArray_ = NULL; if (rhs.downLocks_) { int numberIntegers = model_->numberIntegers(); downLocks_ = CoinCopyOfArray(rhs.downLocks_, numberIntegers); upLocks_ = CoinCopyOfArray(rhs.upLocks_, numberIntegers); } else { downLocks_ = NULL; upLocks_ = NULL; } }
/* Set pointer to array[getNumRows()] of rhs side values This gives same results as OsiSolverInterface for useful cases If getRowUpper()[i] != infinity then getRightHandSide()[i] == getRowUpper()[i] else getRightHandSide()[i] == getRowLower()[i] */ void CoinSnapshot::setRightHandSide(const double * array, bool copyIn) { if (owned_.rightHandSide) delete [] rightHandSide_; if (copyIn) { owned_.rightHandSide=1; rightHandSide_ = CoinCopyOfArray(array,numRows_); } else { owned_.rightHandSide=0; rightHandSide_ = array; } }
// Set pointer to array[getNumCols()] of objective function coefficients void CoinSnapshot::setObjCoefficients(const double * array, bool copyIn) { if (owned_.objCoefficients) delete [] objCoefficients_; if (copyIn) { owned_.objCoefficients=1; objCoefficients_ = CoinCopyOfArray(array,numCols_); } else { owned_.objCoefficients=0; objCoefficients_ = array; } }
// Set pointer to array[getNumCols()] of primal variable values void CoinSnapshot::setColSolution(const double * array, bool copyIn) { if (owned_.colSolution) delete [] colSolution_; if (copyIn) { owned_.colSolution=1; colSolution_ = CoinCopyOfArray(array,numCols_); } else { owned_.colSolution=0; colSolution_ = array; } }
// Set pointer to array[getNumRows()] of dual variable values void CoinSnapshot::setRowPrice(const double * array, bool copyIn) { if (owned_.rowPrice) delete [] rowPrice_; if (copyIn) { owned_.rowPrice=1; rowPrice_ = CoinCopyOfArray(array,numRows_); } else { owned_.rowPrice=0; rowPrice_ = array; } }
// Set a pointer to array[getNumCols()] of reduced costs void CoinSnapshot::setReducedCost(const double * array, bool copyIn) { if (owned_.reducedCost) delete [] reducedCost_; if (copyIn) { owned_.reducedCost=1; reducedCost_ = CoinCopyOfArray(array,numCols_); } else { owned_.reducedCost=0; reducedCost_ = array; } }
// Set pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vector). void CoinSnapshot::setRowActivity(const double * array, bool copyIn) { if (owned_.rowActivity) delete [] rowActivity_; if (copyIn) { owned_.rowActivity=1; rowActivity_ = CoinCopyOfArray(array,numRows_); } else { owned_.rowActivity=0; rowActivity_ = array; } }
//------------------------------------------------------------------- // Constructor from solver //------------------------------------------------------------------- OsiSolverResult::OsiSolverResult(const OsiSolverInterface &solver, const double *lowerBefore, const double *upperBefore) : objectiveValue_(COIN_DBL_MAX) , primalSolution_(NULL) , dualSolution_(NULL) { if (solver.isProvenOptimal() && !solver.isDualObjectiveLimitReached()) { objectiveValue_ = solver.getObjValue() * solver.getObjSense(); CoinWarmStartBasis *basis = dynamic_cast< CoinWarmStartBasis * >(solver.getWarmStart()); assert(basis); basis_ = *basis; delete basis; int numberRows = basis_.getNumArtificial(); int numberColumns = basis_.getNumStructural(); assert(numberColumns == solver.getNumCols()); assert(numberRows == solver.getNumRows()); primalSolution_ = CoinCopyOfArray(solver.getColSolution(), numberColumns); dualSolution_ = CoinCopyOfArray(solver.getRowPrice(), numberRows); fixed_.addBranch(-1, numberColumns, lowerBefore, solver.getColLower(), upperBefore, solver.getColUpper()); } }
// Set pointer to array[getNumCols()] of primal variable values which should not be separated (for debug) void CoinSnapshot::setDoNotSeparateThis(const double * array, bool copyIn) { if (owned_.doNotSeparateThis) delete [] doNotSeparateThis_; if (copyIn) { owned_.doNotSeparateThis=1; doNotSeparateThis_ = CoinCopyOfArray(array,numCols_); } else { owned_.doNotSeparateThis=0; doNotSeparateThis_ = array; } }