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

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/ClpSimplex.hpp
r2322 r2385 105 105 106 106 class ClpSimplex : public ClpModel { 107 friend void ClpSimplexUnitTest(const std::string &mpsDir);107 friend void ClpSimplexUnitTest(const std::string &mpsDir); 108 108 109 109 public: 110 110 /** enums for status of various sorts. 111 111 First 4 match CoinWarmStartBasis, 112 112 isFixed means fixed at lower bound and out of basis 113 113 */ 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 ClpSimplex (bool emptyMessages = false);134 135 114 enum Status { 115 isFree = 0x00, 116 basic = 0x01, 117 atUpperBound = 0x02, 118 atLowerBound = 0x03, 119 superBasic = 0x04, 120 isFixed = 0x05 121 }; 122 // For Dual 123 enum FakeBound { 124 noFake = 0x00, 125 lowerFake = 0x01, 126 upperFake = 0x02, 127 bothFake = 0x03 128 }; 129 130 /**@name Constructors and destructor and copy */ 131 //@{ 132 /// Default constructor 133 ClpSimplex(bool emptyMessages = false); 134 135 /** Copy constructor. May scale depending on mode 136 136 1 leave mode as is 137 137 0 off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) 138 138 */ 139 ClpSimplex(const ClpSimplex &rhs, int scalingMode = 1);140 139 ClpSimplex(const ClpSimplex &rhs, int scalingMode = 1); 140 /** Copy constructor from model. May scale depending on mode 141 141 1 leave mode as is 142 142 0 off, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic(later) 143 143 */ 144 ClpSimplex(const ClpModel &rhs, int scalingMode = 1);145 144 ClpSimplex(const ClpModel &rhs, int scalingMode = 1); 145 /** Subproblem constructor. A subset of whole model is created from the 146 146 row and column lists given. The new order is given by list order and 147 147 duplicates are allowed. Name and integer information can be dropped … … 149 149 in this case duplicates are not allowed (also see getbackSolution) 150 150 */ 151 ClpSimplex (const ClpModel *wholeModel,152 int numberRows, const int *whichRows,153 int numberColumns, const int *whichColumns,154 155 156 151 ClpSimplex(const ClpModel *wholeModel, 152 int numberRows, const int *whichRows, 153 int numberColumns, const int *whichColumns, 154 bool dropNames = true, bool dropIntegers = true, 155 bool fixOthers = false); 156 /** Subproblem constructor. A subset of whole model is created from the 157 157 row and column lists given. The new order is given by list order and 158 158 duplicates are allowed. Name and integer information can be dropped … … 160 160 in this case duplicates are not allowed (also see getbackSolution) 161 161 */ 162 ClpSimplex (const ClpSimplex *wholeModel,163 int numberRows, const int *whichRows,164 int numberColumns, const int *whichColumns,165 166 167 162 ClpSimplex(const ClpSimplex *wholeModel, 163 int numberRows, const int *whichRows, 164 int numberColumns, const int *whichColumns, 165 bool dropNames = true, bool dropIntegers = true, 166 bool fixOthers = false); 167 /** This constructor modifies original ClpSimplex and stores 168 168 original stuff in created ClpSimplex. It is only to be used in 169 169 conjunction with originalModel */ 170 ClpSimplex (ClpSimplex *wholeModel,171 int numberColumns, const int *whichColumns);172 170 ClpSimplex(ClpSimplex *wholeModel, 171 int numberColumns, const int *whichColumns); 172 /** This copies back stuff from miniModel and then deletes miniModel. 173 173 Only to be used with mini constructor */ 174 void originalModel(ClpSimplex *miniModel);174 void originalModel(ClpSimplex *miniModel); 175 175 #ifdef ABC_INHERIT 176 176 inline int abcState() const 177 { return abcState_;} 177 { 178 return abcState_; 179 } 178 180 inline void setAbcState(int state) 179 { abcState_=state;} 180 inline AbcSimplex * abcSimplex() const 181 { return abcSimplex_;} 182 inline void setAbcSimplex(AbcSimplex * simplex) 183 { abcSimplex_=simplex;} 181 { 182 abcState_ = state; 183 } 184 inline AbcSimplex *abcSimplex() const 185 { 186 return abcSimplex_; 187 } 188 inline void setAbcSimplex(AbcSimplex *simplex) 189 { 190 abcSimplex_ = simplex; 191 } 184 192 /// Returns 0 if dual can be skipped 185 193 int doAbcDual(); … … 187 195 int doAbcPrimal(int ifValuesPass); 188 196 #endif 189 197 /** Array persistence flag 190 198 If 0 then as now (delete/new) 191 199 1 then only do arrays if bigger needed 192 200 2 as 1 but give a bit extra if bigger needed 193 201 */ 194 void setPersistenceFlag(int value); 195 /// Save a copy of model with certain state  normally without cuts 196 void makeBaseModel(); 197 /// Switch off base model 198 void deleteBaseModel(); 199 /// See if we have base model 200 inline ClpSimplex * baseModel() const { 201 return baseModel_; 202 } 203 /** Reset to base model (just size and arrays needed) 202 void setPersistenceFlag(int value); 203 /// Save a copy of model with certain state  normally without cuts 204 void makeBaseModel(); 205 /// Switch off base model 206 void deleteBaseModel(); 207 /// See if we have base model 208 inline ClpSimplex *baseModel() const 209 { 210 return baseModel_; 211 } 212 /** Reset to base model (just size and arrays needed) 204 213 If model NULL use internal copy 205 214 */ 206 void setToBaseModel(ClpSimplex *model = NULL);207 208 ClpSimplex & operator=(const ClpSimplex &rhs);209 210 ~ClpSimplex ();211 212 215 void setToBaseModel(ClpSimplex *model = NULL); 216 /// Assignment operator. This copies the data 217 ClpSimplex &operator=(const ClpSimplex &rhs); 218 /// Destructor 219 ~ClpSimplex(); 220 // Ones below are just ClpModel with some changes 221 /** Loads a problem (the constraints on the 213 222 rows are given by lower and upper bounds). If a pointer is 0 then the 214 223 following values are the default: … … 221 230 </ul> 222 231 */ 223 void loadProblem ( const ClpMatrixBase&matrix,224 const double* collb, const double*colub,225 const double*obj,226 const double* rowlb, const double*rowub,227 const double *rowObjective = NULL);228 void loadProblem ( const CoinPackedMatrix&matrix,229 const double* collb, const double*colub,230 const double*obj,231 const double* rowlb, const double*rowub,232 const double *rowObjective = NULL);233 234 232 void loadProblem(const ClpMatrixBase &matrix, 233 const double *collb, const double *colub, 234 const double *obj, 235 const double *rowlb, const double *rowub, 236 const double *rowObjective = NULL); 237 void loadProblem(const CoinPackedMatrix &matrix, 238 const double *collb, const double *colub, 239 const double *obj, 240 const double *rowlb, const double *rowub, 241 const double *rowObjective = NULL); 242 243 /** Just like the other loadProblem() method except that the matrix is 235 244 given in a standard column major ordered format (without gaps). */ 236 void loadProblem (const int numcols, const int numrows,237 const CoinBigIndex* start, const int*index,238 const double*value,239 const double* collb, const double*colub,240 const double*obj,241 const double* rowlb, const double*rowub,242 const double *rowObjective = NULL);243 244 void loadProblem (const int numcols, const int numrows,245 const CoinBigIndex* start, const int*index,246 const double* value, const int *length,247 const double* collb, const double*colub,248 const double*obj,249 const double* rowlb, const double*rowub,250 const double *rowObjective = NULL);251 245 void loadProblem(const int numcols, const int numrows, 246 const CoinBigIndex *start, const int *index, 247 const double *value, 248 const double *collb, const double *colub, 249 const double *obj, 250 const double *rowlb, const double *rowub, 251 const double *rowObjective = NULL); 252 /// This one is for after presolve to save memory 253 void loadProblem(const int numcols, const int numrows, 254 const CoinBigIndex *start, const int *index, 255 const double *value, const int *length, 256 const double *collb, const double *colub, 257 const double *obj, 258 const double *rowlb, const double *rowub, 259 const double *rowObjective = NULL); 260 /** This loads a model from a coinModel object  returns number of errors. 252 261 If keepSolution true and size is same as current then 253 262 keeps current status and solution 254 263 */ 255 int loadProblem ( CoinModel &modelObject, bool keepSolution = false);256 257 258 259 260 261 int readGMPL(const char *filename, const char *dataName,262 263 264 265 266 264 int loadProblem(CoinModel &modelObject, bool keepSolution = false); 265 /// Read an mps file from the given filename 266 int readMps(const char *filename, 267 bool keepNames = false, 268 bool ignoreErrors = false); 269 /// Read GMPL files from the given filenames 270 int readGMPL(const char *filename, const char *dataName, 271 bool keepNames = false); 272 /// Read file in LP format from file with name filename. 273 /// See class CoinLpIO for description of this format. 274 int readLp(const char *filename, const double epsilon = 1e5); 275 /** Write the problem into an Lp file of the given filename. 267 276 If objSense is non zero then 1.0 forces the code to write a 268 277 maximization objective and +1.0 to write a minimization one. 269 278 If 0.0 then solver can do what it wants.*/ 270 271 272 273 274 275 276 277 279 void writeLp(const char *filename, 280 const char *extension = "lp", 281 double epsilon = 1e5, 282 int numberAcross = 10, 283 int decimals = 5, 284 double objSense = 0.0, 285 bool useRowNames = true) const; 286 /** Borrow model. This is so we dont have to copy large amounts 278 287 of data around. It assumes a derived class wants to overwrite 279 288 an empty model with a real one  while it does an algorithm. 280 289 This is same as ClpModel one, but sets scaling on etc. */ 281 void borrowModel(ClpModel &otherModel);282 void borrowModel(ClpSimplex &otherModel);283 284 void passInEventHandler(const ClpEventHandler *eventHandler);285 286 void getbackSolution(const ClpSimplex & smallModel, const int * whichRow, const int *whichColumn);287 290 void borrowModel(ClpModel &otherModel); 291 void borrowModel(ClpSimplex &otherModel); 292 /// Pass in Event handler (cloned and deleted at end) 293 void passInEventHandler(const ClpEventHandler *eventHandler); 294 /// Puts solution back into small model 295 void getbackSolution(const ClpSimplex &smallModel, const int *whichRow, const int *whichColumn); 296 /** Load nonlinear part of problem from AMPL info 288 297 Returns 0 if linear 289 298 1 if quadratic objective … … 293 302 1 on failure 294 303 */ 295 int loadNonLinear(void * info, int &numberConstraints,296 ClpConstraint ** &constraints);304 int loadNonLinear(void *info, int &numberConstraints, 305 ClpConstraint **&constraints); 297 306 #ifdef ABC_INHERIT 298 307 /// Loads tolerances etc 299 void loadTolerancesEtc(const AbcTolerancesEtc & 308 void loadTolerancesEtc(const AbcTolerancesEtc &data); 300 309 /// Unloads tolerances etc 301 void unloadTolerancesEtc(AbcTolerancesEtc & 302 #endif 303 304 305 306 307 310 void unloadTolerancesEtc(AbcTolerancesEtc &data); 311 #endif 312 //@} 313 314 /**@name Functions most useful to user */ 315 //@{ 316 /** General solve algorithm which can do presolve. 308 317 See ClpSolve.hpp for options 309 318 */ 310 int initialSolve(ClpSolve &options);311 312 313 314 315 316 317 318 319 320 321 319 int initialSolve(ClpSolve &options); 320 /// Default initial solve 321 int initialSolve(); 322 /// Dual initial solve 323 int initialDualSolve(); 324 /// Primal initial solve 325 int initialPrimalSolve(); 326 /// Barrier initial solve 327 int initialBarrierSolve(); 328 /// Barrier initial solve, not to be followed by crossover 329 int initialBarrierNoCrossSolve(); 330 /** Dual algorithm  see ClpSimplexDual.hpp for method. 322 331 ifValuesPass==2 just does values pass and then stops. 323 332 … … 329 338 maybe other bits later 330 339 */ 331 332 333 334 340 int dual(int ifValuesPass = 0, int startFinishOptions = 0); 341 // If using Debug 342 int dualDebug(int ifValuesPass = 0, int startFinishOptions = 0); 343 /** Primal algorithm  see ClpSimplexPrimal.hpp for method. 335 344 ifValuesPass==2 just does values pass and then stops. 336 345 … … 342 351 maybe other bits later 343 352 */ 344 345 353 int primal(int ifValuesPass = 0, int startFinishOptions = 0); 354 /** Solves nonlinear problem using SLP  may be used as crash 346 355 for other algorithms when number of iterations small. 347 356 Also exits if all problematical variables are changing 348 357 less than deltaTolerance 349 358 */ 350 351 359 int nonlinearSLP(int numberPasses, double deltaTolerance); 360 /** Solves problem with nonlinear constraints using SLP  may be used as crash 352 361 for other algorithms when number of iterations small. 353 362 Also exits if all problematical variables are changing 354 363 less than deltaTolerance 355 364 */ 356 int nonlinearSLP(int numberConstraints, ClpConstraint **constraints,357 358 365 int nonlinearSLP(int numberConstraints, ClpConstraint **constraints, 366 int numberPasses, double deltaTolerance); 367 /** Solves using barrier (assumes you have good cholesky factor code). 359 368 Does crossover to simplex if asked*/ 360 361 369 int barrier(bool crossover = true); 370 /** Solves nonlinear using reduced gradient. Phase = 0 get feasible, 362 371 =1 use solution */ 363 364 365 int solve(CoinStructuredModel *model);372 int reducedGradient(int phase = 0); 373 /// Solve using structure of model and maybe in parallel 374 int solve(CoinStructuredModel *model); 366 375 #ifdef ABC_INHERIT 367 376 /** solvetype 0 for dual, 1 for primal … … 370 379 add 10 to return AbcSimplex 371 380 */ 372 AbcSimplex * dealWithAbc(int solveType,int startUp,bool interrupt=false);381 AbcSimplex *dealWithAbc(int solveType, int startUp, bool interrupt = false); 373 382 //void dealWithAbc(int solveType,int startUp,bool interrupt=false); 374 383 #endif 375 384 /** This loads a model from a CoinStructuredModel object  returns number of errors. 376 385 If originalOrder then keep to order stored in blocks, 377 386 otherwise first column/rows correspond to first block  etc. … … 379 388 keeps current status and solution 380 389 */ 381 int loadProblem ( CoinStructuredModel &modelObject,382 383 390 int loadProblem(CoinStructuredModel &modelObject, 391 bool originalOrder = true, bool keepSolution = false); 392 /** 384 393 When scaling is on it is possible that the scaled problem 385 394 is feasible but the unscaled is not. Clp returns a secondary … … 395 404 return code as dual/primal 396 405 */ 397 398 406 int cleanup(int cleanupScaling); 407 /** Clean primal solution 399 408 If you expect solution to only have exact multiples of "exactMultiple" then 400 409 this tries moving solution values to nearest multiple. If still feasible … … 406 415 The dual version may be written if this gets used. 407 416 */ 408 409 417 int cleanPrimalSolution(double exactMultiple); 418 /** Dual ranging. 410 419 This computes increase/decrease in cost for each given variable and corresponding 411 420 sequence numbers which would change basis. Sequence numbers are 0..numberColumns … … 427 436 Returns nonzero if infeasible unbounded etc 428 437 */ 429 int dualRanging(int numberCheck, const int *which,430 double * costIncrease, int *sequenceIncrease,431 double * costDecrease, int *sequenceDecrease,432 double * valueIncrease = NULL, double *valueDecrease = NULL);433 438 int dualRanging(int numberCheck, const int *which, 439 double *costIncrease, int *sequenceIncrease, 440 double *costDecrease, int *sequenceDecrease, 441 double *valueIncrease = NULL, double *valueDecrease = NULL); 442 /** Primal ranging. 434 443 This computes increase/decrease in value for each given variable and corresponding 435 444 sequence numbers which would change basis. Sequence numbers are 0..numberColumns … … 445 454 Returns nonzero if infeasible unbounded etc 446 455 */ 447 int primalRanging(int numberCheck, const int *which,448 double * valueIncrease, int *sequenceIncrease,449 double * valueDecrease, int *sequenceDecrease);450 456 int primalRanging(int numberCheck, const int *which, 457 double *valueIncrease, int *sequenceIncrease, 458 double *valueDecrease, int *sequenceDecrease); 459 /** 451 460 Modifies coefficients etc and if necessary pivots in and out. 452 461 All at same status will be done (basis may go singular). … … 457 466 status array is (char) Status enum 458 467 */ 459 460 const int *which,461 const CoinBigIndex *start,462 const int *row,463 const double *newCoefficient,464 const unsigned char * newStatus=NULL,465 const double * newLower=NULL,466 const double * newUpper=NULL,467 const double * newObjective=NULL);468 468 int modifyCoefficientsAndPivot(int number, 469 const int *which, 470 const CoinBigIndex *start, 471 const int *row, 472 const double *newCoefficient, 473 const unsigned char *newStatus = NULL, 474 const double *newLower = NULL, 475 const double *newUpper = NULL, 476 const double *newObjective = NULL); 477 /** Take out duplicate rows (includes scaled rows and intersections). 469 478 On exit whichRows has rows to delete  return code is number can be deleted 470 479 or 1 if would be infeasible. … … 473 482 and make row bounds exact multiple of cleanUp if close enough 474 483 */ 475 int outDuplicateRows(int numberLook,int * whichRows, bool noOverlaps=false, double tolerance=1.0,476 double cleanUp=0.0);477 484 int outDuplicateRows(int numberLook, int *whichRows, bool noOverlaps = false, double tolerance = 1.0, 485 double cleanUp = 0.0); 486 /** Try simple crash like techniques to get closer to primal feasibility 478 487 returns final sum of infeasibilities */ 479 480 488 double moveTowardsPrimalFeasible(); 489 /** Try simple crash like techniques to remove super basic slacks 481 490 but only if > threshold */ 482 void removeSuperBasicSlacks(int threshold=0);483 491 void removeSuperBasicSlacks(int threshold = 0); 492 /** Mini presolve (faster) 484 493 Char arrays must be numberRows and numberColumns long 485 494 on entry second part must be filled in as follows  … … 493 502 user must delete struct 494 503 */ 495 ClpSimplex * miniPresolve(char * rowType, char * columnType,void **info);496 497 void miniPostsolve(const ClpSimplex * presolvedModel,void *info);498 499 void miniSolve(char * rowType, char *columnType,int algorithm, int startUp);500 504 ClpSimplex *miniPresolve(char *rowType, char *columnType, void **info); 505 /// After mini presolve 506 void miniPostsolve(const ClpSimplex *presolvedModel, void *info); 507 /// mini presolve and solve 508 void miniSolve(char *rowType, char *columnType, int algorithm, int startUp); 509 /** Write the basis in MPS format to the specified file. 501 510 If writeValues true writes values of structurals 502 511 (and adds VALUES to end of NAME card) … … 512 521 Returns nonzero on I/O error 513 522 */ 514 515 516 517 523 int writeBasis(const char *filename, 524 bool writeValues = false, 525 int formatType = 0) const; 526 /** Read a basis from the given filename, 518 527 returns 1 on file error, 0 if no values, 1 if values */ 519 520 521 CoinWarmStartBasis *getBasis() const;522 523 void setFactorization( ClpFactorization &factorization);524 525 ClpFactorization * swapFactorization( ClpFactorization *factorization);526 527 void copyFactorization( ClpFactorization &factorization);528 528 int readBasis(const char *filename); 529 /// Returns a basis (to be deleted by user) 530 CoinWarmStartBasis *getBasis() const; 531 /// Passes in factorization 532 void setFactorization(ClpFactorization &factorization); 533 // Swaps factorization 534 ClpFactorization *swapFactorization(ClpFactorization *factorization); 535 /// Copies in factorization to existing one 536 void copyFactorization(ClpFactorization &factorization); 537 /** Tightens primal bounds to make dual faster. Unless 529 538 fixed or doTight>10, bounds are slightly looser than they could be. 530 539 This is to make dual go faster and is probably not needed … … 535 544 in branch and bound on infeasible branches (0.0 is off) 536 545 */ 537 538 546 int tightenPrimalBounds(double factor = 0.0, int doTight = 0, bool tightIntegers = false); 547 /** Crash  at present just aimed at dual, returns 539 548 2 if dual preferred and crash basis created 540 549 1 if dual preferred and all slack basis preferred … … 552 561 2 Mini iterations 553 562 */ 554 555 556 void setDualRowPivotAlgorithm(ClpDualRowPivot &choice);557 558 void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot &choice);559 560 void markHotStart(void * &saveStuff);561 562 void solveFromHotStart(void *saveStuff);563 564 void unmarkHotStart(void *saveStuff);565 563 int crash(double gap, int pivot); 564 /// Sets row pivot choice algorithm in dual 565 void setDualRowPivotAlgorithm(ClpDualRowPivot &choice); 566 /// Sets column pivot choice algorithm in primal 567 void setPrimalColumnPivotAlgorithm(ClpPrimalColumnPivot &choice); 568 /// Create a hotstart point of the optimization process 569 void markHotStart(void *&saveStuff); 570 /// Optimize starting from the hotstart 571 void solveFromHotStart(void *saveStuff); 572 /// Delete the snapshot 573 void unmarkHotStart(void *saveStuff); 574 /** For strong branching. On input lower and upper are new bounds 566 575 while on output they are change in objective function values 567 576 (>1.0e50 infeasible). … … 571 580 status and number of iterations 572 581 */ 573 int strongBranching(int numberVariables, const int *variables,574 double * newLower, double *newUpper,575 double **outputSolution,576 int * outputStatus, int *outputIterations,577 578 579 580 581 int fathom(void *stuff);582 582 int strongBranching(int numberVariables, const int *variables, 583 double *newLower, double *newUpper, 584 double **outputSolution, 585 int *outputStatus, int *outputIterations, 586 bool stopOnFirstInfeasible = true, 587 bool alwaysFinish = false, 588 int startFinishOptions = 0); 589 /// Fathom  1 if solution 590 int fathom(void *stuff); 591 /** Do up to N deep  returns 583 592 1  no solution nNodes_ valid nodes 584 593 >= if solution and that node gives solution 585 594 ClpNode array is 2**N long. Values for N and 586 595 array are in stuff (nNodes_ also in stuff) */ 587 int fathomMany(void *stuff);588 589 590 591 int startFastDual2(ClpNodeStuff *stuff);592 593 int fastDual2(ClpNodeStuff *stuff);594 595 void stopFastDual2(ClpNodeStuff *stuff);596 596 int fathomMany(void *stuff); 597 /// Double checks OK 598 double doubleCheck(); 599 /// Starts Fast dual2 600 int startFastDual2(ClpNodeStuff *stuff); 601 /// Like Fast dual 602 int fastDual2(ClpNodeStuff *stuff); 603 /// Stops Fast dual2 604 void stopFastDual2(ClpNodeStuff *stuff); 605 /** Deals with crunch aspects 597 606 mode 0  in 598 607 1  out with solution … … 600 609 returns small model or NULL 601 610 */ 602 ClpSimplex * fastCrunch(ClpNodeStuff *stuff, int mode);603 604 605 606 607 611 ClpSimplex *fastCrunch(ClpNodeStuff *stuff, int mode); 612 //@} 613 614 /**@name Needed for functionality of OsiSimplexInterface */ 615 //@{ 616 /** Pivot in a variable and out a variable. Returns 0 if okay, 608 617 1 if inaccuracy forced refactorization, 1 if would be singular. 609 618 Also updates primal/dual infeasibilities. 610 619 Assumes sequenceIn_ and pivotRow_ set and also directionIn and Out. 611 620 */ 612 613 614 621 int pivot(); 622 623 /** Pivot in a variable and choose an outgoing one. Assumes primal 615 624 feasible  will not go through a bound. Returns step length in theta 616 625 Returns ray in ray_ (or NULL if no pivot) 617 626 Return codes as before but 1 means no acceptable pivot 618 627 */ 619 620 621 628 int primalPivotResult(); 629 630 /** Pivot out a variable and choose an incoing one. Assumes dual 622 631 feasible  will not go through a reduced cost. 623 632 Returns step length in theta 624 633 Return codes as before but 1 means no acceptable pivot 625 634 */ 626 627 635 int dualPivotResultPart1(); 636 /** Do actual pivot 628 637 state is 0 if need tableau column, 1 if in rowArray_[1] 629 638 */ 630 int pivotResultPart2(int algorithm, int state);631 632 639 int pivotResultPart2(int algorithm, int state); 640 641 /** Common bits of coding for dual and primal. Return 0 if okay, 633 642 1 if bad matrix, 2 if very bad factorization 634 643 … … 641 650 642 651 */ 643 int startup(int ifValuesPass, int startFinishOptions = 0); 644 void finish(int startFinishOptions = 0); 645 646 /** Factorizes and returns true if optimal. Used by user */ 647 bool statusOfProblem(bool initial = false); 648 /// If user left factorization frequency then compute 649 void defaultFactorizationFrequency(); 650 /// Copy across enabled stuff from one solver to another 651 void copyEnabledStuff(const ClpSimplex * rhs); 652 //@} 653 654 /**@name most useful gets and sets */ 655 //@{ 656 /// If problem is primal feasible 657 inline bool primalFeasible() const { 658 return (numberPrimalInfeasibilities_ == 0); 659 } 660 /// If problem is dual feasible 661 inline bool dualFeasible() const { 662 return (numberDualInfeasibilities_ == 0); 663 } 664 /// factorization 665 inline ClpFactorization * factorization() const { 666 return factorization_; 667 } 668 /// Sparsity on or off 669 bool sparseFactorization() const; 670 void setSparseFactorization(bool value); 671 /// Factorization frequency 672 int factorizationFrequency() const; 673 void setFactorizationFrequency(int value); 674 /// Dual bound 675 inline double dualBound() const { 676 return dualBound_; 677 } 678 void setDualBound(double value); 679 /// Infeasibility cost 680 inline double infeasibilityCost() const { 681 return infeasibilityCost_; 682 } 683 void setInfeasibilityCost(double value); 684 /** Amount of print out: 652 int startup(int ifValuesPass, int startFinishOptions = 0); 653 void finish(int startFinishOptions = 0); 654 655 /** Factorizes and returns true if optimal. Used by user */ 656 bool statusOfProblem(bool initial = false); 657 /// If user left factorization frequency then compute 658 void defaultFactorizationFrequency(); 659 /// Copy across enabled stuff from one solver to another 660 void copyEnabledStuff(const ClpSimplex *rhs); 661 //@} 662 663 /**@name most useful gets and sets */ 664 //@{ 665 /// If problem is primal feasible 666 inline bool primalFeasible() const 667 { 668 return (numberPrimalInfeasibilities_ == 0); 669 } 670 /// If problem is dual feasible 671 inline bool dualFeasible() const 672 { 673 return (numberDualInfeasibilities_ == 0); 674 } 675 /// factorization 676 inline ClpFactorization *factorization() const 677 { 678 return factorization_; 679 } 680 /// Sparsity on or off 681 bool sparseFactorization() const; 682 void setSparseFactorization(bool value); 683 /// Factorization frequency 684 int factorizationFrequency() const; 685 void setFactorizationFrequency(int value); 686 /// Dual bound 687 inline double dualBound() const 688 { 689 return dualBound_; 690 } 691 void setDualBound(double value); 692 /// Infeasibility cost 693 inline double infeasibilityCost() const 694 { 695 return infeasibilityCost_; 696 } 697 void setInfeasibilityCost(double value); 698 /** Amount of print out: 685 699 0  none 686 700 1  just final … … 690 704 above that 8,16,32 etc just for selective debug 691 705 */ 692 706 /** Perturbation: 693 707 50  switch on perturbation 694 708 100  auto perturb if takes too long (1.0e6 largest nonzero) … … 698 712 others are for playing 699 713 */ 700 inline int perturbation() const { 701 return perturbation_; 702 } 703 void setPerturbation(int value); 704 /// Current (or last) algorithm 705 inline int algorithm() const { 706 return algorithm_; 707 } 708 /// Set algorithm 709 inline void setAlgorithm(int value) { 710 algorithm_ = value; 711 } 712 /// Return true if the objective limit test can be relied upon 713 bool isObjectiveLimitTestValid() const ; 714 /// Sum of dual infeasibilities 715 inline double sumDualInfeasibilities() const { 716 return sumDualInfeasibilities_; 717 } 718 inline void setSumDualInfeasibilities(double value) { 719 sumDualInfeasibilities_ = value; 720 } 721 /// Sum of relaxed dual infeasibilities 722 inline double sumOfRelaxedDualInfeasibilities() const { 723 return sumOfRelaxedDualInfeasibilities_; 724 } 725 inline void setSumOfRelaxedDualInfeasibilities(double value) { 726 sumOfRelaxedDualInfeasibilities_ = value; 727 } 728 /// Number of dual infeasibilities 729 inline int numberDualInfeasibilities() const { 730 return numberDualInfeasibilities_; 731 } 732 inline void setNumberDualInfeasibilities(int value) { 733 numberDualInfeasibilities_ = value; 734 } 735 /// Number of dual infeasibilities (without free) 736 inline int numberDualInfeasibilitiesWithoutFree() const { 737 return numberDualInfeasibilitiesWithoutFree_; 738 } 739 /// Sum of primal infeasibilities 740 inline double sumPrimalInfeasibilities() const { 741 return sumPrimalInfeasibilities_; 742 } 743 inline void setSumPrimalInfeasibilities(double value) { 744 sumPrimalInfeasibilities_ = value; 745 } 746 /// Sum of relaxed primal infeasibilities 747 inline double sumOfRelaxedPrimalInfeasibilities() const { 748 return sumOfRelaxedPrimalInfeasibilities_; 749 } 750 inline void setSumOfRelaxedPrimalInfeasibilities(double value) { 751 sumOfRelaxedPrimalInfeasibilities_ = value; 752 } 753 /// Number of primal infeasibilities 754 inline int numberPrimalInfeasibilities() const { 755 return numberPrimalInfeasibilities_; 756 } 757 inline void setNumberPrimalInfeasibilities(int value) { 758 numberPrimalInfeasibilities_ = value; 759 } 760 /** Save model to file, returns 0 if success. This is designed for 714 inline int perturbation() const 715 { 716 return perturbation_; 717 } 718 void setPerturbation(int value); 719 /// Current (or last) algorithm 720 inline int algorithm() const 721 { 722 return algorithm_; 723 } 724 /// Set algorithm 725 inline void setAlgorithm(int value) 726 { 727 algorithm_ = value; 728 } 729 /// Return true if the objective limit test can be relied upon 730 bool isObjectiveLimitTestValid() const; 731 /// Sum of dual infeasibilities 732 inline double sumDualInfeasibilities() const 733 { 734 return sumDualInfeasibilities_; 735 } 736 inline void setSumDualInfeasibilities(double value) 737 { 738 sumDualInfeasibilities_ = value; 739 } 740 /// Sum of relaxed dual infeasibilities 741 inline double sumOfRelaxedDualInfeasibilities() const 742 { 743 return sumOfRelaxedDualInfeasibilities_; 744 } 745 inline void setSumOfRelaxedDualInfeasibilities(double value) 746 { 747 sumOfRelaxedDualInfeasibilities_ = value; 748 } 749 /// Number of dual infeasibilities 750 inline int numberDualInfeasibilities() const 751 { 752 return numberDualInfeasibilities_; 753 } 754 inline void setNumberDualInfeasibilities(int value) 755 { 756 numberDualInfeasibilities_ = value; 757 } 758 /// Number of dual infeasibilities (without free) 759 inline int numberDualInfeasibilitiesWithoutFree() const 760 { 761 return numberDualInfeasibilitiesWithoutFree_; 762 } 763 /// Sum of primal infeasibilities 764 inline double sumPrimalInfeasibilities() const 765 { 766 return sumPrimalInfeasibilities_; 767 } 768 inline void setSumPrimalInfeasibilities(double value) 769 { 770 sumPrimalInfeasibilities_ = value; 771 } 772 /// Sum of relaxed primal infeasibilities 773 inline double sumOfRelaxedPrimalInfeasibilities() const 774 { 775 return sumOfRelaxedPrimalInfeasibilities_; 776 } 777 inline void setSumOfRelaxedPrimalInfeasibilities(double value) 778 { 779 sumOfRelaxedPrimalInfeasibilities_ = value; 780 } 781 /// Number of primal infeasibilities 782 inline int numberPrimalInfeasibilities() const 783 { 784 return numberPrimalInfeasibilities_; 785 } 786 inline void setNumberPrimalInfeasibilities(int value) 787 { 788 numberPrimalInfeasibilities_ = value; 789 } 790 /** Save model to file, returns 0 if success. This is designed for 761 791 use outside algorithms so does not save iterating arrays etc. 762 792 It does not save any messaging information. … … 764 794 It does not know about all types of virtual functions. 765 795 */ 766 int saveModel(const char *fileName);767 796 int saveModel(const char *fileName); 797 /** Restore model from file, returns 0 if success, 768 798 deletes current model */ 769 int restoreModel(const char *fileName);770 771 799 int restoreModel(const char *fileName); 800 801 /** Just check solution (for external use)  sets sum of 772 802 infeasibilities etc. 773 803 If setToBounds 0 then primal column values not changed … … 776 806 indicated bound and if any values changed (or ==2) basic values recomputed. 777 807 */ 778 779 808 void checkSolution(int setToBounds = 0); 809 /** Just check solution (for internal use)  sets sum of 780 810 infeasibilities etc. */ 781 void checkSolutionInternal(); 782 /// Check unscaled primal solution but allow for rounding error 783 void checkUnscaledSolution(); 784 /// Useful row length arrays (0,1,2,3,4,5) 785 inline CoinIndexedVector * rowArray(int index) const { 786 return rowArray_[index]; 787 } 788 /// Useful column length arrays (0,1,2,3,4,5) 789 inline CoinIndexedVector * columnArray(int index) const { 790 return columnArray_[index]; 791 } 792 //@} 793 794 /******************** End of most useful part **************/ 795 /**@name Functions less likely to be useful to casual user */ 796 //@{ 797 /** Given an existing factorization computes and checks 811 void checkSolutionInternal(); 812 /// Check unscaled primal solution but allow for rounding error 813 void checkUnscaledSolution(); 814 /// Useful row length arrays (0,1,2,3,4,5) 815 inline CoinIndexedVector *rowArray(int index) const 816 { 817 return rowArray_[index]; 818 } 819 /// Useful column length arrays (0,1,2,3,4,5) 820 inline CoinIndexedVector *columnArray(int index) const 821 { 822 return columnArray_[index]; 823 } 824 //@} 825 826 /******************** End of most useful part **************/ 827 /**@name Functions less likely to be useful to casual user */ 828 //@{ 829 /** Given an existing factorization computes and checks 798 830 primal and dual solutions. Uses input arrays for variables at 799 831 bounds. Returns feasibility states */ 800 int getSolution ( const double *rowActivities,801 const double *columnActivities);802 832 int getSolution(const double *rowActivities, 833 const double *columnActivities); 834 /** Given an existing factorization computes and checks 803 835 primal and dual solutions. Uses current problem arrays for 804 836 bounds. Returns feasibility states */ 805 int getSolution();806 837 int getSolution(); 838 /** Constructs a non linear cost from list of nonlinearities (columns only) 807 839 First lower of each column is taken as real lower 808 840 Last lower is taken as real upper and cost ignored … … 810 842 Returns nonzero if bad data e.g. lowers not monotonic 811 843 */ 812 int createPiecewiseLinearCosts(const int * starts, 813 const double * lower, const double * gradient); 814 /// dual row pivot choice 815 inline ClpDualRowPivot * dualRowPivot() const { 816 return dualRowPivot_; 817 } 818 /// primal column pivot choice 819 inline ClpPrimalColumnPivot * primalColumnPivot() const { 820 return primalColumnPivot_; 821 } 822 /// Returns true if model looks OK 823 inline bool goodAccuracy() const { 824 return (largestPrimalError_ < 1.0e7 && largestDualError_ < 1.0e7); 825 } 826 /** Return model  updates any scalars */ 827 void returnModel(ClpSimplex & otherModel); 828 /** Factorizes using current basis. 844 int createPiecewiseLinearCosts(const int *starts, 845 const double *lower, const double *gradient); 846 /// dual row pivot choice 847 inline ClpDualRowPivot *dualRowPivot() const 848 { 849 return dualRowPivot_; 850 } 851 /// primal column pivot choice 852 inline ClpPrimalColumnPivot *primalColumnPivot() const 853 { 854 return primalColumnPivot_; 855 } 856 /// Returns true if model looks OK 857 inline bool goodAccuracy() const 858 { 859 return (largestPrimalError_ < 1.0e7 && largestDualError_ < 1.0e7); 860 } 861 /** Return model  updates any scalars */ 862 void returnModel(ClpSimplex &otherModel); 863 /** Factorizes using current basis. 829 864 solveType  1 iterating, 0 initial, 1 external 830 865 If 10 added then in primal values pass … … 833 868 Special case is numberRows_+1 > all slack basis. 834 869 */ 835 836 837 ClpDataSave saveData();838 839 840 841 842 843 844 870 int internalFactorize(int solveType); 871 /// Save data 872 ClpDataSave saveData(); 873 /// Restore data 874 void restoreData(ClpDataSave saved); 875 /// Clean up status 876 void cleanStatus(); 877 /// Factorizes using current basis. For external use 878 int factorize(); 879 /** Computes duals from scratch. If givenDjs then 845 880 allows for nonzero basic djs */ 846 void computeDuals(double *givenDjs);847 848 void computePrimals ( const double *rowActivities,849 const double *columnActivities);850 851 void add(double *array,852 853 881 void computeDuals(double *givenDjs); 882 /// Computes primals from scratch 883 void computePrimals(const double *rowActivities, 884 const double *columnActivities); 885 /** Adds multiple of a column into an array */ 886 void add(double *array, 887 int column, double multiplier) const; 888 /** 854 889 Unpacks one column of the matrix into indexed array 855 890 Uses sequenceIn_ 856 891 Also applies scaling if needed 857 892 */ 858 void unpack(CoinIndexedVector * rowArray) const;859 893 void unpack(CoinIndexedVector *rowArray) const; 894 /** 860 895 Unpacks one column of the matrix into indexed array 861 896 Slack if sequence>= numberColumns 862 897 Also applies scaling if needed 863 898 */ 864 void unpack(CoinIndexedVector *rowArray, int sequence) const;865 899 void unpack(CoinIndexedVector *rowArray, int sequence) const; 900 /** 866 901 Unpacks one column of the matrix into indexed array 867 902 ** as packed vector … … 869 904 Also applies scaling if needed 870 905 */ 871 void unpackPacked(CoinIndexedVector * rowArray);872 906 void unpackPacked(CoinIndexedVector *rowArray); 907 /** 873 908 Unpacks one column of the matrix into indexed array 874 909 ** as packed vector … … 876 911 Also applies scaling if needed 877 912 */ 878 void unpackPacked(CoinIndexedVector *rowArray, int sequence);913 void unpackPacked(CoinIndexedVector *rowArray, int sequence); 879 914 #ifndef CLP_USER_DRIVEN 880 915 protected: 881 916 #endif 882 917 /** 883 918 This does basis housekeeping and does values for in/out variables. 884 919 Can also decide to refactorize 885 920 */ 886 887 921 int housekeeping(double objectiveChange); 922 /** This sets largest infeasibility and most infeasible and sum 888 923 and number of infeasibilities (Primal) */ 889 void checkPrimalSolution(const double *rowActivities = NULL,890 const double *columnActivies = NULL);891 924 void checkPrimalSolution(const double *rowActivities = NULL, 925 const double *columnActivies = NULL); 926 /** This sets largest infeasibility and most infeasible and sum 892 927 and number of infeasibilities (Dual) */ 893 894 895 896 928 void checkDualSolution(); 929 /** This sets sum and number of infeasibilities (Dual and Primal) */ 930 void checkBothSolutions(); 931 /** If input negative scales objective so maximum <= value 897 932 and returns scale factor used. If positive unscales and also 898 933 redoes dual stuff 899 934 */ 900 double scaleObjective(double value); 901 /// Solve using DantzigWolfe decomposition and maybe in parallel 902 int solveDW(CoinStructuredModel * model, ClpSolve & options); 903 /// Solve using Benders decomposition and maybe in parallel 904 int solveBenders(CoinStructuredModel * model, ClpSolve & options); 935 double scaleObjective(double value); 936 /// Solve using DantzigWolfe decomposition and maybe in parallel 937 int solveDW(CoinStructuredModel *model, ClpSolve &options); 938 /// Solve using Benders decomposition and maybe in parallel 939 int solveBenders(CoinStructuredModel *model, ClpSolve &options); 940 905 941 public: 906 942 /** For advanced use. When doing iterative solves things can get 907 943 nasty so on values pass if incoming solution has largest 908 944 infeasibility < incomingInfeasibility throw out variables … … 914 950 Defaults are 1.0,10.0 915 951 */ 916 917 918 952 void setValuesPassAction(double incomingInfeasibility, 953 double allowedInfeasibility); 954 /** Get a clean factorization  i.e. throw out singularities 919 955 may do more later */ 920 921 922 923 956 int cleanFactorization(int ifValuesPass); 957 //@} 958 /**@name most useful gets and sets */ 959 //@{ 924 960 public: 925 /// Initial value for alpha accuracy calculation (1.0 off) 926 inline double alphaAccuracy() const { 927 return alphaAccuracy_; 928 } 929 inline void setAlphaAccuracy(double value) { 930 alphaAccuracy_ = value; 931 } 961 /// Initial value for alpha accuracy calculation (1.0 off) 962 inline double alphaAccuracy() const 963 { 964 return alphaAccuracy_; 965 } 966 inline void setAlphaAccuracy(double value) 967 { 968 alphaAccuracy_ = value; 969 } 970 932 971 public: 933 /// Objective value 934 //inline double objectiveValue() const { 935 //return (objectiveValue_bestPossibleImprovement_)*optimizationDirection_  dblParam_[ClpObjOffset]; 936 //} 937 /// Set disaster handler 938 inline void setDisasterHandler(ClpDisasterHandler * handler) { 939 disasterArea_ = handler; 940 } 941 /// Get disaster handler 942 inline ClpDisasterHandler * disasterHandler() const { 943 return disasterArea_; 944 } 945 /// Large bound value (for complementarity etc) 946 inline double largeValue() const { 947 return largeValue_; 948 } 949 void setLargeValue( double value) ; 950 /// Largest error on Axb 951 inline double largestPrimalError() const { 952 return largestPrimalError_; 953 } 954 /// Largest error on basic duals 955 inline double largestDualError() const { 956 return largestDualError_; 957 } 958 /// Largest error on Axb 959 inline void setLargestPrimalError(double value) { 960 largestPrimalError_ = value; 961 } 962 /// Largest error on basic duals 963 inline void setLargestDualError(double value) { 964 largestDualError_ = value; 965 } 966 /// Get zero tolerance 967 inline double zeroTolerance() const { 968 return zeroTolerance_;/*factorization_>zeroTolerance();*/ 969 } 970 /// Set zero tolerance 971 inline void setZeroTolerance( double value) { 972 zeroTolerance_ = value; 973 } 974 /// Basic variables pivoting on which rows 975 inline int * pivotVariable() const { 976 return pivotVariable_; 977 } 978 /// If automatic scaling on 979 inline bool automaticScaling() const { 980 return automaticScale_ != 0; 981 } 982 inline void setAutomaticScaling(bool onOff) { 983 automaticScale_ = onOff ? 1 : 0; 984 } 985 /// Current dual tolerance 986 inline double currentDualTolerance() const { 987 return dualTolerance_; 988 } 989 inline void setCurrentDualTolerance(double value) { 990 dualTolerance_ = value; 991 } 992 /// Current primal tolerance 993 inline double currentPrimalTolerance() const { 994 return primalTolerance_; 995 } 996 inline void setCurrentPrimalTolerance(double value) { 997 primalTolerance_ = value; 998 } 999 /// How many iterative refinements to do 1000 inline int numberRefinements() const { 1001 return numberRefinements_; 1002 } 1003 void setNumberRefinements( int value) ; 1004 /// Alpha (pivot element) for use by classes e.g. steepestedge 1005 inline double alpha() const { 1006 return alpha_; 1007 } 1008 inline void setAlpha(double value) { 1009 alpha_ = value; 1010 } 1011 /// Reduced cost of last incoming for use by classes e.g. steepestedge 1012 inline double dualIn() const { 1013 return dualIn_; 1014 } 1015 /// Set reduced cost of last incoming to force error 1016 inline void setDualIn(double value) { 1017 dualIn_ = value; 1018 } 1019 /// Pivot Row for use by classes e.g. steepestedge 1020 inline int pivotRow() const { 1021 return pivotRow_; 1022 } 1023 inline void setPivotRow(int value) { 1024 pivotRow_ = value; 1025 } 1026 /// value of incoming variable (in Dual) 1027 double valueIncomingDual() const; 1028 //@} 972 /// Objective value 973 //inline double objectiveValue() const { 974 //return (objectiveValue_bestPossibleImprovement_)*optimizationDirection_  dblParam_[ClpObjOffset]; 975 //} 976 /// Set disaster handler 977 inline void setDisasterHandler(ClpDisasterHandler *handler) 978 { 979 disasterArea_ = handler; 980 } 981 /// Get disaster handler 982 inline ClpDisasterHandler *disasterHandler() const 983 { 984 return disasterArea_; 985 } 986 /// Large bound value (for complementarity etc) 987 inline double largeValue() const 988 { 989 return largeValue_; 990 } 991 void setLargeValue(double value); 992 /// Largest error on Axb 993 inline double largestPrimalError() const 994 { 995 return largestPrimalError_; 996 } 997 /// Largest error on basic duals 998 inline double largestDualError() const 999 { 1000 return largestDualError_; 1001 } 1002 /// Largest error on Axb 1003 inline void setLargestPrimalError(double value) 1004 { 1005 largestPrimalError_ = value; 1006 } 1007 /// Largest error on basic duals 1008 inline void setLargestDualError(double value) 1009 { 1010 largestDualError_ = value; 1011 } 1012 /// Get zero tolerance 1013 inline double zeroTolerance() const 1014 { 1015 return zeroTolerance_; /*factorization_>zeroTolerance();*/ 1016 } 1017 /// Set zero tolerance 1018 inline void setZeroTolerance(double value) 1019 { 1020 zeroTolerance_ = value; 1021 } 1022 /// Basic variables pivoting on which rows 1023 inline int *pivotVariable() const 1024 { 1025 return pivotVariable_; 1026 } 1027 /// If automatic scaling on 1028 inline bool automaticScaling() const 1029 { 1030 return automaticScale_ != 0; 1031 } 1032 inline void setAutomaticScaling(bool onOff) 1033 { 1034 automaticScale_ = onOff ? 1 : 0; 1035 } 1036 /// Current dual tolerance 1037 inline double currentDualTolerance() const 1038 { 1039 return dualTolerance_; 1040 } 1041 inline void setCurrentDualTolerance(double value) 1042 { 1043 dualTolerance_ = value; 1044 } 1045 /// Current primal tolerance 1046 inline double currentPrimalTolerance() const 1047 { 1048 return primalTolerance_; 1049 } 1050 inline void setCurrentPrimalTolerance(double value) 1051 { 1052 primalTolerance_ = value; 1053 } 1054 /// How many iterative refinements to do 1055 inline int numberRefinements() const 1056 { 1057 return numberRefinements_; 1058 } 1059 void setNumberRefinements(int value); 1060 /// Alpha (pivot element) for use by classes e.g. steepestedge 1061 inline double alpha() const 1062 { 1063 return alpha_; 1064 } 1065 inline void setAlpha(double value) 1066 { 1067 alpha_ = value; 1068 } 1069 /// Reduced cost of last incoming for use by classes e.g. steepestedge 1070 inline double dualIn() const 1071 { 1072 return dualIn_; 1073 } 1074 /// Set reduced cost of last incoming to force error 1075 inline void setDualIn(double value) 1076 { 1077 dualIn_ = value; 1078 } 1079 /// Pivot Row for use by classes e.g. steepestedge 1080 inline int pivotRow() const 1081 { 1082 return pivotRow_; 1083 } 1084 inline void setPivotRow(int value) 1085 { 1086 pivotRow_ = value; 1087 } 1088 /// value of incoming variable (in Dual) 1089 double valueIncomingDual() const; 1090 //@} 1029 1091 1030 1092 #ifndef CLP_USER_DRIVEN 1031 1093 protected: 1032 1094 #endif 1033 1034 1035 1095 /**@name protected methods */ 1096 //@{ 1097 /** May change basis and then returns number changed. 1036 1098 Computation of solutions may be overriden by given pi and solution 1037 1099 */ 1038 int gutsOfSolution ( double *givenDuals,1039 const double *givenPrimals,1040 1041 1042 1043 1044 void gutsOfCopy(const ClpSimplex &rhs);1045 1100 int gutsOfSolution(double *givenDuals, 1101 const double *givenPrimals, 1102 bool valuesPass = false); 1103 /// Does most of deletion (0 = all, 1 = most, 2 most + factorization) 1104 void gutsOfDelete(int type); 1105 /// Does most of copying 1106 void gutsOfCopy(const ClpSimplex &rhs); 1107 /** puts in format I like (rowLower,rowUpper) also see StandardMatrix 1046 1108 1 bit does rows (now and columns), (2 bit does column bounds), 4 bit does objective(s). 1047 1109 8 bit does solution scaling in … … 1054 1116 so do arrays but keep pivotVariable_ 1055 1117 */ 1056 1057 1058 1059 1060 1061 1062 1063 1118 bool createRim(int what, bool makeRowCopy = false, int startFinishOptions = 0); 1119 /// Does rows and columns 1120 void createRim1(bool initial); 1121 /// Does objective 1122 void createRim4(bool initial); 1123 /// Does rows and columns and objective 1124 void createRim5(bool initial); 1125 /** releases above arrays and does solution scaling out. May also 1064 1126 get rid of factorization data  1065 1127 0 get rid of nothing, 1 get rid of arrays, 2 also factorization 1066 1128 */ 1067 1068 1069 1070 1129 void deleteRim(int getRidOfFactorizationData = 2); 1130 /// Sanity check on input rim data (after scaling)  returns true if okay 1131 bool sanityCheck(); 1132 //@} 1071 1133 public: 1072 1073 1074 1134 /**@name public methods */ 1135 //@{ 1136 /** Return row or column sections  not as much needed as it 1075 1137 once was. These just map into single arrays */ 1076 inline double * solutionRegion(int section) const { 1077 if (!section) return rowActivityWork_; 1078 else return columnActivityWork_; 1079 } 1080 inline double * djRegion(int section) const { 1081 if (!section) return rowReducedCost_; 1082 else return reducedCostWork_; 1083 } 1084 inline double * lowerRegion(int section) const { 1085 if (!section) return rowLowerWork_; 1086 else return columnLowerWork_; 1087 } 1088 inline double * upperRegion(int section) const { 1089 if (!section) return rowUpperWork_; 1090 else return columnUpperWork_; 1091 } 1092 inline double * costRegion(int section) const { 1093 if (!section) return rowObjectiveWork_; 1094 else return objectiveWork_; 1095 } 1096 /// Return region as single array 1097 inline double * solutionRegion() const { 1098 return solution_; 1099 } 1100 inline double * djRegion() const { 1101 return dj_; 1102 } 1103 inline double * lowerRegion() const { 1104 return lower_; 1105 } 1106 inline double * upperRegion() const { 1107 return upper_; 1108 } 1109 inline double * costRegion() const { 1110 return cost_; 1111 } 1112 inline Status getStatus(int sequence) const { 1113 return static_cast<Status> (status_[sequence] & 7); 1114 } 1115 inline void setStatus(int sequence, Status newstatus) { 1116 unsigned char & st_byte = status_[sequence]; 1117 st_byte = static_cast<unsigned char>(st_byte & ~7); 1118 st_byte = static_cast<unsigned char>(st_byte  newstatus); 1119 } 1120 /// Start or reset using maximumRows_ and Columns_  true if change 1121 bool startPermanentArrays(); 1122 /** Normally the first factorization does sparse coding because 1138 inline double *solutionRegion(int section) const 1139 { 1140 if (!section) 1141 return rowActivityWork_; 1142 else 1143 return columnActivityWork_; 1144 } 1145 inline double *djRegion(int section) const 1146 { 1147 if (!section) 1148 return rowReducedCost_; 1149 else 1150 return reducedCostWork_; 1151 } 1152 inline double *lowerRegion(int section) const 1153 { 1154 if (!section) 1155 return rowLowerWork_; 1156 else 1157 return columnLowerWork_; 1158 } 1159 inline double *upperRegion(int section) const 1160 { 1161 if (!section) 1162 return rowUpperWork_; 1163 else 1164 return columnUpperWork_; 1165 } 1166 inline double *costRegion(int section) const 1167 { 1168 if (!section) 1169 return rowObjectiveWork_; 1170 else 1171 return objectiveWork_; 1172 } 1173 /// Return region as single array 1174 inline double *solutionRegion() const 1175 { 1176 return solution_; 1177 } 1178 inline double *djRegion() const 1179 { 1180 return dj_; 1181 } 1182 inline double *lowerRegion() const 1183 { 1184 return lower_; 1185 } 1186 inline double *upperRegion() const 1187 { 1188 return upper_; 1189 } 1190 inline double *costRegion() const 1191 { 1192 return cost_; 1193 } 1194 inline Status getStatus(int sequence) const 1195 { 1196 return static_cast< Status >(status_[sequence] & 7); 1197 } 1198 inline void setStatus(int sequence, Status newstatus) 1199 { 1200 unsigned char &st_byte = status_[sequence]; 1201 st_byte = static_cast< unsigned char >(st_byte & ~7); 1202 st_byte = static_cast< unsigned char >(st_byte  newstatus); 1203 } 1204 /// Start or reset using maximumRows_ and Columns_  true if change 1205 bool startPermanentArrays(); 1206 /** Normally the first factorization does sparse coding because 1123 1207 the factorization could be singular. This allows initial dense 1124 1208 factorization when it is known to be safe 1125 1209 */ 1126 void setInitialDenseFactorization(bool onOff); 1127 bool initialDenseFactorization() const; 1128 /** Return sequence In or Out */ 1129 inline int sequenceIn() const { 1130 return sequenceIn_; 1131 } 1132 inline int sequenceOut() const { 1133 return sequenceOut_; 1134 } 1135 /** Set sequenceIn or Out */ 1136 inline void setSequenceIn(int sequence) { 1137 sequenceIn_ = sequence; 1138 } 1139 inline void setSequenceOut(int sequence) { 1140 sequenceOut_ = sequence; 1141 } 1142 /** Return direction In or Out */ 1143 inline int directionIn() const { 1144 return directionIn_; 1145 } 1146 inline int directionOut() const { 1147 return directionOut_; 1148 } 1149 /** Set directionIn or Out */ 1150 inline void setDirectionIn(int direction) { 1151 directionIn_ = direction; 1152 } 1153 inline void setDirectionOut(int direction) { 1154 directionOut_ = direction; 1155 } 1156 /// Value of Out variable 1157 inline double valueOut() const { 1158 return valueOut_; 1159 } 1160 /// Lower of out variable 1161 inline double lowerOut() const { 1162 return lowerOut_ ; 1163 } 1164 /// Upper of out variable 1165 inline double upperOut() const { 1166 return upperOut_ ; 1167 } 1168 /// Set value of out variable 1169 inline void setValueOut(double value) { 1170 valueOut_ = value; 1171 } 1172 /// Dual value of Out variable 1173 inline double dualOut() const { 1174 return dualOut_; 1175 } 1176 /// Set dual value of out variable 1177 inline void setDualOut(double value) { 1178 dualOut_ = value; 1179 } 1180 /// Set lower of out variable 1181 inline void setLowerOut(double value) { 1182 lowerOut_ = value; 1183 } 1184 /// Set upper of out variable 1185 inline void setUpperOut(double value) { 1186 upperOut_ = value; 1187 } 1188 /// Set theta of out variable 1189 inline void setTheta(double value) { 1190 theta_ = value; 1191 } 1192 /// Returns 1 if sequence indicates column 1193 inline int isColumn(int sequence) const { 1194 return sequence < numberColumns_ ? 1 : 0; 1195 } 1196 /// Returns sequence number within section 1197 inline int sequenceWithin(int sequence) const { 1198 return sequence < numberColumns_ ? sequence : sequence  numberColumns_; 1199 } 1200 /// Return row or column values 1201 inline double solution(int sequence) { 1202 return solution_[sequence]; 1203 } 1204 /// Return address of row or column values 1205 inline double & solutionAddress(int sequence) { 1206 return solution_[sequence]; 1207 } 1208 inline double reducedCost(int sequence) { 1209 return dj_[sequence]; 1210 } 1211 inline double & reducedCostAddress(int sequence) { 1212 return dj_[sequence]; 1213 } 1214 inline double lower(int sequence) { 1215 return lower_[sequence]; 1216 } 1217 /// Return address of row or column lower bound 1218 inline double & lowerAddress(int sequence) { 1219 return lower_[sequence]; 1220 } 1221 inline double upper(int sequence) { 1222 return upper_[sequence]; 1223 } 1224 /// Return address of row or column upper bound 1225 inline double & upperAddress(int sequence) { 1226 return upper_[sequence]; 1227 } 1228 inline double cost(int sequence) { 1229 return cost_[sequence]; 1230 } 1231 /// Return address of row or column cost 1232 inline double & costAddress(int sequence) { 1233 return cost_[sequence]; 1234 } 1235 /// Return original lower bound 1236 inline double originalLower(int iSequence) const { 1237 if (iSequence < numberColumns_) return columnLower_[iSequence]; 1238 else 1239 return rowLower_[iSequencenumberColumns_]; 1240 } 1241 /// Return original lower bound 1242 inline double originalUpper(int iSequence) const { 1243 if (iSequence < numberColumns_) return columnUpper_[iSequence]; 1244 else 1245 return rowUpper_[iSequencenumberColumns_]; 1246 } 1247 /// Theta (pivot change) 1248 inline double theta() const { 1249 return theta_; 1250 } 1251 /// Lower Bound on In variable 1252 inline double lowerIn() const 1253 { return lowerIn_;} 1254 /// Value of In variable 1255 inline double valueIn() const 1256 { return valueIn_;} 1257 /// Upper Bound on In variable 1258 inline double upperIn() const 1259 { return upperIn_;} 1260 /** Best possible improvement using djs (primal) or 1210 void setInitialDenseFactorization(bool onOff); 1211 bool initialDenseFactorization() const; 1212 /** Return sequence In or Out */ 1213 inline int sequenceIn() const 1214 { 1215 return sequenceIn_; 1216 } 1217 inline int sequenceOut() const 1218 { 1219 return sequenceOut_; 1220 } 1221 /** Set sequenceIn or Out */ 1222 inline void setSequenceIn(int sequence) 1223 { 1224 sequenceIn_ = sequence; 1225 } 1226 inline void setSequenceOut(int sequence) 1227 { 1228 sequenceOut_ = sequence; 1229 } 1230 /** Return direction In or Out */ 1231 inline int directionIn() const 1232 { 1233 return directionIn_; 1234 } 1235 inline int directionOut() const 1236 { 1237 return directionOut_; 1238 } 1239 /** Set directionIn or Out */ 1240 inline void setDirectionIn(int direction) 1241 { 1242 directionIn_ = direction; 1243 } 1244 inline void setDirectionOut(int direction) 1245 { 1246 directionOut_ = direction; 1247 } 1248 /// Value of Out variable 1249 inline double valueOut() const 1250 { 1251 return valueOut_; 1252 } 1253 /// Lower of out variable 1254 inline double lowerOut() const 1255 { 1256 return lowerOut_; 1257 } 1258 /// Upper of out variable 1259 inline double upperOut() const 1260 { 1261 return upperOut_; 1262 } 1263 /// Set value of out variable 1264 inline void setValueOut(double value) 1265 { 1266 valueOut_ = value; 1267 } 1268 /// Dual value of Out variable 1269 inline double dualOut() const 1270 { 1271 return dualOut_; 1272 } 1273 /// Set dual value of out variable 1274 inline void setDualOut(double value) 1275 { 1276 dualOut_ = value; 1277 } 1278 /// Set lower of out variable 1279 inline void setLowerOut(double value) 1280 { 1281 lowerOut_ = value; 1282 } 1283 /// Set upper of out variable 1284 inline void setUpperOut(double value) 1285 { 1286 upperOut_ = value; 1287 } 1288 /// Set theta of out variable 1289 inline void setTheta(double value) 1290 { 1291 theta_ = value; 1292 } 1293 /// Returns 1 if sequence indicates column 1294 inline int isColumn(int sequence) const 1295 { 1296 return sequence < numberColumns_ ? 1 : 0; 1297 } 1298 /// Returns sequence number within section 1299 inline int sequenceWithin(int sequence) const 1300 { 1301 return sequence < numberColumns_ ? sequence : sequence  numberColumns_; 1302 } 1303 /// Return row or column values 1304 inline double solution(int sequence) 1305 { 1306 return solution_[sequence]; 1307 } 1308 /// Return address of row or column values 1309 inline double &solutionAddress(int sequence) 1310 { 1311 return solution_[sequence]; 1312 } 1313 inline double reducedCost(int sequence) 1314 { 1315 return dj_[sequence]; 1316 } 1317 inline double &reducedCostAddress(int sequence) 1318 { 1319 return dj_[sequence]; 1320 } 1321 inline double lower(int sequence) 1322 { 1323 return lower_[sequence]; 1324 } 1325 /// Return address of row or column lower bound 1326 inline double &lowerAddress(int sequence) 1327 { 1328 return lower_[sequence]; 1329 } 1330 inline double upper(int sequence) 1331 { 1332 return upper_[sequence]; 1333 } 1334 /// Return address of row or column upper bound 1335 inline double &upperAddress(int sequence) 1336 { 1337 return upper_[sequence]; 1338 } 1339 inline double cost(int sequence) 1340 { 1341 return cost_[sequence]; 1342 } 1343 /// Return address of row or column cost 1344 inline double &costAddress(int sequence) 1345 { 1346 return cost_[sequence]; 1347 } 1348 /// Return original lower bound 1349 inline double originalLower(int iSequence) const 1350 { 1351 if (iSequence < numberColumns_) 1352 return columnLower_[iSequence]; 1353 else 1354 return rowLower_[iSequence  numberColumns_]; 1355 } 1356 /// Return original lower bound 1357 inline double originalUpper(int iSequence) const 1358 { 1359 if (iSequence < numberColumns_) 1360 return columnUpper_[iSequence]; 1361 else 1362 return rowUpper_[iSequence  numberColumns_]; 1363 } 1364 /// Theta (pivot change) 1365 inline double theta() const 1366 { 1367 return theta_; 1368 } 1369 /// Lower Bound on In variable 1370 inline double lowerIn() const 1371 { 1372 return lowerIn_; 1373 } 1374 /// Value of In variable 1375 inline double valueIn() const 1376 { 1377 return valueIn_; 1378 } 1379 /// Upper Bound on In variable 1380 inline double upperIn() const 1381 { 1382 return upperIn_; 1383 } 1384 /** Best possible improvement using djs (primal) or 1261 1385 obj change by flipping bounds to make dual feasible (dual) */ 1262 inline double bestPossibleImprovement() const { 1263 return bestPossibleImprovement_; 1264 } 1265 /// Return pointer to details of costs 1266 inline ClpNonLinearCost * nonLinearCost() const { 1267 return nonLinearCost_; 1268 } 1269 /// Set pointer to details of costs 1270 void setNonLinearCost(ClpNonLinearCost & nonLinearCost); 1271 /** Return more special options 1386 inline double bestPossibleImprovement() const 1387 { 1388 return bestPossibleImprovement_; 1389 } 1390 /// Return pointer to details of costs 1391 inline ClpNonLinearCost *nonLinearCost() const 1392 { 1393 return nonLinearCost_; 1394 } 1395 /// Set pointer to details of costs 1396 void setNonLinearCost(ClpNonLinearCost &nonLinearCost); 1397 /** Return more special options 1272 1398 1 bit  if presolve says infeasible in ClpSolve return 1273 1399 2 bit  if presolved problem infeasible return … … 1295 1421 16777216 bit  if factorization kept can still declare optimal at once 1296 1422 */ 1297 inline int moreSpecialOptions() const { 1298 return moreSpecialOptions_; 1299 } 1300 /// Get vector mode 1301 inline int vectorMode() const { 1302 return vectorMode_; 1303 } 1304 /** Set more special options 1423 inline int moreSpecialOptions() const 1424 { 1425 return moreSpecialOptions_; 1426 } 1427 /// Get vector mode 1428 inline int vectorMode() const 1429 { 1430 return vectorMode_; 1431 } 1432 /** Set more special options 1305 1433 1 bit  if presolve says infeasible in ClpSolve return 1306 1434 2 bit  if presolved problem infeasible return … … 1328 1456 16777216 bit  if factorization kept can still declare optimal at once 1329 1457 */ 1330 inline void setMoreSpecialOptions(int value) { 1331 moreSpecialOptions_ = value; 1332 } 1333 /// Set vector mode 1334 inline void setVectorMode(int value) { 1335 vectorMode_ = value; 1336 } 1337 //@} 1338 /**@name status methods */ 1339 //@{ 1340 inline void setFakeBound(int sequence, FakeBound fakeBound) { 1341 unsigned char & st_byte = status_[sequence]; 1342 st_byte = static_cast<unsigned char>(st_byte & ~24); 1343 st_byte = static_cast<unsigned char>(st_byte  (fakeBound << 3)); 1344 } 1345 inline FakeBound getFakeBound(int sequence) const { 1346 return static_cast<FakeBound> ((status_[sequence] >> 3) & 3); 1347 } 1348 inline void setRowStatus(int sequence, Status newstatus) { 1349 unsigned char & st_byte = status_[sequence+numberColumns_]; 1350 st_byte = static_cast<unsigned char>(st_byte & ~7); 1351 st_byte = static_cast<unsigned char>(st_byte  newstatus); 1352 } 1353 inline Status getRowStatus(int sequence) const { 1354 return static_cast<Status> (status_[sequence+numberColumns_] & 7); 1355 } 1356 inline void setColumnStatus(int sequence, Status newstatus) { 1357 unsigned char & st_byte = status_[sequence]; 1358 st_byte = static_cast<unsigned char>(st_byte & ~7); 1359 st_byte = static_cast<unsigned char>(st_byte  newstatus); 1360 } 1361 inline Status getColumnStatus(int sequence) const { 1362 return static_cast<Status> (status_[sequence] & 7); 1363 } 1364 inline void setPivoted( int sequence) { 1365 status_[sequence] = static_cast<unsigned char>(status_[sequence]  32); 1366 } 1367 inline void clearPivoted( int sequence) { 1368 status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~32); 1369 } 1370 inline bool pivoted(int sequence) const { 1371 return (((status_[sequence] >> 5) & 1) != 0); 1372 } 1373 /// To flag a variable (not inline to allow for column generation) 1374 void setFlagged( int sequence); 1375 inline void clearFlagged( int sequence) { 1376 status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64); 1377 } 1378 inline bool flagged(int sequence) const { 1379 return ((status_[sequence] & 64) != 0); 1380 } 1381 /// To say row active in primal pivot row choice 1382 inline void setActive( int iRow) { 1383 status_[iRow] = static_cast<unsigned char>(status_[iRow]  128); 1384 } 1385 inline void clearActive( int iRow) { 1386 status_[iRow] = static_cast<unsigned char>(status_[iRow] & ~128); 1387 } 1388 inline bool active(int iRow) const { 1389 return ((status_[iRow] & 128) != 0); 1390 } 1391 /// To say perturbed 1392 inline void setPerturbed( int iSequence) { 1393 status_[iSequence] = static_cast<unsigned char>(status_[iSequence]  128); 1394 } 1395 inline void clearPerturbed( int iSequence) { 1396 status_[iSequence] = static_cast<unsigned char>(status_[iSequence] & ~128); 1397 } 1398 inline bool perturbed(int iSequence) const { 1399 return ((status_[iSequence] & 128) != 0); 1400 } 1401 /** Set up status array (can be used by OsiClp). 1458 inline void setMoreSpecialOptions(int value) 1459 { 1460 moreSpecialOptions_ = value; 1461 } 1462 /// Set vector mode 1463 inline void setVectorMode(int value) 1464 { 1465 vectorMode_ = value; 1466 } 1467 //@} 1468 /**@name status methods */ 1469 //@{ 1470 inline void setFakeBound(int sequence, FakeBound fakeBound) 1471 { 1472 unsigned char &st_byte = status_[sequence]; 1473 st_byte = static_cast< unsigned char >(st_byte & ~24); 1474 st_byte = static_cast< unsigned char >(st_byte  (fakeBound << 3)); 1475 } 1476 inline FakeBound getFakeBound(int sequence) const 1477 { 1478 return static_cast< FakeBound >((status_[sequence] >> 3) & 3); 1479 } 1480 inline void setRowStatus(int sequence, Status newstatus) 1481 { 1482 unsigned char &st_byte = status_[sequence + numberColumns_]; 1483 st_byte = static_cast< unsigned char >(st_byte & ~7); 1484 st_byte = static_cast< unsigned char >(st_byte  newstatus); 1485 } 1486 inline Status getRowStatus(int sequence) const 1487 { 1488 return static_cast< Status >(status_[sequence + numberColumns_] & 7); 1489 } 1490 inline void setColumnStatus(int sequence, Status newstatus) 1491 { 1492 unsigned char &st_byte = status_[sequence]; 1493 st_byte = static_cast< unsigned char >(st_byte & ~7); 1494 st_byte = static_cast< unsigned char >(st_byte  newstatus); 1495 } 1496 inline Status getColumnStatus(int sequence) const 1497 { 1498 return static_cast< Status >(status_[sequence] & 7); 1499 } 1500 inline void setPivoted(int sequence) 1501 { 1502 status_[sequence] = static_cast< unsigned char >(status_[sequence]  32); 1503 } 1504 inline void clearPivoted(int sequence) 1505 { 1506 status_[sequence] = static_cast< unsigned char >(status_[sequence] & ~32); 1507 } 1508 inline bool pivoted(int sequence) const 1509 { 1510 return (((status_[sequence] >> 5) & 1) != 0); 1511 } 1512 /// To flag a variable (not inline to allow for column generation) 1513 void setFlagged(int sequence); 1514 inline void clearFlagged(int sequence) 1515 { 1516 status_[sequence] = static_cast< unsigned char >(status_[sequence] & ~64); 1517 } 1518 inline bool flagged(int sequence) const 1519 { 1520 return ((status_[sequence] & 64) != 0); 1521 } 1522 /// To say row active in primal pivot row choice 1523 inline void setActive(int iRow) 1524 { 1525 status_[iRow] = static_cast< unsigned char >(status_[iRow]  128); 1526 } 1527 inline void clearActive(int iRow) 1528 { 1529 status_[iRow] = static_cast< unsigned char >(status_[iRow] & ~128); 1530 } 1531 inline bool active(int iRow) const 1532 { 1533 return ((status_[iRow] & 128) != 0); 1534 } 1535 /// To say perturbed 1536 inline void setPerturbed(int iSequence) 1537 { 1538 status_[iSequence] = static_cast< unsigned char >(status_[iSequence]  128); 1539 } 1540 inline void clearPerturbed(int iSequence) 1541 { 1542 status_[iSequence] = static_cast< unsigned char >(status_[iSequence] & ~128); 1543 } 1544 inline bool perturbed(int iSequence) const 1545 { 1546 return ((status_[iSequence] & 128) != 0); 1547 } 1548 /** Set up status array (can be used by OsiClp). 1402 1549 Also can be used to set up all slack basis */ 1403 void createStatus();1404 1550 void createStatus(); 1551 /** Sets up all slack basis and resets solution to 1405 1552 as it was after initial load or readMps */ 1406 void allSlackBasis(bool resetSolution = false); 1407 1408 /// So we know when to be cautious 1409 inline int lastBadIteration() const { 1410 return lastBadIteration_; 1411 } 1412 /// Set so we know when to be cautious 1413 inline void setLastBadIteration(int value) { 1414 lastBadIteration_=value; 1415 } 1416 /// Progress flag  at present 0 bit says artificials out 1417 inline int progressFlag() const { 1418 return (progressFlag_ & 3); 1419 } 1420 /// For dealing with all issues of cycling etc 1421 inline ClpSimplexProgress * progress() 1422 { return &progress_;} 1423 /// Force refactorization early value 1424 inline int forceFactorization() const { 1425 return forceFactorization_ ; 1426 } 1427 /// Force refactorization early 1428 inline void forceFactorization(int value) { 1429 forceFactorization_ = value; 1430 } 1431 /// Raw objective value (so always minimize in primal) 1432 inline double rawObjectiveValue() const { 1433 return objectiveValue_; 1434 } 1435 /// Compute objective value from solution and put in objectiveValue_ 1436 void computeObjectiveValue(bool useWorkingSolution = false); 1437 /// Compute minimization objective value from internal solution without perturbation 1438 double computeInternalObjectiveValue(); 1439 /** Infeasibility/unbounded ray (NULL returned if none/wrong) 1553 void allSlackBasis(bool resetSolution = false); 1554 1555 /// So we know when to be cautious 1556 inline int lastBadIteration() const 1557 { 1558 return lastBadIteration_; 1559 } 1560 /// Set so we know when to be cautious 1561 inline void setLastBadIteration(int value) 1562 { 1563 lastBadIteration_ = value; 1564 } 1565 /// Progress flag  at present 0 bit says artificials out 1566 inline int progressFlag() const 1567 { 1568 return (progressFlag_ & 3); 1569 } 1570 /// For dealing with all issues of cycling etc 1571 inline ClpSimplexProgress *progress() 1572 { 1573 return &progress_; 1574 } 1575 /// Force refactorization early value 1576 inline int forceFactorization() const 1577 { 1578 return forceFactorization_; 1579 } 1580 /// Force refactorization early 1581 inline void forceFactorization(int value) 1582 { 1583 forceFactorization_ = value; 1584 } 1585 /// Raw objective value (so always minimize in primal) 1586 inline double rawObjectiveValue() const 1587 { 1588 return objectiveValue_; 1589 } 1590 /// Compute objective value from solution and put in objectiveValue_ 1591 void computeObjectiveValue(bool useWorkingSolution = false); 1592 /// Compute minimization objective value from internal solution without perturbation 1593 double computeInternalObjectiveValue(); 1594 /** Infeasibility/unbounded ray (NULL returned if none/wrong) 1440 1595 Up to user to use delete [] on these arrays. */ 1441 double * infeasibilityRay(bool fullRay=false) const;1442 1596 double *infeasibilityRay(bool fullRay = false) const; 1597 /** Number of extra rows. These are ones which will be dynamically created 1443 1598 each iteration. This is for GUB but may have other uses. 1444 1599 */ 1445 inline int numberExtraRows() const { 1446 return numberExtraRows_; 1447 } 1448 /** Maximum number of basic variables  can be more than number of rows if GUB 1449 */ 1450 inline int maximumBasic() const { 1451 return maximumBasic_; 1452 } 1453 /// Iteration when we entered dual or primal 1454 inline int baseIteration() const { 1455 return baseIteration_; 1456 } 1457 /// Create C++ lines to get to current state 1458 void generateCpp( FILE * fp, bool defaultFactor = false); 1459 /// Gets clean and emptyish factorization 1460 ClpFactorization * getEmptyFactorization(); 1461 /// May delete or may make clean and emptyish factorization 1462 void setEmptyFactorization(); 1463 /// Move status and solution across 1464 void moveInfo(const ClpSimplex & rhs, bool justStatus = false); 1465 //@} 1466 1467 ///@name Basis handling 1468 // These are only to be used using startFinishOptions (ClpSimplexDual, ClpSimplexPrimal) 1469 // *** At present only without scaling 1470 // *** Slacks havve 1.0 element (so == row activity)  take care 1471 ///Get a row of the tableau (slack part in slack if not NULL) 1472 void getBInvARow(int row, double* z, double * slack = NULL); 1473 1474 ///Get a row of the basis inverse 1475 void getBInvRow(int row, double* z); 1476 1477 ///Get a column of the tableau 1478 void getBInvACol(int col, double* vec); 1479 1480 ///Get a column of the basis inverse 1481 void getBInvCol(int col, double* vec); 1482 1483 /** Get basic indices (order of indices corresponds to the 1600 inline int numberExtraRows() const 1601 { 1602 return numberExtraRows_; 1603 } 1604 /** Maximum number of basic variables  can be more than number of rows if GUB 1605 */ 1606 inline int maximumBasic() const 1607 { 1608 return maximumBasic_; 1609 } 1610 /// Iteration when we entered dual or primal 1611 inline int baseIteration() const 1612 { 1613 return baseIteration_; 1614 } 1615 /// Create C++ lines to get to current state 1616 void generateCpp(FILE *fp, bool defaultFactor = false); 1617 /// Gets clean and emptyish factorization 1618 ClpFactorization *getEmptyFactorization(); 1619 /// May delete or may make clean and emptyish factorization 1620 void setEmptyFactorization(); 1621 /// Move status and solution across 1622 void moveInfo(const ClpSimplex &rhs, bool justStatus = false); 1623 //@} 1624 1625 ///@name Basis handling 1626 // These are only to be used using startFinishOptions (ClpSimplexDual, ClpSimplexPrimal) 1627 // *** At present only without scaling 1628 // *** Slacks havve 1.0 element (so == row activity)  take care 1629 ///Get a row of the tableau (slack part in slack if not NULL) 1630 void getBInvARow(int row, double *z, double *slack = NULL); 1631 1632 ///Get a row of the basis inverse 1633 void getBInvRow(int row, double *z); 1634 1635 ///Get a column of the tableau 1636 void getBInvACol(int col, double *vec); 1637 1638 ///Get a column of the basis inverse 1639 void getBInvCol(int col, double *vec); 1640 1641 /** Get basic indices (order of indices corresponds to the 1484 1642 order of elements in a vector retured by getBInvACol() and 1485 1643 getBInvCol()). 1486 1644 */ 1487 void getBasics(int* index); 1488 1489 //@} 1490 // 1491 /**@name Changing bounds on variables and constraints */ 1492 //@{ 1493 /** Set an objective function coefficient */ 1494 void setObjectiveCoefficient( int elementIndex, double elementValue ); 1495 /** Set an objective function coefficient */ 1496 inline void setObjCoeff( int elementIndex, double elementValue ) { 1497 setObjectiveCoefficient( elementIndex, elementValue); 1498 } 1499 1500 /** Set a single column lower bound<br> 1645 void getBasics(int *index); 1646 1647 //@} 1648 // 1649 /**@name Changing bounds on variables and constraints */ 1650 //@{ 1651 /** Set an objective function coefficient */ 1652 void setObjectiveCoefficient(int elementIndex, double elementValue); 1653 /** Set an objective function coefficient */ 1654 inline void setObjCoeff(int elementIndex, double elementValue) 1655 { 1656 setObjectiveCoefficient(elementIndex, elementValue); 1657 } 1658 1659 /** Set a single column lower bound<br> 1501 1660 Use DBL_MAX for infinity. */ 1502 void setColumnLower( int elementIndex, double elementValue);1503 1504 1661 void setColumnLower(int elementIndex, double elementValue); 1662 1663 /** Set a single column upper bound<br> 1505 1664 Use DBL_MAX for infinity. */ 1506 void setColumnUpper( int elementIndex, double elementValue);1507 1508 1509 void setColumnBounds(int elementIndex,1510 double lower, double upper);1511 1512 1665 void setColumnUpper(int elementIndex, double elementValue); 1666 1667 /** Set a single column lower and upper bound */ 1668 void setColumnBounds(int elementIndex, 1669 double lower, double upper); 1670 1671 /** Set the bounds on a number of columns simultaneously<br> 1513 1672 The default implementation just invokes setColLower() and 1514 1673 setColUpper() over and over again. … … 1518 1677 @param boundList the new lower/upper bound pairs for the variables 1519 1678 */ 1520 void setColumnSetBounds(const int*indexFirst,1521 const int*indexLast,1522 const double*boundList);1523 1524 1679 void setColumnSetBounds(const int *indexFirst, 1680 const int *indexLast, 1681 const double *boundList); 1682 1683 /** Set a single column lower bound<br> 1525 1684 Use DBL_MAX for infinity. */ 1526 inline void setColLower( int elementIndex, double elementValue ) { 1527 setColumnLower(elementIndex, elementValue); 1528 } 1529 /** Set a single column upper bound<br> 1685 inline void setColLower(int elementIndex, double elementValue) 1686 { 1687 setColumnLower(elementIndex, elementValue); 1688 } 1689 /** Set a single column upper bound<br> 1530 1690 Use DBL_MAX for infinity. */ 1531 inline void setColUpper( int elementIndex, double elementValue ) { 1532 setColumnUpper(elementIndex, elementValue); 1533 } 1534 1535 /** Set a single column lower and upper bound */ 1536 inline void setColBounds( int elementIndex, 1537 double newlower, double newupper ) { 1538 setColumnBounds(elementIndex, newlower, newupper); 1539 } 1540 1541 /** Set the bounds on a number of columns simultaneously<br> 1691 inline void setColUpper(int elementIndex, double elementValue) 1692 { 1693 setColumnUpper(elementIndex, elementValue); 1694 } 1695 1696 /** Set a single column lower and upper bound */ 1697 inline void setColBounds(int elementIndex, 1698 double newlower, double newupper) 1699 { 1700 setColumnBounds(elementIndex, newlower, newupper); 1701 } 1702 1703 /** Set the bounds on a number of columns simultaneously<br> 1542 1704 @param indexFirst,indexLast pointers to the beginning and after the 1543 1705 end of the array of the indices of the variables whose … … 1545 1707 @param boundList the new lower/upper bound pairs for the variables 1546 1708 */ 1547 inline void setColSetBounds(const int* indexFirst, 1548 const int* indexLast, 1549 const double* boundList) { 1550 setColumnSetBounds(indexFirst, indexLast, boundList); 1551 } 1552 1553 /** Set a single row lower bound<br> 1709 inline void setColSetBounds(const int *indexFirst, 1710 const int *indexLast, 1711 const double *boundList) 1712 { 1713 setColumnSetBounds(indexFirst, indexLast, boundList); 1714 } 1715 1716 /** Set a single row lower bound<br> 1554 1717 Use DBL_MAX for infinity. */ 1555 void setRowLower( int elementIndex, double elementValue);1556 1557 1718 void setRowLower(int elementIndex, double elementValue); 1719 1720 /** Set a single row upper bound<br> 1558 1721 Use DBL_MAX for infinity. */ 1559 void setRowUpper( int elementIndex, double elementValue );1560 1561 1562 void setRowBounds(int elementIndex,1563 double lower, double upper );1564 1565 1722 void setRowUpper(int elementIndex, double elementValue); 1723 1724 /** Set a single row lower and upper bound */ 1725 void setRowBounds(int elementIndex, 1726 double lower, double upper); 1727 1728 /** Set the bounds on a number of rows simultaneously<br> 1566 1729 @param indexFirst,indexLast pointers to the beginning and after the 1567 1730 end of the array of the indices of the constraints whose … … 1569 1732 @param boundList the new lower/upper bound pairs for the constraints 1570 1733 */ 1571 void setRowSetBounds(const int*indexFirst,1572 const int*indexLast,1573 const double*boundList);1574 1575 void resize(int newNumberRows, int newNumberColumns);1576 1577 1578 1579 ////////////////// data //////////////////1734 void setRowSetBounds(const int *indexFirst, 1735 const int *indexLast, 1736 const double *boundList); 1737 /// Resizes rim part of model 1738 void resize(int newNumberRows, int newNumberColumns); 1739 1740 //@} 1741 1742 ////////////////// data ////////////////// 1580 1743 protected: 1581 1582 /**@name data. Many arrays have a row part and a column part. 1744 /**@name data. Many arrays have a row part and a column part. 1583 1745 There is a single array with both  columns then rows and 1584 1746 then normally two arrays pointing to rows and columns. The 1585 1747 single array is the owner of memory 1586 1748 */ 1587 1588 1749 //@{ 1750 /** Best possible improvement using djs (primal) or 1589 1751 obj change by flipping bounds to make dual feasible (dual) */ 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1752 double bestPossibleImprovement_; 1753 /// Zero tolerance 1754 double zeroTolerance_; 1755 /// Sequence of worst (1 if feasible) 1756 int columnPrimalSequence_; 1757 /// Sequence of worst (1 if feasible) 1758 int rowPrimalSequence_; 1759 /// "Best" objective value 1760 double bestObjectiveValue_; 1761 /// More special options  see set for details 1762 int moreSpecialOptions_; 1763 /// Iteration when we entered dual or primal 1764 int baseIteration_; 1765 /// Vector mode  try and use vector instructions 1766 int vectorMode_; 1767 /// Primal tolerance needed to make dual feasible (<largeTolerance) 1768 double primalToleranceToGetOptimal_; 1769 /// Large bound value (for complementarity etc) 1770 double largeValue_; 1771 /// Largest error on Axb 1772 double largestPrimalError_; 1773 /// Largest error on basic duals 1774 double largestDualError_; 1775 /// For computing whether to refactorize 1776 double alphaAccuracy_; 1777 /// Dual bound 1778 double dualBound_; 1779 /// Alpha (pivot element) 1780 double alpha_; 1781 /// Theta (pivot change) 1782 double theta_; 1783 /// Lower Bound on In variable 1784 double lowerIn_; 1785 /// Value of In variable 1786 double valueIn_; 1787 /// Upper Bound on In variable 1788 double upperIn_; 1789 /// Reduced cost of In variable 1790 double dualIn_; 1791 /// Lower Bound on Out variable 1792 double lowerOut_; 1793 /// Value of Out variable 1794 double valueOut_; 1795 /// Upper Bound on Out variable 1796 double upperOut_; 1797 /// Infeasibility (dual) or ? (primal) of Out variable 1798 double dualOut_; 1799 /// Current dual tolerance for algorithm 1800 double dualTolerance_; 1801 /// Current primal tolerance for algorithm 1802 double primalTolerance_; 1803 /// Sum of dual infeasibilities 1804 double sumDualInfeasibilities_; 1805 /// Sum of primal infeasibilities 1806 double sumPrimalInfeasibilities_; 1807 /// Weight assigned to being infeasible in primal 1808 double infeasibilityCost_; 1809 /// Sum of Dual infeasibilities using tolerance based on error in duals 1810 double sumOfRelaxedDualInfeasibilities_; 1811 /// Sum of Primal infeasibilities using tolerance based on error in primals 1812 double sumOfRelaxedPrimalInfeasibilities_; 1813 /// Acceptable pivot value just after factorization 1814 double acceptablePivot_; 1815 /// Minimum primal tolerance 1816 double minimumPrimalTolerance_; 1817 /// Last few infeasibilities 1656 1818 #define CLP_INFEAS_SAVE 5 1657 1658 1659 double *lower_;1660 1661 double *rowLowerWork_;1662 1663 double *columnLowerWork_;1664 1665 double *upper_;1666 1667 double *rowUpperWork_;1668 1669 double *columnUpperWork_;1670 1671 double *cost_;1672 1673 double *rowObjectiveWork_;1674 1675 double *objectiveWork_;1676 1677 CoinIndexedVector *rowArray_[6];1678 1679 CoinIndexedVector *columnArray_[6];1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 double *dj_;1694 1695 double *rowReducedCost_;1696 1697 double *reducedCostWork_;1698 1699 double *solution_;1700 1701 double *rowActivityWork_;1702 1703 double *columnActivityWork_;1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 ClpDualRowPivot *dualRowPivot_;1714 1715 ClpPrimalColumnPivot *primalColumnPivot_;1716 1717 int *pivotVariable_;1718 1719 ClpFactorization *factorization_;1720 1721 double *savedSolution_;1722 1723 1724 1725 ClpDisasterHandler *disasterArea_;1726 1727 1728 1729 1730 1819 double averageInfeasibility_[CLP_INFEAS_SAVE]; 1820 /// Working copy of lower bounds (Owner of arrays below) 1821 double *lower_; 1822 /// Row lower bounds  working copy 1823 double *rowLowerWork_; 1824 /// Column lower bounds  working copy 1825 double *columnLowerWork_; 1826 /// Working copy of upper bounds (Owner of arrays below) 1827 double *upper_; 1828 /// Row upper bounds  working copy 1829 double *rowUpperWork_; 1830 /// Column upper bounds  working copy 1831 double *columnUpperWork_; 1832 /// Working copy of objective (Owner of arrays below) 1833 double *cost_; 1834 /// Row objective  working copy 1835 double *rowObjectiveWork_; 1836 /// Column objective  working copy 1837 double *objectiveWork_; 1838 /// Useful row length arrays 1839 CoinIndexedVector *rowArray_[6]; 1840 /// Useful column length arrays 1841 CoinIndexedVector *columnArray_[6]; 1842 /// Sequence of In variable 1843 int sequenceIn_; 1844 /// Direction of In, 1 going up, 1 going down, 0 not a clue 1845 int directionIn_; 1846 /// Sequence of Out variable 1847 int sequenceOut_; 1848 /// Direction of Out, 1 to upper bound, 1 to lower bound, 0  superbasic 1849 int directionOut_; 1850 /// Pivot Row 1851 int pivotRow_; 1852 /// Last good iteration (immediately after a refactorization) 1853 int lastGoodIteration_; 1854 /// Working copy of reduced costs (Owner of arrays below) 1855 double *dj_; 1856 /// Reduced costs of slacks not same as duals (or  duals) 1857 double *rowReducedCost_; 1858 /// Possible scaled reduced costs 1859 double *reducedCostWork_; 1860 /// Working copy of primal solution (Owner of arrays below) 1861 double *solution_; 1862 /// Row activities  working copy 1863 double *rowActivityWork_; 1864 /// Column activities  working copy 1865 double *columnActivityWork_; 1866 /// Number of dual infeasibilities 1867 int numberDualInfeasibilities_; 1868 /// Number of dual infeasibilities (without free) 1869 int numberDualInfeasibilitiesWithoutFree_; 1870 /// Number of primal infeasibilities 1871 int numberPrimalInfeasibilities_; 1872 /// How many iterative refinements to do 1873 int numberRefinements_; 1874 /// dual row pivot choice 1875 ClpDualRowPivot *dualRowPivot_; 1876 /// primal column pivot choice 1877 ClpPrimalColumnPivot *primalColumnPivot_; 1878 /// Basic variables pivoting on which rows 1879 int *pivotVariable_; 1880 /// factorization 1881 ClpFactorization *factorization_; 1882 /// Saved version of solution 1883 double *savedSolution_; 1884 /// Number of times code has tentatively thought optimal 1885 int numberTimesOptimal_; 1886 /// Disaster handler 1887 ClpDisasterHandler *disasterArea_; 1888 /// If change has been made (first attempt at stopping looping) 1889 int changeMade_; 1890 /// Algorithm >0 == Primal, <0 == Dual 1891 int algorithm_; 1892 /** Now for some reliability aids 1731 1893 This forces refactorization early */ 1732 1733 1894 int forceFactorization_; 1895 /** Perturbation: 1734 1896 50 to +50  perturb by this power of ten (6 sounds good) 1735 1897 100  auto perturb if takes too long (1.0e6 largest nonzero) … … 1738 1900 default is 100 1739 1901 */ 1740 1741 1742 unsigned char *saveStatus_;1743 1902 int perturbation_; 1903 /// Saved status regions 1904 unsigned char *saveStatus_; 1905 /** Very wasteful way of dealing with infeasibilities in primal. 1744 1906 However it will allow nonlinearities and use of dual 1745 1907 analysis. If it doesn't work it can easily be replaced. 1746 1908 */ 1747 ClpNonLinearCost *nonLinearCost_;1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1909 ClpNonLinearCost *nonLinearCost_; 1910 /// So we know when to be cautious 1911 int lastBadIteration_; 1912 /// So we know when to open up again 1913 int lastFlaggedIteration_; 1914 /// Can be used for count of fake bounds (dual) or fake costs (primal) 1915 int numberFake_; 1916 /// Can be used for count of changed costs (dual) or changed bounds (primal) 1917 int numberChanged_; 1918 /// Progress flag  at present 0 bit says artificials out, 1 free in 1919 int progressFlag_; 1920 /// First free/superbasic variable (1 if none) 1921 int firstFree_; 1922 /** Number of extra rows. These are ones which will be dynamically created 1761 1923 each iteration. This is for GUB but may have other uses. 1762 1924 */ 1763 1764 1765 */ 1766 1767 1768 1769 1925 int numberExtraRows_; 1926 /** Maximum number of basic variables  can be more than number of rows if GUB 1927 */ 1928 int maximumBasic_; 1929 /// If may skip final factorize then allow up to this pivots (default 20) 1930 int dontFactorizePivots_; 1931 /** For advanced use. When doing iterative solves things can get 1770 1932 nasty so on values pass if incoming solution has largest 1771 1933 infeasibility < incomingInfeasibility throw out variables … … 1776 1938 Defaults are 1.0,10.0 1777 1939 */ 1778 1779 1780 1781 1782 1783 1784 1785 double *perturbationArray_;1786 1787 ClpSimplex *baseModel_;1788 1789 1940 double incomingInfeasibility_; 1941 double allowedInfeasibility_; 1942 /// Automatic scaling of objective and rhs and bounds 1943 int automaticScale_; 1944 /// Maximum perturbation array size (take out when code rewritten) 1945 int maximumPerturbationSize_; 1946 /// Perturbation array (maximumPerturbationSize_) 1947 double *perturbationArray_; 1948 /// A copy of model with certain state  normally without cuts 1949 ClpSimplex *baseModel_; 1950 /// For dealing with all issues of cycling etc 1951 ClpSimplexProgress progress_; 1790 1952 #ifdef ABC_INHERIT 1791 AbcSimplex * 1953 AbcSimplex *abcSimplex_; 1792 1954 int abcState_; 1793 1955 #define CLP_ABC_WANTED 1 … … 1799 1961 /// Number of degenerate pivots since last perturbed 1800 1962 int numberDegeneratePivots_; 1963 1801 1964 public: 1802 /// Spare int array for passing information [0]!=0 switches on 1803 mutable int spareIntArray_[4]; 1804 /// Spare double array for passing information [0]!=0 switches on 1805 mutable double spareDoubleArray_[4]; 1965 /// Spare int array for passing information [0]!=0 switches on 1966 mutable int spareIntArray_[4]; 1967 /// Spare double array for passing information [0]!=0 switches on 1968 mutable double spareDoubleArray_[4]; 1969 1806 1970 protected: 1807 1808 1809 1810 1811 1971 /// Allow OsiClp certain perks 1972 friend class OsiClpSolverInterface; 1973 /// And OsiCLP 1974 friend class OsiCLPSolverInterface; 1975 //@} 1812 1976 }; 1813 1977 //############################################################################# … … 1820 1984 It also does some testing of ClpFactorization class 1821 1985 */ 1822 void 1823 ClpSimplexUnitTest(const std::string & mpsDir); 1986 void ClpSimplexUnitTest(const std::string &mpsDir); 1824 1987 1825 1988 // For Devex stuff … … 1833 1996 //const CoinIndexedVector * constVector; // can get rid of 1834 1997 //CoinIndexedVector * vectors[2]; // can get rid of 1835 void * 1836 void * 1998 void *extraInfo; 1999 void *extraInfo2; 1837 2000 int status; 1838 2001 int stuff[4]; … … 1844 2007 /** Main constructor 1845 2008 */ 1846 CoinPthreadStuff (int numberThreads=0,1847 void * parallelManager(void * stuff)=NULL);2009 CoinPthreadStuff(int numberThreads = 0, 2010 void *parallelManager(void *stuff) = NULL); 1848 2011 /// Assignment operator. This copies the data 1849 CoinPthreadStuff & operator=(const CoinPthreadStuff &rhs);2012 CoinPthreadStuff &operator=(const CoinPthreadStuff &rhs); 1850 2013 /// Destructor 1851 ~CoinPthreadStuff ();2014 ~CoinPthreadStuff(); 1852 2015 /// set stop start 1853 2016 inline void setStopStart(int value) 1854 { stopStart_=value;} 1855 #ifndef NUMBER_THREADS 2017 { 2018 stopStart_ = value; 2019 } 2020 #ifndef NUMBER_THREADS 1856 2021 #define NUMBER_THREADS 8 1857 2022 #endif 1858 2023 // For waking up thread 1859 inline pthread_mutex_t * mutexPointer(int which,int thread=0) 1860 { return mutex_+which+3*thread;} 2024 inline pthread_mutex_t *mutexPointer(int which, int thread = 0) 2025 { 2026 return mutex_ + which + 3 * thread; 2027 } 1861 2028 #ifdef PTHREAD_BARRIER_SERIAL_THREAD 1862 inline pthread_barrier_t * barrierPointer() 1863 { return &barrier_;} 1864 #endif 1865 inline int whichLocked(int thread=0) const 1866 { return locked_[thread];} 1867 inline CoinThreadInfo * threadInfoPointer(int thread=0) 1868 { return threadInfo_+thread;} 1869 void startParallelTask(int type,int iThread,void * info=NULL); 1870 int waitParallelTask(int type, int & iThread,bool allowIdle); 2029 inline pthread_barrier_t *barrierPointer() 2030 { 2031 return &barrier_; 2032 } 2033 #endif 2034 inline int whichLocked(int thread = 0) const 2035 { 2036 return locked_[thread]; 2037 } 2038 inline CoinThreadInfo *threadInfoPointer(int thread = 0) 2039 { 2040 return threadInfo_ + thread; 2041 } 2042 void startParallelTask(int type, int iThread, void *info = NULL); 2043 int waitParallelTask(int type, int &iThread, bool allowIdle); 1871 2044 void waitAllTasks(); 1872 /// so thread can find out which one it is 2045 /// so thread can find out which one it is 1873 2046 int whichThread() const; 1874 2047 void sayIdle(int iThread); … … 1876 2049 //void stopThreads(); 1877 2050 // For waking up thread 1878 pthread_mutex_t mutex_[3 *(NUMBER_THREADS+1)];2051 pthread_mutex_t mutex_[3 * (NUMBER_THREADS + 1)]; 1879 2052 #ifdef PTHREAD_BARRIER_SERIAL_THREAD 1880 pthread_barrier_t barrier_; 1881 #endif 1882 CoinThreadInfo threadInfo_[NUMBER_THREADS +1];1883 pthread_t abcThread_[NUMBER_THREADS +1];1884 int locked_[NUMBER_THREADS +1];2053 pthread_barrier_t barrier_; 2054 #endif 2055 CoinThreadInfo threadInfo_[NUMBER_THREADS + 1]; 2056 pthread_t abcThread_[NUMBER_THREADS + 1]; 2057 int locked_[NUMBER_THREADS + 1]; 1885 2058 int stopStart_; 1886 2059 int numberThreads_; 1887 2060 }; 1888 void * clp_parallelManager(void *stuff);2061 void *clp_parallelManager(void *stuff); 1889 2062 #endif 1890 2063 typedef struct { … … 1892 2065 double bestPossible; 1893 2066 double acceptablePivot; 1894 double tolerance; 1895 double dualTolerance; 1896 double theta; 2067 double tolerance; 2068 double dualTolerance; 2069 double theta; 1897 2070 double primalRatio; 1898 2071 double changeObj; 1899 const double * 1900 double *COIN_RESTRICT solution;1901 double * COIN_RESTRICT reducedCost;1902 const double * COIN_RESTRICT lower;1903 const double * 1904 double * COIN_RESTRICT work;1905 int * 1906 double * 1907 const unsigned char * COIN_RESTRICT status;1908 int * COIN_RESTRICT which;1909 double * 1910 const int * 1911 const double * COIN_RESTRICT element;1912 const CoinBigIndex * 1913 const int * 2072 const double *COIN_RESTRICT cost; 2073 double *COIN_RESTRICT solution; 2074 double *COIN_RESTRICT reducedCost; 2075 const double *COIN_RESTRICT lower; 2076 const double *COIN_RESTRICT upper; 2077 double *COIN_RESTRICT work; 2078 int *COIN_RESTRICT index; 2079 double *COIN_RESTRICT spare; 2080 const unsigned char *COIN_RESTRICT status; 2081 int *COIN_RESTRICT which; 2082 double *COIN_RESTRICT infeas; 2083 const int *COIN_RESTRICT pivotVariable; 2084 const double *COIN_RESTRICT element; 2085 const CoinBigIndex *COIN_RESTRICT start; 2086 const int *COIN_RESTRICT row; 1914 2087 int numberAdded; 1915 int numberInfeasibilities; 2088 int numberInfeasibilities; 1916 2089 int numberRemaining; 1917 2090 int startColumn; … … 1921 2094 #ifndef ABC_INHERIT 1922 2095 #if ABOCA_LITE 1923 void moveAndZero(clpTempInfo * info,int type,void *extra);2096 void moveAndZero(clpTempInfo *info, int type, void *extra); 1924 2097 // 2 is owner of abcState_ 1925 2098 #ifdef ABCSTATE_LITE 1926 #if ABCSTATE_LITE ==21927 int abcState_ =0;2099 #if ABCSTATE_LITE == 2 2100 int abcState_ = 0; 1928 2101 #else 1929 2102 extern int abcState_; 1930 2103 #endif 1931 inline int abcState() 1932 { return abcState_;} 1933 inline void setAbcState(int state) 1934 { abcState_=state;} 2104 inline int abcState() 2105 { 2106 return abcState_; 2107 } 2108 inline void setAbcState(int state) 2109 { 2110 abcState_ = state; 2111 } 1935 2112 #endif 1936 2113 #else … … 1956 2133 #endif 1957 2134 #endif 2135 2136 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 2137 */
Note: See TracChangeset
for help on using the changeset viewer.