// Copyright (C) 2003, International Business Machines // Corporation and others. All Rights Reserved. /* Authors John Tomlin (pdco) John Forrest (standard predictor-corrector) Note JJF has added arrays - this takes more memory but makes flow easier to understand and hopefully easier to extend */ #ifndef ClpInterior_H #define ClpInterior_H #include #include #include "ClpModel.hpp" #include "ClpMatrixBase.hpp" #include "ClpSolve.hpp" class ClpLsqr; class ClpPdcoBase; /// ******** DATA to be moved into protected section of ClpInterior typedef struct{ double atolmin; double r3norm; double LSdamp; double* deltay; } Info; /// ******** DATA to be moved into protected section of ClpInterior typedef struct{ double atolold; double atolnew; double r3ratio; int istop; int itncg; } Outfo; /// ******** DATA to be moved into protected section of ClpInterior typedef struct{ double gamma; double delta; int MaxIter; double FeaTol; double OptTol; double StepTol; double x0min; double z0min; double mu0; int LSmethod; // 1=Cholesky 2=QR 3=LSQR int LSproblem; // See below int LSQRMaxIter; double LSQRatol1; // Initial atol double LSQRatol2; // Smallest atol (unless atol1 is smaller) double LSQRconlim; int wait; } Options; class Lsqr; class ClpCholeskyBase; // ***** END /** This solves LPs using interior point methods It inherits from ClpModel and all its arrays are created at algorithm time. */ class ClpInterior : public ClpModel { friend void ClpInteriorUnitTest(const std::string & mpsDir, const std::string & netlibDir); public: /**@name Constructors and destructor and copy */ //@{ /// Default constructor ClpInterior ( ); /// Copy constructor. ClpInterior(const ClpInterior &); /// Copy constructor from model. ClpInterior(const ClpModel &); /** Subproblem constructor. A subset of whole model is created from the row and column lists given. The new order is given by list order and duplicates are allowed. Name and integer information can be dropped */ ClpInterior (const ClpModel * wholeModel, int numberRows, const int * whichRows, int numberColumns, const int * whichColumns, bool dropNames=true, bool dropIntegers=true); /// Assignment operator. This copies the data ClpInterior & operator=(const ClpInterior & rhs); /// Destructor ~ClpInterior ( ); // Ones below are just ClpModel with some changes /** Loads a problem (the constraints on the rows are given by lower and upper bounds). If a pointer is 0 then the following values are the default: */ void loadProblem ( const ClpMatrixBase& matrix, const double* collb, const double* colub, const double* obj, const double* rowlb, const double* rowub, const double * rowObjective=NULL); void loadProblem ( const CoinPackedMatrix& matrix, const double* collb, const double* colub, const double* obj, const double* rowlb, const double* rowub, const double * rowObjective=NULL); /** Just like the other loadProblem() method except that the matrix is given in a standard column major ordered format (without gaps). */ void loadProblem ( const int numcols, const int numrows, const CoinBigIndex* start, const int* index, const double* value, const double* collb, const double* colub, const double* obj, const double* rowlb, const double* rowub, const double * rowObjective=NULL); /// This one is for after presolve to save memory void loadProblem ( const int numcols, const int numrows, const CoinBigIndex* start, const int* index, const double* value,const int * length, const double* collb, const double* colub, const double* obj, const double* rowlb, const double* rowub, const double * rowObjective=NULL); /// Read an mps file from the given filename int readMps(const char *filename, bool keepNames=false, bool ignoreErrors = false); /** Borrow model. This is so we dont have to copy large amounts of data around. It assumes a derived class wants to overwrite an empty model with a real one - while it does an algorithm. This is same as ClpModel one. */ void borrowModel(ClpModel & otherModel); /** Return model - updates any scalars */ void returnModel(ClpModel & otherModel); //@} /**@name Functions most useful to user */ //@{ /** Pdco algorithm - see ClpPdco.hpp for method */ int pdco(); // ** Temporary version int pdco( ClpPdcoBase * stuff, Options &options, Info &info, Outfo &outfo); /// Primal-Dual Predictor-Corrector barrier int primalDual(); //@} /**@name most useful gets and sets */ //@{ /// If problem is primal feasible inline bool primalFeasible() const { return (sumPrimalInfeasibilities_<=1.0e-5);} /// If problem is dual feasible inline bool dualFeasible() const { return (sumDualInfeasibilities_<=1.0e-5);} /// Current (or last) algorithm inline int algorithm() const {return algorithm_; } /// Set algorithm inline void setAlgorithm(int value) {algorithm_=value; } /// Sum of dual infeasibilities inline double sumDualInfeasibilities() const { return sumDualInfeasibilities_;} /// Sum of primal infeasibilities inline double sumPrimalInfeasibilities() const { return sumPrimalInfeasibilities_;} /// dualObjective. inline double dualObjective() const { return dualObjective_;} /// primalObjective. inline double primalObjective() const { return primalObjective_;} /// diagonalNorm inline double diagonalNorm() const { return diagonalNorm_;} /// linearPerturbation inline double linearPerturbation() const { return linearPerturbation_;} inline void setLinearPerturbation(double value) { linearPerturbation_=value;} /// diagonalPerturbation inline double diagonalPerturbation() const { return diagonalPerturbation_;} inline void setDiagonalPerturbation(double value) { diagonalPerturbation_=value;} /// gamma inline double gamma() const { return gamma_;} inline void setGamma(double value) { gamma_=value;} /// delta inline double delta() const { return delta_;} inline void setDelta(double value) { delta_=value;} /// ComplementarityGap inline double complementarityGap() const { return complementarityGap_;} //@} /**@name most useful gets and sets */ //@{ /// Largest error on Ax-b inline double largestPrimalError() const { return largestPrimalError_;} /// Largest error on basic duals inline double largestDualError() const { return largestDualError_;} /// Maximum iterations inline int maximumBarrierIterations() const { return maximumBarrierIterations_;} inline void setMaximumBarrierIterations(int value) { maximumBarrierIterations_=value;} /// Set cholesky (and delete present one) void setCholesky(ClpCholeskyBase * cholesky); /// Return number fixed to see if worth presolving int numberFixed() const; /** fix variables interior says should be. If reallyFix false then just set values to exact bounds */ void fixFixed(bool reallyFix=true); /// Primal erturbation vector inline double * primalR() const { return primalR_;} /// Dual erturbation vector inline double * dualR() const { return dualR_;} //@} protected: /**@name protected methods */ //@{ /// Does most of deletion void gutsOfDelete(); /// Does most of copying void gutsOfCopy(const ClpInterior & rhs); /// Returns true if data looks okay, false if not bool createWorkingData(); void deleteWorkingData(); /// Sanity check on input rim data bool sanityCheck(); /// This does housekeeping int housekeeping(); //@} public: /**@name public methods */ //@{ /// Raw objective value (so always minimize) inline double rawObjectiveValue() const { return objectiveValue_;} /// Returns 1 if sequence indicates column inline int isColumn(int sequence) const { return sequence