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
00571
00572 inline bool primalFeasible() const {
00573 return (numberPrimalInfeasibilities_ == 0);
00574 }
00576 inline bool dualFeasible() const {
00577 return (numberDualInfeasibilities_ == 0);
00578 }
00580 inline ClpFactorization * factorization() const {
00581 return factorization_;
00582 }
00584 bool sparseFactorization() const;
00585 void setSparseFactorization(bool value);
00587 int factorizationFrequency() const;
00588 void setFactorizationFrequency(int value);
00590 inline double dualBound() const {
00591 return dualBound_;
00592 }
00593 void setDualBound(double value);
00595 inline double infeasibilityCost() const {
00596 return infeasibilityCost_;
00597 }
00598 void setInfeasibilityCost(double value);
00615 inline int perturbation() const {
00616 return perturbation_;
00617 }
00618 void setPerturbation(int value);
00620 inline int algorithm() const {
00621 return algorithm_;
00622 }
00624 inline void setAlgorithm(int value) {
00625 algorithm_ = value;
00626 }
00628 bool isObjectiveLimitTestValid() const ;
00630 inline double sumDualInfeasibilities() const {
00631 return sumDualInfeasibilities_;
00632 }
00633 inline void setSumDualInfeasibilities(double value) {
00634 sumDualInfeasibilities_ = value;
00635 }
00637 inline double sumOfRelaxedDualInfeasibilities() const {
00638 return sumOfRelaxedDualInfeasibilities_;
00639 }
00640 inline void setSumOfRelaxedDualInfeasibilities(double value) {
00641 sumOfRelaxedDualInfeasibilities_ = value;
00642 }
00644 inline int numberDualInfeasibilities() const {
00645 return numberDualInfeasibilities_;
00646 }
00647 inline void setNumberDualInfeasibilities(int value) {
00648 numberDualInfeasibilities_ = value;
00649 }
00651 inline int numberDualInfeasibilitiesWithoutFree() const {
00652 return numberDualInfeasibilitiesWithoutFree_;
00653 }
00655 inline double sumPrimalInfeasibilities() const {
00656 return sumPrimalInfeasibilities_;
00657 }
00658 inline void setSumPrimalInfeasibilities(double value) {
00659 sumPrimalInfeasibilities_ = value;
00660 }
00662 inline double sumOfRelaxedPrimalInfeasibilities() const {
00663 return sumOfRelaxedPrimalInfeasibilities_;
00664 }
00665 inline void setSumOfRelaxedPrimalInfeasibilities(double value) {
00666 sumOfRelaxedPrimalInfeasibilities_ = value;
00667 }
00669 inline int numberPrimalInfeasibilities() const {
00670 return numberPrimalInfeasibilities_;
00671 }
00672 inline void setNumberPrimalInfeasibilities(int value) {
00673 numberPrimalInfeasibilities_ = value;
00674 }
00681 int saveModel(const char * fileName);
00684 int restoreModel(const char * fileName);
00685
00693 void checkSolution(int setToBounds = 0);
00696 void checkSolutionInternal();
00698 void checkUnscaledSolution();
00700 inline CoinIndexedVector * rowArray(int index) const {
00701 return rowArray_[index];
00702 }
00704 inline CoinIndexedVector * columnArray(int index) const {
00705 return columnArray_[index];
00706 }
00708
00709
00715 int getSolution ( const double * rowActivities,
00716 const double * columnActivities);
00720 int getSolution ();
00727 int createPiecewiseLinearCosts(const int * starts,
00728 const double * lower, const double * gradient);
00730 inline ClpDualRowPivot * dualRowPivot() const {
00731 return dualRowPivot_;
00732 }
00734 inline ClpPrimalColumnPivot * primalColumnPivot() const {
00735 return primalColumnPivot_;
00736 }
00738 inline bool goodAccuracy() const {
00739 return (largestPrimalError_ < 1.0e-7 && largestDualError_ < 1.0e-7);
00740 }
00742 void returnModel(ClpSimplex & otherModel);
00750 int internalFactorize(int solveType);
00752 ClpDataSave saveData() ;
00754 void restoreData(ClpDataSave saved);
00756 void cleanStatus();
00758 int factorize();
00761 void computeDuals(double * givenDjs);
00763 void computePrimals ( const double * rowActivities,
00764 const double * columnActivities);
00766 void add(double * array,
00767 int column, double multiplier) const;
00773 void unpack(CoinIndexedVector * rowArray) const ;
00779 void unpack(CoinIndexedVector * rowArray, int sequence) const;
00786 void unpackPacked(CoinIndexedVector * rowArray) ;
00793 void unpackPacked(CoinIndexedVector * rowArray, int sequence);
00794 #ifndef CLP_USER_DRIVEN
00795 protected:
00796 #endif
00797
00801 int housekeeping(double objectiveChange);
00804 void checkPrimalSolution(const double * rowActivities = NULL,
00805 const double * columnActivies = NULL);
00808 void checkDualSolution();
00810 void checkBothSolutions();
00815 double scaleObjective(double value);
00817 int solveDW(CoinStructuredModel * model);
00819 int solveBenders(CoinStructuredModel * model);
00820 public:
00831 void setValuesPassAction(double incomingInfeasibility,
00832 double allowedInfeasibility);
00835 int cleanFactorization(int ifValuesPass);
00837
00839 public:
00841 inline double alphaAccuracy() const {
00842 return alphaAccuracy_;
00843 }
00844 inline void setAlphaAccuracy(double value) {
00845 alphaAccuracy_ = value;
00846 }
00847 public:
00849
00850
00851
00853 inline void setDisasterHandler(ClpDisasterHandler * handler) {
00854 disasterArea_ = handler;
00855 }
00857 inline ClpDisasterHandler * disasterHandler() const {
00858 return disasterArea_;
00859 }
00861 inline double largeValue() const {
00862 return largeValue_;
00863 }
00864 void setLargeValue( double value) ;
00866 inline double largestPrimalError() const {
00867 return largestPrimalError_;
00868 }
00870 inline double largestDualError() const {
00871 return largestDualError_;
00872 }
00874 inline void setLargestPrimalError(double value) {
00875 largestPrimalError_ = value;
00876 }
00878 inline void setLargestDualError(double value) {
00879 largestDualError_ = value;
00880 }
00882 inline double zeroTolerance() const {
00883 return zeroTolerance_;
00884 }
00886 inline void setZeroTolerance( double value) {
00887 zeroTolerance_ = value;
00888 }
00890 inline int * pivotVariable() const {
00891 return pivotVariable_;
00892 }
00894 inline bool automaticScaling() const {
00895 return automaticScale_ != 0;
00896 }
00897 inline void setAutomaticScaling(bool onOff) {
00898 automaticScale_ = onOff ? 1 : 0;
00899 }
00901 inline double currentDualTolerance() const {
00902 return dualTolerance_;
00903 }
00904 inline void setCurrentDualTolerance(double value) {
00905 dualTolerance_ = value;
00906 }
00908 inline double currentPrimalTolerance() const {
00909 return primalTolerance_;
00910 }
00911 inline void setCurrentPrimalTolerance(double value) {
00912 primalTolerance_ = value;
00913 }
00915 inline int numberRefinements() const {
00916 return numberRefinements_;
00917 }
00918 void setNumberRefinements( int value) ;
00920 inline double alpha() const {
00921 return alpha_;
00922 }
00923 inline void setAlpha(double value) {
00924 alpha_ = value;
00925 }
00927 inline double dualIn() const {
00928 return dualIn_;
00929 }
00931 inline void setDualIn(double value) {
00932 dualIn_ = value;
00933 }
00935 inline int pivotRow() const {
00936 return pivotRow_;
00937 }
00938 inline void setPivotRow(int value) {
00939 pivotRow_ = value;
00940 }
00942 double valueIncomingDual() const;
00944
00945 #ifndef CLP_USER_DRIVEN
00946 protected:
00947 #endif
00948
00953 int gutsOfSolution ( double * givenDuals,
00954 const double * givenPrimals,
00955 bool valuesPass = false);
00957 void gutsOfDelete(int type);
00959 void gutsOfCopy(const ClpSimplex & rhs);
00971 bool createRim(int what, bool makeRowCopy = false, int startFinishOptions = 0);
00973 void createRim1(bool initial);
00975 void createRim4(bool initial);
00977 void createRim5(bool initial);
00982 void deleteRim(int getRidOfFactorizationData = 2);
00984 bool sanityCheck();
00986 public:
00991 inline double * solutionRegion(int section) const {
00992 if (!section) return rowActivityWork_;
00993 else return columnActivityWork_;
00994 }
00995 inline double * djRegion(int section) const {
00996 if (!section) return rowReducedCost_;
00997 else return reducedCostWork_;
00998 }
00999 inline double * lowerRegion(int section) const {
01000 if (!section) return rowLowerWork_;
01001 else return columnLowerWork_;
01002 }
01003 inline double * upperRegion(int section) const {
01004 if (!section) return rowUpperWork_;
01005 else return columnUpperWork_;
01006 }
01007 inline double * costRegion(int section) const {
01008 if (!section) return rowObjectiveWork_;
01009 else return objectiveWork_;
01010 }
01012 inline double * solutionRegion() const {
01013 return solution_;
01014 }
01015 inline double * djRegion() const {
01016 return dj_;
01017 }
01018 inline double * lowerRegion() const {
01019 return lower_;
01020 }
01021 inline double * upperRegion() const {
01022 return upper_;
01023 }
01024 inline double * costRegion() const {
01025 return cost_;
01026 }
01027 inline Status getStatus(int sequence) const {
01028 return static_cast<Status> (status_[sequence] & 7);
01029 }
01030 inline void setStatus(int sequence, Status newstatus) {
01031 unsigned char & st_byte = status_[sequence];
01032 st_byte = static_cast<unsigned char>(st_byte & ~7);
01033 st_byte = static_cast<unsigned char>(st_byte | newstatus);
01034 }
01036 bool startPermanentArrays();
01041 void setInitialDenseFactorization(bool onOff);
01042 bool initialDenseFactorization() const;
01044 inline int sequenceIn() const {
01045 return sequenceIn_;
01046 }
01047 inline int sequenceOut() const {
01048 return sequenceOut_;
01049 }
01051 inline void setSequenceIn(int sequence) {
01052 sequenceIn_ = sequence;
01053 }
01054 inline void setSequenceOut(int sequence) {
01055 sequenceOut_ = sequence;
01056 }
01058 inline int directionIn() const {
01059 return directionIn_;
01060 }
01061 inline int directionOut() const {
01062 return directionOut_;
01063 }
01065 inline void setDirectionIn(int direction) {
01066 directionIn_ = direction;
01067 }
01068 inline void setDirectionOut(int direction) {
01069 directionOut_ = direction;
01070 }
01072 inline double valueOut() const {
01073 return valueOut_;
01074 }
01076 inline void setValueOut(double value) {
01077 valueOut_ = value;
01078 }
01080 inline double dualOut() const {
01081 return dualOut_;
01082 }
01084 inline void setDualOut(double value) {
01085 dualOut_ = value;
01086 }
01088 inline void setLowerOut(double value) {
01089 lowerOut_ = value;
01090 }
01092 inline void setUpperOut(double value) {
01093 upperOut_ = value;
01094 }
01096 inline void setTheta(double value) {
01097 theta_ = value;
01098 }
01100 inline int isColumn(int sequence) const {
01101 return sequence < numberColumns_ ? 1 : 0;
01102 }
01104 inline int sequenceWithin(int sequence) const {
01105 return sequence < numberColumns_ ? sequence : sequence - numberColumns_;
01106 }
01108 inline double solution(int sequence) {
01109 return solution_[sequence];
01110 }
01112 inline double & solutionAddress(int sequence) {
01113 return solution_[sequence];
01114 }
01115 inline double reducedCost(int sequence) {
01116 return dj_[sequence];
01117 }
01118 inline double & reducedCostAddress(int sequence) {
01119 return dj_[sequence];
01120 }
01121 inline double lower(int sequence) {
01122 return lower_[sequence];
01123 }
01125 inline double & lowerAddress(int sequence) {
01126 return lower_[sequence];
01127 }
01128 inline double upper(int sequence) {
01129 return upper_[sequence];
01130 }
01132 inline double & upperAddress(int sequence) {
01133 return upper_[sequence];
01134 }
01135 inline double cost(int sequence) {
01136 return cost_[sequence];
01137 }
01139 inline double & costAddress(int sequence) {
01140 return cost_[sequence];
01141 }
01143 inline double originalLower(int iSequence) const {
01144 if (iSequence < numberColumns_) return columnLower_[iSequence];
01145 else
01146 return rowLower_[iSequence-numberColumns_];
01147 }
01149 inline double originalUpper(int iSequence) const {
01150 if (iSequence < numberColumns_) return columnUpper_[iSequence];
01151 else
01152 return rowUpper_[iSequence-numberColumns_];
01153 }
01155 inline double theta() const {
01156 return theta_;
01157 }
01160 inline double bestPossibleImprovement() const {
01161 return bestPossibleImprovement_;
01162 }
01164 inline ClpNonLinearCost * nonLinearCost() const {
01165 return nonLinearCost_;
01166 }
01187 inline int moreSpecialOptions() const {
01188 return moreSpecialOptions_;
01189 }
01207 inline void setMoreSpecialOptions(int value) {
01208 moreSpecialOptions_ = value;
01209 }
01211
01213 inline void setFakeBound(int sequence, FakeBound fakeBound) {
01214 unsigned char & st_byte = status_[sequence];
01215 st_byte = static_cast<unsigned char>(st_byte & ~24);
01216 st_byte = static_cast<unsigned char>(st_byte | (fakeBound << 3));
01217 }
01218 inline FakeBound getFakeBound(int sequence) const {
01219 return static_cast<FakeBound> ((status_[sequence] >> 3) & 3);
01220 }
01221 inline void setRowStatus(int sequence, Status newstatus) {
01222 unsigned char & st_byte = status_[sequence+numberColumns_];
01223 st_byte = static_cast<unsigned char>(st_byte & ~7);
01224 st_byte = static_cast<unsigned char>(st_byte | newstatus);
01225 }
01226 inline Status getRowStatus(int sequence) const {
01227 return static_cast<Status> (status_[sequence+numberColumns_] & 7);
01228 }
01229 inline void setColumnStatus(int sequence, Status newstatus) {
01230 unsigned char & st_byte = status_[sequence];
01231 st_byte = static_cast<unsigned char>(st_byte & ~7);
01232 st_byte = static_cast<unsigned char>(st_byte | newstatus);
01233 }
01234 inline Status getColumnStatus(int sequence) const {
01235 return static_cast<Status> (status_[sequence] & 7);
01236 }
01237 inline void setPivoted( int sequence) {
01238 status_[sequence] = static_cast<unsigned char>(status_[sequence] | 32);
01239 }
01240 inline void clearPivoted( int sequence) {
01241 status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~32);
01242 }
01243 inline bool pivoted(int sequence) const {
01244 return (((status_[sequence] >> 5) & 1) != 0);
01245 }
01247 void setFlagged( int sequence);
01248 inline void clearFlagged( int sequence) {
01249 status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64);
01250 }
01251 inline bool flagged(int sequence) const {
01252 return ((status_[sequence] & 64) != 0);
01253 }
01255 inline void setActive( int iRow) {
01256 status_[iRow] = static_cast<unsigned char>(status_[iRow] | 128);
01257 }
01258 inline void clearActive( int iRow) {
01259 status_[iRow] = static_cast<unsigned char>(status_[iRow] & ~128);
01260 }
01261 inline bool active(int iRow) const {
01262 return ((status_[iRow] & 128) != 0);
01263 }
01266 void createStatus() ;
01269 void allSlackBasis(bool resetSolution = false);
01270
01272 inline int lastBadIteration() const {
01273 return lastBadIteration_;
01274 }
01276 inline void setLastBadIteration(int value) {
01277 lastBadIteration_=value;
01278 }
01280 inline int progressFlag() const {
01281 return (progressFlag_ & 3);
01282 }
01284 inline ClpSimplexProgress * progress()
01285 { return &progress_;}
01287 inline int forceFactorization() const {
01288 return forceFactorization_ ;
01289 }
01291 inline void forceFactorization(int value) {
01292 forceFactorization_ = value;
01293 }
01295 inline double rawObjectiveValue() const {
01296 return objectiveValue_;
01297 }
01299 void computeObjectiveValue(bool useWorkingSolution = false);
01301 double computeInternalObjectiveValue();
01305 inline int numberExtraRows() const {
01306 return numberExtraRows_;
01307 }
01310 inline int maximumBasic() const {
01311 return maximumBasic_;
01312 }
01314 inline int baseIteration() const {
01315 return baseIteration_;
01316 }
01318 void generateCpp( FILE * fp, bool defaultFactor = false);
01320 ClpFactorization * getEmptyFactorization();
01322 void setEmptyFactorization();
01324 void moveInfo(const ClpSimplex & rhs, bool justStatus = false);
01326
01328
01329
01330
01332 void getBInvARow(int row, double* z, double * slack = NULL);
01333
01335 void getBInvRow(int row, double* z);
01336
01338 void getBInvACol(int col, double* vec);
01339
01341 void getBInvCol(int col, double* vec);
01342
01347 void getBasics(int* index);
01348
01350
01354 void setObjectiveCoefficient( int elementIndex, double elementValue );
01356 inline void setObjCoeff( int elementIndex, double elementValue ) {
01357 setObjectiveCoefficient( elementIndex, elementValue);
01358 }
01359
01362 void setColumnLower( int elementIndex, double elementValue );
01363
01366 void setColumnUpper( int elementIndex, double elementValue );
01367
01369 void setColumnBounds( int elementIndex,
01370 double lower, double upper );
01371
01380 void setColumnSetBounds(const int* indexFirst,
01381 const int* indexLast,
01382 const double* boundList);
01383
01386 inline void setColLower( int elementIndex, double elementValue ) {
01387 setColumnLower(elementIndex, elementValue);
01388 }
01391 inline void setColUpper( int elementIndex, double elementValue ) {
01392 setColumnUpper(elementIndex, elementValue);
01393 }
01394
01396 inline void setColBounds( int elementIndex,
01397 double newlower, double newupper ) {
01398 setColumnBounds(elementIndex, newlower, newupper);
01399 }
01400
01407 inline void setColSetBounds(const int* indexFirst,
01408 const int* indexLast,
01409 const double* boundList) {
01410 setColumnSetBounds(indexFirst, indexLast, boundList);
01411 }
01412
01415 void setRowLower( int elementIndex, double elementValue );
01416
01419 void setRowUpper( int elementIndex, double elementValue ) ;
01420
01422 void setRowBounds( int elementIndex,
01423 double lower, double upper ) ;
01424
01431 void setRowSetBounds(const int* indexFirst,
01432 const int* indexLast,
01433 const double* boundList);
01435 void resize (int newNumberRows, int newNumberColumns);
01436
01438
01440 protected:
01441
01450 double bestPossibleImprovement_;
01452 double zeroTolerance_;
01454 int columnPrimalSequence_;
01456 int rowPrimalSequence_;
01458 double bestObjectiveValue_;
01460 int moreSpecialOptions_;
01462 int baseIteration_;
01464 double primalToleranceToGetOptimal_;
01466 double largeValue_;
01468 double largestPrimalError_;
01470 double largestDualError_;
01472 double alphaAccuracy_;
01474 double dualBound_;
01476 double alpha_;
01478 double theta_;
01480 double lowerIn_;
01482 double valueIn_;
01484 double upperIn_;
01486 double dualIn_;
01488 double lowerOut_;
01490 double valueOut_;
01492 double upperOut_;
01494 double dualOut_;
01496 double dualTolerance_;
01498 double primalTolerance_;
01500 double sumDualInfeasibilities_;
01502 double sumPrimalInfeasibilities_;
01504 double infeasibilityCost_;
01506 double sumOfRelaxedDualInfeasibilities_;
01508 double sumOfRelaxedPrimalInfeasibilities_;
01510 double acceptablePivot_;
01512 double * lower_;
01514 double * rowLowerWork_;
01516 double * columnLowerWork_;
01518 double * upper_;
01520 double * rowUpperWork_;
01522 double * columnUpperWork_;
01524 double * cost_;
01526 double * rowObjectiveWork_;
01528 double * objectiveWork_;
01530 CoinIndexedVector * rowArray_[6];
01532 CoinIndexedVector * columnArray_[6];
01534 int sequenceIn_;
01536 int directionIn_;
01538 int sequenceOut_;
01540 int directionOut_;
01542 int pivotRow_;
01544 int lastGoodIteration_;
01546 double * dj_;
01548 double * rowReducedCost_;
01550 double * reducedCostWork_;
01552 double * solution_;
01554 double * rowActivityWork_;
01556 double * columnActivityWork_;
01558 int numberDualInfeasibilities_;
01560 int numberDualInfeasibilitiesWithoutFree_;
01562 int numberPrimalInfeasibilities_;
01564 int numberRefinements_;
01566 ClpDualRowPivot * dualRowPivot_;
01568 ClpPrimalColumnPivot * primalColumnPivot_;
01570 int * pivotVariable_;
01572 ClpFactorization * factorization_;
01574 double * savedSolution_;
01576 int numberTimesOptimal_;
01578 ClpDisasterHandler * disasterArea_;
01580 int changeMade_;
01582 int algorithm_;
01585 int forceFactorization_;
01593 int perturbation_;
01595 unsigned char * saveStatus_;
01600 ClpNonLinearCost * nonLinearCost_;
01602 int lastBadIteration_;
01604 int lastFlaggedIteration_;
01606 int numberFake_;
01608 int numberChanged_;
01610 int progressFlag_;
01612 int firstFree_;
01616 int numberExtraRows_;
01619 int maximumBasic_;
01621 int dontFactorizePivots_;
01631 double incomingInfeasibility_;
01632 double allowedInfeasibility_;
01634 int automaticScale_;
01636 int maximumPerturbationSize_;
01638 double * perturbationArray_;
01640 ClpSimplex * baseModel_;
01642 ClpSimplexProgress progress_;
01643 #ifdef ABC_INHERIT
01644 AbcSimplex * abcSimplex_;
01645 #define CLP_ABC_WANTED 1
01646 #define CLP_ABC_WANTED_PARALLEL 2
01647 #define CLP_ABC_FULL_DONE 8
01648
01649 #endif
01650 #define CLP_ABC_BEEN_FEASIBLE 65536
01651 int abcState_;
01652 public:
01654 mutable int spareIntArray_[4];
01656 mutable double spareDoubleArray_[4];
01657 protected:
01659 friend class OsiClpSolverInterface;
01661 };
01662
01671 void
01672 ClpSimplexUnitTest(const std::string & mpsDir);
01673
01674
01675 #define DEVEX_TRY_NORM 1.0e-4
01676 #define DEVEX_ADD_ONE 1.0
01677 #endif