00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ClpSimplex_H
00012 #define ClpSimplex_H
00013
00014 #include <iostream>
00015 #include <cfloat>
00016 #include "ClpModel.hpp"
00017 #include "ClpMatrixBase.hpp"
00018 #include "ClpSolve.hpp"
00019 #include "ClpConfig.h"
00020 class ClpDualRowPivot;
00021 class ClpPrimalColumnPivot;
00022 class ClpFactorization;
00023 class CoinIndexedVector;
00024 class ClpNonLinearCost;
00025 class ClpNodeStuff;
00026 class CoinStructuredModel;
00027 class OsiClpSolverInterface;
00028 class CoinWarmStartBasis;
00029 class ClpDisasterHandler;
00030 class ClpConstraint;
00031 #ifdef CLP_HAS_ABC
00032 #include "AbcCommon.hpp"
00033 class AbcTolerancesEtc;
00034 class AbcSimplex;
00035 #include "CoinAbcCommon.hpp"
00036 #endif
00037
00055 class ClpSimplex : public ClpModel {
00056 friend void ClpSimplexUnitTest(const std::string & mpsDir);
00057
00058 public:
00063 enum Status {
00064 isFree = 0x00,
00065 basic = 0x01,
00066 atUpperBound = 0x02,
00067 atLowerBound = 0x03,
00068 superBasic = 0x04,
00069 isFixed = 0x05
00070 };
00071
00072 enum FakeBound {
00073 noFake = 0x00,
00074 lowerFake = 0x01,
00075 upperFake = 0x02,
00076 bothFake = 0x03
00077 };
00078
00081
00082 ClpSimplex (bool emptyMessages = false );
00083
00088 ClpSimplex(const ClpSimplex & rhs, int scalingMode = -1);
00093 ClpSimplex(const ClpModel & rhs, int scalingMode = -1);
00100 ClpSimplex (const ClpModel * wholeModel,
00101 int numberRows, const int * whichRows,
00102 int numberColumns, const int * whichColumns,
00103 bool dropNames = true, bool dropIntegers = true,
00104 bool fixOthers = false);
00111 ClpSimplex (const ClpSimplex * wholeModel,
00112 int numberRows, const int * whichRows,
00113 int numberColumns, const int * whichColumns,
00114 bool dropNames = true, bool dropIntegers = true,
00115 bool fixOthers = false);
00119 ClpSimplex (ClpSimplex * wholeModel,
00120 int numberColumns, const int * whichColumns);
00123 void originalModel(ClpSimplex * miniModel);
00124 inline int abcState() const
00125 { return abcState_;}
00126 inline void setAbcState(int state)
00127 { abcState_=state;}
00128 #ifdef ABC_INHERIT
00129 inline AbcSimplex * abcSimplex() const
00130 { return abcSimplex_;}
00131 inline void setAbcSimplex(AbcSimplex * simplex)
00132 { abcSimplex_=simplex;}
00134 int doAbcDual();
00136 int doAbcPrimal(int ifValuesPass);
00137 #endif
00138
00143 void setPersistenceFlag(int value);
00145 void makeBaseModel();
00147 void deleteBaseModel();
00149 inline ClpSimplex * baseModel() const {
00150 return baseModel_;
00151 }
00155 void setToBaseModel(ClpSimplex * model = NULL);
00157 ClpSimplex & operator=(const ClpSimplex & rhs);
00159 ~ClpSimplex ( );
00160
00172 void loadProblem ( const ClpMatrixBase& matrix,
00173 const double* collb, const double* colub,
00174 const double* obj,
00175 const double* rowlb, const double* rowub,
00176 const double * rowObjective = NULL);
00177 void loadProblem ( const CoinPackedMatrix& matrix,
00178 const double* collb, const double* colub,
00179 const double* obj,
00180 const double* rowlb, const double* rowub,
00181 const double * rowObjective = NULL);
00182
00185 void loadProblem ( const int numcols, const int numrows,
00186 const CoinBigIndex* start, const int* index,
00187 const double* value,
00188 const double* collb, const double* colub,
00189 const double* obj,
00190 const double* rowlb, const double* rowub,
00191 const double * rowObjective = NULL);
00193 void loadProblem ( const int numcols, const int numrows,
00194 const CoinBigIndex* start, const int* index,
00195 const double* value, const int * length,
00196 const double* collb, const double* colub,
00197 const double* obj,
00198 const double* rowlb, const double* rowub,
00199 const double * rowObjective = NULL);
00204 int loadProblem ( CoinModel & modelObject, bool keepSolution = false);
00206 int readMps(const char *filename,
00207 bool keepNames = false,
00208 bool ignoreErrors = false);
00210 int readGMPL(const char *filename, const char * dataName,
00211 bool keepNames = false);
00214 int readLp(const char *filename, const double epsilon = 1e-5);
00219 void borrowModel(ClpModel & otherModel);
00220 void borrowModel(ClpSimplex & otherModel);
00222 void passInEventHandler(const ClpEventHandler * eventHandler);
00224 void getbackSolution(const ClpSimplex & smallModel, const int * whichRow, const int * whichColumn);
00233 int loadNonLinear(void * info, int & numberConstraints,
00234 ClpConstraint ** & constraints);
00235 #ifdef ABC_INHERIT
00237 void loadTolerancesEtc(const AbcTolerancesEtc & data);
00239 void unloadTolerancesEtc(AbcTolerancesEtc & data);
00240 #endif
00241
00242
00248 int initialSolve(ClpSolve & options);
00250 int initialSolve();
00252 int initialDualSolve();
00254 int initialPrimalSolve();
00256 int initialBarrierSolve();
00258 int initialBarrierNoCrossSolve();
00269 int dual(int ifValuesPass = 0, int startFinishOptions = 0);
00270
00271 int dualDebug(int ifValuesPass = 0, int startFinishOptions = 0);
00282 int primal(int ifValuesPass = 0, int startFinishOptions = 0);
00288 int nonlinearSLP(int numberPasses, double deltaTolerance);
00294 int nonlinearSLP(int numberConstraints, ClpConstraint ** constraints,
00295 int numberPasses, double deltaTolerance);
00298 int barrier(bool crossover = true);
00301 int reducedGradient(int phase = 0);
00303 int solve(CoinStructuredModel * model);
00304 #ifdef ABC_INHERIT
00305
00309 void dealWithAbc(int solveType,int startUp,bool interrupt=false);
00310 #endif
00311
00317 int loadProblem ( CoinStructuredModel & modelObject,
00318 bool originalOrder = true, bool keepSolution = false);
00333 int cleanup(int cleanupScaling);
00354 int dualRanging(int numberCheck, const int * which,
00355 double * costIncrease, int * sequenceIncrease,
00356 double * costDecrease, int * sequenceDecrease,
00357 double * valueIncrease = NULL, double * valueDecrease = NULL);
00372 int primalRanging(int numberCheck, const int * which,
00373 double * valueIncrease, int * sequenceIncrease,
00374 double * valueDecrease, int * sequenceDecrease);
00384 int modifyCoefficientsAndPivot(int number,
00385 const int * which,
00386 const CoinBigIndex * start,
00387 const int * row,
00388 const double * newCoefficient,
00389 const unsigned char * newStatus=NULL,
00390 const double * newLower=NULL,
00391 const double * newUpper=NULL,
00392 const double * newObjective=NULL);
00400 int outDuplicateRows(int numberLook,int * whichRows, bool noOverlaps=false, double tolerance=-1.0,
00401 double cleanUp=0.0);
00404 double moveTowardsPrimalFeasible();
00407 void removeSuperBasicSlacks(int threshold=0);
00420 ClpSimplex * miniPresolve(char * rowType, char * columnType,void ** info);
00422 void miniPostsolve(const ClpSimplex * presolvedModel,void * info);
00437 int writeBasis(const char *filename,
00438 bool writeValues = false,
00439 int formatType = 0) const;
00442 int readBasis(const char *filename);
00444 CoinWarmStartBasis * getBasis() const;
00446 void setFactorization( ClpFactorization & factorization);
00447
00448 ClpFactorization * swapFactorization( ClpFactorization * factorization);
00450 void copyFactorization( ClpFactorization & factorization);
00460 int tightenPrimalBounds(double factor = 0.0, int doTight = 0, bool tightIntegers = false);
00477 int crash(double gap, int pivot);
00479 void setDualRowPivotAlgorithm(ClpDualRowPivot & choice);
00481 void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot & choice);
00490 int strongBranching(int numberVariables, const int * variables,
00491 double * newLower, double * newUpper,
00492 double ** outputSolution,
00493 int * outputStatus, int * outputIterations,
00494 bool stopOnFirstInfeasible = true,
00495 bool alwaysFinish = false,
00496 int startFinishOptions = 0);
00498 int fathom(void * stuff);
00504 int fathomMany(void * stuff);
00506 double doubleCheck();
00508 int startFastDual2(ClpNodeStuff * stuff);
00510 int fastDual2(ClpNodeStuff * stuff);
00512 void stopFastDual2(ClpNodeStuff * stuff);
00519 ClpSimplex * fastCrunch(ClpNodeStuff * stuff, int mode);
00521
00529 int pivot();
00530
00536 int primalPivotResult();
00537
00543 int dualPivotResultPart1();
00547 int pivotResultPart2(int algorithm,int state);
00548
00560 int startup(int ifValuesPass, int startFinishOptions = 0);
00561 void finish(int startFinishOptions = 0);
00562
00564 bool statusOfProblem(bool initial = false);
00566 void defaultFactorizationFrequency();
00568 void copyEnabledStuff(const ClpSimplex * rhs);
00570
00573
00574 inline bool primalFeasible() const {
00575 return (numberPrimalInfeasibilities_ == 0);
00576 }
00578 inline bool dualFeasible() const {
00579 return (numberDualInfeasibilities_ == 0);
00580 }
00582 inline ClpFactorization * factorization() const {
00583 return factorization_;
00584 }
00586 bool sparseFactorization() const;
00587 void setSparseFactorization(bool value);
00589 int factorizationFrequency() const;
00590 void setFactorizationFrequency(int value);
00592 inline double dualBound() const {
00593 return dualBound_;
00594 }
00595 void setDualBound(double value);
00597 inline double infeasibilityCost() const {
00598 return infeasibilityCost_;
00599 }
00600 void setInfeasibilityCost(double value);
00617 inline int perturbation() const {
00618 return perturbation_;
00619 }
00620 void setPerturbation(int value);
00622 inline int algorithm() const {
00623 return algorithm_;
00624 }
00626 inline void setAlgorithm(int value) {
00627 algorithm_ = value;
00628 }
00630 bool isObjectiveLimitTestValid() const ;
00632 inline double sumDualInfeasibilities() const {
00633 return sumDualInfeasibilities_;
00634 }
00635 inline void setSumDualInfeasibilities(double value) {
00636 sumDualInfeasibilities_ = value;
00637 }
00639 inline double sumOfRelaxedDualInfeasibilities() const {
00640 return sumOfRelaxedDualInfeasibilities_;
00641 }
00642 inline void setSumOfRelaxedDualInfeasibilities(double value) {
00643 sumOfRelaxedDualInfeasibilities_ = value;
00644 }
00646 inline int numberDualInfeasibilities() const {
00647 return numberDualInfeasibilities_;
00648 }
00649 inline void setNumberDualInfeasibilities(int value) {
00650 numberDualInfeasibilities_ = value;
00651 }
00653 inline int numberDualInfeasibilitiesWithoutFree() const {
00654 return numberDualInfeasibilitiesWithoutFree_;
00655 }
00657 inline double sumPrimalInfeasibilities() const {
00658 return sumPrimalInfeasibilities_;
00659 }
00660 inline void setSumPrimalInfeasibilities(double value) {
00661 sumPrimalInfeasibilities_ = value;
00662 }
00664 inline double sumOfRelaxedPrimalInfeasibilities() const {
00665 return sumOfRelaxedPrimalInfeasibilities_;
00666 }
00667 inline void setSumOfRelaxedPrimalInfeasibilities(double value) {
00668 sumOfRelaxedPrimalInfeasibilities_ = value;
00669 }
00671 inline int numberPrimalInfeasibilities() const {
00672 return numberPrimalInfeasibilities_;
00673 }
00674 inline void setNumberPrimalInfeasibilities(int value) {
00675 numberPrimalInfeasibilities_ = value;
00676 }
00683 int saveModel(const char * fileName);
00686 int restoreModel(const char * fileName);
00687
00695 void checkSolution(int setToBounds = 0);
00698 void checkSolutionInternal();
00700 void checkUnscaledSolution();
00702 inline CoinIndexedVector * rowArray(int index) const {
00703 return rowArray_[index];
00704 }
00706 inline CoinIndexedVector * columnArray(int index) const {
00707 return columnArray_[index];
00708 }
00710
00711
00717 int getSolution ( const double * rowActivities,
00718 const double * columnActivities);
00722 int getSolution ();
00729 int createPiecewiseLinearCosts(const int * starts,
00730 const double * lower, const double * gradient);
00732 inline ClpDualRowPivot * dualRowPivot() const {
00733 return dualRowPivot_;
00734 }
00736 inline ClpPrimalColumnPivot * primalColumnPivot() const {
00737 return primalColumnPivot_;
00738 }
00740 inline bool goodAccuracy() const {
00741 return (largestPrimalError_ < 1.0e-7 && largestDualError_ < 1.0e-7);
00742 }
00744 void returnModel(ClpSimplex & otherModel);
00752 int internalFactorize(int solveType);
00754 ClpDataSave saveData() ;
00756 void restoreData(ClpDataSave saved);
00758 void cleanStatus();
00760 int factorize();
00763 void computeDuals(double * givenDjs);
00765 void computePrimals ( const double * rowActivities,
00766 const double * columnActivities);
00768 void add(double * array,
00769 int column, double multiplier) const;
00775 void unpack(CoinIndexedVector * rowArray) const ;
00781 void unpack(CoinIndexedVector * rowArray, int sequence) const;
00788 void unpackPacked(CoinIndexedVector * rowArray) ;
00795 void unpackPacked(CoinIndexedVector * rowArray, int sequence);
00796 #ifndef CLP_USER_DRIVEN
00797 protected:
00798 #endif
00799
00803 int housekeeping(double objectiveChange);
00806 void checkPrimalSolution(const double * rowActivities = NULL,
00807 const double * columnActivies = NULL);
00810 void checkDualSolution();
00812 void checkBothSolutions();
00817 double scaleObjective(double value);
00819 int solveDW(CoinStructuredModel * model);
00821 int solveBenders(CoinStructuredModel * model);
00822 public:
00833 void setValuesPassAction(double incomingInfeasibility,
00834 double allowedInfeasibility);
00837 int cleanFactorization(int ifValuesPass);
00839
00841 public:
00843 inline double alphaAccuracy() const {
00844 return alphaAccuracy_;
00845 }
00846 inline void setAlphaAccuracy(double value) {
00847 alphaAccuracy_ = value;
00848 }
00849 public:
00851
00852
00853
00855 inline void setDisasterHandler(ClpDisasterHandler * handler) {
00856 disasterArea_ = handler;
00857 }
00859 inline ClpDisasterHandler * disasterHandler() const {
00860 return disasterArea_;
00861 }
00863 inline double largeValue() const {
00864 return largeValue_;
00865 }
00866 void setLargeValue( double value) ;
00868 inline double largestPrimalError() const {
00869 return largestPrimalError_;
00870 }
00872 inline double largestDualError() const {
00873 return largestDualError_;
00874 }
00876 inline void setLargestPrimalError(double value) {
00877 largestPrimalError_ = value;
00878 }
00880 inline void setLargestDualError(double value) {
00881 largestDualError_ = value;
00882 }
00884 inline double zeroTolerance() const {
00885 return zeroTolerance_;
00886 }
00888 inline void setZeroTolerance( double value) {
00889 zeroTolerance_ = value;
00890 }
00892 inline int * pivotVariable() const {
00893 return pivotVariable_;
00894 }
00896 inline bool automaticScaling() const {
00897 return automaticScale_ != 0;
00898 }
00899 inline void setAutomaticScaling(bool onOff) {
00900 automaticScale_ = onOff ? 1 : 0;
00901 }
00903 inline double currentDualTolerance() const {
00904 return dualTolerance_;
00905 }
00906 inline void setCurrentDualTolerance(double value) {
00907 dualTolerance_ = value;
00908 }
00910 inline double currentPrimalTolerance() const {
00911 return primalTolerance_;
00912 }
00913 inline void setCurrentPrimalTolerance(double value) {
00914 primalTolerance_ = value;
00915 }
00917 inline int numberRefinements() const {
00918 return numberRefinements_;
00919 }
00920 void setNumberRefinements( int value) ;
00922 inline double alpha() const {
00923 return alpha_;
00924 }
00925 inline void setAlpha(double value) {
00926 alpha_ = value;
00927 }
00929 inline double dualIn() const {
00930 return dualIn_;
00931 }
00933 inline void setDualIn(double value) {
00934 dualIn_ = value;
00935 }
00937 inline int pivotRow() const {
00938 return pivotRow_;
00939 }
00940 inline void setPivotRow(int value) {
00941 pivotRow_ = value;
00942 }
00944 double valueIncomingDual() const;
00946
00947 #ifndef CLP_USER_DRIVEN
00948 protected:
00949 #endif
00950
00955 int gutsOfSolution ( double * givenDuals,
00956 const double * givenPrimals,
00957 bool valuesPass = false);
00959 void gutsOfDelete(int type);
00961 void gutsOfCopy(const ClpSimplex & rhs);
00973 bool createRim(int what, bool makeRowCopy = false, int startFinishOptions = 0);
00975 void createRim1(bool initial);
00977 void createRim4(bool initial);
00979 void createRim5(bool initial);
00984 void deleteRim(int getRidOfFactorizationData = 2);
00986 bool sanityCheck();
00988 public:
00993 inline double * solutionRegion(int section) const {
00994 if (!section) return rowActivityWork_;
00995 else return columnActivityWork_;
00996 }
00997 inline double * djRegion(int section) const {
00998 if (!section) return rowReducedCost_;
00999 else return reducedCostWork_;
01000 }
01001 inline double * lowerRegion(int section) const {
01002 if (!section) return rowLowerWork_;
01003 else return columnLowerWork_;
01004 }
01005 inline double * upperRegion(int section) const {
01006 if (!section) return rowUpperWork_;
01007 else return columnUpperWork_;
01008 }
01009 inline double * costRegion(int section) const {
01010 if (!section) return rowObjectiveWork_;
01011 else return objectiveWork_;
01012 }
01014 inline double * solutionRegion() const {
01015 return solution_;
01016 }
01017 inline double * djRegion() const {
01018 return dj_;
01019 }
01020 inline double * lowerRegion() const {
01021 return lower_;
01022 }
01023 inline double * upperRegion() const {
01024 return upper_;
01025 }
01026 inline double * costRegion() const {
01027 return cost_;
01028 }
01029 inline Status getStatus(int sequence) const {
01030 return static_cast<Status> (status_[sequence] & 7);
01031 }
01032 inline void setStatus(int sequence, Status newstatus) {
01033 unsigned char & st_byte = status_[sequence];
01034 st_byte = static_cast<unsigned char>(st_byte & ~7);
01035 st_byte = static_cast<unsigned char>(st_byte | newstatus);
01036 }
01038 bool startPermanentArrays();
01043 void setInitialDenseFactorization(bool onOff);
01044 bool initialDenseFactorization() const;
01046 inline int sequenceIn() const {
01047 return sequenceIn_;
01048 }
01049 inline int sequenceOut() const {
01050 return sequenceOut_;
01051 }
01053 inline void setSequenceIn(int sequence) {
01054 sequenceIn_ = sequence;
01055 }
01056 inline void setSequenceOut(int sequence) {
01057 sequenceOut_ = sequence;
01058 }
01060 inline int directionIn() const {
01061 return directionIn_;
01062 }
01063 inline int directionOut() const {
01064 return directionOut_;
01065 }
01067 inline void setDirectionIn(int direction) {
01068 directionIn_ = direction;
01069 }
01070 inline void setDirectionOut(int direction) {
01071 directionOut_ = direction;
01072 }
01074 inline double valueOut() const {
01075 return valueOut_;
01076 }
01078 inline void setValueOut(double value) {
01079 valueOut_ = value;
01080 }
01082 inline double dualOut() const {
01083 return dualOut_;
01084 }
01086 inline void setDualOut(double value) {
01087 dualOut_ = value;
01088 }
01090 inline void setLowerOut(double value) {
01091 lowerOut_ = value;
01092 }
01094 inline void setUpperOut(double value) {
01095 upperOut_ = value;
01096 }
01098 inline void setTheta(double value) {
01099 theta_ = value;
01100 }
01102 inline int isColumn(int sequence) const {
01103 return sequence < numberColumns_ ? 1 : 0;
01104 }
01106 inline int sequenceWithin(int sequence) const {
01107 return sequence < numberColumns_ ? sequence : sequence - numberColumns_;
01108 }
01110 inline double solution(int sequence) {
01111 return solution_[sequence];
01112 }
01114 inline double & solutionAddress(int sequence) {
01115 return solution_[sequence];
01116 }
01117 inline double reducedCost(int sequence) {
01118 return dj_[sequence];
01119 }
01120 inline double & reducedCostAddress(int sequence) {
01121 return dj_[sequence];
01122 }
01123 inline double lower(int sequence) {
01124 return lower_[sequence];
01125 }
01127 inline double & lowerAddress(int sequence) {
01128 return lower_[sequence];
01129 }
01130 inline double upper(int sequence) {
01131 return upper_[sequence];
01132 }
01134 inline double & upperAddress(int sequence) {
01135 return upper_[sequence];
01136 }
01137 inline double cost(int sequence) {
01138 return cost_[sequence];
01139 }
01141 inline double & costAddress(int sequence) {
01142 return cost_[sequence];
01143 }
01145 inline double originalLower(int iSequence) const {
01146 if (iSequence < numberColumns_) return columnLower_[iSequence];
01147 else
01148 return rowLower_[iSequence-numberColumns_];
01149 }
01151 inline double originalUpper(int iSequence) const {
01152 if (iSequence < numberColumns_) return columnUpper_[iSequence];
01153 else
01154 return rowUpper_[iSequence-numberColumns_];
01155 }
01157 inline double theta() const {
01158 return theta_;
01159 }
01162 inline double bestPossibleImprovement() const {
01163 return bestPossibleImprovement_;
01164 }
01166 inline ClpNonLinearCost * nonLinearCost() const {
01167 return nonLinearCost_;
01168 }
01188 inline int moreSpecialOptions() const {
01189 return moreSpecialOptions_;
01190 }
01212 inline void setMoreSpecialOptions(int value) {
01213 moreSpecialOptions_ = value;
01214 }
01216
01218 inline void setFakeBound(int sequence, FakeBound fakeBound) {
01219 unsigned char & st_byte = status_[sequence];
01220 st_byte = static_cast<unsigned char>(st_byte & ~24);
01221 st_byte = static_cast<unsigned char>(st_byte | (fakeBound << 3));
01222 }
01223 inline FakeBound getFakeBound(int sequence) const {
01224 return static_cast<FakeBound> ((status_[sequence] >> 3) & 3);
01225 }
01226 inline void setRowStatus(int sequence, Status newstatus) {
01227 unsigned char & st_byte = status_[sequence+numberColumns_];
01228 st_byte = static_cast<unsigned char>(st_byte & ~7);
01229 st_byte = static_cast<unsigned char>(st_byte | newstatus);
01230 }
01231 inline Status getRowStatus(int sequence) const {
01232 return static_cast<Status> (status_[sequence+numberColumns_] & 7);
01233 }
01234 inline void setColumnStatus(int sequence, Status newstatus) {
01235 unsigned char & st_byte = status_[sequence];
01236 st_byte = static_cast<unsigned char>(st_byte & ~7);
01237 st_byte = static_cast<unsigned char>(st_byte | newstatus);
01238 }
01239 inline Status getColumnStatus(int sequence) const {
01240 return static_cast<Status> (status_[sequence] & 7);
01241 }
01242 inline void setPivoted( int sequence) {
01243 status_[sequence] = static_cast<unsigned char>(status_[sequence] | 32);
01244 }
01245 inline void clearPivoted( int sequence) {
01246 status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~32);
01247 }
01248 inline bool pivoted(int sequence) const {
01249 return (((status_[sequence] >> 5) & 1) != 0);
01250 }
01252 void setFlagged( int sequence);
01253 inline void clearFlagged( int sequence) {
01254 status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64);
01255 }
01256 inline bool flagged(int sequence) const {
01257 return ((status_[sequence] & 64) != 0);
01258 }
01260 inline void setActive( int iRow) {
01261 status_[iRow] = static_cast<unsigned char>(status_[iRow] | 128);
01262 }
01263 inline void clearActive( int iRow) {
01264 status_[iRow] = static_cast<unsigned char>(status_[iRow] & ~128);
01265 }
01266 inline bool active(int iRow) const {
01267 return ((status_[iRow] & 128) != 0);
01268 }
01271 void createStatus() ;
01274 void allSlackBasis(bool resetSolution = false);
01275
01277 inline int lastBadIteration() const {
01278 return lastBadIteration_;
01279 }
01281 inline void setLastBadIteration(int value) {
01282 lastBadIteration_=value;
01283 }
01285 inline int progressFlag() const {
01286 return (progressFlag_ & 3);
01287 }
01289 inline ClpSimplexProgress * progress()
01290 { return &progress_;}
01292 inline int forceFactorization() const {
01293 return forceFactorization_ ;
01294 }
01296 inline void forceFactorization(int value) {
01297 forceFactorization_ = value;
01298 }
01300 inline double rawObjectiveValue() const {
01301 return objectiveValue_;
01302 }
01304 void computeObjectiveValue(bool useWorkingSolution = false);
01306 double computeInternalObjectiveValue();
01309 double * infeasibilityRay(bool fullRay=false) const;
01313 inline int numberExtraRows() const {
01314 return numberExtraRows_;
01315 }
01318 inline int maximumBasic() const {
01319 return maximumBasic_;
01320 }
01322 inline int baseIteration() const {
01323 return baseIteration_;
01324 }
01326 void generateCpp( FILE * fp, bool defaultFactor = false);
01328 ClpFactorization * getEmptyFactorization();
01330 void setEmptyFactorization();
01332 void moveInfo(const ClpSimplex & rhs, bool justStatus = false);
01334
01336
01337
01338
01340 void getBInvARow(int row, double* z, double * slack = NULL);
01341
01343 void getBInvRow(int row, double* z);
01344
01346 void getBInvACol(int col, double* vec);
01347
01349 void getBInvCol(int col, double* vec);
01350
01355 void getBasics(int* index);
01356
01358
01362 void setObjectiveCoefficient( int elementIndex, double elementValue );
01364 inline void setObjCoeff( int elementIndex, double elementValue ) {
01365 setObjectiveCoefficient( elementIndex, elementValue);
01366 }
01367
01370 void setColumnLower( int elementIndex, double elementValue );
01371
01374 void setColumnUpper( int elementIndex, double elementValue );
01375
01377 void setColumnBounds( int elementIndex,
01378 double lower, double upper );
01379
01388 void setColumnSetBounds(const int* indexFirst,
01389 const int* indexLast,
01390 const double* boundList);
01391
01394 inline void setColLower( int elementIndex, double elementValue ) {
01395 setColumnLower(elementIndex, elementValue);
01396 }
01399 inline void setColUpper( int elementIndex, double elementValue ) {
01400 setColumnUpper(elementIndex, elementValue);
01401 }
01402
01404 inline void setColBounds( int elementIndex,
01405 double newlower, double newupper ) {
01406 setColumnBounds(elementIndex, newlower, newupper);
01407 }
01408
01415 inline void setColSetBounds(const int* indexFirst,
01416 const int* indexLast,
01417 const double* boundList) {
01418 setColumnSetBounds(indexFirst, indexLast, boundList);
01419 }
01420
01423 void setRowLower( int elementIndex, double elementValue );
01424
01427 void setRowUpper( int elementIndex, double elementValue ) ;
01428
01430 void setRowBounds( int elementIndex,
01431 double lower, double upper ) ;
01432
01439 void setRowSetBounds(const int* indexFirst,
01440 const int* indexLast,
01441 const double* boundList);
01443 void resize (int newNumberRows, int newNumberColumns);
01444
01446
01448 protected:
01449
01458 double bestPossibleImprovement_;
01460 double zeroTolerance_;
01462 int columnPrimalSequence_;
01464 int rowPrimalSequence_;
01466 double bestObjectiveValue_;
01468 int moreSpecialOptions_;
01470 int baseIteration_;
01472 double primalToleranceToGetOptimal_;
01474 double largeValue_;
01476 double largestPrimalError_;
01478 double largestDualError_;
01480 double alphaAccuracy_;
01482 double dualBound_;
01484 double alpha_;
01486 double theta_;
01488 double lowerIn_;
01490 double valueIn_;
01492 double upperIn_;
01494 double dualIn_;
01496 double lowerOut_;
01498 double valueOut_;
01500 double upperOut_;
01502 double dualOut_;
01504 double dualTolerance_;
01506 double primalTolerance_;
01508 double sumDualInfeasibilities_;
01510 double sumPrimalInfeasibilities_;
01512 double infeasibilityCost_;
01514 double sumOfRelaxedDualInfeasibilities_;
01516 double sumOfRelaxedPrimalInfeasibilities_;
01518 double acceptablePivot_;
01520 double * lower_;
01522 double * rowLowerWork_;
01524 double * columnLowerWork_;
01526 double * upper_;
01528 double * rowUpperWork_;
01530 double * columnUpperWork_;
01532 double * cost_;
01534 double * rowObjectiveWork_;
01536 double * objectiveWork_;
01538 CoinIndexedVector * rowArray_[6];
01540 CoinIndexedVector * columnArray_[6];
01542 int sequenceIn_;
01544 int directionIn_;
01546 int sequenceOut_;
01548 int directionOut_;
01550 int pivotRow_;
01552 int lastGoodIteration_;
01554 double * dj_;
01556 double * rowReducedCost_;
01558 double * reducedCostWork_;
01560 double * solution_;
01562 double * rowActivityWork_;
01564 double * columnActivityWork_;
01566 int numberDualInfeasibilities_;
01568 int numberDualInfeasibilitiesWithoutFree_;
01570 int numberPrimalInfeasibilities_;
01572 int numberRefinements_;
01574 ClpDualRowPivot * dualRowPivot_;
01576 ClpPrimalColumnPivot * primalColumnPivot_;
01578 int * pivotVariable_;
01580 ClpFactorization * factorization_;
01582 double * savedSolution_;
01584 int numberTimesOptimal_;
01586 ClpDisasterHandler * disasterArea_;
01588 int changeMade_;
01590 int algorithm_;
01593 int forceFactorization_;
01601 int perturbation_;
01603 unsigned char * saveStatus_;
01608 ClpNonLinearCost * nonLinearCost_;
01610 int lastBadIteration_;
01612 int lastFlaggedIteration_;
01614 int numberFake_;
01616 int numberChanged_;
01618 int progressFlag_;
01620 int firstFree_;
01624 int numberExtraRows_;
01627 int maximumBasic_;
01629 int dontFactorizePivots_;
01639 double incomingInfeasibility_;
01640 double allowedInfeasibility_;
01642 int automaticScale_;
01644 int maximumPerturbationSize_;
01646 double * perturbationArray_;
01648 ClpSimplex * baseModel_;
01650 ClpSimplexProgress progress_;
01651 #ifdef ABC_INHERIT
01652 AbcSimplex * abcSimplex_;
01653 #define CLP_ABC_WANTED 1
01654 #define CLP_ABC_WANTED_PARALLEL 2
01655 #define CLP_ABC_FULL_DONE 8
01656
01657 #endif
01658 #define CLP_ABC_BEEN_FEASIBLE 65536
01659 int abcState_;
01660 public:
01662 mutable int spareIntArray_[4];
01664 mutable double spareDoubleArray_[4];
01665 protected:
01667 friend class OsiClpSolverInterface;
01669 };
01670
01679 void
01680 ClpSimplexUnitTest(const std::string & mpsDir);
01681
01682
01683 #define DEVEX_TRY_NORM 1.0e-4
01684 #define DEVEX_ADD_ONE 1.0
01685 #endif