Changeset 2385 for trunk/Clp/src/ClpModel.hpp
 Timestamp:
 Jan 6, 2019 2:43:06 PM (4 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/ClpModel.hpp
r2322 r2385 39 39 40 40 public: 41 42 /**@name Constructors and destructor 41 /**@name Constructors and destructor 43 42 Note  copy methods copy ALL data so can chew up memory 44 43 until other copy is freed 45 44 */ 46 47 48 ClpModel (bool emptyMessages = false);49 50 45 //@{ 46 /// Default constructor 47 ClpModel(bool emptyMessages = false); 48 49 /** Copy constructor. May scale depending on mode 51 50 1 leave mode as is 52 51 0 off, 1 equilibrium, 2 geometric, 3, auto, 4 autobutasinitialSolveinbab 53 52 */ 54 ClpModel(const ClpModel &rhs, int scalingMode = 1);55 56 ClpModel & operator=(const ClpModel &rhs);57 53 ClpModel(const ClpModel &rhs, int scalingMode = 1); 54 /// Assignment operator. This copies the data 55 ClpModel &operator=(const ClpModel &rhs); 56 /** Subproblem constructor. A subset of whole model is created from the 58 57 row and column lists given. The new order is given by list order and 59 58 duplicates are allowed. Name and integer information can be dropped 60 59 */ 61 ClpModel (const ClpModel *wholeModel,62 int numberRows, const int *whichRows,63 int numberColumns, const int *whichColumns,64 65 66 ~ClpModel ();67 68 69 70 71 60 ClpModel(const ClpModel *wholeModel, 61 int numberRows, const int *whichRows, 62 int numberColumns, const int *whichColumns, 63 bool dropNames = true, bool dropIntegers = true); 64 /// Destructor 65 ~ClpModel(); 66 //@} 67 68 /**@name Load model  loads some stuff and initializes others */ 69 //@{ 70 /** Loads a problem (the constraints on the 72 71 rows are given by lower and upper bounds). If a pointer is 0 then the 73 72 following values are the default: … … 80 79 </ul> 81 80 */ 82 void loadProblem ( const ClpMatrixBase&matrix,83 const double* collb, const double*colub,84 const double*obj,85 const double* rowlb, const double*rowub,86 const double *rowObjective = NULL);87 void loadProblem ( const CoinPackedMatrix&matrix,88 const double* collb, const double*colub,89 const double*obj,90 const double* rowlb, const double*rowub,91 const double *rowObjective = NULL);92 93 81 void loadProblem(const ClpMatrixBase &matrix, 82 const double *collb, const double *colub, 83 const double *obj, 84 const double *rowlb, const double *rowub, 85 const double *rowObjective = NULL); 86 void loadProblem(const CoinPackedMatrix &matrix, 87 const double *collb, const double *colub, 88 const double *obj, 89 const double *rowlb, const double *rowub, 90 const double *rowObjective = NULL); 91 92 /** Just like the other loadProblem() method except that the matrix is 94 93 given in a standard column major ordered format (without gaps). */ 95 void loadProblem (const int numcols, const int numrows,96 const CoinBigIndex* start, const int*index,97 const double*value,98 const double* collb, const double*colub,99 const double*obj,100 const double* rowlb, const double*rowub,101 const double *rowObjective = NULL);102 94 void loadProblem(const int numcols, const int numrows, 95 const CoinBigIndex *start, const int *index, 96 const double *value, 97 const double *collb, const double *colub, 98 const double *obj, 99 const double *rowlb, const double *rowub, 100 const double *rowObjective = NULL); 101 /** This loads a model from a coinModel object  returns number of errors. 103 102 104 103 modelObject not const as may be changed as part of process 105 104 If tryPlusMinusOne then will try adding as +1 matrix 106 105 */ 107 int loadProblem ( CoinModel &modelObject, bool tryPlusMinusOne = false);108 109 void loadProblem (const int numcols, const int numrows,110 const CoinBigIndex* start, const int*index,111 const double* value, const int *length,112 const double* collb, const double*colub,113 const double*obj,114 const double* rowlb, const double*rowub,115 const double *rowObjective = NULL);116 117 118 const CoinBigIndex *start,119 const int * column, const double *element);120 void loadQuadraticObjective ( const CoinPackedMatrix&matrix);121 122 123 124 void setRowObjective(const double *rowObjective);125 126 127 128 129 130 int readGMPL(const char *filename, const char *dataName,131 132 133 void copyInIntegerInformation(const char *information);134 135 136 137 138 139 140 141 142 143 void resize(int newNumberRows, int newNumberColumns);144 145 void deleteRows(int number, const int *which);146 147 void addRow(int numberInRow, const int *columns,148 const double *elements, double rowLower = COIN_DBL_MAX,149 150 151 void addRows(int number, const double *rowLower,152 const double *rowUpper,153 const CoinBigIndex * rowStarts, const int *columns,154 const double *elements);155 156 void addRows(int number, const double *rowLower,157 const double *rowUpper,158 const CoinBigIndex * rowStarts, const int *rowLengths,159 const int *columns,160 const double *elements);106 int loadProblem(CoinModel &modelObject, bool tryPlusMinusOne = false); 107 /// This one is for after presolve to save memory 108 void loadProblem(const int numcols, const int numrows, 109 const CoinBigIndex *start, const int *index, 110 const double *value, const int *length, 111 const double *collb, const double *colub, 112 const double *obj, 113 const double *rowlb, const double *rowub, 114 const double *rowObjective = NULL); 115 /** Load up quadratic objective. This is stored as a CoinPackedMatrix */ 116 void loadQuadraticObjective(const int numberColumns, 117 const CoinBigIndex *start, 118 const int *column, const double *element); 119 void loadQuadraticObjective(const CoinPackedMatrix &matrix); 120 /// Get rid of quadratic objective 121 void deleteQuadraticObjective(); 122 /// This just loads up a row objective 123 void setRowObjective(const double *rowObjective); 124 /// Read an mps file from the given filename 125 int readMps(const char *filename, 126 bool keepNames = false, 127 bool ignoreErrors = false); 128 /// Read GMPL files from the given filenames 129 int readGMPL(const char *filename, const char *dataName, 130 bool keepNames = false); 131 /// Copy in integer informations 132 void copyInIntegerInformation(const char *information); 133 /// Drop integer informations 134 void deleteIntegerInformation(); 135 /** Set the indexth variable to be a continuous variable */ 136 void setContinuous(int index); 137 /** Set the indexth variable to be an integer variable */ 138 void setInteger(int index); 139 /** Return true if the indexth variable is an integer variable */ 140 bool isInteger(int index) const; 141 /// Resizes rim part of model 142 void resize(int newNumberRows, int newNumberColumns); 143 /// Deletes rows 144 void deleteRows(int number, const int *which); 145 /// Add one row 146 void addRow(int numberInRow, const int *columns, 147 const double *elements, double rowLower = COIN_DBL_MAX, 148 double rowUpper = COIN_DBL_MAX); 149 /// Add rows 150 void addRows(int number, const double *rowLower, 151 const double *rowUpper, 152 const CoinBigIndex *rowStarts, const int *columns, 153 const double *elements); 154 /// Add rows 155 void addRows(int number, const double *rowLower, 156 const double *rowUpper, 157 const CoinBigIndex *rowStarts, const int *rowLengths, 158 const int *columns, 159 const double *elements); 161 160 #ifndef CLP_NO_VECTOR 162 void addRows(int number, const double *rowLower,163 const double *rowUpper,164 const CoinPackedVectorBase * const *rows);161 void addRows(int number, const double *rowLower, 162 const double *rowUpper, 163 const CoinPackedVectorBase *const *rows); 165 164 #endif 166 165 /** Add rows from a build object. 167 166 If tryPlusMinusOne then will try adding as +1 matrix 168 167 if no matrix exists. 169 168 Returns number of errors e.g. duplicates 170 169 */ 171 int addRows(const CoinBuild &buildObject, bool tryPlusMinusOne = false,172 173 170 int addRows(const CoinBuild &buildObject, bool tryPlusMinusOne = false, 171 bool checkDuplicates = true); 172 /** Add rows from a model object. returns 174 173 1 if object in bad state (i.e. has column information) 175 174 otherwise number of errors. … … 179 178 if no matrix exists. 180 179 */ 181 int addRows(CoinModel &modelObject, bool tryPlusMinusOne = false,182 183 184 185 void deleteColumns(int number, const int *which);186 187 void deleteRowsAndColumns(int numberRows, const int *whichRows,188 int numberColumns, const int *whichColumns);189 190 191 const int *rows,192 const double *elements,193 194 doublecolumnUpper = COIN_DBL_MAX,195 doubleobjective = 0.0);196 197 void addColumns(int number, const double *columnLower,198 const double *columnUpper,199 const double *objective,200 const CoinBigIndex * columnStarts, const int *rows,201 const double *elements);202 void addColumns(int number, const double *columnLower,203 const double *columnUpper,204 const double *objective,205 const CoinBigIndex * columnStarts, const int *columnLengths,206 const int *rows,207 const double *elements);180 int addRows(CoinModel &modelObject, bool tryPlusMinusOne = false, 181 bool checkDuplicates = true); 182 183 /// Deletes columns 184 void deleteColumns(int number, const int *which); 185 /// Deletes rows AND columns (keeps old sizes) 186 void deleteRowsAndColumns(int numberRows, const int *whichRows, 187 int numberColumns, const int *whichColumns); 188 /// Add one column 189 void addColumn(int numberInColumn, 190 const int *rows, 191 const double *elements, 192 double columnLower = 0.0, 193 double columnUpper = COIN_DBL_MAX, 194 double objective = 0.0); 195 /// Add columns 196 void addColumns(int number, const double *columnLower, 197 const double *columnUpper, 198 const double *objective, 199 const CoinBigIndex *columnStarts, const int *rows, 200 const double *elements); 201 void addColumns(int number, const double *columnLower, 202 const double *columnUpper, 203 const double *objective, 204 const CoinBigIndex *columnStarts, const int *columnLengths, 205 const int *rows, 206 const double *elements); 208 207 #ifndef CLP_NO_VECTOR 209 void addColumns(int number, const double *columnLower,210 const double *columnUpper,211 const double *objective,212 const CoinPackedVectorBase * const *columns);208 void addColumns(int number, const double *columnLower, 209 const double *columnUpper, 210 const double *objective, 211 const CoinPackedVectorBase *const *columns); 213 212 #endif 214 213 /** Add columns from a build object 215 214 If tryPlusMinusOne then will try adding as +1 matrix 216 215 if no matrix exists. 217 216 Returns number of errors e.g. duplicates 218 217 */ 219 int addColumns(const CoinBuild &buildObject, bool tryPlusMinusOne = false,220 221 218 int addColumns(const CoinBuild &buildObject, bool tryPlusMinusOne = false, 219 bool checkDuplicates = true); 220 /** Add columns from a model object. returns 222 221 1 if object in bad state (i.e. has row information) 223 222 otherwise number of errors … … 226 225 if no matrix exists. 227 226 */ 228 int addColumns(CoinModel & modelObject, bool tryPlusMinusOne = false, 229 bool checkDuplicates = true); 230 /// Modify one element of a matrix 231 inline void modifyCoefficient(int row, int column, double newElement, 232 bool keepZero = false) { 233 matrix_>modifyCoefficient(row, column, newElement, keepZero); 234 } 235 /** Change row lower bounds */ 236 void chgRowLower(const double * rowLower); 237 /** Change row upper bounds */ 238 void chgRowUpper(const double * rowUpper); 239 /** Change column lower bounds */ 240 void chgColumnLower(const double * columnLower); 241 /** Change column upper bounds */ 242 void chgColumnUpper(const double * columnUpper); 243 /** Change objective coefficients */ 244 void chgObjCoefficients(const double * objIn); 245 /** Borrow model. This is so we don't have to copy large amounts 227 int addColumns(CoinModel &modelObject, bool tryPlusMinusOne = false, 228 bool checkDuplicates = true); 229 /// Modify one element of a matrix 230 inline void modifyCoefficient(int row, int column, double newElement, 231 bool keepZero = false) 232 { 233 matrix_>modifyCoefficient(row, column, newElement, keepZero); 234 } 235 /** Change row lower bounds */ 236 void chgRowLower(const double *rowLower); 237 /** Change row upper bounds */ 238 void chgRowUpper(const double *rowUpper); 239 /** Change column lower bounds */ 240 void chgColumnLower(const double *columnLower); 241 /** Change column upper bounds */ 242 void chgColumnUpper(const double *columnUpper); 243 /** Change objective coefficients */ 244 void chgObjCoefficients(const double *objIn); 245 /** Borrow model. This is so we don't have to copy large amounts 246 246 of data around. It assumes a derived class wants to overwrite 247 247 an empty model with a real one  while it does an algorithm */ 248 void borrowModel(ClpModel &otherModel);249 248 void borrowModel(ClpModel &otherModel); 249 /** Return model  nulls all arrays so can be deleted safely 250 250 also updates any scalars */ 251 void returnModel(ClpModel &otherModel);252 253 254 255 251 void returnModel(ClpModel &otherModel); 252 253 /// Create empty ClpPackedMatrix 254 void createEmptyMatrix(); 255 /** Really clean up matrix (if ClpPackedMatrix). 256 256 a) eliminate all duplicate AND small elements in matrix 257 257 b) remove all gaps and set extraGap_ and extraMajor_ to 0.0 … … 260 260 returns number of elements eliminated or 1 if not ClpPackedMatrix 261 261 */ 262 263 264 void copy(const ClpMatrixBase * from, ClpMatrixBase * &to);262 CoinBigIndex cleanMatrix(double threshold = 1.0e20); 263 /// Copy contents  resizing if necessary  otherwise reuse memory 264 void copy(const ClpMatrixBase *from, ClpMatrixBase *&to); 265 265 #ifndef CLP_NO_STD 266 267 268 269 void copyNames(const std::vector<std::string> &rowNames,270 const std::vector<std::string> &columnNames);271 272 void copyRowNames(const std::vector<std::string> &rowNames, int first, int last);273 274 void copyColumnNames(const std::vector<std::string> &columnNames, int first, int last);275 276 void copyRowNames(const char * const *rowNames, int first, int last);277 278 void copyColumnNames(const char * const *columnNames, int first, int last);279 280 void setRowName(int rowIndex, std::string & name);281 282 void setColumnName(int colIndex, std::string & name);266 /// Drops names  makes lengthnames 0 and names empty 267 void dropNames(); 268 /// Copies in names 269 void copyNames(const std::vector< std::string > &rowNames, 270 const std::vector< std::string > &columnNames); 271 /// Copies in Row names  modifies names first .. last1 272 void copyRowNames(const std::vector< std::string > &rowNames, int first, int last); 273 /// Copies in Column names  modifies names first .. last1 274 void copyColumnNames(const std::vector< std::string > &columnNames, int first, int last); 275 /// Copies in Row names  modifies names first .. last1 276 void copyRowNames(const char *const *rowNames, int first, int last); 277 /// Copies in Column names  modifies names first .. last1 278 void copyColumnNames(const char *const *columnNames, int first, int last); 279 /// Set name of row 280 void setRowName(int rowIndex, std::string &name); 281 /// Set name of col 282 void setColumnName(int colIndex, std::string &name); 283 283 #endif 284 284 /** Find a network subset. 285 285 rotate array should be numberRows. On output 286 286 1 not in network … … 289 289 Returns number of network rows 290 290 */ 291 int findNetwork(char *rotate, double fractionNeeded = 0.75);292 293 */ 294 CoinModel *createCoinModel() const;295 296 291 int findNetwork(char *rotate, double fractionNeeded = 0.75); 292 /** This creates a coinModel object 293 */ 294 CoinModel *createCoinModel() const; 295 296 /** Write the problem in MPS format to the specified file. 297 297 298 298 Row and column names may be null. … … 306 306 Returns nonzero on I/O error 307 307 */ 308 int writeMps(const char *filename, 309 int formatType = 0, int numberAcross = 2, 310 double objSense = 0.0) const ; 311 //@} 312 /**@name gets and sets */ 313 //@{ 314 /// Number of rows 315 inline int numberRows() const { 316 return numberRows_; 317 } 318 inline int getNumRows() const { 319 return numberRows_; 320 } 321 /// Number of columns 322 inline int getNumCols() const { 323 return numberColumns_; 324 } 325 inline int numberColumns() const { 326 return numberColumns_; 327 } 328 /// Primal tolerance to use 329 inline double primalTolerance() const { 330 return dblParam_[ClpPrimalTolerance]; 331 } 332 void setPrimalTolerance( double value) ; 333 /// Dual tolerance to use 334 inline double dualTolerance() const { 335 return dblParam_[ClpDualTolerance]; 336 } 337 void setDualTolerance( double value) ; 338 /// Primal objective limit 339 inline double primalObjectiveLimit() const { 340 return dblParam_[ClpPrimalObjectiveLimit]; 341 } 342 void setPrimalObjectiveLimit(double value); 343 /// Dual objective limit 344 inline double dualObjectiveLimit() const { 345 return dblParam_[ClpDualObjectiveLimit]; 346 } 347 void setDualObjectiveLimit(double value); 348 /// Objective offset 349 inline double objectiveOffset() const { 350 return dblParam_[ClpObjOffset]; 351 } 352 void setObjectiveOffset(double value); 353 /// Presolve tolerance to use 354 inline double presolveTolerance() const { 355 return dblParam_[ClpPresolveTolerance]; 356 } 308 int writeMps(const char *filename, 309 int formatType = 0, int numberAcross = 2, 310 double objSense = 0.0) const; 311 //@} 312 /**@name gets and sets */ 313 //@{ 314 /// Number of rows 315 inline int numberRows() const 316 { 317 return numberRows_; 318 } 319 inline int getNumRows() const 320 { 321 return numberRows_; 322 } 323 /// Number of columns 324 inline int getNumCols() const 325 { 326 return numberColumns_; 327 } 328 inline int numberColumns() const 329 { 330 return numberColumns_; 331 } 332 /// Primal tolerance to use 333 inline double primalTolerance() const 334 { 335 return dblParam_[ClpPrimalTolerance]; 336 } 337 void setPrimalTolerance(double value); 338 /// Dual tolerance to use 339 inline double dualTolerance() const 340 { 341 return dblParam_[ClpDualTolerance]; 342 } 343 void setDualTolerance(double value); 344 /// Primal objective limit 345 inline double primalObjectiveLimit() const 346 { 347 return dblParam_[ClpPrimalObjectiveLimit]; 348 } 349 void setPrimalObjectiveLimit(double value); 350 /// Dual objective limit 351 inline double dualObjectiveLimit() const 352 { 353 return dblParam_[ClpDualObjectiveLimit]; 354 } 355 void setDualObjectiveLimit(double value); 356 /// Objective offset 357 inline double objectiveOffset() const 358 { 359 return dblParam_[ClpObjOffset]; 360 } 361 void setObjectiveOffset(double value); 362 /// Presolve tolerance to use 363 inline double presolveTolerance() const 364 { 365 return dblParam_[ClpPresolveTolerance]; 366 } 357 367 #ifndef CLP_NO_STD 358 inline const std::string & problemName() const { 359 return strParam_[ClpProbName]; 360 } 368 inline const std::string &problemName() const 369 { 370 return strParam_[ClpProbName]; 371 } 361 372 #endif 362 /// Number of iterations 363 inline int numberIterations() const { 364 return numberIterations_; 365 } 366 inline int getIterationCount() const { 367 return numberIterations_; 368 } 369 inline void setNumberIterations(int numberIterationsNew) { 370 numberIterations_ = numberIterationsNew; 371 } 372 /** Solve type  1 simplex, 2 simplex interface, 3 Interior.*/ 373 inline int solveType() const { 374 return solveType_; 375 } 376 inline void setSolveType(int type) { 377 solveType_ = type; 378 } 379 /// Maximum number of iterations 380 inline int maximumIterations() const { 381 return intParam_[ClpMaxNumIteration]; 382 } 383 void setMaximumIterations(int value); 384 /// Maximum time in seconds (from when set called) 385 inline double maximumSeconds() const { 386 return dblParam_[ClpMaxSeconds]; 387 } 388 void setMaximumSeconds(double value); 389 void setMaximumWallSeconds(double value); 390 /// Returns true if hit maximum iterations (or time) 391 bool hitMaximumIterations() const; 392 /** Status of problem: 373 /// Number of iterations 374 inline int numberIterations() const 375 { 376 return numberIterations_; 377 } 378 inline int getIterationCount() const 379 { 380 return numberIterations_; 381 } 382 inline void setNumberIterations(int numberIterationsNew) 383 { 384 numberIterations_ = numberIterationsNew; 385 } 386 /** Solve type  1 simplex, 2 simplex interface, 3 Interior.*/ 387 inline int solveType() const 388 { 389 return solveType_; 390 } 391 inline void setSolveType(int type) 392 { 393 solveType_ = type; 394 } 395 /// Maximum number of iterations 396 inline int maximumIterations() const 397 { 398 return intParam_[ClpMaxNumIteration]; 399 } 400 void setMaximumIterations(int value); 401 /// Maximum time in seconds (from when set called) 402 inline double maximumSeconds() const 403 { 404 return dblParam_[ClpMaxSeconds]; 405 } 406 void setMaximumSeconds(double value); 407 void setMaximumWallSeconds(double value); 408 /// Returns true if hit maximum iterations (or time) 409 bool hitMaximumIterations() const; 410 /** Status of problem: 393 411 1  unknown e.g. before solve or if postSolve says not optimal 394 412 0  optimal … … 399 417 5  stopped by event handler (virtual int ClpEventHandler::event()) 400 418 */ 401 inline int status() const { 402 return problemStatus_; 403 } 404 inline int problemStatus() const { 405 return problemStatus_; 406 } 407 /// Set problem status 408 inline void setProblemStatus(int problemStatusNew) { 409 problemStatus_ = problemStatusNew; 410 } 411 /** Secondary status of problem  may get extended 419 inline int status() const 420 { 421 return problemStatus_; 422 } 423 inline int problemStatus() const 424 { 425 return problemStatus_; 426 } 427 /// Set problem status 428 inline void setProblemStatus(int problemStatusNew) 429 { 430 problemStatus_ = problemStatusNew; 431 } 432 /** Secondary status of problem  may get extended 412 433 0  none 413 434 1  primal infeasible because dual limit reached OR (probably primal … … 424 445 100 up  translation of enum from ClpEventHandler 425 446 */ 426 inline int secondaryStatus() const { 427 return secondaryStatus_; 428 } 429 inline void setSecondaryStatus(int newstatus) { 430 secondaryStatus_ = newstatus; 431 } 432 /// Are there a numerical difficulties? 433 inline bool isAbandoned() const { 434 return problemStatus_ == 4; 435 } 436 /// Is optimality proven? 437 inline bool isProvenOptimal() const { 438 return problemStatus_ == 0; 439 } 440 /// Is primal infeasiblity proven? 441 inline bool isProvenPrimalInfeasible() const { 442 return problemStatus_ == 1; 443 } 444 /// Is dual infeasiblity proven? 445 inline bool isProvenDualInfeasible() const { 446 return problemStatus_ == 2; 447 } 448 /// Is the given primal objective limit reached? 449 bool isPrimalObjectiveLimitReached() const ; 450 /// Is the given dual objective limit reached? 451 bool isDualObjectiveLimitReached() const ; 452 /// Iteration limit reached? 453 inline bool isIterationLimitReached() const { 454 return problemStatus_ == 3; 455 } 456 /// Direction of optimization (1  minimize, 1  maximize, 0  ignore 457 inline double optimizationDirection() const { 458 return optimizationDirection_; 459 } 460 inline double getObjSense() const { 461 return optimizationDirection_; 462 } 463 void setOptimizationDirection(double value); 464 /// Primal row solution 465 inline double * primalRowSolution() const { 466 return rowActivity_; 467 } 468 inline const double * getRowActivity() const { 469 return rowActivity_; 470 } 471 /// Primal column solution 472 inline double * primalColumnSolution() const { 473 return columnActivity_; 474 } 475 inline const double * getColSolution() const { 476 return columnActivity_; 477 } 478 inline void setColSolution(const double * input) { 479 memcpy(columnActivity_, input, numberColumns_ * sizeof(double)); 480 } 481 /// Dual row solution 482 inline double * dualRowSolution() const { 483 return dual_; 484 } 485 inline const double * getRowPrice() const { 486 return dual_; 487 } 488 /// Reduced costs 489 inline double * dualColumnSolution() const { 490 return reducedCost_; 491 } 492 inline const double * getReducedCost() const { 493 return reducedCost_; 494 } 495 /// Row lower 496 inline double* rowLower() const { 497 return rowLower_; 498 } 499 inline const double* getRowLower() const { 500 return rowLower_; 501 } 502 /// Row upper 503 inline double* rowUpper() const { 504 return rowUpper_; 505 } 506 inline const double* getRowUpper() const { 507 return rowUpper_; 508 } 509 // 510 /**@name Changing bounds on variables and constraints */ 511 //@{ 512 /** Set an objective function coefficient */ 513 void setObjectiveCoefficient( int elementIndex, double elementValue ); 514 /** Set an objective function coefficient */ 515 inline void setObjCoeff( int elementIndex, double elementValue ) { 516 setObjectiveCoefficient( elementIndex, elementValue); 517 } 518 519 /** Set a single column lower bound<br> 447 inline int secondaryStatus() const 448 { 449 return secondaryStatus_; 450 } 451 inline void setSecondaryStatus(int newstatus) 452 { 453 secondaryStatus_ = newstatus; 454 } 455 /// Are there a numerical difficulties? 456 inline bool isAbandoned() const 457 { 458 return problemStatus_ == 4; 459 } 460 /// Is optimality proven? 461 inline bool isProvenOptimal() const 462 { 463 return problemStatus_ == 0; 464 } 465 /// Is primal infeasiblity proven? 466 inline bool isProvenPrimalInfeasible() const 467 { 468 return problemStatus_ == 1; 469 } 470 /// Is dual infeasiblity proven? 471 inline bool isProvenDualInfeasible() const 472 { 473 return problemStatus_ == 2; 474 } 475 /// Is the given primal objective limit reached? 476 bool isPrimalObjectiveLimitReached() const; 477 /// Is the given dual objective limit reached? 478 bool isDualObjectiveLimitReached() const; 479 /// Iteration limit reached? 480 inline bool isIterationLimitReached() const 481 { 482 return problemStatus_ == 3; 483 } 484 /// Direction of optimization (1  minimize, 1  maximize, 0  ignore 485 inline double optimizationDirection() const 486 { 487 return optimizationDirection_; 488 } 489 inline double getObjSense() const 490 { 491 return optimizationDirection_; 492 } 493 void setOptimizationDirection(double value); 494 /// Primal row solution 495 inline double *primalRowSolution() const 496 { 497 return rowActivity_; 498 } 499 inline const double *getRowActivity() const 500 { 501 return rowActivity_; 502 } 503 /// Primal column solution 504 inline double *primalColumnSolution() const 505 { 506 return columnActivity_; 507 } 508 inline const double *getColSolution() const 509 { 510 return columnActivity_; 511 } 512 inline void setColSolution(const double *input) 513 { 514 memcpy(columnActivity_, input, numberColumns_ * sizeof(double)); 515 } 516 /// Dual row solution 517 inline double *dualRowSolution() const 518 { 519 return dual_; 520 } 521 inline const double *getRowPrice() const 522 { 523 return dual_; 524 } 525 /// Reduced costs 526 inline double *dualColumnSolution() const 527 { 528 return reducedCost_; 529 } 530 inline const double *getReducedCost() const 531 { 532 return reducedCost_; 533 } 534 /// Row lower 535 inline double *rowLower() const 536 { 537 return rowLower_; 538 } 539 inline const double *getRowLower() const 540 { 541 return rowLower_; 542 } 543 /// Row upper 544 inline double *rowUpper() const 545 { 546 return rowUpper_; 547 } 548 inline const double *getRowUpper() const 549 { 550 return rowUpper_; 551 } 552 // 553 /**@name Changing bounds on variables and constraints */ 554 //@{ 555 /** Set an objective function coefficient */ 556 void setObjectiveCoefficient(int elementIndex, double elementValue); 557 /** Set an objective function coefficient */ 558 inline void setObjCoeff(int elementIndex, double elementValue) 559 { 560 setObjectiveCoefficient(elementIndex, elementValue); 561 } 562 563 /** Set a single column lower bound<br> 520 564 Use DBL_MAX for infinity. */ 521 void setColumnLower( int elementIndex, double elementValue);522 523 565 void setColumnLower(int elementIndex, double elementValue); 566 567 /** Set a single column upper bound<br> 524 568 Use DBL_MAX for infinity. */ 525 void setColumnUpper( int elementIndex, double elementValue);526 527 528 void setColumnBounds(int elementIndex,529 double lower, double upper);530 531 569 void setColumnUpper(int elementIndex, double elementValue); 570 571 /** Set a single column lower and upper bound */ 572 void setColumnBounds(int elementIndex, 573 double lower, double upper); 574 575 /** Set the bounds on a number of columns simultaneously<br> 532 576 The default implementation just invokes setColLower() and 533 577 setColUpper() over and over again. … … 537 581 @param boundList the new lower/upper bound pairs for the variables 538 582 */ 539 void setColumnSetBounds(const int*indexFirst,540 const int*indexLast,541 const double*boundList);542 543 583 void setColumnSetBounds(const int *indexFirst, 584 const int *indexLast, 585 const double *boundList); 586 587 /** Set a single column lower bound<br> 544 588 Use DBL_MAX for infinity. */ 545 inline void setColLower( int elementIndex, double elementValue ) { 546 setColumnLower(elementIndex, elementValue); 547 } 548 /** Set a single column upper bound<br> 589 inline void setColLower(int elementIndex, double elementValue) 590 { 591 setColumnLower(elementIndex, elementValue); 592 } 593 /** Set a single column upper bound<br> 549 594 Use DBL_MAX for infinity. */ 550 inline void setColUpper( int elementIndex, double elementValue ) { 551 setColumnUpper(elementIndex, elementValue); 552 } 553 554 /** Set a single column lower and upper bound */ 555 inline void setColBounds( int elementIndex, 556 double lower, double upper ) { 557 setColumnBounds(elementIndex, lower, upper); 558 } 559 560 /** Set the bounds on a number of columns simultaneously<br> 595 inline void setColUpper(int elementIndex, double elementValue) 596 { 597 setColumnUpper(elementIndex, elementValue); 598 } 599 600 /** Set a single column lower and upper bound */ 601 inline void setColBounds(int elementIndex, 602 double lower, double upper) 603 { 604 setColumnBounds(elementIndex, lower, upper); 605 } 606 607 /** Set the bounds on a number of columns simultaneously<br> 561 608 @param indexFirst,indexLast pointers to the beginning and after the 562 609 end of the array of the indices of the variables whose … … 564 611 @param boundList the new lower/upper bound pairs for the variables 565 612 */ 566 inline void setColSetBounds(const int* indexFirst, 567 const int* indexLast, 568 const double* boundList) { 569 setColumnSetBounds(indexFirst, indexLast, boundList); 570 } 571 572 /** Set a single row lower bound<br> 613 inline void setColSetBounds(const int *indexFirst, 614 const int *indexLast, 615 const double *boundList) 616 { 617 setColumnSetBounds(indexFirst, indexLast, boundList); 618 } 619 620 /** Set a single row lower bound<br> 573 621 Use DBL_MAX for infinity. */ 574 void setRowLower( int elementIndex, double elementValue);575 576 622 void setRowLower(int elementIndex, double elementValue); 623 624 /** Set a single row upper bound<br> 577 625 Use DBL_MAX for infinity. */ 578 void setRowUpper( int elementIndex, double elementValue );579 580 581 void setRowBounds(int elementIndex,582 double lower, double upper );583 584 626 void setRowUpper(int elementIndex, double elementValue); 627 628 /** Set a single row lower and upper bound */ 629 void setRowBounds(int elementIndex, 630 double lower, double upper); 631 632 /** Set the bounds on a number of rows simultaneously<br> 585 633 @param indexFirst,indexLast pointers to the beginning and after the 586 634 end of the array of the indices of the constraints whose … … 588 636 @param boundList the new lower/upper bound pairs for the constraints 589 637 */ 590 void setRowSetBounds(const int* indexFirst, 591 const int* indexLast, 592 const double* boundList); 593 594 //@} 595 /// Scaling 596 inline const double * rowScale() const { 597 return rowScale_; 598 } 599 inline const double * columnScale() const { 600 return columnScale_; 601 } 602 inline const double * inverseRowScale() const { 603 return inverseRowScale_; 604 } 605 inline const double * inverseColumnScale() const { 606 return inverseColumnScale_; 607 } 608 inline double * mutableRowScale() const { 609 return rowScale_; 610 } 611 inline double * mutableColumnScale() const { 612 return columnScale_; 613 } 614 inline double * mutableInverseRowScale() const { 615 return inverseRowScale_; 616 } 617 inline double * mutableInverseColumnScale() const { 618 return inverseColumnScale_; 619 } 620 inline double * swapRowScale(double * newScale) { 621 double * oldScale = rowScale_; 622 rowScale_ = newScale; 623 return oldScale; 624 } 625 void setRowScale(double * scale) ; 626 void setColumnScale(double * scale); 627 /// Scaling of objective 628 inline double objectiveScale() const { 629 return objectiveScale_; 630 } 631 inline void setObjectiveScale(double value) { 632 objectiveScale_ = value; 633 } 634 /// Scaling of rhs and bounds 635 inline double rhsScale() const { 636 return rhsScale_; 637 } 638 inline void setRhsScale(double value) { 639 rhsScale_ = value; 640 } 641 /// Sets or unsets scaling, 0 off, 1 equilibrium, 2 geometric, 3 auto, 4 autobutasinitialSolveinbab 642 void scaling(int mode = 1); 643 /** If we constructed a "really" scaled model then this reverses the operation. 638 void setRowSetBounds(const int *indexFirst, 639 const int *indexLast, 640 const double *boundList); 641 642 //@} 643 /// Scaling 644 inline const double *rowScale() const 645 { 646 return rowScale_; 647 } 648 inline const double *columnScale() const 649 { 650 return columnScale_; 651 } 652 inline const double *inverseRowScale() const 653 { 654 return inverseRowScale_; 655 } 656 inline const double *inverseColumnScale() const 657 { 658 return inverseColumnScale_; 659 } 660 inline double *mutableRowScale() const 661 { 662 return rowScale_; 663 } 664 inline double *mutableColumnScale() const 665 { 666 return columnScale_; 667 } 668 inline double *mutableInverseRowScale() const 669 { 670 return inverseRowScale_; 671 } 672 inline double *mutableInverseColumnScale() const 673 { 674 return inverseColumnScale_; 675 } 676 inline double *swapRowScale(double *newScale) 677 { 678 double *oldScale = rowScale_; 679 rowScale_ = newScale; 680 return oldScale; 681 } 682 void setRowScale(double *scale); 683 void setColumnScale(double *scale); 684 /// Scaling of objective 685 inline double objectiveScale() const 686 { 687 return objectiveScale_; 688 } 689 inline void setObjectiveScale(double value) 690 { 691 objectiveScale_ = value; 692 } 693 /// Scaling of rhs and bounds 694 inline double rhsScale() const 695 { 696 return rhsScale_; 697 } 698 inline void setRhsScale(double value) 699 { 700 rhsScale_ = value; 701 } 702 /// Sets or unsets scaling, 0 off, 1 equilibrium, 2 geometric, 3 auto, 4 autobutasinitialSolveinbab 703 void scaling(int mode = 1); 704 /** If we constructed a "really" scaled model then this reverses the operation. 644 705 Quantities may not be exactly as they were before due to rounding errors */ 645 void unscale(); 646 /// Gets scalingFlag 647 inline int scalingFlag() const { 648 return scalingFlag_; 649 } 650 /// Objective 651 inline double * objective() const { 652 if (objective_) { 653 double offset; 654 return objective_>gradient(NULL, NULL, offset, false); 655 } else { 656 return NULL; 657 } 658 } 659 inline double * objective(const double * solution, double & offset, bool refresh = true) const { 660 offset = 0.0; 661 if (objective_) { 662 return objective_>gradient(NULL, solution, offset, refresh); 663 } else { 664 return NULL; 665 } 666 } 667 inline const double * getObjCoefficients() const { 668 if (objective_) { 669 double offset; 670 return objective_>gradient(NULL, NULL, offset, false); 671 } else { 672 return NULL; 673 } 674 } 675 /// Row Objective 676 inline double * rowObjective() const { 677 return rowObjective_; 678 } 679 inline const double * getRowObjCoefficients() const { 680 return rowObjective_; 681 } 682 /// Column Lower 683 inline double * columnLower() const { 684 return columnLower_; 685 } 686 inline const double * getColLower() const { 687 return columnLower_; 688 } 689 /// Column Upper 690 inline double * columnUpper() const { 691 return columnUpper_; 692 } 693 inline const double * getColUpper() const { 694 return columnUpper_; 695 } 696 /// Matrix (if not ClpPackedmatrix be careful about memory leak 697 inline CoinPackedMatrix * matrix() const { 698 if ( matrix_ == NULL ) return NULL; 699 else return matrix_>getPackedMatrix(); 700 } 701 /// Number of elements in matrix 702 inline CoinBigIndex getNumElements() const { 703 return matrix_>getNumElements(); 704 } 705 /** Small element value  elements less than this set to zero, 706 void unscale(); 707 /// Gets scalingFlag 708 inline int scalingFlag() const 709 { 710 return scalingFlag_; 711 } 712 /// Objective 713 inline double *objective() const 714 { 715 if (objective_) { 716 double offset; 717 return objective_>gradient(NULL, NULL, offset, false); 718 } else { 719 return NULL; 720 } 721 } 722 inline double *objective(const double *solution, double &offset, bool refresh = true) const 723 { 724 offset = 0.0; 725 if (objective_) { 726 return objective_>gradient(NULL, solution, offset, refresh); 727 } else { 728 return NULL; 729 } 730 } 731 inline const double *getObjCoefficients() const 732 { 733 if (objective_) { 734 double offset; 735 return objective_>gradient(NULL, NULL, offset, false); 736 } else { 737 return NULL; 738 } 739 } 740 /// Row Objective 741 inline double *rowObjective() const 742 { 743 return rowObjective_; 744 } 745 inline const double *getRowObjCoefficients() const 746 { 747 return rowObjective_; 748 } 749 /// Column Lower 750 inline double *columnLower() const 751 { 752 return columnLower_; 753 } 754 inline const double *getColLower() const 755 { 756 return columnLower_; 757 } 758 /// Column Upper 759 inline double *columnUpper() const 760 { 761 return columnUpper_; 762 } 763 inline const double *getColUpper() const 764 { 765 return columnUpper_; 766 } 767 /// Matrix (if not ClpPackedmatrix be careful about memory leak 768 inline CoinPackedMatrix *matrix() const 769 { 770 if (matrix_ == NULL) 771 return NULL; 772 else 773 return matrix_>getPackedMatrix(); 774 } 775 /// Number of elements in matrix 776 inline CoinBigIndex getNumElements() const 777 { 778 return matrix_>getNumElements(); 779 } 780 /** Small element value  elements less than this set to zero, 706 781 default is 1.0e20 */ 707 inline double getSmallElementValue() const { 708 return smallElement_; 709 } 710 inline void setSmallElementValue(double value) { 711 smallElement_ = value; 712 } 713 /// Row Matrix 714 inline ClpMatrixBase * rowCopy() const { 715 return rowCopy_; 716 } 717 /// Set new row matrix 718 void setNewRowCopy(ClpMatrixBase * newCopy); 719 /// Clp Matrix 720 inline ClpMatrixBase * clpMatrix() const { 721 return matrix_; 722 } 723 /// Scaled ClpPackedMatrix 724 inline ClpPackedMatrix * clpScaledMatrix() const { 725 return scaledMatrix_; 726 } 727 /// Sets pointer to scaled ClpPackedMatrix 728 inline void setClpScaledMatrix(ClpPackedMatrix * scaledMatrix) { 729 delete scaledMatrix_; 730 scaledMatrix_ = scaledMatrix; 731 } 732 /// Swaps pointer to scaled ClpPackedMatrix 733 inline ClpPackedMatrix * swapScaledMatrix(ClpPackedMatrix * scaledMatrix) { 734 ClpPackedMatrix * oldMatrix = scaledMatrix_; 735 scaledMatrix_ = scaledMatrix; 736 return oldMatrix; 737 } 738 /** Replace Clp Matrix (current is not deleted unless told to 782 inline double getSmallElementValue() const 783 { 784 return smallElement_; 785 } 786 inline void setSmallElementValue(double value) 787 { 788 smallElement_ = value; 789 } 790 /// Row Matrix 791 inline ClpMatrixBase *rowCopy() const 792 { 793 return rowCopy_; 794 } 795 /// Set new row matrix 796 void setNewRowCopy(ClpMatrixBase *newCopy); 797 /// Clp Matrix 798 inline ClpMatrixBase *clpMatrix() const 799 { 800 return matrix_; 801 } 802 /// Scaled ClpPackedMatrix 803 inline ClpPackedMatrix *clpScaledMatrix() const 804 { 805 return scaledMatrix_; 806 } 807 /// Sets pointer to scaled ClpPackedMatrix 808 inline void setClpScaledMatrix(ClpPackedMatrix *scaledMatrix) 809 { 810 delete scaledMatrix_; 811 scaledMatrix_ = scaledMatrix; 812 } 813 /// Swaps pointer to scaled ClpPackedMatrix 814 inline ClpPackedMatrix *swapScaledMatrix(ClpPackedMatrix *scaledMatrix) 815 { 816 ClpPackedMatrix *oldMatrix = scaledMatrix_; 817 scaledMatrix_ = scaledMatrix; 818 return oldMatrix; 819 } 820 /** Replace Clp Matrix (current is not deleted unless told to 739 821 and new is used) 740 822 So up to user to delete current. This was used where 741 823 matrices were being rotated. ClpModel takes ownership. 742 824 */ 743 void replaceMatrix(ClpMatrixBase *matrix, bool deleteCurrent = false);744 825 void replaceMatrix(ClpMatrixBase *matrix, bool deleteCurrent = false); 826 /** Replace Clp Matrix (current is not deleted unless told to 745 827 and new is used) So up to user to delete current. This was used where 746 828 matrices were being rotated. This version changes CoinPackedMatrix 747 829 to ClpPackedMatrix. ClpModel takes ownership. 748 830 */ 749 inline void replaceMatrix(CoinPackedMatrix * newmatrix, 750 bool deleteCurrent = false) { 751 replaceMatrix(new ClpPackedMatrix(newmatrix), deleteCurrent); 752 } 753 /// Objective value 754 inline double objectiveValue() const { 755 return objectiveValue_ * optimizationDirection_  dblParam_[ClpObjOffset]; 756 } 757 inline void setObjectiveValue(double value) { 758 objectiveValue_ = (value + dblParam_[ClpObjOffset]) / optimizationDirection_; 759 } 760 inline double getObjValue() const { 761 return objectiveValue_ * optimizationDirection_  dblParam_[ClpObjOffset]; 762 } 763 /// Integer information 764 inline char * integerInformation() const { 765 return integerType_; 766 } 767 /** Infeasibility/unbounded ray (NULL returned if none/wrong) 831 inline void replaceMatrix(CoinPackedMatrix *newmatrix, 832 bool deleteCurrent = false) 833 { 834 replaceMatrix(new ClpPackedMatrix(newmatrix), deleteCurrent); 835 } 836 /// Objective value 837 inline double objectiveValue() const 838 { 839 return objectiveValue_ * optimizationDirection_  dblParam_[ClpObjOffset]; 840 } 841 inline void setObjectiveValue(double value) 842 { 843 objectiveValue_ = (value + dblParam_[ClpObjOffset]) / optimizationDirection_; 844 } 845 inline double getObjValue() const 846 { 847 return objectiveValue_ * optimizationDirection_  dblParam_[ClpObjOffset]; 848 } 849 /// Integer information 850 inline char *integerInformation() const 851 { 852 return integerType_; 853 } 854 /** Infeasibility/unbounded ray (NULL returned if none/wrong) 768 855 Up to user to use delete [] on these arrays. */ 769 double * infeasibilityRay(bool fullRay=false) const; 770 double * unboundedRay() const; 771 /// For advanced users  no need to delete  sign not changed 772 inline double * ray() const 773 { return ray_;} 774 /// just test if infeasibility or unbounded Ray exists 775 inline bool rayExists() const { 776 return (ray_!=NULL); 777 } 778 /// just delete ray if exists 779 inline void deleteRay() { 780 delete [] ray_; 781 ray_=NULL; 782 } 783 /// Access internal ray storage. Users should call infeasibilityRay() or unboundedRay() instead. 784 inline const double * internalRay() const { 785 return ray_; 786 } 787 /// See if status (i.e. basis) array exists (partly for OsiClp) 788 inline bool statusExists() const { 789 return (status_ != NULL); 790 } 791 /// Return address of status (i.e. basis) array (char[numberRows+numberColumns]) 792 inline unsigned char * statusArray() const { 793 return status_; 794 } 795 /** Return copy of status (i.e. basis) array (char[numberRows+numberColumns]), 856 double *infeasibilityRay(bool fullRay = false) const; 857 double *unboundedRay() const; 858 /// For advanced users  no need to delete  sign not changed 859 inline double *ray() const 860 { 861 return ray_; 862 } 863 /// just test if infeasibility or unbounded Ray exists 864 inline bool rayExists() const 865 { 866 return (ray_ != NULL); 867 } 868 /// just delete ray if exists 869 inline void deleteRay() 870 { 871 delete[] ray_; 872 ray_ = NULL; 873 } 874 /// Access internal ray storage. Users should call infeasibilityRay() or unboundedRay() instead. 875 inline const double *internalRay() const 876 { 877 return ray_; 878 } 879 /// See if status (i.e. basis) array exists (partly for OsiClp) 880 inline bool statusExists() const 881 { 882 return (status_ != NULL); 883 } 884 /// Return address of status (i.e. basis) array (char[numberRows+numberColumns]) 885 inline unsigned char *statusArray() const 886 { 887 return status_; 888 } 889 /** Return copy of status (i.e. basis) array (char[numberRows+numberColumns]), 796 890 use delete [] */ 797 unsigned char * statusCopy() const; 798 /// Copy in status (basis) vector 799 void copyinStatus(const unsigned char * statusArray); 800 801 /// User pointer for whatever reason 802 inline void setUserPointer (void * pointer) { 803 userPointer_ = pointer; 804 } 805 inline void * getUserPointer () const { 806 return userPointer_; 807 } 808 /// Trusted user pointer 809 inline void setTrustedUserPointer (ClpTrustedData * pointer) { 810 trustedUserPointer_ = pointer; 811 } 812 inline ClpTrustedData * getTrustedUserPointer () const { 813 return trustedUserPointer_; 814 } 815 /// What has changed in model (only for masochistic users) 816 inline int whatsChanged() const { 817 return whatsChanged_; 818 } 819 inline void setWhatsChanged(int value) { 820 whatsChanged_ = value; 821 } 822 /// Number of threads (not really being used) 823 inline int numberThreads() const { 824 return numberThreads_; 825 } 826 inline void setNumberThreads(int value) { 827 numberThreads_ = value; 828 } 829 //@} 830 /**@name Message handling */ 831 //@{ 832 /// Pass in Message handler (not deleted at end) 833 void passInMessageHandler(CoinMessageHandler * handler); 834 /// Pass in Message handler (not deleted at end) and return current 835 CoinMessageHandler * pushMessageHandler(CoinMessageHandler * handler, 836 bool & oldDefault); 837 /// back to previous message handler 838 void popMessageHandler(CoinMessageHandler * oldHandler, bool oldDefault); 839 /// Set language 840 void newLanguage(CoinMessages::Language language); 841 inline void setLanguage(CoinMessages::Language language) { 842 newLanguage(language); 843 } 844 /// Overrides message handler with a default one 845 void setDefaultMessageHandler(); 846 /// Return handler 847 inline CoinMessageHandler * messageHandler() const { 848 return handler_; 849 } 850 /// Return messages 851 inline CoinMessages messages() const { 852 return messages_; 853 } 854 /// Return pointer to messages 855 inline CoinMessages * messagesPointer() { 856 return & messages_; 857 } 858 /// Return Coin messages 859 inline CoinMessages coinMessages() const { 860 return coinMessages_; 861 } 862 /// Return pointer to Coin messages 863 inline CoinMessages * coinMessagesPointer() { 864 return & coinMessages_; 865 } 866 /** Amount of print out: 891 unsigned char *statusCopy() const; 892 /// Copy in status (basis) vector 893 void copyinStatus(const unsigned char *statusArray); 894 895 /// User pointer for whatever reason 896 inline void setUserPointer(void *pointer) 897 { 898 userPointer_ = pointer; 899 } 900 inline void *getUserPointer() const 901 { 902 return userPointer_; 903 } 904 /// Trusted user pointer 905 inline void setTrustedUserPointer(ClpTrustedData *pointer) 906 { 907 trustedUserPointer_ = pointer; 908 } 909 inline ClpTrustedData *getTrustedUserPointer() const 910 { 911 return trustedUserPointer_; 912 } 913 /// What has changed in model (only for masochistic users) 914 inline int whatsChanged() const 915 { 916 return whatsChanged_; 917 } 918 inline void setWhatsChanged(int value) 919 { 920 whatsChanged_ = value; 921 } 922 /// Number of threads (not really being used) 923 inline int numberThreads() const 924 { 925 return numberThreads_; 926 } 927 inline void setNumberThreads(int value) 928 { 929 numberThreads_ = value; 930 } 931 //@} 932 /**@name Message handling */ 933 //@{ 934 /// Pass in Message handler (not deleted at end) 935 void passInMessageHandler(CoinMessageHandler *handler); 936 /// Pass in Message handler (not deleted at end) and return current 937 CoinMessageHandler *pushMessageHandler(CoinMessageHandler *handler, 938 bool &oldDefault); 939 /// back to previous message handler 940 void popMessageHandler(CoinMessageHandler *oldHandler, bool oldDefault); 941 /// Set language 942 void newLanguage(CoinMessages::Language language); 943 inline void setLanguage(CoinMessages::Language language) 944 { 945 newLanguage(language); 946 } 947 /// Overrides message handler with a default one 948 void setDefaultMessageHandler(); 949 /// Return handler 950 inline CoinMessageHandler *messageHandler() const 951 { 952 return handler_; 953 } 954 /// Return messages 955 inline CoinMessages messages() const 956 { 957 return messages_; 958 } 959 /// Return pointer to messages 960 inline CoinMessages *messagesPointer() 961 { 962 return &messages_; 963 } 964 /// Return Coin messages 965 inline CoinMessages coinMessages() const 966 { 967 return coinMessages_; 968 } 969 /// Return pointer to Coin messages 970 inline CoinMessages *coinMessagesPointer() 971 { 972 return &coinMessages_; 973 } 974 /** Amount of print out: 867 975 0  none 868 976 1  just final … … 872 980 above that 8,16,32 etc just for selective debug 873 981 */ 874 inline void setLogLevel(int value) { 875 handler_>setLogLevel(value); 876 } 877 inline int logLevel() const { 878 return handler_>logLevel(); 879 } 880 /// Return true if default handler 881 inline bool defaultHandler() const { 882 return defaultHandler_; 883 } 884 /// Pass in Event handler (cloned and deleted at end) 885 void passInEventHandler(const ClpEventHandler * eventHandler); 886 /// Event handler 887 inline ClpEventHandler * eventHandler() const { 888 return eventHandler_; 889 } 890 /// Thread specific random number generator 891 inline CoinThreadRandom * randomNumberGenerator() { 892 return &randomNumberGenerator_; 893 } 894 /// Thread specific random number generator 895 inline CoinThreadRandom & mutableRandomNumberGenerator() { 896 return randomNumberGenerator_; 897 } 898 /// Set seed for thread specific random number generator 899 inline void setRandomSeed(int value) { 900 randomNumberGenerator_.setSeed(value); 901 } 902 /// length of names (0 means no names0 903 inline int lengthNames() const { 904 return lengthNames_; 905 } 982 inline void setLogLevel(int value) 983 { 984 handler_>setLogLevel(value); 985 } 986 inline int logLevel() const 987 { 988 return handler_>logLevel(); 989 } 990 /// Return true if default handler 991 inline bool defaultHandler() const 992 { 993 return defaultHandler_; 994 } 995 /// Pass in Event handler (cloned and deleted at end) 996 void passInEventHandler(const ClpEventHandler *eventHandler); 997 /// Event handler 998 inline ClpEventHandler *eventHandler() const 999 { 1000 return eventHandler_; 1001 } 1002 /// Thread specific random number generator 1003 inline CoinThreadRandom *randomNumberGenerator() 1004 { 1005 return &randomNumberGenerator_; 1006 } 1007 /// Thread specific random number generator 1008 inline CoinThreadRandom &mutableRandomNumberGenerator() 1009 { 1010 return randomNumberGenerator_; 1011 } 1012 /// Set seed for thread specific random number generator 1013 inline void setRandomSeed(int value) 1014 { 1015 randomNumberGenerator_.setSeed(value); 1016 } 1017 /// length of names (0 means no names0 1018 inline int lengthNames() const 1019 { 1020 return lengthNames_; 1021 } 906 1022 #ifndef CLP_NO_STD 907 /// length of names (0 means no names0 908 inline void setLengthNames(int value) { 909 lengthNames_ = value; 910 } 911 /// Row names 912 inline const std::vector<std::string> * rowNames() const { 913 return &rowNames_; 914 } 915 inline const std::string& rowName(int iRow) const { 916 return rowNames_[iRow]; 917 } 918 /// Return name or Rnnnnnnn 919 std::string getRowName(int iRow) const; 920 /// Column names 921 inline const std::vector<std::string> * columnNames() const { 922 return &columnNames_; 923 } 924 inline const std::string& columnName(int iColumn) const { 925 return columnNames_[iColumn]; 926 } 927 /// Return name or Cnnnnnnn 928 std::string getColumnName(int iColumn) const; 1023 /// length of names (0 means no names0 1024 inline void setLengthNames(int value) 1025 { 1026 lengthNames_ = value; 1027 } 1028 /// Row names 1029 inline const std::vector< std::string > *rowNames() const 1030 { 1031 return &rowNames_; 1032 } 1033 inline const std::string &rowName(int iRow) const 1034 { 1035 return rowNames_[iRow]; 1036 } 1037 /// Return name or Rnnnnnnn 1038 std::string getRowName(int iRow) const; 1039 /// Column names 1040 inline const std::vector< std::string > *columnNames() const 1041 { 1042 return &columnNames_; 1043 } 1044 inline const std::string &columnName(int iColumn) const 1045 { 1046 return columnNames_[iColumn]; 1047 } 1048 /// Return name or Cnnnnnnn 1049 std::string getColumnName(int iColumn) const; 929 1050 #endif 930 /// Objective methods 931 inline ClpObjective * objectiveAsObject() const { 932 return objective_; 933 } 934 void setObjective(ClpObjective * objective); 935 inline void setObjectivePointer(ClpObjective * newobjective) { 936 objective_ = newobjective; 937 } 938 /** Solve a problem with no elements  return status and 1051 /// Objective methods 1052 inline ClpObjective *objectiveAsObject() const 1053 { 1054 return objective_; 1055 } 1056 void setObjective(ClpObjective *objective); 1057 inline void setObjectivePointer(ClpObjective *newobjective) 1058 { 1059 objective_ = newobjective; 1060 } 1061 /** Solve a problem with no elements  return status and 939 1062 dual and primal infeasibilites */ 940 int emptyProblem(int * infeasNumber = NULL, double *infeasSum = NULL, bool printMessage = true);941 942 943 944 1063 int emptyProblem(int *infeasNumber = NULL, double *infeasSum = NULL, bool printMessage = true); 1064 1065 //@} 1066 1067 /**@name Matrix times vector methods 945 1068 They can be faster if scalar is + 1 946 1069 These are covers so user need not worry about scaling 947 1070 Also for simplex I am not using basic/nonbasic split */ 948 949 1071 //@{ 1072 /** Return <code>y + A * x * scalar</code> in <code>y</code>. 950 1073 @pre <code>x</code> must be of size <code>numColumns()</code> 951 1074 @pre <code>y</code> must be of size <code>numRows()</code> */ 952 953 const double * x, double *y) const;954 1075 void times(double scalar, 1076 const double *x, double *y) const; 1077 /** Return <code>y + x * scalar * A</code> in <code>y</code>. 955 1078 @pre <code>x</code> must be of size <code>numRows()</code> 956 1079 @pre <code>y</code> must be of size <code>numColumns()</code> */ 957 void transposeTimes(double scalar, 958 const double * x, double * y) const ; 959 //@} 960 961 962 // 963 /**@name Parameter set/get methods 1080 void transposeTimes(double scalar, 1081 const double *x, double *y) const; 1082 //@} 1083 1084 // 1085 /**@name Parameter set/get methods 964 1086 965 1087 The set methods return true if the parameter was set to the given value, … … 977 1099 ** once it has been decided where solver sits this may be redone 978 1100 */ 979 980 981 bool setIntParam(ClpIntParam key, int value);982 983 bool setDblParam(ClpDblParam key, double value);1101 //@{ 1102 /// Set an integer parameter 1103 bool setIntParam(ClpIntParam key, int value); 1104 /// Set an double parameter 1105 bool setDblParam(ClpDblParam key, double value); 984 1106 #ifndef CLP_NO_STD 985 986 bool setStrParam(ClpStrParam key, const std::string &value);1107 /// Set an string parameter 1108 bool setStrParam(ClpStrParam key, const std::string &value); 987 1109 #endif 988 // Get an integer parameter 989 inline bool getIntParam(ClpIntParam key, int& value) const { 990 if (key < ClpLastIntParam) { 991 value = intParam_[key]; 992 return true; 993 } else { 994 return false; 995 } 996 } 997 // Get an double parameter 998 inline bool getDblParam(ClpDblParam key, double& value) const { 999 if (key < ClpLastDblParam) { 1000 value = dblParam_[key]; 1001 return true; 1002 } else { 1003 return false; 1004 } 1005 } 1110 // Get an integer parameter 1111 inline bool getIntParam(ClpIntParam key, int &value) const 1112 { 1113 if (key < ClpLastIntParam) { 1114 value = intParam_[key]; 1115 return true; 1116 } else { 1117 return false; 1118 } 1119 } 1120 // Get an double parameter 1121 inline bool getDblParam(ClpDblParam key, double &value) const 1122 { 1123 if (key < ClpLastDblParam) { 1124 value = dblParam_[key]; 1125 return true; 1126 } else { 1127 return false; 1128 } 1129 } 1006 1130 #ifndef CLP_NO_STD 1007 // Get a string parameter 1008 inline bool getStrParam(ClpStrParam key, std::string& value) const { 1009 if (key < ClpLastStrParam) { 1010 value = strParam_[key]; 1011 return true; 1012 } else { 1013 return false; 1014 } 1015 } 1131 // Get a string parameter 1132 inline bool getStrParam(ClpStrParam key, std::string &value) const 1133 { 1134 if (key < ClpLastStrParam) { 1135 value = strParam_[key]; 1136 return true; 1137 } else { 1138 return false; 1139 } 1140 } 1016 1141 #endif 1017 1018 void generateCpp( FILE *fp);1019 1142 /// Create C++ lines to get to current state 1143 void generateCpp(FILE *fp); 1144 /** For advanced options 1020 1145 1  Don't keep changing infeasibility weight 1021 1146 2  Keep nonLinearCost round solves … … 1053 1178 0x02000000 is in a different branch and bound 1054 1179 */ 1055 inline unsigned int specialOptions() const { 1056 return specialOptions_; 1057 } 1058 void setSpecialOptions(unsigned int value); 1180 inline unsigned int specialOptions() const 1181 { 1182 return specialOptions_; 1183 } 1184 void setSpecialOptions(unsigned int value); 1059 1185 #define COIN_CBC_USING_CLP 0x01000000 1060 inline bool inCbcBranchAndBound() const { 1061 return (specialOptions_ & COIN_CBC_USING_CLP) != 0; 1062 } 1063 //@} 1064 1065 /**@name private or protected methods */ 1066 //@{ 1186 inline bool inCbcBranchAndBound() const 1187 { 1188 return (specialOptions_ & COIN_CBC_USING_CLP) != 0; 1189 } 1190 //@} 1191 1192 /**@name private or protected methods */ 1193 //@{ 1067 1194 protected: 1068 1069 1070 1195 /// Does most of deletion (0 = all, 1 = most) 1196 void gutsOfDelete(int type); 1197 /** Does most of copying 1071 1198 If trueCopy 0 then just points to arrays 1072 1199 If 1 leaves as much as possible */ 1073 void gutsOfCopy(const ClpModel & rhs, int trueCopy = 1); 1074 /// gets lower and upper bounds on rows 1075 void getRowBound(int iRow, double& lower, double& upper) const; 1076 /// puts in format I like  4 array matrix  may make row copy 1077 void gutsOfLoadModel ( int numberRows, int numberColumns, 1078 const double* collb, const double* colub, 1079 const double* obj, 1080 const double* rowlb, const double* rowub, 1081 const double * rowObjective = NULL); 1082 /// Does much of scaling 1083 void gutsOfScaling(); 1084 /// Objective value  always minimize 1085 inline double rawObjectiveValue() const { 1086 return objectiveValue_; 1087 } 1088 /// If we are using maximumRows_ and Columns_ 1089 inline bool permanentArrays() const { 1090 return (specialOptions_ & 65536) != 0; 1091 } 1092 /// Start using maximumRows_ and Columns_ 1093 void startPermanentArrays(); 1094 /// Stop using maximumRows_ and Columns_ 1095 void stopPermanentArrays(); 1096 /// Create row names as char ** 1097 const char * const * rowNamesAsChar() const; 1098 /// Create column names as char ** 1099 const char * const * columnNamesAsChar() const; 1100 /// Delete char * version of names 1101 void deleteNamesAsChar(const char * const * names, int number) const; 1102 /// On stopped  sets secondary status 1103 void onStopped(); 1104 //@} 1105 1106 1107 ////////////////// data ////////////////// 1200 void gutsOfCopy(const ClpModel &rhs, int trueCopy = 1); 1201 /// gets lower and upper bounds on rows 1202 void getRowBound(int iRow, double &lower, double &upper) const; 1203 /// puts in format I like  4 array matrix  may make row copy 1204 void gutsOfLoadModel(int numberRows, int numberColumns, 1205 const double *collb, const double *colub, 1206 const double *obj, 1207 const double *rowlb, const double *rowub, 1208 const double *rowObjective = NULL); 1209 /// Does much of scaling 1210 void gutsOfScaling(); 1211 /// Objective value  always minimize 1212 inline double rawObjectiveValue() const 1213 { 1214 return objectiveValue_; 1215 } 1216 /// If we are using maximumRows_ and Columns_ 1217 inline bool permanentArrays() const 1218 { 1219 return (specialOptions_ & 65536) != 0; 1220 } 1221 /// Start using maximumRows_ and Columns_ 1222 void startPermanentArrays(); 1223 /// Stop using maximumRows_ and Columns_ 1224 void stopPermanentArrays(); 1225 /// Create row names as char ** 1226 const char *const *rowNamesAsChar() const; 1227 /// Create column names as char ** 1228 const char *const *columnNamesAsChar() const; 1229 /// Delete char * version of names 1230 void deleteNamesAsChar(const char *const *names, int number) const; 1231 /// On stopped  sets secondary status 1232 void onStopped(); 1233 //@} 1234 1235 ////////////////// data ////////////////// 1108 1236 protected: 1109 1110 /**@name data */ 1111 //@{ 1112 /// Direction of optimization (1  minimize, 1  maximize, 0  ignore 1113 double optimizationDirection_; 1114 /// Array of double parameters 1115 double dblParam_[ClpLastDblParam]; 1116 /// Objective value 1117 double objectiveValue_; 1118 /// Small element value 1119 double smallElement_; 1120 /// Scaling of objective 1121 double objectiveScale_; 1122 /// Scaling of rhs and bounds 1123 double rhsScale_; 1124 /// Number of rows 1125 int numberRows_; 1126 /// Number of columns 1127 int numberColumns_; 1128 /// Row activities 1129 double * rowActivity_; 1130 /// Column activities 1131 double * columnActivity_; 1132 /// Duals 1133 double * dual_; 1134 /// Reduced costs 1135 double * reducedCost_; 1136 /// Row lower 1137 double* rowLower_; 1138 /// Row upper 1139 double* rowUpper_; 1140 /// Objective 1141 ClpObjective * objective_; 1142 /// Row Objective (? sign)  may be NULL 1143 double * rowObjective_; 1144 /// Column Lower 1145 double * columnLower_; 1146 /// Column Upper 1147 double * columnUpper_; 1148 /// Packed matrix 1149 ClpMatrixBase * matrix_; 1150 /// Row copy if wanted 1151 ClpMatrixBase * rowCopy_; 1152 /// Scaled packed matrix 1153 ClpPackedMatrix * scaledMatrix_; 1154 /// Infeasible/unbounded ray 1155 double * ray_; 1156 /// Row scale factors for matrix 1157 double * rowScale_; 1158 /// Column scale factors 1159 double * columnScale_; 1160 /// Inverse row scale factors for matrix (end of rowScale_) 1161 double * inverseRowScale_; 1162 /// Inverse column scale factors for matrix (end of columnScale_) 1163 double * inverseColumnScale_; 1164 /** Scale flag, 0 none, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic, 1237 /**@name data */ 1238 //@{ 1239 /// Direction of optimization (1  minimize, 1  maximize, 0  ignore 1240 double optimizationDirection_; 1241 /// Array of double parameters 1242 double dblParam_[ClpLastDblParam]; 1243 /// Objective value 1244 double objectiveValue_; 1245 /// Small element value 1246 double smallElement_; 1247 /// Scaling of objective 1248 double objectiveScale_; 1249 /// Scaling of rhs and bounds 1250 double rhsScale_; 1251 /// Number of rows 1252 int numberRows_; 1253 /// Number of columns 1254 int numberColumns_; 1255 /// Row activities 1256 double *rowActivity_; 1257 /// Column activities 1258 double *columnActivity_; 1259 /// Duals 1260 double *dual_; 1261 /// Reduced costs 1262 double *reducedCost_; 1263 /// Row lower 1264 double *rowLower_; 1265 /// Row upper 1266 double *rowUpper_; 1267 /// Objective 1268 ClpObjective *objective_; 1269 /// Row Objective (? sign)  may be NULL 1270 double *rowObjective_; 1271 /// Column Lower 1272 double *columnLower_; 1273 /// Column Upper 1274 double *columnUpper_; 1275 /// Packed matrix 1276 ClpMatrixBase *matrix_; 1277 /// Row copy if wanted 1278 ClpMatrixBase *rowCopy_; 1279 /// Scaled packed matrix 1280 ClpPackedMatrix *scaledMatrix_; 1281 /// Infeasible/unbounded ray 1282 double *ray_; 1283 /// Row scale factors for matrix 1284 double *rowScale_; 1285 /// Column scale factors 1286 double *columnScale_; 1287 /// Inverse row scale factors for matrix (end of rowScale_) 1288 double *inverseRowScale_; 1289 /// Inverse column scale factors for matrix (end of columnScale_) 1290 double *inverseColumnScale_; 1291 /** Scale flag, 0 none, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic, 1165 1292 5 geometric on rows */ 1166 1167 1293 int scalingFlag_; 1294 /** Status (i.e. basis) Region. I know that not all algorithms need a status 1168 1295 array, but it made sense for things like crossover and put 1169 1296 all permanent stuff in one place. No assumption is made … … 1172 1299 is number of columns + number of rows long (in that order). 1173 1300 */ 1174 unsigned char *status_;1175 1176 char *integerType_;1177 1178 void *userPointer_;1179 1180 ClpTrustedData *trustedUserPointer_;1181 1182 1183 1184 1185 1186 1187 1301 unsigned char *status_; 1302 /// Integer information 1303 char *integerType_; 1304 /// User pointer for whatever reason 1305 void *userPointer_; 1306 /// Trusted user pointer e.g. for heuristics 1307 ClpTrustedData *trustedUserPointer_; 1308 /// Array of integer parameters 1309 int intParam_[ClpLastIntParam]; 1310 /// Number of iterations 1311 int numberIterations_; 1312 /** Solve type  1 simplex, 2 simplex interface, 3 Interior.*/ 1313 int solveType_; 1314 /** Whats changed since last solve. This is a work in progress 1188 1315 It is designed so careful people can make go faster. 1189 1316 It is only used when startFinishOptions used in dual or primal. … … 1207 1334 #define ROW_LOWER_SAME 16 1208 1335 #define ROW_UPPER_SAME 32 1209 #define OBJECTIVE_SAME 64 1336 #define OBJECTIVE_SAME 64 1210 1337 #define COLUMN_LOWER_SAME 128 1211 1338 #define COLUMN_UPPER_SAME 256 … … 1213 1340 #define ALL_SAME 65339 1214 1341 #define ALL_SAME_EXCEPT_COLUMN_BOUNDS 65337 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1342 unsigned int whatsChanged_; 1343 /// Status of problem 1344 int problemStatus_; 1345 /// Secondary status of problem 1346 int secondaryStatus_; 1347 /// length of names (0 means no names) 1348 int lengthNames_; 1349 /// Number of threads (not very operational) 1350 int numberThreads_; 1351 /** For advanced options 1225 1352 See get and set for meaning 1226 1353 */ 1227 1228 1229 CoinMessageHandler *handler_;1230 1231 1232 1233 1234 1235 ClpEventHandler *eventHandler_;1354 unsigned int specialOptions_; 1355 /// Message handler 1356 CoinMessageHandler *handler_; 1357 /// Flag to say if default handler (so delete) 1358 bool defaultHandler_; 1359 /// Thread specific random number generator 1360 CoinThreadRandom randomNumberGenerator_; 1361 /// Event handler 1362 ClpEventHandler *eventHandler_; 1236 1363 #ifndef CLP_NO_STD 1237 1238 std::vector<std::string> rowNames_;1239 1240 std::vector<std::string> columnNames_;1364 /// Row names 1365 std::vector< std::string > rowNames_; 1366 /// Column names 1367 std::vector< std::string > columnNames_; 1241 1368 #endif 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 double *savedRowScale_;1260 1261 double *savedColumnScale_;1369 /// Messages 1370 CoinMessages messages_; 1371 /// Coin messages 1372 CoinMessages coinMessages_; 1373 /// Maximum number of columns in model 1374 int maximumColumns_; 1375 /// Maximum number of rows in model 1376 int maximumRows_; 1377 /// Maximum number of columns (internal arrays) in model 1378 int maximumInternalColumns_; 1379 /// Maximum number of rows (internal arrays) in model 1380 int maximumInternalRows_; 1381 /// Base packed matrix 1382 CoinPackedMatrix baseMatrix_; 1383 /// Base row copy 1384 CoinPackedMatrix baseRowCopy_; 1385 /// Saved row scale factors for matrix 1386 double *savedRowScale_; 1387 /// Saved column scale factors 1388 double *savedColumnScale_; 1262 1389 #ifndef CLP_NO_STD 1263 1264 1390 /// Array of string parameters 1391 std::string strParam_[ClpLastStrParam]; 1265 1392 #endif 1266 1393 //@} 1267 1394 }; 1268 1395 /** This is a tiny class where data can be saved round calls. … … 1271 1398 1272 1399 public: 1273 1400 /**@name Constructors and destructor 1274 1401 */ 1275 1276 1277 ClpDataSave ();1278 1279 1280 1281 1282 ClpDataSave & operator=(const ClpDataSave &rhs);1283 1284 ~ClpDataSave ();1285 1286 1287 1288 ////////////////// data //////////////////1402 //@{ 1403 /// Default constructor 1404 ClpDataSave(); 1405 1406 /// Copy constructor. 1407 ClpDataSave(const ClpDataSave &); 1408 /// Assignment operator. This copies the data 1409 ClpDataSave &operator=(const ClpDataSave &rhs); 1410 /// Destructor 1411 ~ClpDataSave(); 1412 1413 //@} 1414 1415 ////////////////// data ////////////////// 1289 1416 public: 1290 1291 /**@name data  with same names as in other classes*/ 1292 //@{ 1293 double dualBound_; 1294 double infeasibilityCost_; 1295 double pivotTolerance_; 1296 double zeroFactorizationTolerance_; 1297 double zeroSimplexTolerance_; 1298 double acceptablePivot_; 1299 double objectiveScale_; 1300 int sparseThreshold_; 1301 int perturbation_; 1302 int forceFactorization_; 1303 int scalingFlag_; 1304 unsigned int specialOptions_; 1305 //@} 1417 /**@name data  with same names as in other classes*/ 1418 //@{ 1419 double dualBound_; 1420 double infeasibilityCost_; 1421 double pivotTolerance_; 1422 double zeroFactorizationTolerance_; 1423 double zeroSimplexTolerance_; 1424 double acceptablePivot_; 1425 double objectiveScale_; 1426 int sparseThreshold_; 1427 int perturbation_; 1428 int forceFactorization_; 1429 int scalingFlag_; 1430 unsigned int specialOptions_; 1431 //@} 1306 1432 }; 1307 1433 1308 1434 #endif 1435 1436 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 1437 */
Note: See TracChangeset
for help on using the changeset viewer.