AbcSimplex.hpp

Go to the documentation of this file.
00001 /* $Id: AbcSimplex.hpp 2070 2014-11-18 11:12:54Z forrest $ */
00002 // Copyright (C) 2002, International Business Machines
00003 // Corporation and others, Copyright (C) 2012, FasterCoin.  All Rights Reserved.
00004 // This code is licensed under the terms of the Eclipse Public License (EPL).
00005 /*
00006   Authors
00007   
00008   John Forrest
00009   
00010 */
00011 #ifndef AbcSimplex_H
00012 #define AbcSimplex_H
00013 
00014 #include <iostream>
00015 #include <cfloat>
00016 #include "ClpModel.hpp"
00017 #include "ClpMatrixBase.hpp"
00018 #include "CoinIndexedVector.hpp"
00019 #include "AbcCommon.hpp"
00020 class AbcSimplex;
00021 #include "ClpSolve.hpp"
00022 #include "CoinAbcCommon.hpp"
00023 #include "ClpSimplex.hpp"
00024 class AbcDualRowPivot;
00025 class AbcPrimalColumnPivot;
00026 class AbcSimplexFactorization;
00027 class AbcNonLinearCost;
00028 class OsiAbcSolverInterface;
00029 class CoinWarmStartBasis;
00030 class ClpDisasterHandler;
00031 class AbcSimplexProgress;
00032 class AbcMatrix;
00033 class AbcTolerancesEtc;
00034 
00052 #define PAN
00053 #if ABC_NORMAL_DEBUG>0
00054 #define PRINT_PAN 1
00055 #endif
00056 #define TRY_ABC_GUS
00057 #define HEAVY_PERTURBATION 57
00058 #if ABC_PARALLEL==1
00059 // Use pthreads
00060 #include <pthread.h>
00061 #endif
00062 class AbcSimplex : public ClpSimplex {
00063   friend void AbcSimplexUnitTest(const std::string & mpsDir);
00064   
00065 public:
00074   enum Status {
00075     atLowerBound = 0x00, // so we can use bottom two bits to sort and swap signs
00076     atUpperBound = 0x01,
00077     isFree = 0x04,
00078     superBasic = 0x05,
00079     basic = 0x06,
00080     isFixed = 0x07
00081   };
00082   // For Dual
00083   enum FakeBound {
00084     noFake = 0x00,
00085     lowerFake = 0x01,
00086     upperFake = 0x02,
00087     bothFake = 0x03
00088   };
00089   
00092 
00093   AbcSimplex (bool emptyMessages = false  );
00094   
00097   AbcSimplex(const AbcSimplex & rhs);
00100   AbcSimplex(const ClpSimplex & rhs);
00107   AbcSimplex (const ClpSimplex * wholeModel,
00108               int numberRows, const int * whichRows,
00109               int numberColumns, const int * whichColumns,
00110               bool dropNames = true, bool dropIntegers = true,
00111               bool fixOthers = false);
00118   AbcSimplex (const AbcSimplex * wholeModel,
00119               int numberRows, const int * whichRows,
00120               int numberColumns, const int * whichColumns,
00121               bool dropNames = true, bool dropIntegers = true,
00122               bool fixOthers = false);
00126   AbcSimplex (AbcSimplex * wholeModel,
00127               int numberColumns, const int * whichColumns);
00130   void originalModel(AbcSimplex * miniModel);
00132   AbcSimplex (const ClpSimplex * clpSimplex);
00134   void putBackSolution(ClpSimplex * simplex);
00140   //void setPersistenceFlag(int value);
00142   void makeBaseModel();
00144   void deleteBaseModel();
00146   inline AbcSimplex *  baseModel() const {
00147     return abcBaseModel_;
00148   }
00152   void setToBaseModel(AbcSimplex * model = NULL);
00154   AbcSimplex & operator=(const AbcSimplex & rhs);
00156   ~AbcSimplex (  );
00158   
00163   int dual();
00164   int doAbcDual();
00167   int primal(int ifValuesPass);
00168   int doAbcPrimal(int ifValuesPass);
00170   CoinWarmStartBasis * getBasis() const;
00172   void setFactorization( AbcSimplexFactorization & factorization);
00174   AbcSimplexFactorization * swapFactorization( AbcSimplexFactorization * factorization);
00176   AbcSimplexFactorization * getEmptyFactorization();
00186   int tightenPrimalBounds();
00188   void setDualRowPivotAlgorithm(AbcDualRowPivot & choice);
00190   void setPrimalColumnPivotAlgorithm(AbcPrimalColumnPivot & choice);
00192 
00193   void defaultFactorizationFrequency();
00195   
00198 
00199   inline AbcSimplexFactorization * factorization() const {
00200     return reinterpret_cast<AbcSimplexFactorization *>(abcFactorization_);
00201   }
00202 #ifdef EARLY_FACTORIZE
00204   inline AbcSimplexFactorization * earlyFactorization() const {
00205     return reinterpret_cast<AbcSimplexFactorization *>(abcEarlyFactorization_);
00206   }
00207 #endif
00209   int factorizationFrequency() const;
00210   void setFactorizationFrequency(int value);
00212   inline int maximumAbcNumberRows() const
00213   { return maximumAbcNumberRows_;}
00215   inline int maximumNumberTotal() const
00216   { return maximumNumberTotal_;}
00217   inline int maximumTotal() const
00218   { return maximumNumberTotal_;}
00220   bool isObjectiveLimitTestValid() const ;
00222   inline int numberTotal() const
00223   { return numberTotal_;}
00225   inline int numberTotalWithoutFixed() const
00226   { return numberTotalWithoutFixed_;}
00228   inline CoinPartitionedVector * usefulArray(int index) {
00229     return & usefulArray_[index];
00230   }
00231   inline CoinPartitionedVector * usefulArray(int index) const {
00232     return const_cast<CoinPartitionedVector *>(&usefulArray_[index]);
00233   }
00235   
00236   /******************** End of most useful part **************/
00242   int getSolution ();
00244   void setClpSimplexObjectiveValue();
00250   void setupDualValuesPass(const double * fakeDuals,
00251                            const double * fakePrimals,
00252                            int type);
00254   inline double minimizationObjectiveValue() const
00255   { return objectiveValue_-dblParam_[ClpObjOffset];}
00257   inline double currentDualTolerance() const
00258   { return currentDualTolerance_;}
00259   inline void setCurrentDualTolerance(double value) {
00260     currentDualTolerance_ = value;
00261   }
00263   inline AbcNonLinearCost * abcNonLinearCost() const {
00264     return abcNonLinearCost_;
00265   }
00267   double * perturbationSaved() const
00268   { return perturbationSaved_;}
00270   inline double acceptablePivot() const
00271   { return acceptablePivot_;}
00273   inline int ordinaryVariables() const
00274   { return ordinaryVariables_;}
00276   inline int numberOrdinary() const
00277   { return numberOrdinary_;}
00279   inline void setNumberOrdinary(int number)
00280   { numberOrdinary_=number;}
00282   inline double currentDualBound() const
00283   { return currentDualBound_;}
00285   inline AbcDualRowPivot * dualRowPivot() const {
00286     return abcDualRowPivot_;
00287   }
00289   inline AbcPrimalColumnPivot * primalColumnPivot() const {
00290     return abcPrimalColumnPivot_;
00291   }
00293   inline AbcMatrix * abcMatrix() const     {
00294     return abcMatrix_;
00295   }
00305   int internalFactorize(int solveType);
00321   void permuteIn();
00323   void permuteBasis();
00325   void permuteOut(int whatsWanted);
00327   ClpDataSave saveData() ;
00329   void restoreData(ClpDataSave saved);
00331   void cleanStatus(bool valuesPass=false);
00334   int computeDuals(double * givenDjs, CoinIndexedVector * array1, CoinIndexedVector * array2);
00336   int computePrimals (CoinIndexedVector * array1, CoinIndexedVector * array2);
00338   void computeObjective ();
00340   void setMultipleSequenceIn(int sequenceIn[4]);
00345   inline void unpack(CoinIndexedVector & rowArray) const 
00346   {unpack(rowArray,sequenceIn_);}
00350   void unpack(CoinIndexedVector & rowArray, int sequence) const;
00355   int housekeeping(/*double objectiveChange*/);
00358   void checkPrimalSolution(bool justBasic);
00361   void checkDualSolution();
00364   void checkDualSolutionPlusFake();
00366   void checkBothSolutions();
00368   int gutsOfSolution(int type);
00370   int gutsOfPrimalSolution(int type);
00372   void saveGoodStatus();
00374   void restoreGoodStatus(int type);
00375 #define rowUseScale_ scaleFromExternal_
00376 #define inverseRowUseScale_ scaleToExternal_
00378   void refreshCosts();
00379   void refreshLower(unsigned int type=~(ROW_LOWER_SAME|COLUMN_UPPER_SAME));
00380   void refreshUpper(unsigned int type=~(ROW_LOWER_SAME|COLUMN_LOWER_SAME));
00382   void setupPointers(int maxRows,int maxColumns);
00384   void copyFromSaved(int type=31);
00386   void fillPerturbation(int start, int number);
00388   void checkArrays(int ignoreEmpty=0) const;
00390   void checkDjs(int type=1) const;
00392   void checkSolutionBasic() const;
00394   void checkMoveBack(bool checkDuals);
00395 public:
00406   void setValuesPassAction(double incomingInfeasibility,
00407                            double allowedInfeasibility);
00410   int cleanFactorization(int ifValuesPass);
00412   void moveStatusToClp(ClpSimplex * clpModel);
00414   void moveStatusFromClp(ClpSimplex * clpModel);
00416 
00418 public:
00419 
00421   inline double clpObjectiveValue() const {
00422   return (objectiveValue_+objectiveOffset_-bestPossibleImprovement_)*optimizationDirection_ - dblParam_[ClpObjOffset];
00423   }
00426   inline int * pivotVariable() const {
00427     return abcPivotVariable_;
00428   }
00430   inline int stateOfProblem() const
00431   { return stateOfProblem_;}
00433   inline void setStateOfProblem(int value)
00434   { stateOfProblem_=value;}
00436   //inline int * fromExternal() const
00437   //{ return fromExternal_;}
00439   //inline int * toExternal() const
00440   //{return toExternal_;}
00443   inline double * scaleFromExternal() const
00444   {return scaleFromExternal_;}
00447   inline double * scaleToExternal() const
00448   {return scaleToExternal_;}
00450   inline double * rowScale2() const
00451   {return rowUseScale_;}
00452   inline double * inverseRowScale2() const
00453   {return inverseRowUseScale_;}
00454   inline double * inverseColumnScale2() const
00455   {return inverseColumnUseScale_;}
00456   inline double * columnScale2() const
00457   {return columnUseScale_;}
00458   inline int arrayForDualColumn() const
00459   {return arrayForDualColumn_;}
00461   inline double upperTheta() const
00462   {return upperTheta_;}
00463   inline int arrayForReplaceColumn() const
00464   { return arrayForReplaceColumn_;}
00465   inline int arrayForFlipBounds() const
00466   { return arrayForFlipBounds_;}
00467   inline int arrayForFlipRhs() const
00468   { return arrayForFlipRhs_;}
00469   inline int arrayForBtran() const
00470   { return arrayForBtran_;}
00471   inline int arrayForFtran() const
00472   { return arrayForFtran_;}
00473   inline int arrayForTableauRow() const
00474   { return arrayForTableauRow_;}
00476   double valueIncomingDual() const;
00478   const double * getColSolution() const; 
00479   
00481   const double * getRowPrice() const;
00482   
00484   const double * getReducedCost() const; 
00485   
00488   const double * getRowActivity() const; 
00490   
00496   int gutsOfSolution ( double * givenDuals,
00497                        const double * givenPrimals,
00498                        bool valuesPass = false);
00500   void gutsOfDelete(int type);
00502   void gutsOfCopy(const AbcSimplex & rhs);
00504   void gutsOfInitialize(int numberRows,int numberColumns,bool doMore);
00506   void gutsOfResize(int numberRows,int numberColumns);
00510   void translate(int type);
00512   void moveToBasic(int which=15);
00514 public:
00517 
00518   inline double * solutionRegion() const {
00519     return abcSolution_;
00520   }
00521   inline double * djRegion() const {
00522     return abcDj_;
00523   }
00524   inline double * lowerRegion() const {
00525     return abcLower_;
00526   }
00527   inline double * upperRegion() const {
00528     return abcUpper_;
00529   }
00530   inline double * costRegion() const {
00531     return abcCost_;
00532   }
00534   inline double * solutionRegion(int which) const {
00535     return abcSolution_+which*maximumAbcNumberRows_;
00536   }
00537   inline double * djRegion(int which) const {
00538     return abcDj_+which*maximumAbcNumberRows_;
00539   }
00540   inline double * lowerRegion(int which) const {
00541     return abcLower_+which*maximumAbcNumberRows_;
00542   }
00543   inline double * upperRegion(int which) const {
00544     return abcUpper_+which*maximumAbcNumberRows_;
00545   }
00546   inline double * costRegion(int which) const {
00547     return abcCost_+which*maximumAbcNumberRows_;
00548   }
00550   inline double * solutionBasic() const {
00551     return solutionBasic_;
00552   }
00553   inline double * djBasic() const {
00554     return djBasic_;
00555   }
00556   inline double * lowerBasic() const {
00557     return lowerBasic_;
00558   }
00559   inline double * upperBasic() const {
00560     return upperBasic_;
00561   }
00562   inline double * costBasic() const {
00563     return costBasic_;
00564   }
00566   inline double * abcPerturbation() const
00567   { return abcPerturbation_;}
00569   inline double * fakeDjs() const
00570   { return djSaved_;}
00571   inline unsigned char * internalStatus() const 
00572   { return internalStatus_;}
00573   inline AbcSimplex::Status getInternalStatus(int sequence) const {
00574     return static_cast<Status> (internalStatus_[sequence] & 7);
00575   }
00576   inline AbcSimplex::Status getInternalColumnStatus(int sequence) const {
00577     return static_cast<Status> (internalStatus_[sequence+maximumAbcNumberRows_] & 7);
00578   }
00579   inline void setInternalStatus(int sequence, AbcSimplex::Status newstatus) {
00580     unsigned char & st_byte = internalStatus_[sequence];
00581     st_byte = static_cast<unsigned char>(st_byte & ~7);
00582     st_byte = static_cast<unsigned char>(st_byte | newstatus);
00583   }
00584   inline void setInternalColumnStatus(int sequence, AbcSimplex::Status newstatus) {
00585     unsigned char & st_byte = internalStatus_[sequence+maximumAbcNumberRows_];
00586     st_byte = static_cast<unsigned char>(st_byte & ~7);
00587     st_byte = static_cast<unsigned char>(st_byte | newstatus);
00588   }
00593   void setInitialDenseFactorization(bool onOff);
00594   bool  initialDenseFactorization() const;
00596   inline int sequenceIn() const {
00597     return sequenceIn_;
00598   }
00599   inline int sequenceOut() const {
00600     return sequenceOut_;
00601   }
00603   inline void  setSequenceIn(int sequence) {
00604     sequenceIn_ = sequence;
00605   }
00606   inline void  setSequenceOut(int sequence) {
00607     sequenceOut_ = sequence;
00608   }
00609 #if 0
00610 
00611   inline int sequenceInternalIn() const {
00612     return sequenceInternalIn_;
00613   }
00614   inline int sequenceInternalOut() const {
00615     return sequenceInternalOut_;
00616   }
00618   inline void  setSequenceInternalIn(int sequence) {
00619     sequenceInternalIn_ = sequence;
00620   }
00621   inline void  setSequenceInternalOut(int sequence) {
00622     sequenceInternalOut_ = sequence;
00623   }
00624 #endif
00626   inline int isColumn(int sequence) const {
00627     return sequence >= maximumAbcNumberRows_ ? 1 : 0;
00628   }
00630   inline int sequenceWithin(int sequence) const {
00631     return sequence < maximumAbcNumberRows_ ? sequence : sequence - maximumAbcNumberRows_;
00632   }
00634   inline int lastPivotRow() const
00635   { return lastPivotRow_;}
00637   inline int firstFree() const
00638   { return firstFree_;}
00640   inline int lastFirstFree() const
00641   { return lastFirstFree_;}
00643   inline int freeSequenceIn() const
00644   { return freeSequenceIn_;}
00646   inline double currentAcceptablePivot() const
00647   { return currentAcceptablePivot_;}
00648 #ifdef PAN
00649 
00655   inline int fakeSuperBasic(int iSequence) {
00656     if ((internalStatus_[iSequence]&7)==4)
00657       return 0; // free
00658     if ((internalStatus_[iSequence]&7)!=5)
00659       return -2;
00660     double value=abcSolution_[iSequence];
00661     if (value<abcLower_[iSequence]+primalTolerance_) {
00662       if(abcDj_[iSequence]>=-currentDualTolerance_) {
00663         setInternalStatus(iSequence,atLowerBound);
00664 #if PRINT_PAN>1 
00665         printf("Pansetting %d to lb\n",iSequence);
00666 #endif
00667         return -1;
00668       } else {
00669         return 1;
00670       }
00671     } else if (value>abcUpper_[iSequence]-primalTolerance_) {
00672       if (abcDj_[iSequence]<=currentDualTolerance_) {
00673         setInternalStatus(iSequence,atUpperBound);
00674 #if PRINT_PAN>1 
00675         printf("Pansetting %d to ub\n",iSequence);
00676 #endif
00677         return -1;
00678       } else {
00679         return 1;
00680       }
00681     } else {
00682       return 0;
00683     }
00684   }
00685 #endif
00687   inline double solution(int sequence) {
00688     return abcSolution_[sequence];
00689   }
00691   inline double & solutionAddress(int sequence) {
00692     return abcSolution_[sequence];
00693   }
00694   inline double reducedCost(int sequence) {
00695     return abcDj_[sequence];
00696   }
00697   inline double & reducedCostAddress(int sequence) {
00698     return abcDj_[sequence];
00699   }
00700   inline double lower(int sequence) {
00701     return abcLower_[sequence];
00702   }
00704   inline double & lowerAddress(int sequence) {
00705     return abcLower_[sequence];
00706   }
00707   inline double upper(int sequence) {
00708     return abcUpper_[sequence];
00709   }
00711   inline double & upperAddress(int sequence) {
00712     return abcUpper_[sequence];
00713   }
00714   inline double cost(int sequence) {
00715     return abcCost_[sequence];
00716   }
00718   inline double & costAddress(int sequence) {
00719     return abcCost_[sequence];
00720   }
00722   inline double originalLower(int iSequence) const {
00723     if (iSequence < numberColumns_) return columnLower_[iSequence];
00724     else
00725       return rowLower_[iSequence-numberColumns_];
00726   }
00728   inline double originalUpper(int iSequence) const {
00729     if (iSequence < numberColumns_) return columnUpper_[iSequence];
00730     else
00731       return rowUpper_[iSequence-numberColumns_];
00732   }
00734   inline AbcSimplexProgress * abcProgress()
00735   { return &abcProgress_;}
00736 #ifdef ABC_SPRINT
00738   AbcSimplex * createSubProblem(int numberColumns,const int * whichColumn);
00740   void restoreFromSubProblem(AbcSimplex * fullProblem, const int * whichColumn);
00741 #endif
00742 public:
00745   inline void clearArraysPublic(int which)
00746   { clearArrays(which);}
00749   inline int getAvailableArrayPublic() const
00750   { return getAvailableArray();}
00751 #if ABC_PARALLEL
00753   inline int parallelMode() const
00754   { return parallelMode_;}
00756   inline void setParallelMode(int value)
00757   { parallelMode_=value;}
00759   inline int numberCpus() const
00760   { return parallelMode_+1;}
00761 #if ABC_PARALLEL==1
00763   inline void setStopStart(int value)
00764   { stopStart_=value;}
00765 #endif
00766 #endif
00767   //protected:
00769   void clearArrays(int which);
00771   void clearArrays(CoinPartitionedVector * which);
00773   int getAvailableArray() const;
00775   inline void setUsedArray(int which) const 
00776   {int check=1<<which;assert ((stateOfProblem_&check)==0);stateOfProblem_|=check;}
00778   inline void setAvailableArray(int which) const
00779   {int check=1<<which;assert ((stateOfProblem_&check)!=0);
00780     assert (!usefulArray_[which].getNumElements());stateOfProblem_&=~check;}
00782   void swapPrimalStuff();
00784   void swapDualStuff(int lastSequenceOut,int lastDirectionOut);
00785 protected:
00787 
00789 
00790   void swap(int pivotRow,int nonBasicPosition,Status newStatus);
00791   inline void setFakeBound(int sequence, FakeBound fakeBound) {
00792     unsigned char & st_byte = internalStatus_[sequence];
00793     st_byte = static_cast<unsigned char>(st_byte & ~24);
00794     st_byte = static_cast<unsigned char>(st_byte | (fakeBound << 3));
00795   }
00796   inline FakeBound getFakeBound(int sequence) const {
00797     return static_cast<FakeBound> ((internalStatus_[sequence] >> 3) & 3);
00798   }
00799   bool atFakeBound(int sequence) const;
00800   inline void setPivoted( int sequence) {
00801     internalStatus_[sequence] = static_cast<unsigned char>(internalStatus_[sequence] | 32);
00802   }
00803   inline void clearPivoted( int sequence) {
00804     internalStatus_[sequence] = static_cast<unsigned char>(internalStatus_[sequence] & ~32);
00805   }
00806   inline bool pivoted(int sequence) const {
00807     return (((internalStatus_[sequence] >> 5) & 1) != 0);
00808   }
00809 public:
00811   void swap(int pivotRow,int nonBasicPosition);
00813   void setFlagged( int sequence);
00814   inline void clearFlagged( int sequence) {
00815     internalStatus_[sequence] = static_cast<unsigned char>(internalStatus_[sequence] & ~64);
00816   }
00817   inline bool flagged(int sequence) const {
00818     return ((internalStatus_[sequence] & 64) != 0);
00819   }
00820 protected:
00822   inline void setActive( int iRow) {
00823     internalStatus_[iRow] = static_cast<unsigned char>(internalStatus_[iRow] | 128);
00824   }
00825   inline void clearActive( int iRow) {
00826     internalStatus_[iRow] = static_cast<unsigned char>(internalStatus_[iRow] & ~128);
00827   }
00828   inline bool active(int iRow) const {
00829     return ((internalStatus_[iRow] & 128) != 0);
00830   }
00831 public:
00834   void createStatus() ;
00836   void crash(int type);
00841   void putStuffInBasis(int type);
00844   void allSlackBasis();
00846   void checkConsistentPivots() const;
00848   void printStuff() const;
00850   int startup(int ifValuesPass);
00851   
00853   inline double rawObjectiveValue() const {
00854     return objectiveValue_;
00855   }
00857   void computeObjectiveValue(bool useWorkingSolution = false);
00859   double computeInternalObjectiveValue();
00861   void moveInfo(const AbcSimplex & rhs, bool justStatus = false);
00862 #ifndef NUMBER_THREADS 
00863 #define NUMBER_THREADS 3
00864 #endif
00865 #if ABC_PARALLEL==1
00866   // For waking up thread
00867   inline pthread_mutex_t * mutexPointer(int which,int thread=0) 
00868   { return mutex_+which+3*thread;}
00869   inline pthread_barrier_t * barrierPointer() 
00870   { return &barrier_;}
00871   inline int whichLocked(int thread=0) const
00872   { return locked_[thread];}
00873   inline CoinThreadInfo * threadInfoPointer(int thread=0) 
00874   { return threadInfo_+thread;}
00875   void startParallelStuff(int type);
00876   int stopParallelStuff(int type);
00878   int whichThread() const; 
00879 #elif ABC_PARALLEL==2
00880   //inline CoinThreadInfo * threadInfoPointer(int thread=0) 
00881   //{ return threadInfo_+thread;}
00882 #endif
00883 
00884   
00885   //-------------------------------------------------------------------------
00889   void setObjectiveCoefficient( int elementIndex, double elementValue );
00891   inline void setObjCoeff( int elementIndex, double elementValue ) {
00892     setObjectiveCoefficient( elementIndex, elementValue);
00893   }
00894   
00897   void setColumnLower( int elementIndex, double elementValue );
00898   
00901   void setColumnUpper( int elementIndex, double elementValue );
00902   
00904   void setColumnBounds( int elementIndex,
00905                         double lower, double upper );
00906   
00915   void setColumnSetBounds(const int* indexFirst,
00916                           const int* indexLast,
00917                           const double* boundList);
00918   
00921   inline void setColLower( int elementIndex, double elementValue ) {
00922     setColumnLower(elementIndex, elementValue);
00923   }
00926   inline void setColUpper( int elementIndex, double elementValue ) {
00927     setColumnUpper(elementIndex, elementValue);
00928   }
00929   
00931   inline void setColBounds( int elementIndex,
00932                             double newlower, double newupper ) {
00933     setColumnBounds(elementIndex, newlower, newupper);
00934   }
00935   
00942   inline void setColSetBounds(const int* indexFirst,
00943                               const int* indexLast,
00944                               const double* boundList) {
00945     setColumnSetBounds(indexFirst, indexLast, boundList);
00946   }
00947   
00950   void setRowLower( int elementIndex, double elementValue );
00951   
00954   void setRowUpper( int elementIndex, double elementValue ) ;
00955   
00957   void setRowBounds( int elementIndex,
00958                      double lower, double upper ) ;
00959   
00966   void setRowSetBounds(const int* indexFirst,
00967                        const int* indexLast,
00968                        const double* boundList);
00970   void resize (int newNumberRows, int newNumberColumns);
00971   
00973   
00975 protected:
00976   
00983 
00984   double sumNonBasicCosts_;
00986   double rawObjectiveValue_;
00988   double objectiveOffset_;
00993   double perturbationFactor_;
00995   double currentDualTolerance_;
00997   double currentDualBound_;
00999   double largestGap_;
01001   double lastDualBound_;
01003   double sumFakeInfeasibilities_;
01005   double lastPrimalError_;
01007   double lastDualError_;
01009   double currentAcceptablePivot_;
01011   double movement_;
01013   double objectiveChange_;
01015   double btranAlpha_;
01017 #ifdef ABC_LONG_FACTORIZATION 
01018   long
01019 #endif
01020   double ftAlpha_;
01022   double minimumThetaMovement_;
01024   double initialSumInfeasibilities_;
01025 public:
01027   int stateOfIteration_;
01028 protected:
01030   int lastFirstFree_;
01032   int freeSequenceIn_;
01034   int maximumAbcNumberRows_;
01036   int maximumAbcNumberColumns_;
01038   int maximumNumberTotal_;
01040   int numberFlagged_;
01042   int normalDualColumnIteration_;
01048   int stateDualColumn_;
01049   /*
01050     May want to put some arrays into struct 
01051     Two arrays point to/from external
01052     Order is basic,unused basic, at lower, at upper, superbasic, free, fixed with starts
01053   */
01055   int numberTotal_;
01057   int numberTotalWithoutFixed_;
01059 #define startAtLowerNoOther_ maximumAbcNumberRows_
01061   int startAtLowerOther_;
01063   int startAtUpperNoOther_;
01065   int startAtUpperOther_;
01067   int startOther_;
01069   int startFixed_;
01070 #ifdef EARLY_FACTORIZE
01072   int numberEarly_;
01073 #endif
01074 
01091 #define ALL_STATUS_OK 2048
01092 #define ROW_PRIMAL_OK 4096
01093 #define ROW_DUAL_OK 8192
01094 #define COLUMN_PRIMAL_OK 16384
01095 #define COLUMN_DUAL_OK 32768
01096 #define PESSIMISTIC 65536
01097 #define ADD_A_BIT 131072
01098 #define DO_SCALE_AND_MATRIX 262144
01099 #define DO_BASIS_AND_ORDER 524288
01100 #define DO_STATUS 1048576
01101 #define DO_SOLUTION 2097152
01102 #define DO_JUST_BOUNDS 0x400000
01103 #define NEED_BASIS_SORT 0x800000
01104 #define FAKE_SUPERBASIC 0x1000000
01105 #define VALUES_PASS 0x2000000
01106 #define VALUES_PASS2 0x4000000
01107   mutable int stateOfProblem_;
01108 #if ABC_PARALLEL
01109 public:
01111   int parallelMode_;
01112 protected:
01113 #endif
01115   int numberOrdinary_;
01117   int ordinaryVariables_;
01119   int numberFreeNonBasic_;
01121   int lastCleaned_;
01123   int lastPivotRow_;
01125   int swappedAlgorithm_;
01127   int initialNumberInfeasibilities_;
01129   //int * fromExternal_;
01131   //int * toExternal_;
01132 
01134   double * scaleFromExternal_;
01137   double * scaleToExternal_;
01139   double * columnUseScale_;
01141   double * inverseColumnUseScale_;
01145   double * offset_;
01147   double * offsetRhs_;
01149   double * tempArray_;
01154   unsigned char * internalStatus_;
01156   unsigned char * internalStatusSaved_;
01159   double * abcPerturbation_;
01161   double * perturbationSaved_;
01163   double * perturbationBasic_;
01165   AbcMatrix * abcMatrix_;
01168   double * abcLower_;
01171   double * abcUpper_;
01177   double * abcCost_;
01180   double * abcSolution_;
01183   double * abcDj_;
01185   double * lowerSaved_;
01187   double * upperSaved_;
01189   double * costSaved_;
01191   double * solutionSaved_;
01193   double * djSaved_;
01195   double * lowerBasic_;
01197   double * upperBasic_;
01199   double * costBasic_;
01201   double * solutionBasic_;
01203   double * djBasic_;
01205   AbcDualRowPivot * abcDualRowPivot_;
01207   AbcPrimalColumnPivot * abcPrimalColumnPivot_;
01211   int * abcPivotVariable_;
01213   int * reversePivotVariable_;
01215   AbcSimplexFactorization * abcFactorization_;
01216 #ifdef EARLY_FACTORIZE
01218   AbcSimplexFactorization * abcEarlyFactorization_;
01219 #endif
01220 #ifdef TEMPORARY_FACTORIZATION
01222   AbcSimplexFactorization * abcOtherFactorization_;
01223 #endif
01225   //double * savedSolution_;
01227   AbcSimplex * abcBaseModel_;
01229   ClpSimplex * clpModel_;
01230 
01234   AbcNonLinearCost * abcNonLinearCost_;
01236   /* has secondary offset and counts so row goes first then column
01237      Probably back to CoinPartitionedVector as AbcMatrix has slacks
01238      also says if in use - so we can just get next available one */
01239 #define ABC_NUMBER_USEFUL 8
01240   mutable CoinPartitionedVector usefulArray_[ABC_NUMBER_USEFUL];
01242   AbcSimplexProgress abcProgress_;
01244   ClpDataSave saveData_;
01246   double upperTheta_;
01248   int multipleSequenceIn_[4];
01249 public:
01250   int arrayForDualColumn_;
01251   int arrayForReplaceColumn_;
01252   int arrayForFlipBounds_; //2
01253   int arrayForFlipRhs_; // if sequential can re-use
01254   int arrayForBtran_; // 0
01255   int arrayForFtran_; // 1
01256   int arrayForTableauRow_; //3
01257 protected:
01258   int numberFlipped_;
01259   int numberDisasters_;
01260   //int nextCleanNonBasicIteration_;
01261 #if ABC_PARALLEL==1
01262   // For waking up thread
01263   pthread_mutex_t mutex_[3*NUMBER_THREADS];
01264   pthread_barrier_t barrier_; 
01265   CoinThreadInfo threadInfo_[NUMBER_THREADS];
01266   pthread_t abcThread_[NUMBER_THREADS];
01267   int locked_[NUMBER_THREADS];
01268   int stopStart_;
01269 #elif ABC_PARALLEL==2
01270   //CoinThreadInfo threadInfo_[NUMBER_THREADS];
01271 #endif
01272 
01273 };
01274 //#############################################################################
01283 void
01284 AbcSimplexUnitTest(const std::string & mpsDir);
01285 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 3 Jun 2015 for Cgl by  doxygen 1.6.1