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 class ClpDualRowPivot;
00020 class ClpPrimalColumnPivot;
00021 class ClpFactorization;
00022 class CoinIndexedVector;
00023 class ClpNonLinearCost;
00024 class ClpNodeStuff;
00025 class CoinStructuredModel;
00026 class OsiClpSolverInterface;
00027 class CoinWarmStartBasis;
00028 class ClpDisasterHandler;
00029 class ClpConstraint;
00030 #include "AbcCommon.hpp"
00031 #ifdef CLP_HAS_ABC
00032 class AbcTolerancesEtc;
00033 class AbcSimplex;
00034 #include "CoinAbcCommon.hpp"
00035 #endif
00036
00054 class ClpSimplex : public ClpModel {
00055 friend void ClpSimplexUnitTest(const std::string & mpsDir);
00056
00057 public:
00062 enum Status {
00063 isFree = 0x00,
00064 basic = 0x01,
00065 atUpperBound = 0x02,
00066 atLowerBound = 0x03,
00067 superBasic = 0x04,
00068 isFixed = 0x05
00069 };
00070
00071 enum FakeBound {
00072 noFake = 0x00,
00073 lowerFake = 0x01,
00074 upperFake = 0x02,
00075 bothFake = 0x03
00076 };
00077
00080
00081 ClpSimplex (bool emptyMessages = false );
00082
00087 ClpSimplex(const ClpSimplex & rhs, int scalingMode = -1);
00092 ClpSimplex(const ClpModel & rhs, int scalingMode = -1);
00099 ClpSimplex (const ClpModel * wholeModel,
00100 int numberRows, const int * whichRows,
00101 int numberColumns, const int * whichColumns,
00102 bool dropNames = true, bool dropIntegers = true,
00103 bool fixOthers = false);
00110 ClpSimplex (const ClpSimplex * wholeModel,
00111 int numberRows, const int * whichRows,
00112 int numberColumns, const int * whichColumns,
00113 bool dropNames = true, bool dropIntegers = true,
00114 bool fixOthers = false);
00118 ClpSimplex (ClpSimplex * wholeModel,
00119 int numberColumns, const int * whichColumns);
00122 void originalModel(ClpSimplex * miniModel);
00123 inline int abcState() const
00124 { return abcState_;}
00125 inline void setAbcState(int state)
00126 { abcState_=state;}
00127 #ifdef ABC_INHERIT
00128 inline AbcSimplex * abcSimplex() const
00129 { return abcSimplex_;}
00130 inline void setAbcSimplex(AbcSimplex * simplex)
00131 { abcSimplex_=simplex;}
00133 int doAbcDual();
00135 int doAbcPrimal(int ifValuesPass);
00136 #endif
00137
00142 void setPersistenceFlag(int value);
00144 void makeBaseModel();
00146 void deleteBaseModel();
00148 inline ClpSimplex * baseModel() const {
00149 return baseModel_;
00150 }
00154 void setToBaseModel(ClpSimplex * model = NULL);
00156 ClpSimplex & operator=(const ClpSimplex & rhs);
00158 ~ClpSimplex ( );
00159
00171 void loadProblem ( const ClpMatrixBase& matrix,
00172 const double* collb, const double* colub,
00173 const double* obj,
00174 const double* rowlb, const double* rowub,
00175 const double * rowObjective = NULL);
00176 void loadProblem ( const CoinPackedMatrix& matrix,
00177 const double* collb, const double* colub,
00178 const double* obj,
00179 const double* rowlb, const double* rowub,
00180 const double * rowObjective = NULL);
00181
00184 void loadProblem ( const int numcols, const int numrows,
00185 const CoinBigIndex* start, const int* index,
00186 const double* value,
00187 const double* collb, const double* colub,
00188 const double* obj,
00189 const double* rowlb, const double* rowub,
00190 const double * rowObjective = NULL);
00192 void loadProblem ( const int numcols, const int numrows,
00193 const CoinBigIndex* start, const int* index,
00194 const double* value, const int * length,
00195 const double* collb, const double* colub,
00196 const double* obj,
00197 const double* rowlb, const double* rowub,
00198 const double * rowObjective = NULL);
00203 int loadProblem ( CoinModel & modelObject, bool keepSolution = false);
00205 int readMps(const char *filename,
00206 bool keepNames = false,
00207 bool ignoreErrors = false);
00209 int readGMPL(const char *filename, const char * dataName,
00210 bool keepNames = false);
00213 int readLp(const char *filename, const double epsilon = 1e-5);
00218 void borrowModel(ClpModel & otherModel);
00219 void borrowModel(ClpSimplex & otherModel);
00221 void passInEventHandler(const ClpEventHandler * eventHandler);
00223 void getbackSolution(const ClpSimplex & smallModel, const int * whichRow, const int * whichColumn);
00232 int loadNonLinear(void * info, int & numberConstraints,
00233 ClpConstraint ** & constraints);
00234 #ifdef ABC_INHERIT
00235
00236 void loadTolerancesEtc(const AbcTolerancesEtc & data);
00238 void unloadTolerancesEtc(AbcTolerancesEtc & data);
00239 #endif
00240
00241
00247 int initialSolve(ClpSolve & options);
00249 int initialSolve();
00251 int initialDualSolve();
00253 int initialPrimalSolve();
00255 int initialBarrierSolve();
00257 int initialBarrierNoCrossSolve();
00268 int dual(int ifValuesPass = 0, int startFinishOptions = 0);
00269
00270 int dualDebug(int ifValuesPass = 0, int startFinishOptions = 0);
00281 int primal(int ifValuesPass = 0, int startFinishOptions = 0);
00287 int nonlinearSLP(int numberPasses, double deltaTolerance);
00293 int nonlinearSLP(int numberConstraints, ClpConstraint ** constraints,
00294 int numberPasses, double deltaTolerance);
00297 int barrier(bool crossover = true);
00300 int reducedGradient(int phase = 0);
00302 int solve(CoinStructuredModel * model);
00303 #ifdef ABC_INHERIT
00304
00308 void dealWithAbc(int solveType,int startUp,bool interrupt=false);
00309 #endif
00310
00316 int loadProblem ( CoinStructuredModel & modelObject,
00317 bool originalOrder = true, bool keepSolution = false);
00332 int cleanup(int cleanupScaling);
00353 int dualRanging(int numberCheck, const int * which,
00354 double * costIncrease, int * sequenceIncrease,
00355 double * costDecrease, int * sequenceDecrease,
00356 double * valueIncrease = NULL, double * valueDecrease = NULL);
00371 int primalRanging(int numberCheck, const int * which,
00372 double * valueIncrease, int * sequenceIncrease,
00373 double * valueDecrease, int * sequenceDecrease);
00383 int modifyCoefficientsAndPivot(int number,
00384 const int * which,
00385 const CoinBigIndex * start,
00386 const int * row,
00387 const double * newCoefficient,
00388 const unsigned char * newStatus=NULL,
00389 const double * newLower=NULL,
00390 const double * newUpper=NULL,
00391 const double * newObjective=NULL);
00399 int outDuplicateRows(int numberLook,int * whichRows, bool noOverlaps=false, double tolerance=-1.0,
00400 double cleanUp=0.0);
00403 double moveTowardsPrimalFeasible();
00406 void removeSuperBasicSlacks(int threshold=0);
00419 ClpSimplex * miniPresolve(char * rowType, char * columnType,void ** info);
00421 void miniPostsolve(const ClpSimplex * presolvedModel,void * info);
00436 int writeBasis(const char *filename,
00437 bool writeValues = false,
00438 int formatType = 0) const;
00441 int readBasis(const char *filename);
00443 CoinWarmStartBasis * getBasis() const;
00445 void setFactorization( ClpFactorization & factorization);
00446
00447 ClpFactorization * swapFactorization( ClpFactorization * factorization);
00449 void copyFactorization( ClpFactorization & factorization);
00459 int tightenPrimalBounds(double factor = 0.0, int doTight = 0, bool tightIntegers = false);
00476 int crash(double gap, int pivot);
00478 void setDualRowPivotAlgorithm(ClpDualRowPivot & choice);
00480 void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot & choice);
00489 int strongBranching(int numberVariables, const int * variables,
00490 double * newLower, double * newUpper,
00491 double ** outputSolution,
00492 int * outputStatus, int * outputIterations,
00493 bool stopOnFirstInfeasible = true,
00494 bool alwaysFinish = false,
00495 int startFinishOptions = 0);
00497 int fathom(void * stuff);
00503 int fathomMany(void * stuff);
00505 double doubleCheck();
00507 int startFastDual2(ClpNodeStuff * stuff);
00509 int fastDual2(ClpNodeStuff * stuff);
00511 void stopFastDual2(ClpNodeStuff * stuff);
00518 ClpSimplex * fastCrunch(ClpNodeStuff * stuff, int mode);
00520
00528 int pivot();
00529
00535 int primalPivotResult();
00536
00542 int dualPivotResultPart1();
00546 int pivotResultPart2(int algorithm,int state);
00547
00559 int startup(int ifValuesPass, int startFinishOptions = 0);
00560 void finish(int startFinishOptions = 0);
00561
00563 bool statusOfProblem(bool initial = false);
00565 void defaultFactorizationFrequency();
00567
00570
00571 inline bool primalFeasible() const {
00572 return (numberPrimalInfeasibilities_ == 0);
00573 }
00575 inline bool dualFeasible() const {
00576 return (numberDualInfeasibilities_ == 0);
00577 }
00579 inline ClpFactorization * factorization() const {
00580 return factorization_;
00581 }
00583 bool sparseFactorization() const;
00584 void setSparseFactorization(bool value);
00586 int factorizationFrequency() const;
00587 void setFactorizationFrequency(int value);
00589 inline double dualBound() const {
00590 return dualBound_;
00591 }
00592 void setDualBound(double value);
00594 inline double infeasibilityCost() const {
00595 return infeasibilityCost_;
00596 }
00597 void setInfeasibilityCost(double value);
00614 inline int perturbation() const {
00615 return perturbation_;
00616 }
00617 void setPerturbation(int value);
00619 inline int algorithm() const {
00620 return algorithm_;
00621 }
00623 inline void setAlgorithm(int value) {
00624 algorithm_ = value;
00625 }
00627 bool isObjectiveLimitTestValid() const ;
00629 inline double sumDualInfeasibilities() const {
00630 return sumDualInfeasibilities_;
00631 }
00632 inline void setSumDualInfeasibilities(double value) {
00633 sumDualInfeasibilities_ = value;
00634 }
00636 inline double sumOfRelaxedDualInfeasibilities() const {
00637 return sumOfRelaxedDualInfeasibilities_;
00638 }
00639 inline void setSumOfRelaxedDualInfeasibilities(double value) {
00640 sumOfRelaxedDualInfeasibilities_ = value;
00641 }
00643 inline int numberDualInfeasibilities() const {
00644 return numberDualInfeasibilities_;
00645 }
00646 inline void setNumberDualInfeasibilities(int value) {
00647 numberDualInfeasibilities_ = value;
00648 }
00650 inline int numberDualInfeasibilitiesWithoutFree() const {
00651 return numberDualInfeasibilitiesWithoutFree_;
00652 }
00654 inline double sumPrimalInfeasibilities() const {
00655 return sumPrimalInfeasibilities_;
00656 }
00657 inline void setSumPrimalInfeasibilities(double value) {
00658 sumPrimalInfeasibilities_ = value;
00659 }
00661 inline double sumOfRelaxedPrimalInfeasibilities() const {
00662 return sumOfRelaxedPrimalInfeasibilities_;
00663 }
00664 inline void setSumOfRelaxedPrimalInfeasibilities(double value) {
00665 sumOfRelaxedPrimalInfeasibilities_ = value;
00666 }
00668 inline int numberPrimalInfeasibilities() const {
00669 return numberPrimalInfeasibilities_;
00670 }
00671 inline void setNumberPrimalInfeasibilities(int value) {
00672 numberPrimalInfeasibilities_ = value;
00673 }
00680 int saveModel(const char * fileName);
00683 int restoreModel(const char * fileName);
00684
00692 void checkSolution(int setToBounds = 0);
00695 void checkSolutionInternal();
00697 void checkUnscaledSolution();
00699 inline CoinIndexedVector * rowArray(int index) const {
00700 return rowArray_[index];
00701 }
00703 inline CoinIndexedVector * columnArray(int index) const {
00704 return columnArray_[index];
00705 }
00707
00708
00714 int getSolution ( const double * rowActivities,
00715 const double * columnActivities);
00719 int getSolution ();
00726 int createPiecewiseLinearCosts(const int * starts,
00727 const double * lower, const double * gradient);
00729 inline ClpDualRowPivot * dualRowPivot() const {
00730 return dualRowPivot_;
00731 }
00733 inline ClpPrimalColumnPivot * primalColumnPivot() const {
00734 return primalColumnPivot_;
00735 }
00737 inline bool goodAccuracy() const {
00738 return (largestPrimalError_ < 1.0e-7 && largestDualError_ < 1.0e-7);
00739 }
00741 void returnModel(ClpSimplex & otherModel);
00749 int internalFactorize(int solveType);
00751 ClpDataSave saveData() ;
00753 void restoreData(ClpDataSave saved);
00755 void cleanStatus();
00757 int factorize();
00760 void computeDuals(double * givenDjs);
00762 void computePrimals ( const double * rowActivities,
00763 const double * columnActivities);
00765 void add(double * array,
00766 int column, double multiplier) const;
00772 void unpack(CoinIndexedVector * rowArray) const ;
00778 void unpack(CoinIndexedVector * rowArray, int sequence) const;
00785 void unpackPacked(CoinIndexedVector * rowArray) ;
00792 void unpackPacked(CoinIndexedVector * rowArray, int sequence);
00793 #ifndef CLP_USER_DRIVEN
00794 protected:
00795 #endif
00796
00800 int housekeeping(double objectiveChange);
00803 void checkPrimalSolution(const double * rowActivities = NULL,
00804 const double * columnActivies = NULL);
00807 void checkDualSolution();
00809 void checkBothSolutions();
00814 double scaleObjective(double value);
00816 int solveDW(CoinStructuredModel * model);
00818 int solveBenders(CoinStructuredModel * model);
00819 public:
00830 void setValuesPassAction(double incomingInfeasibility,
00831 double allowedInfeasibility);
00834 int cleanFactorization(int ifValuesPass);
00836
00838 public:
00840 inline double alphaAccuracy() const {
00841 return alphaAccuracy_;
00842 }
00843 inline void setAlphaAccuracy(double value) {
00844 alphaAccuracy_ = value;
00845 }
00846 public:
00848
00849
00850
00852 inline void setDisasterHandler(ClpDisasterHandler * handler) {
00853 disasterArea_ = handler;
00854 }
00856 inline ClpDisasterHandler * disasterHandler() const {
00857 return disasterArea_;
00858 }
00860 inline double largeValue() const {
00861 return largeValue_;
00862 }
00863 void setLargeValue( double value) ;
00865 inline double largestPrimalError() const {
00866 return largestPrimalError_;
00867 }
00869 inline double largestDualError() const {
00870 return largestDualError_;
00871 }
00873 inline void setLargestPrimalError(double value) {
00874 largestPrimalError_ = value;
00875 }
00877 inline void setLargestDualError(double value) {
00878 largestDualError_ = value;
00879 }
00881 inline double zeroTolerance() const {
00882 return zeroTolerance_;
00883 }
00885 inline void setZeroTolerance( double value) {
00886 zeroTolerance_ = value;
00887 }
00889 inline int * pivotVariable() const {
00890 return pivotVariable_;
00891 }
00893 inline bool automaticScaling() const {
00894 return automaticScale_ != 0;
00895 }
00896 inline void setAutomaticScaling(bool onOff) {
00897 automaticScale_ = onOff ? 1 : 0;
00898 }
00900 inline double currentDualTolerance() const {
00901 return dualTolerance_;
00902 }
00903 inline void setCurrentDualTolerance(double value) {
00904 dualTolerance_ = value;
00905 }
00907 inline double currentPrimalTolerance() const {
00908 return primalTolerance_;
00909 }
00910 inline void setCurrentPrimalTolerance(double value) {
00911 primalTolerance_ = value;
00912 }
00914 inline int numberRefinements() const {
00915 return numberRefinements_;
00916 }
00917 void setNumberRefinements( int value) ;
00919 inline double alpha() const {
00920 return alpha_;
00921 }
00922 inline void setAlpha(double value) {
00923 alpha_ = value;
00924 }
00926 inline double dualIn() const {
00927 return dualIn_;
00928 }
00930 inline void setDualIn(double value) {
00931 dualIn_ = value;
00932 }
00934 inline int pivotRow() const {
00935 return pivotRow_;
00936 }
00937 inline void setPivotRow(int value) {
00938 pivotRow_ = value;
00939 }
00941 double valueIncomingDual() const;
00943
00944 #ifndef CLP_USER_DRIVEN
00945 protected:
00946 #endif
00947
00952 int gutsOfSolution ( double * givenDuals,
00953 const double * givenPrimals,
00954 bool valuesPass = false);
00956 void gutsOfDelete(int type);
00958 void gutsOfCopy(const ClpSimplex & rhs);
00970 bool createRim(int what, bool makeRowCopy = false, int startFinishOptions = 0);
00972 void createRim1(bool initial);
00974 void createRim4(bool initial);
00976 void createRim5(bool initial);
00981 void deleteRim(int getRidOfFactorizationData = 2);
00983 bool sanityCheck();
00985 public:
00990 inline double * solutionRegion(int section) const {
00991 if (!section) return rowActivityWork_;
00992 else return columnActivityWork_;
00993 }
00994 inline double * djRegion(int section) const {
00995 if (!section) return rowReducedCost_;
00996 else return reducedCostWork_;
00997 }
00998 inline double * lowerRegion(int section) const {
00999 if (!section) return rowLowerWork_;
01000 else return columnLowerWork_;
01001 }
01002 inline double * upperRegion(int section) const {
01003 if (!section) return rowUpperWork_;
01004 else return columnUpperWork_;
01005 }
01006 inline double * costRegion(int section) const {
01007 if (!section) return rowObjectiveWork_;
01008 else return objectiveWork_;
01009 }
01011 inline double * solutionRegion() const {
01012 return solution_;
01013 }
01014 inline double * djRegion() const {
01015 return dj_;
01016 }
01017 inline double * lowerRegion() const {
01018 return lower_;
01019 }
01020 inline double * upperRegion() const {
01021 return upper_;
01022 }
01023 inline double * costRegion() const {
01024 return cost_;
01025 }
01026 inline Status getStatus(int sequence) const {
01027 return static_cast<Status> (status_[sequence] & 7);
01028 }
01029 inline void setStatus(int sequence, Status newstatus) {
01030 unsigned char & st_byte = status_[sequence];
01031 st_byte = static_cast<unsigned char>(st_byte & ~7);
01032 st_byte = static_cast<unsigned char>(st_byte | newstatus);
01033 }
01035 bool startPermanentArrays();
01040 void setInitialDenseFactorization(bool onOff);
01041 bool initialDenseFactorization() const;
01043 inline int sequenceIn() const {
01044 return sequenceIn_;
01045 }
01046 inline int sequenceOut() const {
01047 return sequenceOut_;
01048 }
01050 inline void setSequenceIn(int sequence) {
01051 sequenceIn_ = sequence;
01052 }
01053 inline void setSequenceOut(int sequence) {
01054 sequenceOut_ = sequence;
01055 }
01057 inline int directionIn() const {
01058 return directionIn_;
01059 }
01060 inline int directionOut() const {
01061 return directionOut_;
01062 }
01064 inline void setDirectionIn(int direction) {
01065 directionIn_ = direction;
01066 }
01067 inline void setDirectionOut(int direction) {
01068 directionOut_ = direction;
01069 }
01071 inline double valueOut() const {
01072 return valueOut_;
01073 }
01075 inline void setValueOut(double value) {
01076 valueOut_ = value;
01077 }
01079 inline double dualOut() const {
01080 return dualOut_;
01081 }
01083 inline void setDualOut(double value) {
01084 dualOut_ = value;
01085 }
01087 inline void setLowerOut(double value) {
01088 lowerOut_ = value;
01089 }
01091 inline void setUpperOut(double value) {
01092 upperOut_ = value;
01093 }
01095 inline void setTheta(double value) {
01096 theta_ = value;
01097 }
01099 inline int isColumn(int sequence) const {
01100 return sequence < numberColumns_ ? 1 : 0;
01101 }
01103 inline int sequenceWithin(int sequence) const {
01104 return sequence < numberColumns_ ? sequence : sequence - numberColumns_;
01105 }
01107 inline double solution(int sequence) {
01108 return solution_[sequence];
01109 }
01111 inline double & solutionAddress(int sequence) {
01112 return solution_[sequence];
01113 }
01114 inline double reducedCost(int sequence) {
01115 return dj_[sequence];
01116 }
01117 inline double & reducedCostAddress(int sequence) {
01118 return dj_[sequence];
01119 }
01120 inline double lower(int sequence) {
01121 return lower_[sequence];
01122 }
01124 inline double & lowerAddress(int sequence) {
01125 return lower_[sequence];
01126 }
01127 inline double upper(int sequence) {
01128 return upper_[sequence];
01129 }
01131 inline double & upperAddress(int sequence) {
01132 return upper_[sequence];
01133 }
01134 inline double cost(int sequence) {
01135 return cost_[sequence];
01136 }
01138 inline double & costAddress(int sequence) {
01139 return cost_[sequence];
01140 }
01142 inline double originalLower(int iSequence) const {
01143 if (iSequence < numberColumns_) return columnLower_[iSequence];
01144 else
01145 return rowLower_[iSequence-numberColumns_];
01146 }
01148 inline double originalUpper(int iSequence) const {
01149 if (iSequence < numberColumns_) return columnUpper_[iSequence];
01150 else
01151 return rowUpper_[iSequence-numberColumns_];
01152 }
01154 inline double theta() const {
01155 return theta_;
01156 }
01159 inline double bestPossibleImprovement() const {
01160 return bestPossibleImprovement_;
01161 }
01163 inline ClpNonLinearCost * nonLinearCost() const {
01164 return nonLinearCost_;
01165 }
01186 inline int moreSpecialOptions() const {
01187 return moreSpecialOptions_;
01188 }
01206 inline void setMoreSpecialOptions(int value) {
01207 moreSpecialOptions_ = value;
01208 }
01210
01212 inline void setFakeBound(int sequence, FakeBound fakeBound) {
01213 unsigned char & st_byte = status_[sequence];
01214 st_byte = static_cast<unsigned char>(st_byte & ~24);
01215 st_byte = static_cast<unsigned char>(st_byte | (fakeBound << 3));
01216 }
01217 inline FakeBound getFakeBound(int sequence) const {
01218 return static_cast<FakeBound> ((status_[sequence] >> 3) & 3);
01219 }
01220 inline void setRowStatus(int sequence, Status newstatus) {
01221 unsigned char & st_byte = status_[sequence+numberColumns_];
01222 st_byte = static_cast<unsigned char>(st_byte & ~7);
01223 st_byte = static_cast<unsigned char>(st_byte | newstatus);
01224 }
01225 inline Status getRowStatus(int sequence) const {
01226 return static_cast<Status> (status_[sequence+numberColumns_] & 7);
01227 }
01228 inline void setColumnStatus(int sequence, Status newstatus) {
01229 unsigned char & st_byte = status_[sequence];
01230 st_byte = static_cast<unsigned char>(st_byte & ~7);
01231 st_byte = static_cast<unsigned char>(st_byte | newstatus);
01232 }
01233 inline Status getColumnStatus(int sequence) const {
01234 return static_cast<Status> (status_[sequence] & 7);
01235 }
01236 inline void setPivoted( int sequence) {
01237 status_[sequence] = static_cast<unsigned char>(status_[sequence] | 32);
01238 }
01239 inline void clearPivoted( int sequence) {
01240 status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~32);
01241 }
01242 inline bool pivoted(int sequence) const {
01243 return (((status_[sequence] >> 5) & 1) != 0);
01244 }
01246 void setFlagged( int sequence);
01247 inline void clearFlagged( int sequence) {
01248 status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64);
01249 }
01250 inline bool flagged(int sequence) const {
01251 return ((status_[sequence] & 64) != 0);
01252 }
01254 inline void setActive( int iRow) {
01255 status_[iRow] = static_cast<unsigned char>(status_[iRow] | 128);
01256 }
01257 inline void clearActive( int iRow) {
01258 status_[iRow] = static_cast<unsigned char>(status_[iRow] & ~128);
01259 }
01260 inline bool active(int iRow) const {
01261 return ((status_[iRow] & 128) != 0);
01262 }
01265 void createStatus() ;
01268 void allSlackBasis(bool resetSolution = false);
01269
01271 inline int lastBadIteration() const {
01272 return lastBadIteration_;
01273 }
01275 inline void setLastBadIteration(int value) {
01276 lastBadIteration_=value;
01277 }
01279 inline int progressFlag() const {
01280 return (progressFlag_ & 3);
01281 }
01283 inline ClpSimplexProgress * progress()
01284 { return &progress_;}
01286 inline int forceFactorization() const {
01287 return forceFactorization_ ;
01288 }
01290 inline void forceFactorization(int value) {
01291 forceFactorization_ = value;
01292 }
01294 inline double rawObjectiveValue() const {
01295 return objectiveValue_;
01296 }
01298 void computeObjectiveValue(bool useWorkingSolution = false);
01300 double computeInternalObjectiveValue();
01304 inline int numberExtraRows() const {
01305 return numberExtraRows_;
01306 }
01309 inline int maximumBasic() const {
01310 return maximumBasic_;
01311 }
01313 inline int baseIteration() const {
01314 return baseIteration_;
01315 }
01317 void generateCpp( FILE * fp, bool defaultFactor = false);
01319 ClpFactorization * getEmptyFactorization();
01321 void setEmptyFactorization();
01323 void moveInfo(const ClpSimplex & rhs, bool justStatus = false);
01325
01327
01328
01329
01331 void getBInvARow(int row, double* z, double * slack = NULL);
01332
01334 void getBInvRow(int row, double* z);
01335
01337 void getBInvACol(int col, double* vec);
01338
01340 void getBInvCol(int col, double* vec);
01341
01346 void getBasics(int* index);
01347
01349
01353 void setObjectiveCoefficient( int elementIndex, double elementValue );
01355 inline void setObjCoeff( int elementIndex, double elementValue ) {
01356 setObjectiveCoefficient( elementIndex, elementValue);
01357 }
01358
01361 void setColumnLower( int elementIndex, double elementValue );
01362
01365 void setColumnUpper( int elementIndex, double elementValue );
01366
01368 void setColumnBounds( int elementIndex,
01369 double lower, double upper );
01370
01379 void setColumnSetBounds(const int* indexFirst,
01380 const int* indexLast,
01381 const double* boundList);
01382
01385 inline void setColLower( int elementIndex, double elementValue ) {
01386 setColumnLower(elementIndex, elementValue);
01387 }
01390 inline void setColUpper( int elementIndex, double elementValue ) {
01391 setColumnUpper(elementIndex, elementValue);
01392 }
01393
01395 inline void setColBounds( int elementIndex,
01396 double newlower, double newupper ) {
01397 setColumnBounds(elementIndex, newlower, newupper);
01398 }
01399
01406 inline void setColSetBounds(const int* indexFirst,
01407 const int* indexLast,
01408 const double* boundList) {
01409 setColumnSetBounds(indexFirst, indexLast, boundList);
01410 }
01411
01414 void setRowLower( int elementIndex, double elementValue );
01415
01418 void setRowUpper( int elementIndex, double elementValue ) ;
01419
01421 void setRowBounds( int elementIndex,
01422 double lower, double upper ) ;
01423
01430 void setRowSetBounds(const int* indexFirst,
01431 const int* indexLast,
01432 const double* boundList);
01434 void resize (int newNumberRows, int newNumberColumns);
01435
01437
01439 protected:
01440
01449 double bestPossibleImprovement_;
01451 double zeroTolerance_;
01453 int columnPrimalSequence_;
01455 int rowPrimalSequence_;
01457 double bestObjectiveValue_;
01459 int moreSpecialOptions_;
01461 int baseIteration_;
01463 double primalToleranceToGetOptimal_;
01465 double largeValue_;
01467 double largestPrimalError_;
01469 double largestDualError_;
01471 double alphaAccuracy_;
01473 double dualBound_;
01475 double alpha_;
01477 double theta_;
01479 double lowerIn_;
01481 double valueIn_;
01483 double upperIn_;
01485 double dualIn_;
01487 double lowerOut_;
01489 double valueOut_;
01491 double upperOut_;
01493 double dualOut_;
01495 double dualTolerance_;
01497 double primalTolerance_;
01499 double sumDualInfeasibilities_;
01501 double sumPrimalInfeasibilities_;
01503 double infeasibilityCost_;
01505 double sumOfRelaxedDualInfeasibilities_;
01507 double sumOfRelaxedPrimalInfeasibilities_;
01509 double acceptablePivot_;
01511 double * lower_;
01513 double * rowLowerWork_;
01515 double * columnLowerWork_;
01517 double * upper_;
01519 double * rowUpperWork_;
01521 double * columnUpperWork_;
01523 double * cost_;
01525 double * rowObjectiveWork_;
01527 double * objectiveWork_;
01529 CoinIndexedVector * rowArray_[6];
01531 CoinIndexedVector * columnArray_[6];
01533 int sequenceIn_;
01535 int directionIn_;
01537 int sequenceOut_;
01539 int directionOut_;
01541 int pivotRow_;
01543 int lastGoodIteration_;
01545 double * dj_;
01547 double * rowReducedCost_;
01549 double * reducedCostWork_;
01551 double * solution_;
01553 double * rowActivityWork_;
01555 double * columnActivityWork_;
01557 int numberDualInfeasibilities_;
01559 int numberDualInfeasibilitiesWithoutFree_;
01561 int numberPrimalInfeasibilities_;
01563 int numberRefinements_;
01565 ClpDualRowPivot * dualRowPivot_;
01567 ClpPrimalColumnPivot * primalColumnPivot_;
01569 int * pivotVariable_;
01571 ClpFactorization * factorization_;
01573 double * savedSolution_;
01575 int numberTimesOptimal_;
01577 ClpDisasterHandler * disasterArea_;
01579 int changeMade_;
01581 int algorithm_;
01584 int forceFactorization_;
01592 int perturbation_;
01594 unsigned char * saveStatus_;
01599 ClpNonLinearCost * nonLinearCost_;
01601 int lastBadIteration_;
01603 int lastFlaggedIteration_;
01605 int numberFake_;
01607 int numberChanged_;
01609 int progressFlag_;
01611 int firstFree_;
01615 int numberExtraRows_;
01618 int maximumBasic_;
01620 int dontFactorizePivots_;
01630 double incomingInfeasibility_;
01631 double allowedInfeasibility_;
01633 int automaticScale_;
01635 int maximumPerturbationSize_;
01637 double * perturbationArray_;
01639 ClpSimplex * baseModel_;
01641 ClpSimplexProgress progress_;
01642 #ifdef ABC_INHERIT
01643 AbcSimplex * abcSimplex_;
01644 #define CLP_ABC_WANTED 1
01645 #define CLP_ABC_WANTED_PARALLEL 2
01646 #define CLP_ABC_FULL_DONE 8
01647
01648 #endif
01649 #define CLP_ABC_BEEN_FEASIBLE 65536
01650 int abcState_;
01651 public:
01653 mutable int spareIntArray_[4];
01655 mutable double spareDoubleArray_[4];
01656 protected:
01658 friend class OsiClpSolverInterface;
01660 };
01661
01670 void
01671 ClpSimplexUnitTest(const std::string & mpsDir);
01672
01673
01674 #define DEVEX_TRY_NORM 1.0e-4
01675 #define DEVEX_ADD_ONE 1.0
01676 #endif