// Copyright (C) 2003, International Business Machines // Corporation and others. All Rights Reserved. #include "CoinPragma.hpp" #include "CoinIndexedVector.hpp" #include "ClpFactorization.hpp" #include "ClpSimplex.hpp" #include "ClpLinearObjective.hpp" #include "CoinHelperFunctions.hpp" //############################################################################# // Constructors / Destructor / Assignment //############################################################################# //------------------------------------------------------------------- // Default Constructor //------------------------------------------------------------------- ClpLinearObjective::ClpLinearObjective () : ClpObjective() { type_=1; objective_=NULL; numberColumns_=0; } //------------------------------------------------------------------- // Useful Constructor //------------------------------------------------------------------- ClpLinearObjective::ClpLinearObjective (const double * objective , int numberColumns) : ClpObjective() { type_=1; numberColumns_=numberColumns; objective_ = CoinCopyOfArray(objective,numberColumns_,0.0); } //------------------------------------------------------------------- // Copy constructor //------------------------------------------------------------------- ClpLinearObjective::ClpLinearObjective (const ClpLinearObjective & rhs) : ClpObjective(rhs) { numberColumns_=rhs.numberColumns_; objective_ = CoinCopyOfArray(rhs.objective_,numberColumns_); } /* Subset constructor. Duplicates are allowed and order is as given. */ ClpLinearObjective::ClpLinearObjective (const ClpLinearObjective &rhs, int numberColumns, const int * whichColumn) : ClpObjective(rhs) { objective_=NULL; numberColumns_=0; if (numberColumns>0) { // check valid lists int numberBad=0; int i; for (i=0;i=rhs.numberColumns_) numberBad++; if (numberBad) throw CoinError("bad column list", "subset constructor", "ClpLinearObjective"); numberColumns_ = numberColumns; objective_ = new double[numberColumns_]; for (i=0;inumberRows(); //work space CoinIndexedVector * workSpace = model->rowArray(0); CoinIndexedVector arrayVector; arrayVector.reserve(numberRows+1); int iRow; #ifdef CLP_DEBUG workSpace->checkClear(); #endif double * array = arrayVector.denseVector(); int * index = arrayVector.getIndices(); int number=0; const double * cost = model->costRegion(); assert (!useFeasibleCosts); const int * pivotVariable = model->pivotVariable(); for (iRow=0;iRownumberColumns(); // Btran basic costs double * work = workSpace->denseVector(); model->factorization()->updateColumnTranspose(workSpace,&arrayVector); ClpFillN(work,numberRows,0.0); // now look at dual solution double * rowReducedCost = region+numberColumns; double * dual = rowReducedCost; double * rowCost = model->costRegion(0); for (iRow=0;iRowcostRegion(1),numberColumns,dj); model->transposeTimes(-1.0,dual,dj); for (iRow=0;iRowcostRegion(); double delta=0.0; int numberRows = model->numberRows(); int numberColumns = model->numberColumns(); currentObj=0.0; thetaObj=0.0; for (int iColumn=0;iColumncostRegion()) cost = model->costRegion(); double currentObj=0.0; for (int iColumn=0;iColumn=0&&j