Clp  1.15.10
ClpSimplex.hpp
Go to the documentation of this file.
1 /* $Id: ClpSimplex.hpp 2006 2013-12-12 15:40:41Z forrest $ */
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 /*
6  Authors
7 
8  John Forrest
9 
10  */
11 #ifndef ClpSimplex_H
12 #define ClpSimplex_H
13 
14 #include <iostream>
15 #include <cfloat>
16 #include "ClpModel.hpp"
17 #include "ClpMatrixBase.hpp"
18 #include "ClpSolve.hpp"
19 #include "ClpConfig.h"
20 class ClpDualRowPivot;
22 class ClpFactorization;
23 class CoinIndexedVector;
24 class ClpNonLinearCost;
25 class ClpNodeStuff;
26 class CoinStructuredModel;
28 class CoinWarmStartBasis;
29 class ClpDisasterHandler;
30 class ClpConstraint;
31 #ifdef CLP_HAS_ABC
32 #include "AbcCommon.hpp"
33 class AbcTolerancesEtc;
34 class AbcSimplex;
35 #include "CoinAbcCommon.hpp"
36 #endif
37 
55 class ClpSimplex : public ClpModel {
56  friend void ClpSimplexUnitTest(const std::string & mpsDir);
57 
58 public:
63  enum Status {
64  isFree = 0x00,
65  basic = 0x01,
66  atUpperBound = 0x02,
67  atLowerBound = 0x03,
68  superBasic = 0x04,
69  isFixed = 0x05
70  };
71  // For Dual
72  enum FakeBound {
73  noFake = 0x00,
74  lowerFake = 0x01,
75  upperFake = 0x02,
76  bothFake = 0x03
77  };
78 
81  ClpSimplex (bool emptyMessages = false );
83 
88  ClpSimplex(const ClpSimplex & rhs, int scalingMode = -1);
93  ClpSimplex(const ClpModel & rhs, int scalingMode = -1);
100  ClpSimplex (const ClpModel * wholeModel,
101  int numberRows, const int * whichRows,
102  int numberColumns, const int * whichColumns,
103  bool dropNames = true, bool dropIntegers = true,
104  bool fixOthers = false);
111  ClpSimplex (const ClpSimplex * wholeModel,
112  int numberRows, const int * whichRows,
113  int numberColumns, const int * whichColumns,
114  bool dropNames = true, bool dropIntegers = true,
115  bool fixOthers = false);
119  ClpSimplex (ClpSimplex * wholeModel,
120  int numberColumns, const int * whichColumns);
123  void originalModel(ClpSimplex * miniModel);
124  inline int abcState() const
125  { return abcState_;}
126  inline void setAbcState(int state)
127  { abcState_=state;}
128 #ifdef ABC_INHERIT
129  inline AbcSimplex * abcSimplex() const
130  { return abcSimplex_;}
131  inline void setAbcSimplex(AbcSimplex * simplex)
132  { abcSimplex_=simplex;}
134  int doAbcDual();
136  int doAbcPrimal(int ifValuesPass);
137 #endif
138 
143  void setPersistenceFlag(int value);
145  void makeBaseModel();
147  void deleteBaseModel();
149  inline ClpSimplex * baseModel() const {
150  return baseModel_;
151  }
155  void setToBaseModel(ClpSimplex * model = NULL);
157  ClpSimplex & operator=(const ClpSimplex & rhs);
159  ~ClpSimplex ( );
160  // Ones below are just ClpModel with some changes
172  void loadProblem ( const ClpMatrixBase& matrix,
173  const double* collb, const double* colub,
174  const double* obj,
175  const double* rowlb, const double* rowub,
176  const double * rowObjective = NULL);
177  void loadProblem ( const CoinPackedMatrix& matrix,
178  const double* collb, const double* colub,
179  const double* obj,
180  const double* rowlb, const double* rowub,
181  const double * rowObjective = NULL);
182 
185  void loadProblem ( const int numcols, const int numrows,
186  const CoinBigIndex* start, const int* index,
187  const double* value,
188  const double* collb, const double* colub,
189  const double* obj,
190  const double* rowlb, const double* rowub,
191  const double * rowObjective = NULL);
193  void loadProblem ( const int numcols, const int numrows,
194  const CoinBigIndex* start, const int* index,
195  const double* value, const int * length,
196  const double* collb, const double* colub,
197  const double* obj,
198  const double* rowlb, const double* rowub,
199  const double * rowObjective = NULL);
204  int loadProblem ( CoinModel & modelObject, bool keepSolution = false);
206  int readMps(const char *filename,
207  bool keepNames = false,
208  bool ignoreErrors = false);
210  int readGMPL(const char *filename, const char * dataName,
211  bool keepNames = false);
214  int readLp(const char *filename, const double epsilon = 1e-5);
219  void borrowModel(ClpModel & otherModel);
220  void borrowModel(ClpSimplex & otherModel);
224  void getbackSolution(const ClpSimplex & smallModel, const int * whichRow, const int * whichColumn);
233  int loadNonLinear(void * info, int & numberConstraints,
234  ClpConstraint ** & constraints);
235 #ifdef ABC_INHERIT
236  void loadTolerancesEtc(const AbcTolerancesEtc & data);
239  void unloadTolerancesEtc(AbcTolerancesEtc & data);
240 #endif
241 
242 
248  int initialSolve(ClpSolve & options);
250  int initialSolve();
252  int initialDualSolve();
254  int initialPrimalSolve();
256  int initialBarrierSolve();
269  int dual(int ifValuesPass = 0, int startFinishOptions = 0);
270  // If using Debug
271  int dualDebug(int ifValuesPass = 0, int startFinishOptions = 0);
282  int primal(int ifValuesPass = 0, int startFinishOptions = 0);
288  int nonlinearSLP(int numberPasses, double deltaTolerance);
294  int nonlinearSLP(int numberConstraints, ClpConstraint ** constraints,
295  int numberPasses, double deltaTolerance);
298  int barrier(bool crossover = true);
301  int reducedGradient(int phase = 0);
303  int solve(CoinStructuredModel * model);
304 #ifdef ABC_INHERIT
305 
309  void dealWithAbc(int solveType,int startUp,bool interrupt=false);
310 #endif
311 
317  int loadProblem ( CoinStructuredModel & modelObject,
318  bool originalOrder = true, bool keepSolution = false);
333  int cleanup(int cleanupScaling);
354  int dualRanging(int numberCheck, const int * which,
355  double * costIncrease, int * sequenceIncrease,
356  double * costDecrease, int * sequenceDecrease,
357  double * valueIncrease = NULL, double * valueDecrease = NULL);
372  int primalRanging(int numberCheck, const int * which,
373  double * valueIncrease, int * sequenceIncrease,
374  double * valueDecrease, int * sequenceDecrease);
384  int modifyCoefficientsAndPivot(int number,
385  const int * which,
386  const CoinBigIndex * start,
387  const int * row,
388  const double * newCoefficient,
389  const unsigned char * newStatus=NULL,
390  const double * newLower=NULL,
391  const double * newUpper=NULL,
392  const double * newObjective=NULL);
400  int outDuplicateRows(int numberLook,int * whichRows, bool noOverlaps=false, double tolerance=-1.0,
401  double cleanUp=0.0);
404  double moveTowardsPrimalFeasible();
407  void removeSuperBasicSlacks(int threshold=0);
420  ClpSimplex * miniPresolve(char * rowType, char * columnType,void ** info);
422  void miniPostsolve(const ClpSimplex * presolvedModel,void * info);
437  int writeBasis(const char *filename,
438  bool writeValues = false,
439  int formatType = 0) const;
442  int readBasis(const char *filename);
444  CoinWarmStartBasis * getBasis() const;
447  // Swaps factorization
450  void copyFactorization( ClpFactorization & factorization);
460  int tightenPrimalBounds(double factor = 0.0, int doTight = 0, bool tightIntegers = false);
477  int crash(double gap, int pivot);
490  int strongBranching(int numberVariables, const int * variables,
491  double * newLower, double * newUpper,
492  double ** outputSolution,
493  int * outputStatus, int * outputIterations,
494  bool stopOnFirstInfeasible = true,
495  bool alwaysFinish = false,
496  int startFinishOptions = 0);
498  int fathom(void * stuff);
504  int fathomMany(void * stuff);
506  double doubleCheck();
508  int startFastDual2(ClpNodeStuff * stuff);
510  int fastDual2(ClpNodeStuff * stuff);
512  void stopFastDual2(ClpNodeStuff * stuff);
519  ClpSimplex * fastCrunch(ClpNodeStuff * stuff, int mode);
521 
529  int pivot();
530 
536  int primalPivotResult();
537 
543  int dualPivotResultPart1();
547  int pivotResultPart2(int algorithm,int state);
548 
560  int startup(int ifValuesPass, int startFinishOptions = 0);
561  void finish(int startFinishOptions = 0);
562 
564  bool statusOfProblem(bool initial = false);
568  void copyEnabledStuff(const ClpSimplex * rhs);
570 
573  inline bool primalFeasible() const {
575  return (numberPrimalInfeasibilities_ == 0);
576  }
578  inline bool dualFeasible() const {
579  return (numberDualInfeasibilities_ == 0);
580  }
582  inline ClpFactorization * factorization() const {
583  return factorization_;
584  }
586  bool sparseFactorization() const;
587  void setSparseFactorization(bool value);
589  int factorizationFrequency() const;
590  void setFactorizationFrequency(int value);
592  inline double dualBound() const {
593  return dualBound_;
594  }
595  void setDualBound(double value);
597  inline double infeasibilityCost() const {
598  return infeasibilityCost_;
599  }
600  void setInfeasibilityCost(double value);
617  inline int perturbation() const {
618  return perturbation_;
619  }
620  void setPerturbation(int value);
622  inline int algorithm() const {
623  return algorithm_;
624  }
626  inline void setAlgorithm(int value) {
627  algorithm_ = value;
628  }
630  bool isObjectiveLimitTestValid() const ;
632  inline double sumDualInfeasibilities() const {
634  }
635  inline void setSumDualInfeasibilities(double value) {
636  sumDualInfeasibilities_ = value;
637  }
639  inline double sumOfRelaxedDualInfeasibilities() const {
641  }
642  inline void setSumOfRelaxedDualInfeasibilities(double value) {
644  }
646  inline int numberDualInfeasibilities() const {
648  }
649  inline void setNumberDualInfeasibilities(int value) {
651  }
655  }
657  inline double sumPrimalInfeasibilities() const {
659  }
660  inline void setSumPrimalInfeasibilities(double value) {
662  }
664  inline double sumOfRelaxedPrimalInfeasibilities() const {
666  }
667  inline void setSumOfRelaxedPrimalInfeasibilities(double value) {
669  }
671  inline int numberPrimalInfeasibilities() const {
673  }
674  inline void setNumberPrimalInfeasibilities(int value) {
676  }
683  int saveModel(const char * fileName);
686  int restoreModel(const char * fileName);
687 
695  void checkSolution(int setToBounds = 0);
698  void checkSolutionInternal();
700  void checkUnscaledSolution();
702  inline CoinIndexedVector * rowArray(int index) const {
703  return rowArray_[index];
704  }
706  inline CoinIndexedVector * columnArray(int index) const {
707  return columnArray_[index];
708  }
710 
711  /******************** End of most useful part **************/
717  int getSolution ( const double * rowActivities,
718  const double * columnActivities);
722  int getSolution ();
729  int createPiecewiseLinearCosts(const int * starts,
730  const double * lower, const double * gradient);
732  inline ClpDualRowPivot * dualRowPivot() const {
733  return dualRowPivot_;
734  }
737  return primalColumnPivot_;
738  }
740  inline bool goodAccuracy() const {
741  return (largestPrimalError_ < 1.0e-7 && largestDualError_ < 1.0e-7);
742  }
744  void returnModel(ClpSimplex & otherModel);
752  int internalFactorize(int solveType);
756  void restoreData(ClpDataSave saved);
758  void cleanStatus();
760  int factorize();
763  void computeDuals(double * givenDjs);
765  void computePrimals ( const double * rowActivities,
766  const double * columnActivities);
768  void add(double * array,
769  int column, double multiplier) const;
775  void unpack(CoinIndexedVector * rowArray) const ;
781  void unpack(CoinIndexedVector * rowArray, int sequence) const;
788  void unpackPacked(CoinIndexedVector * rowArray) ;
795  void unpackPacked(CoinIndexedVector * rowArray, int sequence);
796 #ifndef CLP_USER_DRIVEN
797 protected:
798 #endif
799 
803  int housekeeping(double objectiveChange);
806  void checkPrimalSolution(const double * rowActivities = NULL,
807  const double * columnActivies = NULL);
810  void checkDualSolution();
812  void checkBothSolutions();
817  double scaleObjective(double value);
819  int solveDW(CoinStructuredModel * model);
821  int solveBenders(CoinStructuredModel * model);
822 public:
833  void setValuesPassAction(double incomingInfeasibility,
834  double allowedInfeasibility);
837  int cleanFactorization(int ifValuesPass);
839 
841 public:
843  inline double alphaAccuracy() const {
844  return alphaAccuracy_;
845  }
846  inline void setAlphaAccuracy(double value) {
847  alphaAccuracy_ = value;
848  }
849 public:
851  //inline double objectiveValue() const {
852  //return (objectiveValue_-bestPossibleImprovement_)*optimizationDirection_ - dblParam_[ClpObjOffset];
853  //}
855  inline void setDisasterHandler(ClpDisasterHandler * handler) {
856  disasterArea_ = handler;
857  }
860  return disasterArea_;
861  }
863  inline double largeValue() const {
864  return largeValue_;
865  }
866  void setLargeValue( double value) ;
868  inline double largestPrimalError() const {
869  return largestPrimalError_;
870  }
872  inline double largestDualError() const {
873  return largestDualError_;
874  }
876  inline void setLargestPrimalError(double value) {
877  largestPrimalError_ = value;
878  }
880  inline void setLargestDualError(double value) {
881  largestDualError_ = value;
882  }
884  inline double zeroTolerance() const {
885  return zeroTolerance_;/*factorization_->zeroTolerance();*/
886  }
888  inline void setZeroTolerance( double value) {
889  zeroTolerance_ = value;
890  }
892  inline int * pivotVariable() const {
893  return pivotVariable_;
894  }
896  inline bool automaticScaling() const {
897  return automaticScale_ != 0;
898  }
899  inline void setAutomaticScaling(bool onOff) {
900  automaticScale_ = onOff ? 1 : 0;
901  }
903  inline double currentDualTolerance() const {
904  return dualTolerance_;
905  }
906  inline void setCurrentDualTolerance(double value) {
907  dualTolerance_ = value;
908  }
910  inline double currentPrimalTolerance() const {
911  return primalTolerance_;
912  }
913  inline void setCurrentPrimalTolerance(double value) {
914  primalTolerance_ = value;
915  }
917  inline int numberRefinements() const {
918  return numberRefinements_;
919  }
920  void setNumberRefinements( int value) ;
922  inline double alpha() const {
923  return alpha_;
924  }
925  inline void setAlpha(double value) {
926  alpha_ = value;
927  }
929  inline double dualIn() const {
930  return dualIn_;
931  }
933  inline void setDualIn(double value) {
934  dualIn_ = value;
935  }
937  inline int pivotRow() const {
938  return pivotRow_;
939  }
940  inline void setPivotRow(int value) {
941  pivotRow_ = value;
942  }
944  double valueIncomingDual() const;
946 
947 #ifndef CLP_USER_DRIVEN
948 protected:
949 #endif
950 
955  int gutsOfSolution ( double * givenDuals,
956  const double * givenPrimals,
957  bool valuesPass = false);
959  void gutsOfDelete(int type);
961  void gutsOfCopy(const ClpSimplex & rhs);
973  bool createRim(int what, bool makeRowCopy = false, int startFinishOptions = 0);
975  void createRim1(bool initial);
977  void createRim4(bool initial);
979  void createRim5(bool initial);
984  void deleteRim(int getRidOfFactorizationData = 2);
986  bool sanityCheck();
988 public:
993  inline double * solutionRegion(int section) const {
994  if (!section) return rowActivityWork_;
995  else return columnActivityWork_;
996  }
997  inline double * djRegion(int section) const {
998  if (!section) return rowReducedCost_;
999  else return reducedCostWork_;
1000  }
1001  inline double * lowerRegion(int section) const {
1002  if (!section) return rowLowerWork_;
1003  else return columnLowerWork_;
1004  }
1005  inline double * upperRegion(int section) const {
1006  if (!section) return rowUpperWork_;
1007  else return columnUpperWork_;
1008  }
1009  inline double * costRegion(int section) const {
1010  if (!section) return rowObjectiveWork_;
1011  else return objectiveWork_;
1012  }
1014  inline double * solutionRegion() const {
1015  return solution_;
1016  }
1017  inline double * djRegion() const {
1018  return dj_;
1019  }
1020  inline double * lowerRegion() const {
1021  return lower_;
1022  }
1023  inline double * upperRegion() const {
1024  return upper_;
1025  }
1026  inline double * costRegion() const {
1027  return cost_;
1028  }
1029  inline Status getStatus(int sequence) const {
1030  return static_cast<Status> (status_[sequence] & 7);
1031  }
1032  inline void setStatus(int sequence, Status newstatus) {
1033  unsigned char & st_byte = status_[sequence];
1034  st_byte = static_cast<unsigned char>(st_byte & ~7);
1035  st_byte = static_cast<unsigned char>(st_byte | newstatus);
1036  }
1038  bool startPermanentArrays();
1043  void setInitialDenseFactorization(bool onOff);
1044  bool initialDenseFactorization() const;
1046  inline int sequenceIn() const {
1047  return sequenceIn_;
1048  }
1049  inline int sequenceOut() const {
1050  return sequenceOut_;
1051  }
1053  inline void setSequenceIn(int sequence) {
1054  sequenceIn_ = sequence;
1055  }
1056  inline void setSequenceOut(int sequence) {
1057  sequenceOut_ = sequence;
1058  }
1060  inline int directionIn() const {
1061  return directionIn_;
1062  }
1063  inline int directionOut() const {
1064  return directionOut_;
1065  }
1067  inline void setDirectionIn(int direction) {
1068  directionIn_ = direction;
1069  }
1070  inline void setDirectionOut(int direction) {
1071  directionOut_ = direction;
1072  }
1074  inline double valueOut() const {
1075  return valueOut_;
1076  }
1078  inline void setValueOut(double value) {
1079  valueOut_ = value;
1080  }
1082  inline double dualOut() const {
1083  return dualOut_;
1084  }
1086  inline void setDualOut(double value) {
1087  dualOut_ = value;
1088  }
1090  inline void setLowerOut(double value) {
1091  lowerOut_ = value;
1092  }
1094  inline void setUpperOut(double value) {
1095  upperOut_ = value;
1096  }
1098  inline void setTheta(double value) {
1099  theta_ = value;
1100  }
1102  inline int isColumn(int sequence) const {
1103  return sequence < numberColumns_ ? 1 : 0;
1104  }
1106  inline int sequenceWithin(int sequence) const {
1107  return sequence < numberColumns_ ? sequence : sequence - numberColumns_;
1108  }
1110  inline double solution(int sequence) {
1111  return solution_[sequence];
1112  }
1114  inline double & solutionAddress(int sequence) {
1115  return solution_[sequence];
1116  }
1117  inline double reducedCost(int sequence) {
1118  return dj_[sequence];
1119  }
1120  inline double & reducedCostAddress(int sequence) {
1121  return dj_[sequence];
1122  }
1123  inline double lower(int sequence) {
1124  return lower_[sequence];
1125  }
1127  inline double & lowerAddress(int sequence) {
1128  return lower_[sequence];
1129  }
1130  inline double upper(int sequence) {
1131  return upper_[sequence];
1132  }
1134  inline double & upperAddress(int sequence) {
1135  return upper_[sequence];
1136  }
1137  inline double cost(int sequence) {
1138  return cost_[sequence];
1139  }
1141  inline double & costAddress(int sequence) {
1142  return cost_[sequence];
1143  }
1145  inline double originalLower(int iSequence) const {
1146  if (iSequence < numberColumns_) return columnLower_[iSequence];
1147  else
1148  return rowLower_[iSequence-numberColumns_];
1149  }
1151  inline double originalUpper(int iSequence) const {
1152  if (iSequence < numberColumns_) return columnUpper_[iSequence];
1153  else
1154  return rowUpper_[iSequence-numberColumns_];
1155  }
1157  inline double theta() const {
1158  return theta_;
1159  }
1162  inline double bestPossibleImprovement() const {
1163  return bestPossibleImprovement_;
1164  }
1166  inline ClpNonLinearCost * nonLinearCost() const {
1167  return nonLinearCost_;
1168  }
1188  inline int moreSpecialOptions() const {
1189  return moreSpecialOptions_;
1190  }
1211  inline void setMoreSpecialOptions(int value) {
1212  moreSpecialOptions_ = value;
1213  }
1215 
1217  inline void setFakeBound(int sequence, FakeBound fakeBound) {
1218  unsigned char & st_byte = status_[sequence];
1219  st_byte = static_cast<unsigned char>(st_byte & ~24);
1220  st_byte = static_cast<unsigned char>(st_byte | (fakeBound << 3));
1221  }
1222  inline FakeBound getFakeBound(int sequence) const {
1223  return static_cast<FakeBound> ((status_[sequence] >> 3) & 3);
1224  }
1225  inline void setRowStatus(int sequence, Status newstatus) {
1226  unsigned char & st_byte = status_[sequence+numberColumns_];
1227  st_byte = static_cast<unsigned char>(st_byte & ~7);
1228  st_byte = static_cast<unsigned char>(st_byte | newstatus);
1229  }
1230  inline Status getRowStatus(int sequence) const {
1231  return static_cast<Status> (status_[sequence+numberColumns_] & 7);
1232  }
1233  inline void setColumnStatus(int sequence, Status newstatus) {
1234  unsigned char & st_byte = status_[sequence];
1235  st_byte = static_cast<unsigned char>(st_byte & ~7);
1236  st_byte = static_cast<unsigned char>(st_byte | newstatus);
1237  }
1238  inline Status getColumnStatus(int sequence) const {
1239  return static_cast<Status> (status_[sequence] & 7);
1240  }
1241  inline void setPivoted( int sequence) {
1242  status_[sequence] = static_cast<unsigned char>(status_[sequence] | 32);
1243  }
1244  inline void clearPivoted( int sequence) {
1245  status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~32);
1246  }
1247  inline bool pivoted(int sequence) const {
1248  return (((status_[sequence] >> 5) & 1) != 0);
1249  }
1251  void setFlagged( int sequence);
1252  inline void clearFlagged( int sequence) {
1253  status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64);
1254  }
1255  inline bool flagged(int sequence) const {
1256  return ((status_[sequence] & 64) != 0);
1257  }
1259  inline void setActive( int iRow) {
1260  status_[iRow] = static_cast<unsigned char>(status_[iRow] | 128);
1261  }
1262  inline void clearActive( int iRow) {
1263  status_[iRow] = static_cast<unsigned char>(status_[iRow] & ~128);
1264  }
1265  inline bool active(int iRow) const {
1266  return ((status_[iRow] & 128) != 0);
1267  }
1270  void createStatus() ;
1273  void allSlackBasis(bool resetSolution = false);
1274 
1276  inline int lastBadIteration() const {
1277  return lastBadIteration_;
1278  }
1280  inline void setLastBadIteration(int value) {
1281  lastBadIteration_=value;
1282  }
1284  inline int progressFlag() const {
1285  return (progressFlag_ & 3);
1286  }
1289  { return &progress_;}
1291  inline int forceFactorization() const {
1292  return forceFactorization_ ;
1293  }
1295  inline void forceFactorization(int value) {
1296  forceFactorization_ = value;
1297  }
1299  inline double rawObjectiveValue() const {
1300  return objectiveValue_;
1301  }
1303  void computeObjectiveValue(bool useWorkingSolution = false);
1308  double * infeasibilityRay(bool fullRay=false) const;
1312  inline int numberExtraRows() const {
1313  return numberExtraRows_;
1314  }
1317  inline int maximumBasic() const {
1318  return maximumBasic_;
1319  }
1321  inline int baseIteration() const {
1322  return baseIteration_;
1323  }
1325  void generateCpp( FILE * fp, bool defaultFactor = false);
1329  void setEmptyFactorization();
1331  void moveInfo(const ClpSimplex & rhs, bool justStatus = false);
1333 
1335  // These are only to be used using startFinishOptions (ClpSimplexDual, ClpSimplexPrimal)
1336  // *** At present only without scaling
1337  // *** Slacks havve -1.0 element (so == row activity) - take care
1339  void getBInvARow(int row, double* z, double * slack = NULL);
1340 
1342  void getBInvRow(int row, double* z);
1343 
1345  void getBInvACol(int col, double* vec);
1346 
1348  void getBInvCol(int col, double* vec);
1349 
1354  void getBasics(int* index);
1355 
1357  //-------------------------------------------------------------------------
1361  void setObjectiveCoefficient( int elementIndex, double elementValue );
1363  inline void setObjCoeff( int elementIndex, double elementValue ) {
1364  setObjectiveCoefficient( elementIndex, elementValue);
1365  }
1366 
1369  void setColumnLower( int elementIndex, double elementValue );
1370 
1373  void setColumnUpper( int elementIndex, double elementValue );
1374 
1376  void setColumnBounds( int elementIndex,
1377  double lower, double upper );
1378 
1387  void setColumnSetBounds(const int* indexFirst,
1388  const int* indexLast,
1389  const double* boundList);
1390 
1393  inline void setColLower( int elementIndex, double elementValue ) {
1394  setColumnLower(elementIndex, elementValue);
1395  }
1398  inline void setColUpper( int elementIndex, double elementValue ) {
1399  setColumnUpper(elementIndex, elementValue);
1400  }
1401 
1403  inline void setColBounds( int elementIndex,
1404  double newlower, double newupper ) {
1405  setColumnBounds(elementIndex, newlower, newupper);
1406  }
1407 
1414  inline void setColSetBounds(const int* indexFirst,
1415  const int* indexLast,
1416  const double* boundList) {
1417  setColumnSetBounds(indexFirst, indexLast, boundList);
1418  }
1419 
1422  void setRowLower( int elementIndex, double elementValue );
1423 
1426  void setRowUpper( int elementIndex, double elementValue ) ;
1427 
1429  void setRowBounds( int elementIndex,
1430  double lower, double upper ) ;
1431 
1438  void setRowSetBounds(const int* indexFirst,
1439  const int* indexLast,
1440  const double* boundList);
1442  void resize (int newNumberRows, int newNumberColumns);
1443 
1445 
1447 protected:
1448 
1473  double largeValue_;
1481  double dualBound_;
1483  double alpha_;
1485  double theta_;
1487  double lowerIn_;
1489  double valueIn_;
1491  double upperIn_;
1493  double dualIn_;
1495  double lowerOut_;
1497  double valueOut_;
1499  double upperOut_;
1501  double dualOut_;
1519  double * lower_;
1521  double * rowLowerWork_;
1525  double * upper_;
1527  double * rowUpperWork_;
1531  double * cost_;
1535  double * objectiveWork_;
1537  CoinIndexedVector * rowArray_[6];
1539  CoinIndexedVector * columnArray_[6];
1553  double * dj_;
1559  double * solution_;
1581  double * savedSolution_;
1602  unsigned char * saveStatus_;
1650 #ifdef ABC_INHERIT
1651  AbcSimplex * abcSimplex_;
1652 #define CLP_ABC_WANTED 1
1653 #define CLP_ABC_WANTED_PARALLEL 2
1654 #define CLP_ABC_FULL_DONE 8
1655  // bits 256,512,1024 for crash
1656 #endif
1657 #define CLP_ABC_BEEN_FEASIBLE 65536
1659 public:
1661  mutable int spareIntArray_[4];
1663  mutable double spareDoubleArray_[4];
1664 protected:
1668 };
1669 //#############################################################################
1678 void
1679 ClpSimplexUnitTest(const std::string & mpsDir);
1680 
1681 // For Devex stuff
1682 #define DEVEX_TRY_NORM 1.0e-4
1683 #define DEVEX_ADD_ONE 1.0
1684 #endif
void deleteRim(int getRidOfFactorizationData=2)
releases above arrays and does solution scaling out.
This is a very simple class to guide algorithms.
Definition: ClpSolve.hpp:20
double lowerIn_
Lower Bound on In variable.
int perturbation() const
Amount of print out: 0 - none 1 - just final 2 - just factorizations 3 - as 2 plus a bit more 4 - ver...
Definition: ClpSimplex.hpp:617
void unpack(CoinIndexedVector *rowArray) const
Unpacks one column of the matrix into indexed array Uses sequenceIn_ Also applies scaling if needed...
void setObjCoeff(int elementIndex, double elementValue)
Set an objective function coefficient.
double * reducedCostWork_
Possible scaled reduced costs.
void returnModel(ClpSimplex &otherModel)
Return model - updates any scalars.
int perturbation_
Perturbation: -50 to +50 - perturb by this power of ten (-6 sounds good) 100 - auto perturb if takes ...
void setColumnBounds(int elementIndex, double lower, double upper)
Set a single column lower and upper bound.
int getSolution()
Given an existing factorization computes and checks primal and dual solutions.
void setRowUpper(int elementIndex, double elementValue)
Set a single row upper bound Use DBL_MAX for infinity.
ClpNonLinearCost * nonLinearCost_
Very wasteful way of dealing with infeasibilities in primal.
void setAlpha(double value)
Definition: ClpSimplex.hpp:925
int startup(int ifValuesPass, int startFinishOptions=0)
Common bits of coding for dual and primal.
void setRowBounds(int elementIndex, double lower, double upper)
Set a single row lower and upper bound.
int moreSpecialOptions_
More special options - see set for details.
int initialBarrierSolve()
Barrier initial solve.
int writeBasis(const char *filename, bool writeValues=false, int formatType=0) const
Write the basis in MPS format to the specified file.
Status
enums for status of various sorts.
Definition: ClpSimplex.hpp:63
double * rowUpper_
Row upper.
Definition: ClpModel.hpp:1136
ClpNonLinearCost * nonLinearCost() const
Return pointer to details of costs.
double * lower_
Working copy of lower bounds (Owner of arrays below)
int lastBadIteration_
So we know when to be cautious.
CoinWarmStartBasis * getBasis() const
Returns a basis (to be deleted by user)
void setMoreSpecialOptions(int value)
Set more special options 1 bit - if presolve says infeasible in ClpSolve return 2 bit - if presolved ...
int modifyCoefficientsAndPivot(int number, const int *which, const CoinBigIndex *start, const int *row, const double *newCoefficient, const unsigned char *newStatus=NULL, const double *newLower=NULL, const double *newUpper=NULL, const double *newObjective=NULL)
Modifies coefficients etc and if necessary pivots in and out.
ClpSimplex & operator=(const ClpSimplex &rhs)
Assignment operator. This copies the data.
int numberDualInfeasibilities_
Number of dual infeasibilities.
ClpFactorization * factorization_
factorization
CoinIndexedVector * rowArray(int index) const
Useful row length arrays (0,1,2,3,4,5)
Definition: ClpSimplex.hpp:702
bool dualFeasible() const
If problem is dual feasible.
Definition: ClpSimplex.hpp:578
void setCurrentPrimalTolerance(double value)
Definition: ClpSimplex.hpp:913
void setDualBound(double value)
bool sparseFactorization() const
Sparsity on or off.
Primal Column Pivot Abstract Base Class.
void finish(int startFinishOptions=0)
int reducedGradient(int phase=0)
Solves non-linear using reduced gradient.
double dualBound_
Dual bound.
void loadProblem(const ClpMatrixBase &matrix, const double *collb, const double *colub, const double *obj, const double *rowlb, const double *rowub, const double *rowObjective=NULL)
Loads a problem (the constraints on the rows are given by lower and upper bounds).
Abstract base class for Clp Matrices.
double & costAddress(int sequence)
Return address of row or column cost.
void setDirectionIn(int direction)
Set directionIn or Out.
void setAutomaticScaling(bool onOff)
Definition: ClpSimplex.hpp:899
bool flagged(int sequence) const
void setDisasterHandler(ClpDisasterHandler *handler)
Objective value.
Definition: ClpSimplex.hpp:855
int numberColumns() const
Definition: ClpModel.hpp:325
void setCurrentDualTolerance(double value)
Definition: ClpSimplex.hpp:906
int restoreModel(const char *fileName)
Restore model from file, returns 0 if success, deletes current model.
void clearFlagged(int sequence)
double incomingInfeasibility_
For advanced use.
int numberDualInfeasibilities() const
Number of dual infeasibilities.
Definition: ClpSimplex.hpp:646
double * costRegion() const
double spareDoubleArray_[4]
Spare double array for passing information [0]!=0 switches on.
double theta() const
Theta (pivot change)
CoinIndexedVector * rowArray_[6]
Useful row length arrays.
bool primalFeasible() const
If problem is primal feasible.
Definition: ClpSimplex.hpp:574
int barrier(bool crossover=true)
Solves using barrier (assumes you have good cholesky factor code).
double dualOut_
Infeasibility (dual) or ? (primal) of Out variable.
double sumDualInfeasibilities() const
Sum of dual infeasibilities.
Definition: ClpSimplex.hpp:632
double & reducedCostAddress(int sequence)
void getbackSolution(const ClpSimplex &smallModel, const int *whichRow, const int *whichColumn)
Puts solution back into small model.
int dualPivotResultPart1()
Pivot out a variable and choose an incoing one.
int forceFactorization() const
Force re-factorization early value.
double valueIn_
Value of In variable.
void defaultFactorizationFrequency()
If user left factorization frequency then compute.
void moveInfo(const ClpSimplex &rhs, bool justStatus=false)
Move status and solution across.
double & upperAddress(int sequence)
Return address of row or column upper bound.
void setUpperOut(double value)
Set upper of out variable.
int dualRanging(int numberCheck, const int *which, double *costIncrease, int *sequenceIncrease, double *costDecrease, int *sequenceDecrease, double *valueIncrease=NULL, double *valueDecrease=NULL)
Dual ranging.
void stopFastDual2(ClpNodeStuff *stuff)
Stops Fast dual2.
int startFastDual2(ClpNodeStuff *stuff)
Starts Fast dual2.
Constraint Abstract Base Class.
double * cost_
Working copy of objective (Owner of arrays below)
void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot &choice)
Sets column pivot choice algorithm in primal.
double bestPossibleImprovement_
Best possible improvement using djs (primal) or obj change by flipping bounds to make dual feasible (...
double valueIncomingDual() const
value of incoming variable (in Dual)
void setColumnStatus(int sequence, Status newstatus)
void setDirectionOut(int direction)
int maximumPerturbationSize_
Maximum perturbation array size (take out when code rewritten)
void setToBaseModel(ClpSimplex *model=NULL)
Reset to base model (just size and arrays needed) If model NULL use internal copy.
For saving extra information to see if looping.
Definition: ClpSolve.hpp:252
int solveType() const
Solve type - 1 simplex, 2 simplex interface, 3 Interior.
Definition: ClpModel.hpp:373
void checkSolutionInternal()
Just check solution (for internal use) - sets sum of infeasibilities etc.
int forceFactorization_
Now for some reliability aids This forces re-factorization early.
void checkUnscaledSolution()
Check unscaled primal solution but allow for rounding error.
int directionOut() const
Base class for Clp disaster handling.
int sequenceIn() const
Return sequence In or Out.
double infeasibilityCost() const
Infeasibility cost.
Definition: ClpSimplex.hpp:597
double upperOut_
Upper Bound on Out variable.
double scaleObjective(double value)
If input negative scales objective so maximum <= -value and returns scale factor used.
double upperIn_
Upper Bound on In variable.
double largeValue() const
Large bound value (for complementarity etc)
Definition: ClpSimplex.hpp:863
int primalRanging(int numberCheck, const int *which, double *valueIncrease, int *sequenceIncrease, double *valueDecrease, int *sequenceDecrease)
Primal ranging.
void setColSetBounds(const int *indexFirst, const int *indexLast, const double *boundList)
Set the bounds on a number of columns simultaneously
Clp Solver Interface.
int cleanFactorization(int ifValuesPass)
Get a clean factorization - i.e.
double largestDualError() const
Largest error on basic duals.
Definition: ClpSimplex.hpp:872
void setAlgorithm(int value)
Set algorithm.
Definition: ClpSimplex.hpp:626
double * infeasibilityRay(bool fullRay=false) const
Infeasibility/unbounded ray (NULL returned if none/wrong) Up to user to use delete [] on these arrays...
double theta_
Theta (pivot change)
double alpha() const
Alpha (pivot element) for use by classes e.g. steepestedge.
Definition: ClpSimplex.hpp:922
This just implements CoinFactorization when an ClpMatrixBase object is passed.
double alphaAccuracy() const
Initial value for alpha accuracy calculation (-1.0 off)
Definition: ClpSimplex.hpp:843
int sequenceOut() const
void setZeroTolerance(double value)
Set zero tolerance.
Definition: ClpSimplex.hpp:888
ClpSimplex * miniPresolve(char *rowType, char *columnType, void **info)
Mini presolve (faster) Char arrays must be numberRows and numberColumns long on entry second part mus...
ClpDualRowPivot * dualRowPivot() const
dual row pivot choice
Definition: ClpSimplex.hpp:732
int lastBadIteration() const
So we know when to be cautious.
int loadNonLinear(void *info, int &numberConstraints, ClpConstraint **&constraints)
Load nonlinear part of problem from AMPL info Returns 0 if linear 1 if quadratic objective 2 if quadr...
int directionIn_
Direction of In, 1 going up, -1 going down, 0 not a clude.
Status getRowStatus(int sequence) const
int gutsOfSolution(double *givenDuals, const double *givenPrimals, bool valuesPass=false)
May change basis and then returns number changed.
void checkDualSolution()
This sets largest infeasibility and most infeasible and sum and number of infeasibilities (Dual) ...
void computePrimals(const double *rowActivities, const double *columnActivities)
Computes primals from scratch.
int directionIn() const
Return direction In or Out.
int dualDebug(int ifValuesPass=0, int startFinishOptions=0)
void resize(int newNumberRows, int newNumberColumns)
Resizes rim part of model.
int primal(int ifValuesPass=0, int startFinishOptions=0)
Primal algorithm - see ClpSimplexPrimal.hpp for method.
CoinPackedMatrix * matrix() const
Matrix (if not ClpPackedmatrix be careful about memory leak.
Definition: ClpModel.hpp:697
void getBInvRow(int row, double *z)
Get a row of the basis inverse.
int initialDualSolve()
Dual initial solve.
void makeBaseModel()
Save a copy of model with certain state - normally without cuts.
int maximumBasic() const
Maximum number of basic variables - can be more than number of rows if GUB.
void cleanStatus()
Clean up status.
ClpEventHandler * eventHandler() const
Event handler.
Definition: ClpModel.hpp:887
int numberFake_
Can be used for count of fake bounds (dual) or fake costs (primal)
ClpFactorization * factorization() const
factorization
Definition: ClpSimplex.hpp:582
double & lowerAddress(int sequence)
Return address of row or column lower bound.
void copyEnabledStuff(const ClpSimplex *rhs)
Copy across enabled stuff from one solver to another.
void setNumberRefinements(int value)
int outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps=false, double tolerance=-1.0, double cleanUp=0.0)
Take out duplicate rows (includes scaled rows and intersections).
void deleteBaseModel()
Switch off base model.
int sequenceIn_
Sequence of In variable.
double bestObjectiveValue_
"Best" objective value
void allSlackBasis(bool resetSolution=false)
Sets up all slack basis and resets solution to as it was after initial load or readMps.
double computeInternalObjectiveValue()
Compute minimization objective value from internal solution without perturbation. ...
void setNumberDualInfeasibilities(int value)
Definition: ClpSimplex.hpp:649
double currentDualTolerance() const
Current dual tolerance.
Definition: ClpSimplex.hpp:903
double currentPrimalTolerance() const
Current primal tolerance.
Definition: ClpSimplex.hpp:910
int lastFlaggedIteration_
So we know when to open up again.
void computeDuals(double *givenDjs)
Computes duals from scratch.
double * solutionRegion() const
Return region as single array.
double originalUpper(int iSequence) const
Return original lower bound.
void forceFactorization(int value)
Force re-factorization early.
double lowerOut_
Lower Bound on Out variable.
void setSumDualInfeasibilities(double value)
Definition: ClpSimplex.hpp:635
ClpDisasterHandler * disasterArea_
Disaster handler.
int factorizationFrequency() const
Factorization frequency.
void getBasics(int *index)
Get basic indices (order of indices corresponds to the order of elements in a vector retured by getBI...
int spareIntArray_[4]
Spare int array for passing information [0]!=0 switches on.
void setLastBadIteration(int value)
Set so we know when to be cautious.
CoinIndexedVector * columnArray(int index) const
Useful column length arrays (0,1,2,3,4,5)
Definition: ClpSimplex.hpp:706
int dual(int ifValuesPass=0, int startFinishOptions=0)
Dual algorithm - see ClpSimplexDual.hpp for method.
void checkPrimalSolution(const double *rowActivities=NULL, const double *columnActivies=NULL)
This sets largest infeasibility and most infeasible and sum and number of infeasibilities (Primal) ...
int moreSpecialOptions() const
Return more special options 1 bit - if presolve says infeasible in ClpSolve return 2 bit - if presolv...
int pivot()
Pivot in a variable and out a variable.
void clearActive(int iRow)
void setInitialDenseFactorization(bool onOff)
Normally the first factorization does sparse coding because the factorization could be singular...
int algorithm() const
Current (or last) algorithm.
Definition: ClpSimplex.hpp:622
void getBInvACol(int col, double *vec)
Get a column of the tableau.
double * upper_
Working copy of upper bounds (Owner of arrays below)
CoinIndexedVector * columnArray_[6]
Useful column length arrays.
double bestPossibleImprovement() const
Best possible improvement using djs (primal) or obj change by flipping bounds to make dual feasible (...
double * columnLowerWork_
Column lower bounds - working copy.
void generateCpp(FILE *fp, bool defaultFactor=false)
Create C++ lines to get to current state.
void clearPivoted(int sequence)
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:55
void setColumnSetBounds(const int *indexFirst, const int *indexLast, const double *boundList)
Set the bounds on a number of columns simultaneously The default implementation just invokes setColL...
double dualBound() const
Dual bound.
Definition: ClpSimplex.hpp:592
int * pivotVariable() const
Basic variables pivoting on which rows.
Definition: ClpSimplex.hpp:892
int housekeeping(double objectiveChange)
This does basis housekeeping and does values for in/out variables.
int numberChanged_
Can be used for count of changed costs (dual) or changed bounds (primal)
double * columnUpper_
Column Upper.
Definition: ClpModel.hpp:1144
int baseIteration_
Iteration when we entered dual or primal.
void createRim5(bool initial)
Does rows and columns and objective.
void setDualIn(double value)
Set reduced cost of last incoming to force error.
Definition: ClpSimplex.hpp:933
int initialPrimalSolve()
Primal initial solve.
int progressFlag() const
Progress flag - at present 0 bit says artificials out.
void restoreData(ClpDataSave saved)
Restore data.
double moveTowardsPrimalFeasible()
Try simple crash like techniques to get closer to primal feasibility returns final sum of infeasibili...
void setInfeasibilityCost(double value)
void setColLower(int elementIndex, double elementValue)
Set a single column lower bound Use -DBL_MAX for -infinity.
void borrowModel(ClpModel &otherModel)
Borrow model.
double sumOfRelaxedPrimalInfeasibilities() const
Sum of relaxed primal infeasibilities.
Definition: ClpSimplex.hpp:664
double sumPrimalInfeasibilities() const
Sum of primal infeasibilities.
Definition: ClpSimplex.hpp:657
int readMps(const char *filename, bool keepNames=false, bool ignoreErrors=false)
Read an mps file from the given filename.
void setSequenceOut(int sequence)
int numberRefinements_
How many iterative refinements to do.
int numberDualInfeasibilitiesWithoutFree_
Number of dual infeasibilities (without free)
double * columnActivityWork_
Column activities - working copy.
void setPivotRow(int value)
Definition: ClpSimplex.hpp:940
void setObjectiveCoefficient(int elementIndex, double elementValue)
Set an objective function coefficient.
ClpDualRowPivot * dualRowPivot_
dual row pivot choice
int columnPrimalSequence_
Sequence of worst (-1 if feasible)
void unpackPacked(CoinIndexedVector *rowArray)
Unpacks one column of the matrix into indexed array as packed vector Uses sequenceIn_ Also applies sc...
int changeMade_
If change has been made (first attempt at stopping looping)
void add(double *array, int column, double multiplier) const
Adds multiple of a column into an array.
double largestDualError_
Largest error on basic duals.
int * pivotVariable_
Basic variables pivoting on which rows.
unsigned char * saveStatus_
Saved status regions.
void setPerturbation(int value)
int numberColumns_
Number of columns.
Definition: ClpModel.hpp:1124
bool goodAccuracy() const
Returns true if model looks OK.
Definition: ClpSimplex.hpp:740
void gutsOfCopy(const ClpSimplex &rhs)
Does most of copying.
void setValueOut(double value)
Set value of out variable.
double * upperRegion(int section) const
friend void ClpSimplexUnitTest(const std::string &mpsDir)
A function that tests the methods in the ClpSimplex class.
This is a tiny class where data can be saved round calls.
Definition: ClpModel.hpp:1267
void setLargeValue(double value)
int dontFactorizePivots_
If may skip final factorize then allow up to this pivots (default 20)
ClpSimplex(bool emptyMessages=false)
Default constructor.
void setAlphaAccuracy(double value)
Definition: ClpSimplex.hpp:846
int nonlinearSLP(int numberPasses, double deltaTolerance)
Solves nonlinear problem using SLP - may be used as crash for other algorithms when number of iterati...
double * costRegion(int section) const
void computeObjectiveValue(bool useWorkingSolution=false)
Compute objective value from solution and put in objectiveValue_.
void setFactorizationFrequency(int value)
void setAbcState(int state)
Definition: ClpSimplex.hpp:126
int abcState() const
Definition: ClpSimplex.hpp:124
int numberTimesOptimal_
Number of times code has tentatively thought optimal.
void setColumnLower(int elementIndex, double elementValue)
Set a single column lower bound Use -DBL_MAX for -infinity.
bool initialDenseFactorization() const
double * lowerRegion(int section) const
int tightenPrimalBounds(double factor=0.0, int doTight=0, bool tightIntegers=false)
Tightens primal bounds to make dual faster.
ClpPrimalColumnPivot * primalColumnPivot() const
primal column pivot choice
Definition: ClpSimplex.hpp:736
double * savedSolution_
Saved version of solution.
int fathom(void *stuff)
Fathom - 1 if solution.
void copyFactorization(ClpFactorization &factorization)
Copies in factorization to existing one.
double * djRegion(int section) const
Definition: ClpSimplex.hpp:997
double primalTolerance_
Current primal tolerance for algorithm.
int progressFlag_
Progress flag - at present 0 bit says artificials out, 1 free in.
double upper(int sequence)
int algorithm_
Algorithm >0 == Primal, <0 == Dual.
int lastGoodIteration_
Last good iteration (immediately after a re-factorization)
double * perturbationArray_
Perturbation array (maximumPerturbationSize_)
void miniPostsolve(const ClpSimplex *presolvedModel, void *info)
After mini presolve.
double * rowReducedCost_
Reduced costs of slacks not same as duals (or - duals)
double * rowObjectiveWork_
Row objective - working copy.
double * upperRegion() const
int primalPivotResult()
Pivot in a variable and choose an outgoing one.
int pivotRow_
Pivot Row.
int maximumBasic_
Maximum number of basic variables - can be more than number of rows if GUB.
~ClpSimplex()
Destructor.
int solveBenders(CoinStructuredModel *model)
Solve using Benders decomposition and maybe in parallel.
double largestPrimalError_
Largest error on Ax-b.
Status getColumnStatus(int sequence) const
double & solutionAddress(int sequence)
Return address of row or column values.
double sumOfRelaxedDualInfeasibilities() const
Sum of relaxed dual infeasibilities.
Definition: ClpSimplex.hpp:639
void setFactorization(ClpFactorization &factorization)
Passes in factorization.
void setSequenceIn(int sequence)
Set sequenceIn or Out.
double primalToleranceToGetOptimal_
Primal tolerance needed to make dual feasible (<largeTolerance)
bool startPermanentArrays()
Start or reset using maximumRows_ and Columns_ - true if change.
double sumOfRelaxedPrimalInfeasibilities_
Sum of Primal infeasibilities using tolerance based on error in primals.
int cleanup(int cleanupScaling)
When scaling is on it is possible that the scaled problem is feasible but the unscaled is not...
bool isObjectiveLimitTestValid() const
Return true if the objective limit test can be relied upon.
double sumDualInfeasibilities_
Sum of dual infeasibilities.
double acceptablePivot_
Acceptable pivot value just after factorization.
ClpDisasterHandler * disasterHandler() const
Get disaster handler.
Definition: ClpSimplex.hpp:859
bool statusOfProblem(bool initial=false)
Factorizes and returns true if optimal.
int initialSolve()
Default initial solve.
double sumOfRelaxedDualInfeasibilities_
Sum of Dual infeasibilities using tolerance based on error in duals.
double dualOut() const
Dual value of Out variable.
double dualIn_
Reduced cost of In variable.
Status getStatus(int sequence) const
double * rowUpperWork_
Row upper bounds - working copy.
int createPiecewiseLinearCosts(const int *starts, const double *lower, const double *gradient)
Constructs a non linear cost from list of non-linearities (columns only) First lower of each column i...
double lower(int sequence)
double * objectiveWork_
Column objective - working copy.
int readBasis(const char *filename)
Read a basis from the given filename, returns -1 on file error, 0 if no values, 1 if values...
void setRowLower(int elementIndex, double elementValue)
Set a single row lower bound Use -DBL_MAX for -infinity.
void setSumOfRelaxedPrimalInfeasibilities(double value)
Definition: ClpSimplex.hpp:667
Base class for Clp event handling.
ClpFactorization * getEmptyFactorization()
Gets clean and emptyish factorization.
void setDualOut(double value)
Set dual value of out variable.
int solveDW(CoinStructuredModel *model)
Solve using Dantzig-Wolfe decomposition and maybe in parallel.
void setColBounds(int elementIndex, double newlower, double newupper)
Set a single column lower and upper bound.
ClpFactorization * swapFactorization(ClpFactorization *factorization)
bool automaticScaling() const
If automatic scaling on.
Definition: ClpSimplex.hpp:896
int numberDualInfeasibilitiesWithoutFree() const
Number of dual infeasibilities (without free)
Definition: ClpSimplex.hpp:653
int numberRows() const
Number of rows.
Definition: ClpModel.hpp:315
void setColUpper(int elementIndex, double elementValue)
Set a single column upper bound Use DBL_MAX for infinity.
unsigned char * status_
Status (i.e.
Definition: ClpModel.hpp:1171
int internalFactorize(int solveType)
Factorizes using current basis.
int saveModel(const char *fileName)
Save model to file, returns 0 if success.
double valueOut_
Value of Out variable.
void getBInvCol(int col, double *vec)
Get a column of the basis inverse.
int numberPrimalInfeasibilities() const
Number of primal infeasibilities.
Definition: ClpSimplex.hpp:671
double reducedCost(int sequence)
void gutsOfDelete(int type)
Does most of deletion (0 = all, 1 = most, 2 most + factorization)
double dualTolerance_
Current dual tolerance for algorithm.
void setLowerOut(double value)
Set lower of out variable.
int sequenceOut_
Sequence of Out variable.
void setLargestPrimalError(double value)
Largest error on Ax-b.
Definition: ClpSimplex.hpp:876
int numberExtraRows() const
Number of extra rows.
void setFakeBound(int sequence, FakeBound fakeBound)
void getBInvARow(int row, double *z, double *slack=NULL)
Get a row of the tableau (slack part in slack if not NULL)
void removeSuperBasicSlacks(int threshold=0)
Try simple crash like techniques to remove super basic slacks but only if > threshold.
int readLp(const char *filename, const double epsilon=1e-5)
Read file in LP format from file with name filename.
void setTheta(double value)
Set theta of out variable.
double cost(int sequence)
int sequenceWithin(int sequence) const
Returns sequence number within section.
void createRim4(bool initial)
Does objective.
ClpSimplexProgress * progress()
For dealing with all issues of cycling etc.
double largeValue_
Large bound value (for complementarity etc)
double zeroTolerance() const
Get zero tolerance.
Definition: ClpSimplex.hpp:884
int pivotResultPart2(int algorithm, int state)
Do actual pivot state is 0 if need tableau column, 1 if in rowArray_[1].
void setRowSetBounds(const int *indexFirst, const int *indexLast, const double *boundList)
Set the bounds on a number of rows simultaneously
void originalModel(ClpSimplex *miniModel)
This copies back stuff from miniModel and then deletes miniModel.
ClpSimplex * fastCrunch(ClpNodeStuff *stuff, int mode)
Deals with crunch aspects mode 0 - in 1 - out with solution 2 - out without solution returns small mo...
double infeasibilityCost_
Weight assigned to being infeasible in primal.
ClpSimplex * baseModel_
A copy of model with certain state - normally without cuts.
bool active(int iRow) const
double * rowLower_
Row lower.
Definition: ClpModel.hpp:1134
double * rowObjective() const
Row Objective.
Definition: ClpModel.hpp:676
int initialBarrierNoCrossSolve()
Barrier initial solve, not to be followed by crossover.
ClpSimplex * baseModel() const
See if we have base model.
Definition: ClpSimplex.hpp:149
double solution(int sequence)
Return row or column values.
double largestPrimalError() const
Largest error on Ax-b.
Definition: ClpSimplex.hpp:868
int pivotRow() const
Pivot Row for use by classes e.g. steepestedge.
Definition: ClpSimplex.hpp:937
void checkBothSolutions()
This sets sum and number of infeasibilities (Dual and Primal)
double originalLower(int iSequence) const
Return original lower bound.
double * columnUpperWork_
Column upper bounds - working copy.
double zeroTolerance_
Zero tolerance.
void setFlagged(int sequence)
To flag a variable (not inline to allow for column generation)
void setSumOfRelaxedDualInfeasibilities(double value)
Definition: ClpSimplex.hpp:642
ClpPrimalColumnPivot * primalColumnPivot_
primal column pivot choice
double valueOut() const
Value of Out variable.
double rawObjectiveValue() const
Raw objective value (so always minimize in primal)
void createStatus()
Set up status array (can be used by OsiClp).
double dualIn() const
Reduced cost of last incoming for use by classes e.g. steepestedge.
Definition: ClpSimplex.hpp:929
double alpha_
Alpha (pivot element)
int directionOut_
Direction of Out, 1 to upper bound, -1 to lower bound, 0 - superbasic.
int numberExtraRows_
Number of extra rows.
double * rowLowerWork_
Row lower bounds - working copy.
int readGMPL(const char *filename, const char *dataName, bool keepNames=false)
Read GMPL files from the given filenames.
int baseIteration() const
Iteration when we entered dual or primal.
void setNumberPrimalInfeasibilities(int value)
Definition: ClpSimplex.hpp:674
void setSumPrimalInfeasibilities(double value)
Definition: ClpSimplex.hpp:660
void createRim1(bool initial)
Does rows and columns.
ClpDataSave saveData()
Save data.
int numberPrimalInfeasibilities_
Number of primal infeasibilities.
void setStatus(int sequence, Status newstatus)
void setEmptyFactorization()
May delete or may make clean and emptyish factorization.
bool createRim(int what, bool makeRowCopy=false, int startFinishOptions=0)
puts in format I like (rowLower,rowUpper) also see StandardMatrix 1 bit does rows (now and columns)...
void dropNames()
Drops names - makes lengthnames 0 and names empty.
void setRowStatus(int sequence, Status newstatus)
void setPivoted(int sequence)
int fastDual2(ClpNodeStuff *stuff)
Like Fast dual.
double objectiveValue_
Objective value.
Definition: ClpModel.hpp:1114
ClpSimplexProgress progress_
For dealing with all issues of cycling etc.
void setPersistenceFlag(int value)
Array persistence flag If 0 then as now (delete/new) 1 then only do arrays if bigger needed 2 as 1 bu...
double sumPrimalInfeasibilities_
Sum of primal infeasibilities.
void setDualRowPivotAlgorithm(ClpDualRowPivot &choice)
Sets row pivot choice algorithm in dual.
int fathomMany(void *stuff)
Do up to N deep - returns -1 - no solution nNodes_ valid nodes >= if solution and that node gives sol...
void passInEventHandler(const ClpEventHandler *eventHandler)
Pass in Event handler (cloned and deleted at end)
Dual Row Pivot Abstract Base Class.
double allowedInfeasibility_
double * rowActivityWork_
Row activities - working copy.
void setSparseFactorization(bool value)
double * lowerRegion() const
int crash(double gap, int pivot)
Crash - at present just aimed at dual, returns -2 if dual preferred and crash basis created -1 if dua...
int strongBranching(int numberVariables, const int *variables, double *newLower, double *newUpper, double **outputSolution, int *outputStatus, int *outputIterations, bool stopOnFirstInfeasible=true, bool alwaysFinish=false, int startFinishOptions=0)
For strong branching.
void setActive(int iRow)
To say row active in primal pivot row choice.
double * djRegion() const
double * columnLower_
Column Lower.
Definition: ClpModel.hpp:1142
double alphaAccuracy_
For computing whether to re-factorize.
int solve(CoinStructuredModel *model)
Solve using structure of model and maybe in parallel.
double * solutionRegion(int section) const
Return row or column sections - not as much needed as it once was.
Definition: ClpSimplex.hpp:993
int isColumn(int sequence) const
Returns 1 if sequence indicates column.
double * dj_
Working copy of reduced costs (Owner of arrays below)
double * solution_
Working copy of primal solution (Owner of arrays below)
void setLargestDualError(double value)
Largest error on basic duals.
Definition: ClpSimplex.hpp:880
int numberRefinements() const
How many iterative refinements to do.
Definition: ClpSimplex.hpp:917
FakeBound getFakeBound(int sequence) const
int automaticScale_
Automatic scaling of objective and rhs and bounds.
bool sanityCheck()
Sanity check on input rim data (after scaling) - returns true if okay.
void setValuesPassAction(double incomingInfeasibility, double allowedInfeasibility)
For advanced use.
void checkSolution(int setToBounds=0)
Just check solution (for external use) - sets sum of infeasibilities etc.
bool pivoted(int sequence) const
double doubleCheck()
Double checks OK.
int firstFree_
First free/super-basic variable (-1 if none)
int factorize()
Factorizes using current basis. For external use.
void setColumnUpper(int elementIndex, double elementValue)
Set a single column upper bound Use DBL_MAX for infinity.
int rowPrimalSequence_
Sequence of worst (-1 if feasible)