- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/svn-release/Alps-1.5.0/Clp/src/ClpSimplex.hpp

Go to the documentation of this file.

    00001 /* $Id: ClpSimplex.hpp 2086 2015-01-15 08:55:27Z forrest $ */
    00002 // Copyright (C) 2002, International Business Machines
    00003 // Corporation and others.  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 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 /*
    00032   May want to use Clp defaults so that with ABC defined but not used
    00033   it behaves as Clp (and ABC used will be different than if not defined)
    00034  */
    00035 #ifdef ABC_INHERIT
    00036 #ifndef CLP_INHERIT_MODE
    00037 #define CLP_INHERIT_MODE 1
    00038 #endif
    00039 #ifndef ABC_CLP_DEFAULTS
    00040 #define ABC_CLP_DEFAULTS 0
    00041 #endif
    00042 #else
    00043 #undef ABC_CLP_DEFAULTS
    00044 #define ABC_CLP_DEFAULTS 1
    00045 #endif
    00046 #ifdef CLP_HAS_ABC
    00047 #include "AbcCommon.hpp"
    00048 class AbcTolerancesEtc;
    00049 class AbcSimplex;
    00050 #include "CoinAbcCommon.hpp"
    00051 #endif
    00052
    00070 class ClpSimplex : public ClpModel {
    00071      friend void ClpSimplexUnitTest(const std::string & mpsDir);
    00072
    00073 public:
    00078      enum Status {
    00079           isFree = 0x00,
    00080           basic = 0x01,
    00081           atUpperBound = 0x02,
    00082           atLowerBound = 0x03,
    00083           superBasic = 0x04,
    00084           isFixed = 0x05
    00085      };
    00086      // For Dual
    00087      enum FakeBound {
    00088           noFake = 0x00,
    00089           lowerFake = 0x01,
    00090           upperFake = 0x02,
    00091           bothFake = 0x03
    00092      };
    00093
    00096
    00097      ClpSimplex (bool emptyMessages = false  );
    00098
    00103      ClpSimplex(const ClpSimplex & rhs, int scalingMode = -1);
    00108      ClpSimplex(const ClpModel & rhs, int scalingMode = -1);
    00115      ClpSimplex (const ClpModel * wholeModel,
    00116                  int numberRows, const int * whichRows,
    00117                  int numberColumns, const int * whichColumns,
    00118                  bool dropNames = true, bool dropIntegers = true,
    00119                  bool fixOthers = false);
    00126      ClpSimplex (const ClpSimplex * wholeModel,
    00127                  int numberRows, const int * whichRows,
    00128                  int numberColumns, const int * whichColumns,
    00129                  bool dropNames = true, bool dropIntegers = true,
    00130                  bool fixOthers = false);
    00134      ClpSimplex (ClpSimplex * wholeModel,
    00135                  int numberColumns, const int * whichColumns);
    00138      void originalModel(ClpSimplex * miniModel);
    00139   inline int abcState() const
    00140   { return abcState_;}
    00141   inline void setAbcState(int state)
    00142   { abcState_=state;}
    00143 #ifdef ABC_INHERIT
    00144   inline AbcSimplex * abcSimplex() const
    00145   { return abcSimplex_;}
    00146   inline void setAbcSimplex(AbcSimplex * simplex)
    00147   { abcSimplex_=simplex;}
    00149   int doAbcDual();
    00151   int doAbcPrimal(int ifValuesPass);
    00152 #endif
    00153
    00158      void setPersistenceFlag(int value);
    00160      void makeBaseModel();
    00162      void deleteBaseModel();
    00164      inline ClpSimplex *  baseModel() const {
    00165           return baseModel_;
    00166      }
    00170      void setToBaseModel(ClpSimplex * model = NULL);
    00172      ClpSimplex & operator=(const ClpSimplex & rhs);
    00174      ~ClpSimplex (  );
    00175      // Ones below are just ClpModel with some changes
    00187      void loadProblem (  const ClpMatrixBase& matrix,
    00188                          const double* collb, const double* colub,
    00189                          const double* obj,
    00190                          const double* rowlb, const double* rowub,
    00191                          const double * rowObjective = NULL);
    00192      void loadProblem (  const CoinPackedMatrix& matrix,
    00193                          const double* collb, const double* colub,
    00194                          const double* obj,
    00195                          const double* rowlb, const double* rowub,
    00196                          const double * rowObjective = NULL);
    00197
    00200      void loadProblem (  const int numcols, const int numrows,
    00201                          const CoinBigIndex* start, const int* index,
    00202                          const double* value,
    00203                          const double* collb, const double* colub,
    00204                          const double* obj,
    00205                          const double* rowlb, const double* rowub,
    00206                          const double * rowObjective = NULL);
    00208      void loadProblem (  const int numcols, const int numrows,
    00209                          const CoinBigIndex* start, const int* index,
    00210                          const double* value, const int * length,
    00211                          const double* collb, const double* colub,
    00212                          const double* obj,
    00213                          const double* rowlb, const double* rowub,
    00214                          const double * rowObjective = NULL);
    00219      int loadProblem (  CoinModel & modelObject, bool keepSolution = false);
    00221      int readMps(const char *filename,
    00222                  bool keepNames = false,
    00223                  bool ignoreErrors = false);
    00225      int readGMPL(const char *filename, const char * dataName,
    00226                   bool keepNames = false);
    00229      int readLp(const char *filename, const double epsilon = 1e-5);
    00234      void borrowModel(ClpModel & otherModel);
    00235      void borrowModel(ClpSimplex & otherModel);
    00237      void passInEventHandler(const ClpEventHandler * eventHandler);
    00239      void getbackSolution(const ClpSimplex & smallModel, const int * whichRow, const int * whichColumn);
    00248      int loadNonLinear(void * info, int & numberConstraints,
    00249                        ClpConstraint ** & constraints);
    00250 #ifdef ABC_INHERIT
    00252   void loadTolerancesEtc(const AbcTolerancesEtc & data);
    00254   void unloadTolerancesEtc(AbcTolerancesEtc & data);
    00255 #endif
    00256
    00257
    00263      int initialSolve(ClpSolve & options);
    00265      int initialSolve();
    00267      int initialDualSolve();
    00269      int initialPrimalSolve();
    00271      int initialBarrierSolve();
    00273      int initialBarrierNoCrossSolve();
    00284      int dual(int ifValuesPass = 0, int startFinishOptions = 0);
    00285      // If using Debug
    00286      int dualDebug(int ifValuesPass = 0, int startFinishOptions = 0);
    00297      int primal(int ifValuesPass = 0, int startFinishOptions = 0);
    00303      int nonlinearSLP(int numberPasses, double deltaTolerance);
    00309      int nonlinearSLP(int numberConstraints, ClpConstraint ** constraints,
    00310                       int numberPasses, double deltaTolerance);
    00313      int barrier(bool crossover = true);
    00316      int reducedGradient(int phase = 0);
    00318      int solve(CoinStructuredModel * model);
    00319 #ifdef ABC_INHERIT
    00320
    00325   AbcSimplex * dealWithAbc(int solveType,int startUp,bool interrupt=false);
    00326   //void dealWithAbc(int solveType,int startUp,bool interrupt=false);
    00327 #endif
    00328
    00334      int loadProblem (  CoinStructuredModel & modelObject,
    00335                         bool originalOrder = true, bool keepSolution = false);
    00350      int cleanup(int cleanupScaling);
    00371      int dualRanging(int numberCheck, const int * which,
    00372                      double * costIncrease, int * sequenceIncrease,
    00373                      double * costDecrease, int * sequenceDecrease,
    00374                      double * valueIncrease = NULL, double * valueDecrease = NULL);
    00389      int primalRanging(int numberCheck, const int * which,
    00390                        double * valueIncrease, int * sequenceIncrease,
    00391                        double * valueDecrease, int * sequenceDecrease);
    00401      int modifyCoefficientsAndPivot(int number,
    00402                                  const int * which,
    00403                                  const CoinBigIndex * start,
    00404                                  const int * row,
    00405                                  const double * newCoefficient,
    00406                                  const unsigned char * newStatus=NULL,
    00407                                  const double * newLower=NULL,
    00408                                  const double * newUpper=NULL,
    00409                                  const double * newObjective=NULL);
    00417      int outDuplicateRows(int numberLook,int * whichRows, bool noOverlaps=false, double tolerance=-1.0,
    00418                           double cleanUp=0.0);
    00421      double moveTowardsPrimalFeasible();
    00424      void removeSuperBasicSlacks(int threshold=0);
    00437      ClpSimplex * miniPresolve(char * rowType, char * columnType,void ** info);
    00439      void miniPostsolve(const ClpSimplex * presolvedModel,void * info);
    00441      void miniSolve(char * rowType, char *columnType,int algorithm, int startUp);
    00456      int writeBasis(const char *filename,
    00457                     bool writeValues = false,
    00458                     int formatType = 0) const;
    00461      int readBasis(const char *filename);
    00463      CoinWarmStartBasis * getBasis() const;
    00465      void setFactorization( ClpFactorization & factorization);
    00466      // Swaps factorization
    00467      ClpFactorization * swapFactorization( ClpFactorization * factorization);
    00469      void copyFactorization( ClpFactorization & factorization);
    00479      int tightenPrimalBounds(double factor = 0.0, int doTight = 0, bool tightIntegers = false);
    00496      int crash(double gap, int pivot);
    00498      void setDualRowPivotAlgorithm(ClpDualRowPivot & choice);
    00500      void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot & choice);
    00502      void markHotStart(void * & saveStuff);
    00504      void solveFromHotStart(void * saveStuff);
    00506      void unmarkHotStart(void * saveStuff);
    00515      int strongBranching(int numberVariables, const int * variables,
    00516                          double * newLower, double * newUpper,
    00517                          double ** outputSolution,
    00518                          int * outputStatus, int * outputIterations,
    00519                          bool stopOnFirstInfeasible = true,
    00520                          bool alwaysFinish = false,
    00521                          int startFinishOptions = 0);
    00523      int fathom(void * stuff);
    00529      int fathomMany(void * stuff);
    00531      double doubleCheck();
    00533      int startFastDual2(ClpNodeStuff * stuff);
    00535      int fastDual2(ClpNodeStuff * stuff);
    00537      void stopFastDual2(ClpNodeStuff * stuff);
    00544      ClpSimplex * fastCrunch(ClpNodeStuff * stuff, int mode);
    00546
    00554      int pivot();
    00555
    00561      int primalPivotResult();
    00562
    00568      int dualPivotResultPart1();
    00572   int pivotResultPart2(int algorithm,int state);
    00573
    00585      int startup(int ifValuesPass, int startFinishOptions = 0);
    00586      void finish(int startFinishOptions = 0);
    00587
    00589      bool statusOfProblem(bool initial = false);
    00591      void defaultFactorizationFrequency();
    00593      void copyEnabledStuff(const ClpSimplex * rhs);
    00595
    00598
    00599      inline bool primalFeasible() const {
    00600           return (numberPrimalInfeasibilities_ == 0);
    00601      }
    00603      inline bool dualFeasible() const {
    00604           return (numberDualInfeasibilities_ == 0);
    00605      }
    00607      inline ClpFactorization * factorization() const {
    00608           return factorization_;
    00609      }
    00611      bool sparseFactorization() const;
    00612      void setSparseFactorization(bool value);
    00614      int factorizationFrequency() const;
    00615      void setFactorizationFrequency(int value);
    00617      inline double dualBound() const {
    00618           return dualBound_;
    00619      }
    00620      void setDualBound(double value);
    00622      inline double infeasibilityCost() const {
    00623           return infeasibilityCost_;
    00624      }
    00625      void setInfeasibilityCost(double value);
    00642      inline int perturbation() const {
    00643           return perturbation_;
    00644      }
    00645      void setPerturbation(int value);
    00647      inline int algorithm() const {
    00648           return algorithm_;
    00649      }
    00651      inline void setAlgorithm(int value) {
    00652           algorithm_ = value;
    00653      }
    00655      bool isObjectiveLimitTestValid() const ;
    00657      inline double sumDualInfeasibilities() const {
    00658           return sumDualInfeasibilities_;
    00659      }
    00660      inline void setSumDualInfeasibilities(double value) {
    00661           sumDualInfeasibilities_ = value;
    00662      }
    00664      inline double sumOfRelaxedDualInfeasibilities() const {
    00665           return sumOfRelaxedDualInfeasibilities_;
    00666      }
    00667      inline void setSumOfRelaxedDualInfeasibilities(double value) {
    00668           sumOfRelaxedDualInfeasibilities_ = value;
    00669      }
    00671      inline int numberDualInfeasibilities() const {
    00672           return numberDualInfeasibilities_;
    00673      }
    00674      inline void setNumberDualInfeasibilities(int value) {
    00675           numberDualInfeasibilities_ = value;
    00676      }
    00678      inline int numberDualInfeasibilitiesWithoutFree() const {
    00679           return numberDualInfeasibilitiesWithoutFree_;
    00680      }
    00682      inline double sumPrimalInfeasibilities() const {
    00683           return sumPrimalInfeasibilities_;
    00684      }
    00685      inline void setSumPrimalInfeasibilities(double value) {
    00686           sumPrimalInfeasibilities_ = value;
    00687      }
    00689      inline double sumOfRelaxedPrimalInfeasibilities() const {
    00690           return sumOfRelaxedPrimalInfeasibilities_;
    00691      }
    00692      inline void setSumOfRelaxedPrimalInfeasibilities(double value) {
    00693           sumOfRelaxedPrimalInfeasibilities_ = value;
    00694      }
    00696      inline int numberPrimalInfeasibilities() const {
    00697           return numberPrimalInfeasibilities_;
    00698      }
    00699      inline void setNumberPrimalInfeasibilities(int value) {
    00700           numberPrimalInfeasibilities_ = value;
    00701      }
    00708      int saveModel(const char * fileName);
    00711      int restoreModel(const char * fileName);
    00712
    00720      void checkSolution(int setToBounds = 0);
    00723      void checkSolutionInternal();
    00725      void checkUnscaledSolution();
    00727      inline CoinIndexedVector * rowArray(int index) const {
    00728           return rowArray_[index];
    00729      }
    00731      inline CoinIndexedVector * columnArray(int index) const {
    00732           return columnArray_[index];
    00733      }
    00735
    00736      /******************** End of most useful part **************/
    00742      int getSolution (  const double * rowActivities,
    00743                         const double * columnActivities);
    00747      int getSolution ();
    00754      int createPiecewiseLinearCosts(const int * starts,
    00755                                     const double * lower, const double * gradient);
    00757      inline ClpDualRowPivot * dualRowPivot() const {
    00758           return dualRowPivot_;
    00759      }
    00761      inline ClpPrimalColumnPivot * primalColumnPivot() const {
    00762           return primalColumnPivot_;
    00763      }
    00765      inline bool goodAccuracy() const {
    00766           return (largestPrimalError_ < 1.0e-7 && largestDualError_ < 1.0e-7);
    00767      }
    00769      void returnModel(ClpSimplex & otherModel);
    00777      int internalFactorize(int solveType);
    00779      ClpDataSave saveData() ;
    00781      void restoreData(ClpDataSave saved);
    00783      void cleanStatus();
    00785      int factorize();
    00788      void computeDuals(double * givenDjs);
    00790      void computePrimals (  const double * rowActivities,
    00791                             const double * columnActivities);
    00793      void add(double * array,
    00794               int column, double multiplier) const;
    00800      void unpack(CoinIndexedVector * rowArray) const ;
    00806      void unpack(CoinIndexedVector * rowArray, int sequence) const;
    00813      void unpackPacked(CoinIndexedVector * rowArray) ;
    00820      void unpackPacked(CoinIndexedVector * rowArray, int sequence);
    00821 #ifndef CLP_USER_DRIVEN
    00822 protected:
    00823 #endif
    00824
    00828      int housekeeping(double objectiveChange);
    00831      void checkPrimalSolution(const double * rowActivities = NULL,
    00832                               const double * columnActivies = NULL);
    00835      void checkDualSolution();
    00837      void checkBothSolutions();
    00842      double scaleObjective(double value);
    00844     int solveDW(CoinStructuredModel * model, ClpSolve & options);
    00846      int solveBenders(CoinStructuredModel * model, ClpSolve & options);
    00847 public:
    00858      void setValuesPassAction(double incomingInfeasibility,
    00859                               double allowedInfeasibility);
    00862      int cleanFactorization(int ifValuesPass);
    00864
    00866 public:
    00868      inline double alphaAccuracy() const {
    00869           return alphaAccuracy_;
    00870      }
    00871      inline void setAlphaAccuracy(double value) {
    00872           alphaAccuracy_ = value;
    00873      }
    00874 public:
    00876      //inline double objectiveValue() const {
    00877      //return (objectiveValue_-bestPossibleImprovement_)*optimizationDirection_ - dblParam_[ClpObjOffset];
    00878      //}
    00880      inline void setDisasterHandler(ClpDisasterHandler * handler) {
    00881           disasterArea_ = handler;
    00882      }
    00884      inline ClpDisasterHandler * disasterHandler() const {
    00885           return disasterArea_;
    00886      }
    00888      inline double largeValue() const {
    00889           return largeValue_;
    00890      }
    00891      void setLargeValue( double value) ;
    00893      inline double largestPrimalError() const {
    00894           return largestPrimalError_;
    00895      }
    00897      inline double largestDualError() const {
    00898           return largestDualError_;
    00899      }
    00901      inline void setLargestPrimalError(double value) {
    00902           largestPrimalError_ = value;
    00903      }
    00905      inline void setLargestDualError(double value) {
    00906           largestDualError_ = value;
    00907      }
    00909      inline double zeroTolerance() const {
    00910           return zeroTolerance_;/*factorization_->zeroTolerance();*/
    00911      }
    00913      inline void setZeroTolerance( double value) {
    00914           zeroTolerance_ = value;
    00915      }
    00917      inline int * pivotVariable() const {
    00918           return pivotVariable_;
    00919      }
    00921      inline bool automaticScaling() const {
    00922           return automaticScale_ != 0;
    00923      }
    00924      inline void setAutomaticScaling(bool onOff) {
    00925           automaticScale_ = onOff ? 1 : 0;
    00926      }
    00928      inline double currentDualTolerance() const {
    00929           return dualTolerance_;
    00930      }
    00931      inline void setCurrentDualTolerance(double value) {
    00932           dualTolerance_ = value;
    00933      }
    00935      inline double currentPrimalTolerance() const {
    00936           return primalTolerance_;
    00937      }
    00938      inline void setCurrentPrimalTolerance(double value) {
    00939           primalTolerance_ = value;
    00940      }
    00942      inline int numberRefinements() const {
    00943           return numberRefinements_;
    00944      }
    00945      void setNumberRefinements( int value) ;
    00947      inline double alpha() const {
    00948           return alpha_;
    00949      }
    00950      inline void setAlpha(double value) {
    00951           alpha_ = value;
    00952      }
    00954      inline double dualIn() const {
    00955           return dualIn_;
    00956      }
    00958      inline void setDualIn(double value) {
    00959           dualIn_ = value;
    00960      }
    00962      inline int pivotRow() const {
    00963           return pivotRow_;
    00964      }
    00965      inline void setPivotRow(int value) {
    00966           pivotRow_ = value;
    00967      }
    00969      double valueIncomingDual() const;
    00971
    00972 #ifndef CLP_USER_DRIVEN
    00973 protected:
    00974 #endif
    00975
    00980      int gutsOfSolution ( double * givenDuals,
    00981                           const double * givenPrimals,
    00982                           bool valuesPass = false);
    00984      void gutsOfDelete(int type);
    00986      void gutsOfCopy(const ClpSimplex & rhs);
    00998      bool createRim(int what, bool makeRowCopy = false, int startFinishOptions = 0);
    01000      void createRim1(bool initial);
    01002      void createRim4(bool initial);
    01004      void createRim5(bool initial);
    01009      void deleteRim(int getRidOfFactorizationData = 2);
    01011      bool sanityCheck();
    01013 public:
    01018      inline double * solutionRegion(int section) const {
    01019           if (!section) return rowActivityWork_;
    01020           else return columnActivityWork_;
    01021      }
    01022      inline double * djRegion(int section) const {
    01023           if (!section) return rowReducedCost_;
    01024           else return reducedCostWork_;
    01025      }
    01026      inline double * lowerRegion(int section) const {
    01027           if (!section) return rowLowerWork_;
    01028           else return columnLowerWork_;
    01029      }
    01030      inline double * upperRegion(int section) const {
    01031           if (!section) return rowUpperWork_;
    01032           else return columnUpperWork_;
    01033      }
    01034      inline double * costRegion(int section) const {
    01035           if (!section) return rowObjectiveWork_;
    01036           else return objectiveWork_;
    01037      }
    01039      inline double * solutionRegion() const {
    01040           return solution_;
    01041      }
    01042      inline double * djRegion() const {
    01043           return dj_;
    01044      }
    01045      inline double * lowerRegion() const {
    01046           return lower_;
    01047      }
    01048      inline double * upperRegion() const {
    01049           return upper_;
    01050      }
    01051      inline double * costRegion() const {
    01052           return cost_;
    01053      }
    01054      inline Status getStatus(int sequence) const {
    01055           return static_cast<Status> (status_[sequence] & 7);
    01056      }
    01057      inline void setStatus(int sequence, Status newstatus) {
    01058           unsigned char & st_byte = status_[sequence];
    01059           st_byte = static_cast<unsigned char>(st_byte & ~7);
    01060           st_byte = static_cast<unsigned char>(st_byte | newstatus);
    01061      }
    01063      bool startPermanentArrays();
    01068      void setInitialDenseFactorization(bool onOff);
    01069      bool  initialDenseFactorization() const;
    01071      inline int sequenceIn() const {
    01072           return sequenceIn_;
    01073      }
    01074      inline int sequenceOut() const {
    01075           return sequenceOut_;
    01076      }
    01078      inline void  setSequenceIn(int sequence) {
    01079           sequenceIn_ = sequence;
    01080      }
    01081      inline void  setSequenceOut(int sequence) {
    01082           sequenceOut_ = sequence;
    01083      }
    01085      inline int directionIn() const {
    01086           return directionIn_;
    01087      }
    01088      inline int directionOut() const {
    01089           return directionOut_;
    01090      }
    01092      inline void  setDirectionIn(int direction) {
    01093           directionIn_ = direction;
    01094      }
    01095      inline void  setDirectionOut(int direction) {
    01096           directionOut_ = direction;
    01097      }
    01099      inline double valueOut() const {
    01100           return valueOut_;
    01101      }
    01103      inline void setValueOut(double value) {
    01104           valueOut_ = value;
    01105      }
    01107      inline double dualOut() const {
    01108           return dualOut_;
    01109      }
    01111      inline void setDualOut(double value) {
    01112           dualOut_ = value;
    01113      }
    01115      inline void setLowerOut(double value) {
    01116           lowerOut_ = value;
    01117      }
    01119      inline void setUpperOut(double value) {
    01120           upperOut_ = value;
    01121      }
    01123      inline void setTheta(double value) {
    01124           theta_ = value;
    01125      }
    01127      inline int isColumn(int sequence) const {
    01128           return sequence < numberColumns_ ? 1 : 0;
    01129      }
    01131      inline int sequenceWithin(int sequence) const {
    01132           return sequence < numberColumns_ ? sequence : sequence - numberColumns_;
    01133      }
    01135      inline double solution(int sequence) {
    01136           return solution_[sequence];
    01137      }
    01139      inline double & solutionAddress(int sequence) {
    01140           return solution_[sequence];
    01141      }
    01142      inline double reducedCost(int sequence) {
    01143           return dj_[sequence];
    01144      }
    01145      inline double & reducedCostAddress(int sequence) {
    01146           return dj_[sequence];
    01147      }
    01148      inline double lower(int sequence) {
    01149           return lower_[sequence];
    01150      }
    01152      inline double & lowerAddress(int sequence) {
    01153           return lower_[sequence];
    01154      }
    01155      inline double upper(int sequence) {
    01156           return upper_[sequence];
    01157      }
    01159      inline double & upperAddress(int sequence) {
    01160           return upper_[sequence];
    01161      }
    01162      inline double cost(int sequence) {
    01163           return cost_[sequence];
    01164      }
    01166      inline double & costAddress(int sequence) {
    01167           return cost_[sequence];
    01168      }
    01170      inline double originalLower(int iSequence) const {
    01171           if (iSequence < numberColumns_) return columnLower_[iSequence];
    01172           else
    01173                return rowLower_[iSequence-numberColumns_];
    01174      }
    01176      inline double originalUpper(int iSequence) const {
    01177           if (iSequence < numberColumns_) return columnUpper_[iSequence];
    01178           else
    01179                return rowUpper_[iSequence-numberColumns_];
    01180      }
    01182      inline double theta() const {
    01183           return theta_;
    01184      }
    01187      inline double bestPossibleImprovement() const {
    01188           return bestPossibleImprovement_;
    01189      }
    01191      inline ClpNonLinearCost * nonLinearCost() const {
    01192           return nonLinearCost_;
    01193      }
    01215      inline int moreSpecialOptions() const {
    01216           return moreSpecialOptions_;
    01217      }
    01243      inline void setMoreSpecialOptions(int value) {
    01244           moreSpecialOptions_ = value;
    01245      }
    01247
    01249      inline void setFakeBound(int sequence, FakeBound fakeBound) {
    01250           unsigned char & st_byte = status_[sequence];
    01251           st_byte = static_cast<unsigned char>(st_byte & ~24);
    01252           st_byte = static_cast<unsigned char>(st_byte | (fakeBound << 3));
    01253      }
    01254      inline FakeBound getFakeBound(int sequence) const {
    01255           return static_cast<FakeBound> ((status_[sequence] >> 3) & 3);
    01256      }
    01257      inline void setRowStatus(int sequence, Status newstatus) {
    01258           unsigned char & st_byte = status_[sequence+numberColumns_];
    01259           st_byte = static_cast<unsigned char>(st_byte & ~7);
    01260           st_byte = static_cast<unsigned char>(st_byte | newstatus);
    01261      }
    01262      inline Status getRowStatus(int sequence) const {
    01263           return static_cast<Status> (status_[sequence+numberColumns_] & 7);
    01264      }
    01265      inline void setColumnStatus(int sequence, Status newstatus) {
    01266           unsigned char & st_byte = status_[sequence];
    01267           st_byte = static_cast<unsigned char>(st_byte & ~7);
    01268           st_byte = static_cast<unsigned char>(st_byte | newstatus);
    01269      }
    01270      inline Status getColumnStatus(int sequence) const {
    01271           return static_cast<Status> (status_[sequence] & 7);
    01272      }
    01273      inline void setPivoted( int sequence) {
    01274           status_[sequence] = static_cast<unsigned char>(status_[sequence] | 32);
    01275      }
    01276      inline void clearPivoted( int sequence) {
    01277           status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~32);
    01278      }
    01279      inline bool pivoted(int sequence) const {
    01280           return (((status_[sequence] >> 5) & 1) != 0);
    01281      }
    01283      void setFlagged( int sequence);
    01284      inline void clearFlagged( int sequence) {
    01285           status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64);
    01286      }
    01287      inline bool flagged(int sequence) const {
    01288           return ((status_[sequence] & 64) != 0);
    01289      }
    01291      inline void setActive( int iRow) {
    01292           status_[iRow] = static_cast<unsigned char>(status_[iRow] | 128);
    01293      }
    01294      inline void clearActive( int iRow) {
    01295           status_[iRow] = static_cast<unsigned char>(status_[iRow] & ~128);
    01296      }
    01297      inline bool active(int iRow) const {
    01298           return ((status_[iRow] & 128) != 0);
    01299      }
    01301      inline void setPerturbed( int iSequence) {
    01302           status_[iSequence] = static_cast<unsigned char>(status_[iSequence] | 128);
    01303      }
    01304      inline void clearPerturbed( int iSequence) {
    01305           status_[iSequence] = static_cast<unsigned char>(status_[iSequence] & ~128);
    01306      }
    01307      inline bool perturbed(int iSequence) const {
    01308           return ((status_[iSequence] & 128) != 0);
    01309      }
    01312      void createStatus() ;
    01315      void allSlackBasis(bool resetSolution = false);
    01316
    01318      inline int lastBadIteration() const {
    01319           return lastBadIteration_;
    01320      }
    01322      inline void setLastBadIteration(int value) {
    01323           lastBadIteration_=value;
    01324      }
    01326      inline int progressFlag() const {
    01327           return (progressFlag_ & 3);
    01328      }
    01330      inline ClpSimplexProgress * progress()
    01331      { return &progress_;}
    01333      inline int forceFactorization() const {
    01334           return forceFactorization_ ;
    01335      }
    01337      inline void forceFactorization(int value) {
    01338           forceFactorization_ = value;
    01339      }
    01341      inline double rawObjectiveValue() const {
    01342           return objectiveValue_;
    01343      }
    01345      void computeObjectiveValue(bool useWorkingSolution = false);
    01347      double computeInternalObjectiveValue();
    01350      double * infeasibilityRay(bool fullRay=false) const;
    01354      inline int numberExtraRows() const {
    01355           return numberExtraRows_;
    01356      }
    01359      inline int maximumBasic() const {
    01360           return maximumBasic_;
    01361      }
    01363      inline int baseIteration() const {
    01364           return baseIteration_;
    01365      }
    01367      void generateCpp( FILE * fp, bool defaultFactor = false);
    01369      ClpFactorization * getEmptyFactorization();
    01371      void setEmptyFactorization();
    01373      void moveInfo(const ClpSimplex & rhs, bool justStatus = false);
    01375
    01377      // These are only to be used using startFinishOptions (ClpSimplexDual, ClpSimplexPrimal)
    01378      // *** At present only without scaling
    01379      // *** Slacks havve -1.0 element (so == row activity) - take care
    01381      void getBInvARow(int row, double* z, double * slack = NULL);
    01382
    01384      void getBInvRow(int row, double* z);
    01385
    01387      void getBInvACol(int col, double* vec);
    01388
    01390      void getBInvCol(int col, double* vec);
    01391
    01396      void getBasics(int* index);
    01397
    01399      //-------------------------------------------------------------------------
    01403      void setObjectiveCoefficient( int elementIndex, double elementValue );
    01405      inline void setObjCoeff( int elementIndex, double elementValue ) {
    01406           setObjectiveCoefficient( elementIndex, elementValue);
    01407      }
    01408
    01411      void setColumnLower( int elementIndex, double elementValue );
    01412
    01415      void setColumnUpper( int elementIndex, double elementValue );
    01416
    01418      void setColumnBounds( int elementIndex,
    01419                            double lower, double upper );
    01420
    01429      void setColumnSetBounds(const int* indexFirst,
    01430                              const int* indexLast,
    01431                              const double* boundList);
    01432
    01435      inline void setColLower( int elementIndex, double elementValue ) {
    01436           setColumnLower(elementIndex, elementValue);
    01437      }
    01440      inline void setColUpper( int elementIndex, double elementValue ) {
    01441           setColumnUpper(elementIndex, elementValue);
    01442      }
    01443
    01445      inline void setColBounds( int elementIndex,
    01446                                double newlower, double newupper ) {
    01447           setColumnBounds(elementIndex, newlower, newupper);
    01448      }
    01449
    01456      inline void setColSetBounds(const int* indexFirst,
    01457                                  const int* indexLast,
    01458                                  const double* boundList) {
    01459           setColumnSetBounds(indexFirst, indexLast, boundList);
    01460      }
    01461
    01464      void setRowLower( int elementIndex, double elementValue );
    01465
    01468      void setRowUpper( int elementIndex, double elementValue ) ;
    01469
    01471      void setRowBounds( int elementIndex,
    01472                         double lower, double upper ) ;
    01473
    01480      void setRowSetBounds(const int* indexFirst,
    01481                           const int* indexLast,
    01482                           const double* boundList);
    01484      void resize (int newNumberRows, int newNumberColumns);
    01485
    01487
    01489 protected:
    01490
    01499      double bestPossibleImprovement_;
    01501      double zeroTolerance_;
    01503      int columnPrimalSequence_;
    01505      int rowPrimalSequence_;
    01507      double bestObjectiveValue_;
    01509      int moreSpecialOptions_;
    01511      int baseIteration_;
    01513      double primalToleranceToGetOptimal_;
    01515      double largeValue_;
    01517      double largestPrimalError_;
    01519      double largestDualError_;
    01521      double alphaAccuracy_;
    01523      double dualBound_;
    01525      double alpha_;
    01527      double theta_;
    01529      double lowerIn_;
    01531      double valueIn_;
    01533      double upperIn_;
    01535      double dualIn_;
    01537      double lowerOut_;
    01539      double valueOut_;
    01541      double upperOut_;
    01543      double dualOut_;
    01545      double dualTolerance_;
    01547      double primalTolerance_;
    01549      double sumDualInfeasibilities_;
    01551      double sumPrimalInfeasibilities_;
    01553      double infeasibilityCost_;
    01555      double sumOfRelaxedDualInfeasibilities_;
    01557      double sumOfRelaxedPrimalInfeasibilities_;
    01559      double acceptablePivot_;
    01561      double * lower_;
    01563      double * rowLowerWork_;
    01565      double * columnLowerWork_;
    01567      double * upper_;
    01569      double * rowUpperWork_;
    01571      double * columnUpperWork_;
    01573      double * cost_;
    01575      double * rowObjectiveWork_;
    01577      double * objectiveWork_;
    01579      CoinIndexedVector * rowArray_[6];
    01581      CoinIndexedVector * columnArray_[6];
    01583      int sequenceIn_;
    01585      int directionIn_;
    01587      int sequenceOut_;
    01589      int directionOut_;
    01591      int pivotRow_;
    01593      int lastGoodIteration_;
    01595      double * dj_;
    01597      double * rowReducedCost_;
    01599      double * reducedCostWork_;
    01601      double * solution_;
    01603      double * rowActivityWork_;
    01605      double * columnActivityWork_;
    01607      int numberDualInfeasibilities_;
    01609      int numberDualInfeasibilitiesWithoutFree_;
    01611      int numberPrimalInfeasibilities_;
    01613      int numberRefinements_;
    01615      ClpDualRowPivot * dualRowPivot_;
    01617      ClpPrimalColumnPivot * primalColumnPivot_;
    01619      int * pivotVariable_;
    01621      ClpFactorization * factorization_;
    01623      double * savedSolution_;
    01625      int numberTimesOptimal_;
    01627      ClpDisasterHandler * disasterArea_;
    01629      int changeMade_;
    01631      int algorithm_;
    01634      int forceFactorization_;
    01642      int perturbation_;
    01644      unsigned char * saveStatus_;
    01649      ClpNonLinearCost * nonLinearCost_;
    01651      int lastBadIteration_;
    01653      int lastFlaggedIteration_;
    01655      int numberFake_;
    01657      int numberChanged_;
    01659      int progressFlag_;
    01661      int firstFree_;
    01665      int numberExtraRows_;
    01668      int maximumBasic_;
    01670      int dontFactorizePivots_;
    01680      double incomingInfeasibility_;
    01681      double allowedInfeasibility_;
    01683      int automaticScale_;
    01685      int maximumPerturbationSize_;
    01687      double * perturbationArray_;
    01689      ClpSimplex * baseModel_;
    01691      ClpSimplexProgress progress_;
    01692 #ifdef ABC_INHERIT
    01693   AbcSimplex * abcSimplex_;
    01694 #define CLP_ABC_WANTED 1
    01695 #define CLP_ABC_WANTED_PARALLEL 2
    01696 #define CLP_ABC_FULL_DONE 8
    01697   // bits 256,512,1024 for crash
    01698 #endif
    01699 #define CLP_ABC_BEEN_FEASIBLE 65536
    01700   int abcState_;
    01702   int numberDegeneratePivots_;
    01703 public:
    01705      mutable int spareIntArray_[4];
    01707      mutable double spareDoubleArray_[4];
    01708 protected:
    01710      friend class OsiClpSolverInterface;
    01712      friend class OsiCLPSolverInterface;
    01714 };
    01715 //#############################################################################
    01724 void
    01725 ClpSimplexUnitTest(const std::string & mpsDir);
    01726
    01727 // For Devex stuff
    01728 #define DEVEX_TRY_NORM 1.0e-4
    01729 #define DEVEX_ADD_ONE 1.0
    01730 #if defined(ABC_INHERIT) || defined(CBC_THREAD) || defined(THREADS_IN_ANALYZE)
    01731 // Use pthreads
    01732 #include <pthread.h>
    01733 typedef struct {
    01734   double result;
    01735   //const CoinIndexedVector * constVector; // can get rid of
    01736   //CoinIndexedVector * vectors[2]; // can get rid of
    01737   void * extraInfo;
    01738   void * extraInfo2;
    01739   int status;
    01740   int stuff[4];
    01741 } CoinThreadInfo;
    01742 class CoinPthreadStuff {
    01743 public:
    01748   CoinPthreadStuff (int numberThreads=0,
    01749                     void * parallelManager(void * stuff)=NULL);
    01751   CoinPthreadStuff & operator=(const CoinPthreadStuff & rhs);
    01753   ~CoinPthreadStuff (  );
    01755   inline void setStopStart(int value)
    01756   { stopStart_=value;}
    01757 #ifndef NUMBER_THREADS
    01758 #define NUMBER_THREADS 8
    01759 #endif
    01760   // For waking up thread
    01761   inline pthread_mutex_t * mutexPointer(int which,int thread=0)
    01762   { return mutex_+which+3*thread;}
    01763 #ifdef PTHREAD_BARRIER_SERIAL_THREAD
    01764   inline pthread_barrier_t * barrierPointer()
    01765   { return &barrier_;}
    01766 #endif
    01767   inline int whichLocked(int thread=0) const
    01768   { return locked_[thread];}
    01769   inline CoinThreadInfo * threadInfoPointer(int thread=0)
    01770   { return threadInfo_+thread;}
    01771   void startParallelTask(int type,int iThread,void * info=NULL);
    01772   int waitParallelTask(int type, int & iThread,bool allowIdle);
    01773   void waitAllTasks();
    01775   int whichThread() const;
    01776   void sayIdle(int iThread);
    01777   //void startThreads(int numberThreads);
    01778   //void stopThreads();
    01779   // For waking up thread
    01780   pthread_mutex_t mutex_[3*(NUMBER_THREADS+1)];
    01781 #ifdef PTHREAD_BARRIER_SERIAL_THREAD
    01782   pthread_barrier_t barrier_;
    01783 #endif
    01784   CoinThreadInfo threadInfo_[NUMBER_THREADS+1];
    01785   pthread_t abcThread_[NUMBER_THREADS+1];
    01786   int locked_[NUMBER_THREADS+1];
    01787   int stopStart_;
    01788   int numberThreads_;
    01789 };
    01790 void * clp_parallelManager(void * stuff);
    01791 #endif
    01792 #endif