Changeset 2386 for trunk/Clp/src/OsiClp/OsiClpSolverInterface.hpp
 Timestamp:
 Jan 6, 2019 6:03:50 PM (2 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/OsiClp/OsiClpSolverInterface.hpp
r2332 r2386 3 3 // Corporation and others. All Rights Reserved. 4 4 // This code is licensed under the terms of the Eclipse Public License (EPL). 5 6 5 7 6 #ifndef OsiClpSolverInterface_H … … 36 35 */ 37 36 38 class OsiClpSolverInterface : 39 virtual public OsiSolverInterface { 40 friend void OsiClpSolverInterfaceUnitTest(const std::string & mpsDir, const std::string & netlibDir); 41 37 class OsiClpSolverInterface : virtual public OsiSolverInterface { 38 friend void OsiClpSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir); 39 42 40 public: 43 41 // 44 42 /**@name Solve methods */ 45 43 //@{ 46 /// Solve initial LP relaxation 44 /// Solve initial LP relaxation 47 45 virtual void initialSolve(); 48 46 49 47 /// Resolve an LP relaxation after problem modification 50 48 virtual void resolve(); 51 49 52 50 /// Resolve an LP relaxation after problem modification (try GUB) 53 51 virtual void resolveGub(int needed); 54 52 55 53 /// Invoke solver's builtin enumeration algorithm 56 54 virtual void branchAndBound(); … … 63 61 1 try and put some in basis 64 62 */ 65 void crossover(int options, int basis);66 //@} 67 63 void crossover(int options, int basis); 64 //@} 65 68 66 /*! @name OsiSimplexInterface methods 69 67 \brief Methods for the Osi Simplex API. … … 95 93 /*! \brief Undo any setting changes made by #enableFactorization */ 96 94 virtual void disableFactorization() const; 97 95 98 96 /** Returns true if a basis is available 99 97 AND problem is optimal. This should be used to see if … … 101 99 */ 102 100 virtual bool basisIsAvailable() const; 103 101 104 102 /** The following two methods may be replaced by the 105 103 methods of OsiSolverInterface using OsiWarmStartBasis if: … … 117 115 in terms of row activities 118 116 */ 119 virtual void getBasisStatus(int * cstat, int*rstat) const;120 117 virtual void getBasisStatus(int *cstat, int *rstat) const; 118 121 119 /** Set the status of structural/artificial variables and 122 120 factorize, update solution etc … … 129 127 Returns 0 if OK, 1 if problem is bad e.g. duplicate elements, too large ... 130 128 */ 131 virtual int setBasisStatus(const int * cstat, const int*rstat);132 133 ///Get the reduced gradient for the cost vector c 134 virtual void getReducedGradient(double * columnReducedCosts,135 double *duals,136 const double * c) const;137 129 virtual int setBasisStatus(const int *cstat, const int *rstat); 130 131 ///Get the reduced gradient for the cost vector c 132 virtual void getReducedGradient(double *columnReducedCosts, 133 double *duals, 134 const double *c) const; 135 138 136 ///Get a row of the tableau (slack part in slack if not NULL) 139 virtual void getBInvARow(int row, double * z, double * slack=NULL) const;140 137 virtual void getBInvARow(int row, double *z, double *slack = NULL) const; 138 141 139 /** Get a row of the tableau (slack part in slack if not NULL) 142 140 If keepScaled is true then scale factors not applied after so 143 141 user has to use coding similar to what is in this method 144 142 */ 145 virtual void getBInvARow(int row, CoinIndexedVector * z, CoinIndexedVector * slack=NULL,146 bool keepScaled=false) const;147 143 virtual void getBInvARow(int row, CoinIndexedVector *z, CoinIndexedVector *slack = NULL, 144 bool keepScaled = false) const; 145 148 146 ///Get a row of the basis inverse 149 virtual void getBInvRow(int row, double *z) const;150 147 virtual void getBInvRow(int row, double *z) const; 148 151 149 ///Get a column of the tableau 152 virtual void getBInvACol(int col, double * vec) const;153 150 virtual void getBInvACol(int col, double *vec) const; 151 154 152 ///Get a column of the tableau 155 virtual void getBInvACol(int col, CoinIndexedVector * vec) const;156 153 virtual void getBInvACol(int col, CoinIndexedVector *vec) const; 154 157 155 /** Update (i.e. ftran) the vector passed in. 158 156 Unscaling is applied after  can't be applied before 159 157 */ 160 161 virtual void getBInvACol(CoinIndexedVector * vec) const;162 158 159 virtual void getBInvACol(CoinIndexedVector *vec) const; 160 163 161 ///Get a column of the basis inverse 164 virtual void getBInvCol(int col, double * vec) const;165 162 virtual void getBInvCol(int col, double *vec) const; 163 166 164 /** Get basic indices (order of indices corresponds to the 167 165 order of elements in a vector retured by getBInvACol() and 168 166 getBInvCol()). 169 167 */ 170 virtual void getBasics(int *index) const;168 virtual void getBasics(int *index) const; 171 169 172 170 /*! \brief Enables simplex mode 2 (individual pivot control) … … 178 176 virtual void enableSimplexInterface(bool doingPrimal); 179 177 /// Copy across enabled stuff from one solver to another 180 void copyEnabledSuff(OsiClpSolverInterface & 181 178 void copyEnabledSuff(OsiClpSolverInterface &rhs); 179 182 180 /*! \brief Undo setting changes made by #enableSimplexInterface */ 183 181 virtual void disableSimplexInterface(); 184 182 /// Copy across enabled stuff from one solver to another 185 void copyEnabledStuff(ClpSimplex & 183 void copyEnabledStuff(ClpSimplex &rhs); 186 184 187 185 /** Perform a pivot by substituting a colIn for colOut in the basis. … … 193 191 */ 194 192 virtual int pivot(int colIn, int colOut, int outStatus); 195 193 196 194 /** Obtain a result of the primal pivot 197 195 Outputs: colOut  leaving column, outStatus  its status, … … 205 203 Primal and dual solutions are updated 206 204 */ 207 virtual int primalPivotResult(int colIn, int sign, 208 int& colOut, int& outStatus, 209 double& t, CoinPackedVector*dx);210 205 virtual int primalPivotResult(int colIn, int sign, 206 int &colOut, int &outStatus, 207 double &t, CoinPackedVector *dx); 208 211 209 /** Obtain a result of the dual pivot (similar to the previous method) 212 210 Differences: entering variable and a sign of its change are now … … 215 213 Return code: same 216 214 */ 217 virtual int dualPivotResult(int& colIn, int& sign, 218 int colOut, int outStatus, 219 double& t, CoinPackedVector* dx); 220 221 215 virtual int dualPivotResult(int &colIn, int &sign, 216 int colOut, int outStatus, 217 double &t, CoinPackedVector *dx); 218 222 219 //@} 223 220 // … … 242 239 bool setDblParam(OsiDblParam key, double value); 243 240 // Set a string parameter 244 bool setStrParam(OsiStrParam key, const std::string & 241 bool setStrParam(OsiStrParam key, const std::string &value); 245 242 // Get an integer parameter 246 bool getIntParam(OsiIntParam key, int &value) const;243 bool getIntParam(OsiIntParam key, int &value) const; 247 244 // Get an double parameter 248 bool getDblParam(OsiDblParam key, double &value) const;245 bool getDblParam(OsiDblParam key, double &value) const; 249 246 // Get a string parameter 250 bool getStrParam(OsiStrParam key, std::string &value) const;247 bool getStrParam(OsiStrParam key, std::string &value) const; 251 248 // Set a hint parameter  overrides OsiSolverInterface 252 virtual bool setHintParam(OsiHintParam key, bool yesNo =true,253 OsiHintStrength strength=OsiHintTry,254 void * otherInformation=NULL);255 //@} 256 249 virtual bool setHintParam(OsiHintParam key, bool yesNo = true, 250 OsiHintStrength strength = OsiHintTry, 251 void *otherInformation = NULL); 252 //@} 253 257 254 // 258 255 ///@name Methods returning info on how the solution process terminated … … 273 270 virtual bool isIterationLimitReached() const; 274 271 //@} 275 272 276 273 // 277 274 /**@name WarmStart related methods */ 278 275 //@{ 279 276 280 277 /*! \brief Get an empty warm start object 281 278 … … 284 281 appropriate type, which can resized and modified as desired. 285 282 */ 286 287 virtual CoinWarmStart *getEmptyWarmStart 288 283 284 virtual CoinWarmStart *getEmptyWarmStart() const; 285 289 286 /// Get warmstarting information 290 virtual CoinWarmStart *getWarmStart() const;287 virtual CoinWarmStart *getWarmStart() const; 291 288 /// Get warmstarting information 292 inline CoinWarmStartBasis* getPointerToWarmStart() 293 { return &basis_;} 289 inline CoinWarmStartBasis *getPointerToWarmStart() 290 { 291 return &basis_; 292 } 294 293 /// Get warmstarting information 295 inline const CoinWarmStartBasis* getConstPointerToWarmStart() const 296 { return &basis_;} 294 inline const CoinWarmStartBasis *getConstPointerToWarmStart() const 295 { 296 return &basis_; 297 } 297 298 /** Set warmstarting information. Return true/false depending on whether 298 299 the warmstart information was accepted or not. */ 299 virtual bool setWarmStart(const CoinWarmStart *warmstart);300 virtual bool setWarmStart(const CoinWarmStart *warmstart); 300 301 /** \brief Get warm start information. 301 302 … … 307 308 OsiClp version always returns pointer and false. 308 309 */ 309 virtual CoinWarmStart * getPointerToWarmStart(bool & mustDelete);310 virtual CoinWarmStart *getPointerToWarmStart(bool &mustDelete); 310 311 311 312 /// Set column status in ClpSimplex and warmStart … … 313 314 314 315 //@} 315 316 316 317 // 317 318 /**@name Hotstart related methods (primarily used in strong branching). … … 339 340 void stopFastDual(); 340 341 /// Sets integer tolerance and increment 341 void setStuff(double tolerance, double increment);342 void setStuff(double tolerance, double increment); 342 343 /// Return a conflict analysis cut from small model 343 OsiRowCut * smallModelCut(const double * originalLower, const double *originalUpper,344 int numberRowsAtContinuous,const int *whichGenerator,345 int typeCut=0);344 OsiRowCut *smallModelCut(const double *originalLower, const double *originalUpper, 345 int numberRowsAtContinuous, const int *whichGenerator, 346 int typeCut = 0); 346 347 /** Return a conflict analysis cut from model 347 348 If type is 0 then genuine cut, if 1 then only partially processed 348 349 */ 349 OsiRowCut * modelCut(const double * originalLower, const double *originalUpper,350 int numberRowsAtContinuous,const int *whichGenerator,351 int typeCut=0);352 //@} 353 350 OsiRowCut *modelCut(const double *originalLower, const double *originalUpper, 351 int numberRowsAtContinuous, const int *whichGenerator, 352 int typeCut = 0); 353 //@} 354 354 355 // 355 356 /**@name Problem information methods … … 368 369 //@{ 369 370 /// Get number of columns 370 virtual int getNumCols() const { 371 return modelPtr_>numberColumns(); } 372 371 virtual int getNumCols() const 372 { 373 return modelPtr_>numberColumns(); 374 } 375 373 376 /// Get number of rows 374 virtual int getNumRows() const { 375 return modelPtr_>numberRows(); } 376 377 virtual int getNumRows() const 378 { 379 return modelPtr_>numberRows(); 380 } 381 377 382 /// Get number of nonzero elements 378 virtual CoinBigIndex getNumElements() const { 383 virtual CoinBigIndex getNumElements() const 384 { 379 385 CoinBigIndex retVal = 0; 380 const CoinPackedMatrix * matrix =modelPtr_>matrix(); 381 if ( matrix != NULL ) retVal=matrix>getNumElements(); 382 return retVal; } 383 384 /// Return name of row if one exists or Rnnnnnnn 385 /// maxLen is currently ignored and only there to match the signature from the base class! 386 virtual std::string getRowName(int rowIndex, 387 unsigned maxLen = static_cast<unsigned>(std::string::npos)) const; 388 389 /// Return name of column if one exists or Cnnnnnnn 390 /// maxLen is currently ignored and only there to match the signature from the base class! 391 virtual std::string getColName(int colIndex, 392 unsigned maxLen = static_cast<unsigned>(std::string::npos)) const; 393 394 386 const CoinPackedMatrix *matrix = modelPtr_>matrix(); 387 if (matrix != NULL) 388 retVal = matrix>getNumElements(); 389 return retVal; 390 } 391 392 /// Return name of row if one exists or Rnnnnnnn 393 /// maxLen is currently ignored and only there to match the signature from the base class! 394 virtual std::string getRowName(int rowIndex, 395 unsigned maxLen = static_cast< unsigned >(std::string::npos)) const; 396 397 /// Return name of column if one exists or Cnnnnnnn 398 /// maxLen is currently ignored and only there to match the signature from the base class! 399 virtual std::string getColName(int colIndex, 400 unsigned maxLen = static_cast< unsigned >(std::string::npos)) const; 401 395 402 /// Get pointer to array[getNumCols()] of column lower bounds 396 virtual const double * 397 403 virtual const double *getColLower() const { return modelPtr_>columnLower(); } 404 398 405 /// Get pointer to array[getNumCols()] of column upper bounds 399 virtual const double * 400 406 virtual const double *getColUpper() const { return modelPtr_>columnUpper(); } 407 401 408 /** Get pointer to array[getNumRows()] of row constraint senses. 402 409 <ul> … … 408 415 </ul> 409 416 */ 410 virtual const char * 411 417 virtual const char *getRowSense() const; 418 412 419 /** Get pointer to array[getNumRows()] of rows righthand sides 413 420 <ul> … … 418 425 </ul> 419 426 */ 420 virtual const double * getRightHandSide() const;421 427 virtual const double *getRightHandSide() const; 428 422 429 /** Get pointer to array[getNumRows()] of row ranges. 423 430 <ul> … … 428 435 </ul> 429 436 */ 430 virtual const double * getRowRange() const;431 437 virtual const double *getRowRange() const; 438 432 439 /// Get pointer to array[getNumRows()] of row lower bounds 433 virtual const double * 434 440 virtual const double *getRowLower() const { return modelPtr_>rowLower(); } 441 435 442 /// Get pointer to array[getNumRows()] of row upper bounds 436 virtual const double * 437 443 virtual const double *getRowUpper() const { return modelPtr_>rowUpper(); } 444 438 445 /// Get pointer to array[getNumCols()] of objective function coefficients 439 virtual const double * getObjCoefficients() const 440 { if (fakeMinInSimplex_) 441 return linearObjective_ ; 446 virtual const double *getObjCoefficients() const 447 { 448 if (fakeMinInSimplex_) 449 return linearObjective_; 442 450 else 443 return modelPtr_>objective(); } 444 451 return modelPtr_>objective(); 452 } 453 445 454 /// Get objective function sense (1 for min (default), 1 for max) 446 virtual double getObjSense() const 447 { return ((fakeMinInSimplex_)?modelPtr_>optimizationDirection(): 448 modelPtr_>optimizationDirection()); } 449 455 virtual double getObjSense() const 456 { 457 return ((fakeMinInSimplex_) ? modelPtr_>optimizationDirection() : modelPtr_>optimizationDirection()); 458 } 459 450 460 /// Return true if column is continuous 451 461 virtual bool isContinuous(int colNumber) const; 452 462 /// Return true if variable is binary 453 463 virtual bool isBinary(int colIndex) const; 454 464 455 465 /** Return true if column is integer. 456 466 Note: This function returns true if the the column … … 458 468 */ 459 469 virtual bool isInteger(int colIndex) const; 460 470 461 471 /// Return true if variable is general integer 462 472 virtual bool isIntegerNonBinary(int colIndex) const; 463 473 464 474 /// Return true if variable is binary and not fixed at either bound 465 virtual bool isFreeBinary(int colIndex) const; 475 virtual bool isFreeBinary(int colIndex) const; 466 476 /** Return array of column length 467 477 0  continuous … … 469 479 2  general integer (may get fixed later) 470 480 */ 471 virtual const char * getColType(bool refresh=false) const;472 481 virtual const char *getColType(bool refresh = false) const; 482 473 483 /** Return true if column is integer but does not have to 474 484 be declared as such. … … 481 491 /// Return true only if integer and not optional 482 492 inline bool isHeuristicInteger(int colIndex) const 483 { return ( integerInformation_&& integerInformation_[colIndex]==1 );} 493 { 494 return (integerInformation_ && integerInformation_[colIndex] == 1); 495 } 484 496 /// Return integer type (0,1,2=optional,3=sc,4=scint) 485 497 inline int integerType(int colIndex) const 486 { return integerInformation_ ? integerInformation_[colIndex] : 0;} 498 { 499 return integerInformation_ ? integerInformation_[colIndex] : 0; 500 } 487 501 /// Set integer type (0,1,2=optional,3=sc,4=scint) 488 inline void setIntegerType(int colIndex,int value) 489 { integerInformation_[colIndex] = static_cast<char>(value);} 502 inline void setIntegerType(int colIndex, int value) 503 { 504 integerInformation_[colIndex] = static_cast< char >(value); 505 } 490 506 /// Get pointer to rowwise copy of matrix 491 virtual const CoinPackedMatrix * 492 507 virtual const CoinPackedMatrix *getMatrixByRow() const; 508 493 509 /// Get pointer to columnwise copy of matrix 494 virtual const CoinPackedMatrix * 495 510 virtual const CoinPackedMatrix *getMatrixByCol() const; 511 496 512 /// Get pointer to mutable columnwise copy of matrix 497 virtual CoinPackedMatrix * 498 499 513 virtual CoinPackedMatrix *getMutableMatrixByCol() const; 514 515 /// Get solver's value for infinity 500 516 virtual double getInfinity() const { return OsiClpInfinity; } 501 517 //@} 502 518 503 519 /**@name Methods related to querying the solution */ 504 520 //@{ 505 521 /// Get pointer to array[getNumCols()] of primal solution vector 506 virtual const double * getColSolution() const;507 522 virtual const double *getColSolution() const; 523 508 524 /// Get pointer to array[getNumRows()] of dual prices 509 virtual const double * 510 525 virtual const double *getRowPrice() const; 526 511 527 /// Get a pointer to array[getNumCols()] of reduced costs 512 virtual const double * getReducedCost() const;513 528 virtual const double *getReducedCost() const; 529 514 530 /** Get pointer to array[getNumRows()] of row activity levels (constraint 515 531 matrix times the solution vector */ 516 virtual const double * getRowActivity() const;517 532 virtual const double *getRowActivity() const; 533 518 534 /// Get objective function value 519 535 virtual double getObjValue() const; 520 536 521 537 /** Get how many iterations it took to solve the problem (whatever 522 538 "iteration" mean to the solver. */ 523 virtual int getIterationCount() const 524 { return modelPtr_>numberIterations(); } 525 539 virtual int getIterationCount() const 540 { 541 return modelPtr_>numberIterations(); 542 } 543 526 544 /** Get as many dual rays as the solver can provide. (In case of proven 527 545 primal infeasibility there should be at least one.) … … 541 559 vector using delete[]. 542 560 */ 543 virtual std::vector< double*> getDualRays(int maxNumRays,544 561 virtual std::vector< double * > getDualRays(int maxNumRays, 562 bool fullRay = false) const; 545 563 /** Get as many primal rays as the solver can provide. (In case of proven 546 564 dual infeasibility there should be at least one.) … … 554 572 vector using delete[]. 555 573 */ 556 virtual std::vector< double*> getPrimalRays(int maxNumRays) const;557 558 //@} 559 //@} 560 574 virtual std::vector< double * > getPrimalRays(int maxNumRays) const; 575 576 //@} 577 //@} 578 561 579 // 562 580 563 581 /**@name Problem modifying methods */ 564 582 //@{ … … 567 585 //@{ 568 586 /** Set an objective function coefficient */ 569 virtual void setObjCoeff( int elementIndex, double elementValue);570 587 virtual void setObjCoeff(int elementIndex, double elementValue); 588 571 589 /** Set a single column lower bound<br> 572 590 Use DBL_MAX for infinity. */ 573 virtual void setColLower( int elementIndex, double elementValue);574 591 virtual void setColLower(int elementIndex, double elementValue); 592 575 593 /** Set a single column upper bound<br> 576 594 Use DBL_MAX for infinity. */ 577 virtual void setColUpper( int elementIndex, double elementValue);578 595 virtual void setColUpper(int elementIndex, double elementValue); 596 579 597 /** Set a single column lower and upper bound */ 580 virtual void setColBounds( 581 double lower, double upper);582 598 virtual void setColBounds(int elementIndex, 599 double lower, double upper); 600 583 601 /** Set the bounds on a number of columns simultaneously<br> 584 602 The default implementation just invokes setColLower() and … … 589 607 @param boundList the new lower/upper bound pairs for the variables 590 608 */ 591 virtual void setColSetBounds(const int *indexFirst,592 const int*indexLast,593 const double*boundList);594 609 virtual void setColSetBounds(const int *indexFirst, 610 const int *indexLast, 611 const double *boundList); 612 595 613 /** Set a single row lower bound<br> 596 614 Use DBL_MAX for infinity. */ 597 virtual void setRowLower( int elementIndex, double elementValue);598 615 virtual void setRowLower(int elementIndex, double elementValue); 616 599 617 /** Set a single row upper bound<br> 600 618 Use DBL_MAX for infinity. */ 601 virtual void setRowUpper( int elementIndex, double elementValue );602 619 virtual void setRowUpper(int elementIndex, double elementValue); 620 603 621 /** Set a single row lower and upper bound */ 604 virtual void setRowBounds( 605 double lower, double upper );606 622 virtual void setRowBounds(int elementIndex, 623 double lower, double upper); 624 607 625 /** Set the type of a single row<br> */ 608 626 virtual void setRowType(int index, char sense, double rightHandSide, 609 610 627 double range); 628 611 629 /** Set the bounds on a number of rows simultaneously<br> 612 630 The default implementation just invokes setRowLower() and … … 617 635 @param boundList the new lower/upper bound pairs for the constraints 618 636 */ 619 virtual void setRowSetBounds(const int *indexFirst,620 const int*indexLast,621 const double*boundList);622 637 virtual void setRowSetBounds(const int *indexFirst, 638 const int *indexLast, 639 const double *boundList); 640 623 641 /** Set the type of a number of rows simultaneously<br> 624 642 The default implementation just invokes setRowType() … … 631 649 @param rangeList the new ranges 632 650 */ 633 virtual void setRowSetTypes(const int *indexFirst,634 const int*indexLast,635 const char*senseList,636 const double*rhsList,637 const double*rangeList);638 651 virtual void setRowSetTypes(const int *indexFirst, 652 const int *indexLast, 653 const char *senseList, 654 const double *rhsList, 655 const double *rangeList); 656 /** Set the objective coefficients for all columns 639 657 array [getNumCols()] is an array of values for the objective. 640 658 This defaults to a series of set operations and is here for speed. 641 659 */ 642 virtual void setObjective(const double *array);643 644 660 virtual void setObjective(const double *array); 661 662 /** Set the lower bounds for all columns 645 663 array [getNumCols()] is an array of values for the objective. 646 664 This defaults to a series of set operations and is here for speed. 647 665 */ 648 virtual void setColLower(const double *array);649 650 666 virtual void setColLower(const double *array); 667 668 /** Set the upper bounds for all columns 651 669 array [getNumCols()] is an array of values for the objective. 652 670 This defaults to a series of set operations and is here for speed. 653 671 */ 654 virtual void setColUpper(const double *array);655 656 // using OsiSolverInterface::setRowName ;657 658 // virtual void setRowName(int rowIndex, std::string & name) ;659 virtual void setRowName(int rowIndex, std::string name);660 661 // using OsiSolverInterface::setColName ;662 663 // virtual void setColName(int colIndex, std::string & name) ;664 virtual void setColName(int colIndex, std::string name);665 666 //@} 667 672 virtual void setColUpper(const double *array); 673 674 // using OsiSolverInterface::setRowName ; 675 /// Set name of row 676 // virtual void setRowName(int rowIndex, std::string & name) ; 677 virtual void setRowName(int rowIndex, std::string name); 678 679 // using OsiSolverInterface::setColName ; 680 /// Set name of column 681 // virtual void setColName(int colIndex, std::string & name) ; 682 virtual void setColName(int colIndex, std::string name); 683 684 //@} 685 668 686 // 669 687 /**@name Integrality related changing methods */ … … 675 693 /** Set the variables listed in indices (which is of length len) to be 676 694 continuous variables */ 677 virtual void setContinuous(const int *indices, int len);695 virtual void setContinuous(const int *indices, int len); 678 696 /** Set the variables listed in indices (which is of length len) to be 679 697 integer variables */ 680 virtual void setInteger(const int *indices, int len);698 virtual void setInteger(const int *indices, int len); 681 699 /// Number of SOS sets 682 700 inline int numberSOS() const 683 { return numberSOS_;} 701 { 702 return numberSOS_; 703 } 684 704 /// SOS set info 685 inline const CoinSet * setInfo() const 686 { return setInfo_;} 705 inline const CoinSet *setInfo() const 706 { 707 return setInfo_; 708 } 687 709 /// Replace setInfo (takes over ownership) 688 void replaceSetInfo(int numberSOS, CoinSet *setInfo);710 void replaceSetInfo(int numberSOS, CoinSet *setInfo); 689 711 /** \brief Identify integer variables and SOS and create corresponding objects. 690 712 … … 698 720 virtual int findIntegersAndSOS(bool justCount); 699 721 //@} 700 722 701 723 // 702 724 /// Set objective function sense (1 for min (default), 1 for max,) 703 virtual void setObjSense(double s ) 704 { modelPtr_>setOptimizationDirection( s < 0 ? 1 : 1); } 705 725 virtual void setObjSense(double s) 726 { 727 modelPtr_>setOptimizationDirection(s < 0 ? 1 : 1); 728 } 729 706 730 /** Set the primal solution column values 707 731 … … 714 738 solverdependent. 715 739 */ 716 virtual void setColSolution(const double * 717 740 virtual void setColSolution(const double *colsol); 741 718 742 /** Set dual solution vector 719 743 … … 726 750 solverdependent. 727 751 */ 728 virtual void setRowPrice(const double * 729 752 virtual void setRowPrice(const double *rowprice); 753 730 754 // 731 755 /**@name Methods to expand a problem.<br> … … 736 760 //using OsiSolverInterface::addCol ; 737 761 /** */ 738 virtual void addCol(const CoinPackedVectorBase &vec,739 const double collb, const double colub,740 762 virtual void addCol(const CoinPackedVectorBase &vec, 763 const double collb, const double colub, 764 const double obj); 741 765 /*! \brief Add a named column (primal variable) to the problem. 742 766 */ 743 virtual void addCol(const CoinPackedVectorBase &vec,744 const double collb, const double colub, 745 const double obj, std::string name);767 virtual void addCol(const CoinPackedVectorBase &vec, 768 const double collb, const double colub, 769 const double obj, std::string name); 746 770 /** Add a column (primal variable) to the problem. */ 747 virtual void addCol(int numberElements, const int * rows, const double *elements,748 const double collb, const double colub,749 const double obj);771 virtual void addCol(int numberElements, const int *rows, const double *elements, 772 const double collb, const double colub, 773 const double obj); 750 774 /*! \brief Add a named column (primal variable) to the problem. 751 775 */ 752 776 virtual void addCol(int numberElements, 753 const int* rows, const double*elements,754 const double collb, const double colub, 755 const double obj, std::string name);777 const int *rows, const double *elements, 778 const double collb, const double colub, 779 const double obj, std::string name); 756 780 /** */ 757 781 virtual void addCols(const int numcols, 758 const CoinPackedVectorBase * const *cols,759 const double* collb, const double* colub,760 const double*obj);782 const CoinPackedVectorBase *const *cols, 783 const double *collb, const double *colub, 784 const double *obj); 761 785 /** */ 762 786 virtual void addCols(const int numcols, 763 const CoinBigIndex * columnStarts, const int * rows, const double *elements,764 const double* collb, const double* colub, 765 const double*obj);787 const CoinBigIndex *columnStarts, const int *rows, const double *elements, 788 const double *collb, const double *colub, 789 const double *obj); 766 790 /** */ 767 virtual void deleteCols(const int num, const int * 768 791 virtual void deleteCols(const int num, const int *colIndices); 792 769 793 /** */ 770 virtual void addRow(const CoinPackedVectorBase &vec,771 794 virtual void addRow(const CoinPackedVectorBase &vec, 795 const double rowlb, const double rowub); 772 796 /** */ 773 797 /*! \brief Add a named row (constraint) to the problem. 774 798 775 799 The default implementation adds the row, then changes the name. This 776 800 can surely be made more efficient within an OsiXXX class. 777 801 */ 778 virtual void addRow(const CoinPackedVectorBase&vec,779 780 std::string name);781 virtual void addRow(const CoinPackedVectorBase &vec,782 const char rowsen, const double rowrhs,783 802 virtual void addRow(const CoinPackedVectorBase &vec, 803 const double rowlb, const double rowub, 804 std::string name); 805 virtual void addRow(const CoinPackedVectorBase &vec, 806 const char rowsen, const double rowrhs, 807 const double rowrng); 784 808 /** Add a row (constraint) to the problem. */ 785 virtual void addRow(int numberElements, const int * columns, const double *element,786 const double rowlb, const double rowub);787 809 virtual void addRow(int numberElements, const int *columns, const double *element, 810 const double rowlb, const double rowub); 811 /*! \brief Add a named row (constraint) to the problem. 788 812 */ 789 virtual void addRow(const CoinPackedVectorBase&vec,790 const char rowsen, const double rowrhs, 791 const double rowrng, std::string name);813 virtual void addRow(const CoinPackedVectorBase &vec, 814 const char rowsen, const double rowrhs, 815 const double rowrng, std::string name); 792 816 /** */ 793 817 virtual void addRows(const int numrows, 794 const CoinPackedVectorBase * const *rows,795 const double* rowlb, const double*rowub);818 const CoinPackedVectorBase *const *rows, 819 const double *rowlb, const double *rowub); 796 820 /** */ 797 821 virtual void addRows(const int numrows, 798 const CoinPackedVectorBase * const *rows,799 const char* rowsen, const double* rowrhs,800 const double*rowrng);822 const CoinPackedVectorBase *const *rows, 823 const char *rowsen, const double *rowrhs, 824 const double *rowrng); 801 825 802 826 /** */ 803 827 virtual void addRows(const int numrows, 804 const CoinBigIndex * rowStarts, const int * columns, const double *element,805 const double* rowlb, const double*rowub);828 const CoinBigIndex *rowStarts, const int *columns, const double *element, 829 const double *rowlb, const double *rowub); 806 830 /// 807 831 void modifyCoefficient(int row, int column, double newElement, 808 bool keepZero=false) 809 {modelPtr_>modifyCoefficient(row,column,newElement, keepZero);} 832 bool keepZero = false) 833 { 834 modelPtr_>modifyCoefficient(row, column, newElement, keepZero); 835 } 810 836 811 837 /** */ 812 virtual void deleteRows(const int num, const int * 838 virtual void deleteRows(const int num, const int *rowIndices); 813 839 /** If solver wants it can save a copy of "base" (continuous) model here 814 840 */ 815 virtual void saveBaseModel() 841 virtual void saveBaseModel(); 816 842 /** Strip off rows to get to this number of rows. 817 843 If solver wants it can restore a copy of "base" (continuous) model here 818 844 */ 819 845 virtual void restoreBaseModel(int numberRows); 820 846 821 847 // 822 848 /** Apply a collection of row cuts which are all effective. 823 849 applyCuts seems to do one at a time which seems inefficient. 824 850 */ 825 virtual void applyRowCuts(int numberCuts, const OsiRowCut * 851 virtual void applyRowCuts(int numberCuts, const OsiRowCut *cuts); 826 852 /** Apply a collection of row cuts which are all effective. 827 853 applyCuts seems to do one at a time which seems inefficient. 828 854 This uses array of pointers 829 855 */ 830 virtual void applyRowCuts(int numberCuts, const OsiRowCut ** 831 856 virtual void applyRowCuts(int numberCuts, const OsiRowCut **cuts); 857 /** Apply a collection of cuts. 832 858 833 859 Only cuts which have an <code>effectiveness >= effectivenessLb</code> … … 851 877 </ul> 852 878 */ 853 virtual ApplyCutsReturnCode applyCuts(const OsiCuts &cs,854 855 856 //@} 857 //@} 858 879 virtual ApplyCutsReturnCode applyCuts(const OsiCuts &cs, 880 double effectivenessLb = 0.0); 881 882 //@} 883 //@} 884 859 885 // 860 886 861 887 public: 862 863 888 /**@name Methods to input a problem */ 864 889 //@{ … … 874 899 </ul> 875 900 */ 876 virtual void loadProblem(const CoinPackedMatrix &matrix,877 const double* collb, const double* colub,878 const double*obj,879 const double* rowlb, const double*rowub);880 901 virtual void loadProblem(const CoinPackedMatrix &matrix, 902 const double *collb, const double *colub, 903 const double *obj, 904 const double *rowlb, const double *rowub); 905 881 906 /** Load in an problem by assuming ownership of the arguments (the 882 907 constraints on the rows are given by lower and upper bounds). For … … 886 911 functions. 887 912 */ 888 virtual void assignProblem(CoinPackedMatrix *&matrix,889 double*& collb, double*& colub, double*&obj,890 double*& rowlb, double*&rowub);891 913 virtual void assignProblem(CoinPackedMatrix *&matrix, 914 double *&collb, double *&colub, double *&obj, 915 double *&rowlb, double *&rowub); 916 892 917 /** Load in an problem by copying the arguments (the constraints on the 893 918 rows are given by sense/rhs/range triplets). If a pointer is NULL then the … … 902 927 </ul> 903 928 */ 904 virtual void loadProblem(const CoinPackedMatrix &matrix,905 const double* collb, const double*colub,906 const double*obj,907 const char* rowsen, const double* rowrhs,908 const double*rowrng);909 929 virtual void loadProblem(const CoinPackedMatrix &matrix, 930 const double *collb, const double *colub, 931 const double *obj, 932 const char *rowsen, const double *rowrhs, 933 const double *rowrng); 934 910 935 /** Load in an problem by assuming ownership of the arguments (the 911 936 constraints on the rows are given by sense/rhs/range triplets). For … … 915 940 functions. 916 941 */ 917 virtual void assignProblem(CoinPackedMatrix *&matrix,918 double*& collb, double*& colub, double*&obj,919 char*& rowsen, double*&rowrhs,920 double*&rowrng);921 942 virtual void assignProblem(CoinPackedMatrix *&matrix, 943 double *&collb, double *&colub, double *&obj, 944 char *&rowsen, double *&rowrhs, 945 double *&rowrng); 946 922 947 /** Just like the other loadProblem() methods except that the matrix is 923 948 given as a ClpMatrixBase. */ 924 virtual void loadProblem(const ClpMatrixBase &matrix,925 const double* collb, const double*colub,926 const double*obj,927 const double* rowlb, const double* rowub);949 virtual void loadProblem(const ClpMatrixBase &matrix, 950 const double *collb, const double *colub, 951 const double *obj, 952 const double *rowlb, const double *rowub); 928 953 929 954 /** Just like the other loadProblem() methods except that the matrix is 930 955 given in a standard column major ordered format (without gaps). */ 931 956 virtual void loadProblem(const int numcols, const int numrows, 932 const CoinBigIndex * start, const int*index,933 const double*value,934 const double* collb, const double* colub,935 const double*obj,936 const double* rowlb, const double*rowub);937 957 const CoinBigIndex *start, const int *index, 958 const double *value, 959 const double *collb, const double *colub, 960 const double *obj, 961 const double *rowlb, const double *rowub); 962 938 963 /** Just like the other loadProblem() methods except that the matrix is 939 964 given in a standard column major ordered format (without gaps). */ 940 965 virtual void loadProblem(const int numcols, const int numrows, 941 const CoinBigIndex * start, const int*index,942 const double*value,943 const double* collb, const double* colub,944 const double*obj,945 const char* rowsen, const double* rowrhs,946 const double*rowrng);966 const CoinBigIndex *start, const int *index, 967 const double *value, 968 const double *collb, const double *colub, 969 const double *obj, 970 const char *rowsen, const double *rowrhs, 971 const double *rowrng); 947 972 /// This loads a model from a coinModel object  returns number of errors 948 virtual int loadFromCoinModel ( CoinModel & modelObject, bool keepSolution=false);949 950 using OsiSolverInterface::readMps 973 virtual int loadFromCoinModel(CoinModel &modelObject, bool keepSolution = false); 974 975 using OsiSolverInterface::readMps; 951 976 /** Read an mps file from the given filename (defaults to Osi reader)  returns 952 977 number of errors (see OsiMpsReader class) */ 953 978 virtual int readMps(const char *filename, 954 const char *extension = "mps");979 const char *extension = "mps"); 955 980 /** Read an mps file from the given filename returns 956 981 number of errors (see OsiMpsReader class) */ 957 int readMps(const char *filename, bool keepNames,bool allowErrors);982 int readMps(const char *filename, bool keepNames, bool allowErrors); 958 983 /// Read an mps file 959 virtual int readMps (const char *filename, const char*extension,960 int & numberSets, CoinSet ** &sets);961 984 virtual int readMps(const char *filename, const char *extension, 985 int &numberSets, CoinSet **&sets); 986 962 987 /** Write the problem into an mps file of the given filename. 963 988 If objSense is non zero then 1.0 forces the code to write a … … 965 990 If 0.0 then solver can do what it wants */ 966 991 virtual void writeMps(const char *filename, 967 968 double objSense=0.0) const;992 const char *extension = "mps", 993 double objSense = 0.0) const; 969 994 /** Write the problem into an mps file of the given filename, 970 995 names may be null. formatType is … … 975 1000 Returns nonzero on I/O error 976 1001 */ 977 virtual int writeMpsNative(const char *filename, 978 const char ** rowNames, const char **columnNames,979 int formatType=0,int numberAcross=2,980 double objSense=0.0) const;1002 virtual int writeMpsNative(const char *filename, 1003 const char **rowNames, const char **columnNames, 1004 int formatType = 0, int numberAcross = 2, 1005 double objSense = 0.0) const; 981 1006 /// Read file in LP format (with names) 982 1007 virtual int readLp(const char *filename, const double epsilon = 1e5); … … 987 1012 This version calls writeLpNative with names */ 988 1013 virtual void writeLp(const char *filename, 989 990 991 992 993 994 1014 const char *extension = "lp", 1015 double epsilon = 1e5, 1016 int numberAcross = 10, 1017 int decimals = 5, 1018 double objSense = 0.0, 1019 bool useRowNames = true) const; 995 1020 /** Write the problem into the file pointed to by the parameter fp. 996 1021 Other parameters are similar to … … 998 1023 */ 999 1024 virtual void writeLp(FILE *fp, 1000 1001 1002 1003 1004 1025 double epsilon = 1e5, 1026 int numberAcross = 10, 1027 int decimals = 5, 1028 double objSense = 0.0, 1029 bool useRowNames = true) const; 1005 1030 /** 1006 1031 I (JJF) am getting annoyed because I can't just replace a matrix. … … 1008 1033 e.g. strengthening a matrix for MIP 1009 1034 */ 1010 virtual void replaceMatrixOptional(const CoinPackedMatrix & 1035 virtual void replaceMatrixOptional(const CoinPackedMatrix &matrix); 1011 1036 /// And if it does matter (not used at present) 1012 virtual void replaceMatrix(const CoinPackedMatrix & matrix);1013 //@} 1014 1037 virtual void replaceMatrix(const CoinPackedMatrix &matrix); 1038 //@} 1039 1015 1040 /**@name Message handling (extra for Clp messages). 1016 1041 Normally I presume you would want the same language. … … 1023 1048 destroyed. 1024 1049 */ 1025 virtual void passInMessageHandler(CoinMessageHandler * 1050 virtual void passInMessageHandler(CoinMessageHandler *handler); 1026 1051 /// Set language 1027 1052 void newLanguage(CoinMessages::Language language); 1028 1053 void setLanguage(CoinMessages::Language language) 1029 {newLanguage(language);} 1054 { 1055 newLanguage(language); 1056 } 1030 1057 /// Set log level (will also set underlying solver's log level) 1031 1058 void setLogLevel(int value); 1032 1059 /// Create C++ lines to get to current state 1033 void generateCpp( FILE *fp);1060 void generateCpp(FILE *fp); 1034 1061 //@} 1035 1062 // 1036 1063 1037 1064 /**@name Clp specific public interfaces */ 1038 1065 //@{ 1039 1066 /// Get pointer to Clp model 1040 ClpSimplex * getModelPtr() const;1067 ClpSimplex *getModelPtr() const; 1041 1068 /// Set pointer to Clp model and return old 1042 inline ClpSimplex * swapModelPtr(ClpSimplex * newModel) 1043 { ClpSimplex * model = modelPtr_; modelPtr_=newModel;return model;} 1069 inline ClpSimplex *swapModelPtr(ClpSimplex *newModel) 1070 { 1071 ClpSimplex *model = modelPtr_; 1072 modelPtr_ = newModel; 1073 return model; 1074 } 1044 1075 /// Get special options 1045 1076 inline unsigned int specialOptions() const 1046 { return specialOptions_;} 1077 { 1078 return specialOptions_; 1079 } 1047 1080 void setSpecialOptions(unsigned int value); 1048 1081 /// Last algorithm used , 1 = primal, 2 = dual other unknown 1049 1082 inline int lastAlgorithm() const 1050 { return lastAlgorithm_;} 1083 { 1084 return lastAlgorithm_; 1085 } 1051 1086 /// Set last algorithm used , 1 = primal, 2 = dual other unknown 1052 1087 inline void setLastAlgorithm(int value) 1053 { lastAlgorithm_ = value;} 1088 { 1089 lastAlgorithm_ = value; 1090 } 1054 1091 /// Get scaling action option 1055 1092 inline int cleanupScaling() const 1056 { return cleanupScaling_;} 1093 { 1094 return cleanupScaling_; 1095 } 1057 1096 /** Set Scaling option 1058 1097 When scaling is on it is possible that the scaled problem … … 1068 1107 */ 1069 1108 inline void setCleanupScaling(int value) 1070 { cleanupScaling_=value;} 1109 { 1110 cleanupScaling_ = value; 1111 } 1071 1112 /** Get smallest allowed element in cut. 1072 1113 If smaller than this then ignored */ 1073 1114 inline double smallestElementInCut() const 1074 { return smallestElementInCut_;} 1115 { 1116 return smallestElementInCut_; 1117 } 1075 1118 /** Set smallest allowed element in cut. 1076 1119 If smaller than this then ignored */ 1077 1120 inline void setSmallestElementInCut(double value) 1078 { smallestElementInCut_=value;} 1121 { 1122 smallestElementInCut_ = value; 1123 } 1079 1124 /** Get smallest change in cut. 1080 1125 If (upperlower)*element < this then element is … … 1084 1129 */ 1085 1130 inline double smallestChangeInCut() const 1086 { return smallestChangeInCut_;} 1131 { 1132 return smallestChangeInCut_; 1133 } 1087 1134 /** Set smallest change in cut. 1088 1135 If (upperlower)*element < this then element is … … 1092 1139 */ 1093 1140 inline void setSmallestChangeInCut(double value) 1094 { smallestChangeInCut_=value;} 1141 { 1142 smallestChangeInCut_ = value; 1143 } 1095 1144 /// Pass in initial solve options 1096 inline void setSolveOptions(const ClpSolve & options) 1097 { solveOptions_ = options;} 1145 inline void setSolveOptions(const ClpSolve &options) 1146 { 1147 solveOptions_ = options; 1148 } 1098 1149 /** Tighten bounds  lightweight or very lightweight 1099 1150 0  normal, 1 lightweight but just integers, 2 lightweight and all 1100 1151 */ 1101 virtual int tightenBounds(int lightweight =0);1152 virtual int tightenBounds(int lightweight = 0); 1102 1153 /// See if any integer variables make infeasible other way 1103 int infeasibleOtherWay(char * 1154 int infeasibleOtherWay(char *whichWay); 1104 1155 /// Return number of entries in L part of current factorization 1105 1156 virtual CoinBigIndex getSizeL() const; … … 1107 1158 virtual CoinBigIndex getSizeU() const; 1108 1159 /// Get disaster handler 1109 const OsiClpDisasterHandler * disasterHandler() const 1110 { return disasterHandler_;} 1160 const OsiClpDisasterHandler *disasterHandler() const 1161 { 1162 return disasterHandler_; 1163 } 1111 1164 /// Pass in disaster handler 1112 void passInDisasterHandler(OsiClpDisasterHandler * 1165 void passInDisasterHandler(OsiClpDisasterHandler *handler); 1113 1166 /// Get fake objective 1114 ClpLinearObjective * fakeObjective() const 1115 { return fakeObjective_;} 1167 ClpLinearObjective *fakeObjective() const 1168 { 1169 return fakeObjective_; 1170 } 1116 1171 /// Set fake objective (and take ownership) 1117 void setFakeObjective(ClpLinearObjective * 1172 void setFakeObjective(ClpLinearObjective *fakeObjective); 1118 1173 /// Set fake objective 1119 void setFakeObjective(double * 1174 void setFakeObjective(double *fakeObjective); 1120 1175 /*! \brief Set up solver for repeated use by Osi interface. 1121 1176 … … 1137 1192  1 leaves 1138 1193 */ 1139 void setupForRepeatedUse(int senseOfAdventure =0, int printOut=0);1194 void setupForRepeatedUse(int senseOfAdventure = 0, int printOut = 0); 1140 1195 /// Synchronize model (really if no cuts in tree) 1141 1196 virtual void synchronizeModel(); … … 1147 1202 1148 1203 //@} 1149 1204 1150 1205 // 1151 1206 1152 1207 /**@name Constructors and destructors */ 1153 1208 //@{ 1154 1209 /// Default Constructor 1155 OsiClpSolverInterface 1156 1210 OsiClpSolverInterface(); 1211 1157 1212 /// Clone 1158 virtual OsiSolverInterface * 1159 1160 /// Copy constructor 1161 OsiClpSolverInterface 1162 1213 virtual OsiSolverInterface *clone(bool copyData = true) const; 1214 1215 /// Copy constructor 1216 OsiClpSolverInterface(const OsiClpSolverInterface &); 1217 1163 1218 /// Borrow constructor  only delete one copy 1164 OsiClpSolverInterface (ClpSimplex * rhs, bool reallyOwn=false);1165 1219 OsiClpSolverInterface(ClpSimplex *rhs, bool reallyOwn = false); 1220 1166 1221 /// Releases so won't error 1167 1222 void releaseClp(); 1168 1169 /// Assignment operator 1170 OsiClpSolverInterface & operator=(const OsiClpSolverInterface&rhs);1171 1172 /// Destructor 1173 virtual ~OsiClpSolverInterface 1174 1223 1224 /// Assignment operator 1225 OsiClpSolverInterface &operator=(const OsiClpSolverInterface &rhs); 1226 1227 /// Destructor 1228 virtual ~OsiClpSolverInterface(); 1229 1175 1230 /// Resets as if default constructor 1176 1231 virtual void reset(); 1177 1232 //@} 1178 1233 1179 1234 // 1180 1235 1181 1236 protected: 1182 1237 ///@name Protected methods 1183 1238 //@{ 1184 1239 /** Apply a row cut (append to constraint matrix). */ 1185 virtual void applyRowCut(const OsiRowCut &rc);1186 1240 virtual void applyRowCut(const OsiRowCut &rc); 1241 1187 1242 /** Apply a column cut (adjust one or more bounds). */ 1188 virtual void applyColCut(const OsiColCut &cc);1189 //@} 1190 1243 virtual void applyColCut(const OsiColCut &cc); 1244 //@} 1245 1191 1246 // 1192 1247 1193 1248 protected: 1194 1249 /**@name Protected methods */ … … 1196 1251 /// The real work of a copy constructor (used by copy and assignment) 1197 1252 void gutsOfDestructor(); 1198 1253 1199 1254 /// Deletes all mutable stuff 1200 1255 void freeCachedResults() const; 1201 1256 1202 1257 /// Deletes all mutable stuff for row ranges etc 1203 1258 void freeCachedResults0() const; 1204 1259 1205 1260 /// Deletes all mutable stuff for matrix etc 1206 1261 void freeCachedResults1() const; 1207 1262 1208 1263 /// A method that fills up the rowsense_, rhs_ and rowrange_ arrays 1209 1264 void extractSenseRhsRange() const; 1210 1265 1211 1266 /// 1212 1267 void fillParamMaps(); … … 1219 1274 in terms of row activities 1220 1275 */ 1221 CoinWarmStartBasis getBasis(ClpSimplex * 1276 CoinWarmStartBasis getBasis(ClpSimplex *model) const; 1222 1277 /** Sets up working basis as a copy of input 1223 1278 … … 1228 1283 in terms of row activities 1229 1284 */ 1230 void setBasis( const CoinWarmStartBasis & basis, ClpSimplex *model);1285 void setBasis(const CoinWarmStartBasis &basis, ClpSimplex *model); 1231 1286 /// Crunch down problem a bit 1232 1287 void crunch(); 1233 1288 /// Extend scale factors 1234 void redoScaleFactors(int numberRows,const CoinBigIndex * starts, 1235 const int * indices, const double * elements); 1289 void redoScaleFactors(int numberRows, const CoinBigIndex *starts, 1290 const int *indices, const double *elements); 1291 1236 1292 public: 1237 1293 /** Sets up working basis as a copy of input and puts in as basis 1238 1294 */ 1239 void setBasis( const CoinWarmStartBasis &basis);1295 void setBasis(const CoinWarmStartBasis &basis); 1240 1296 /// Just puts current basis_ into ClpSimplex model 1241 inline void setBasis( ) 1242 { setBasis(basis_,modelPtr_);} 1297 inline void setBasis() 1298 { 1299 setBasis(basis_, modelPtr_); 1300 } 1243 1301 /// Warm start difference from basis_ to statusArray 1244 CoinWarmStartDiff * getBasisDiff(const unsigned char * statusArray) const;1302 CoinWarmStartDiff *getBasisDiff(const unsigned char *statusArray) const; 1245 1303 /// Warm start from statusArray 1246 CoinWarmStartBasis * getBasis(const unsigned char * statusArray) const;1304 CoinWarmStartBasis *getBasis(const unsigned char *statusArray) const; 1247 1305 /// Delete all scale factor stuff and reset option 1248 1306 void deleteScaleFactors(); 1249 1307 /// If doing fast hot start then ranges are computed 1250 inline const double * upRange() const 1251 { return rowActivity_;} 1252 inline const double * downRange() const 1253 { return columnActivity_;} 1308 inline const double *upRange() const 1309 { 1310 return rowActivity_; 1311 } 1312 inline const double *downRange() const 1313 { 1314 return columnActivity_; 1315 } 1254 1316 /// Pass in range array 1255 inline void passInRanges(int * array) 1256 { whichRange_=array;} 1317 inline void passInRanges(int *array) 1318 { 1319 whichRange_ = array; 1320 } 1257 1321 /// Pass in sos stuff from AMPl 1258 void setSOSData(int numberSOS, const char *type,1259 const int * start,const int * indices, const double * weights=NULL);1322 void setSOSData(int numberSOS, const char *type, 1323 const int *start, const int *indices, const double *weights = NULL); 1260 1324 /// Compute largest amount any at continuous away from bound 1261 1325 void computeLargestAway(); 1262 1326 /// Get largest amount continuous away from bound 1263 1327 inline double largestAway() const 1264 { return largestAway_;} 1328 { 1329 return largestAway_; 1330 } 1265 1331 /// Set largest amount continuous away from bound 1266 1332 inline void setLargestAway(double value) 1267 { largestAway_ = value;} 1333 { 1334 largestAway_ = value; 1335 } 1268 1336 /// Sort of lexicographic resolve 1269 1337 void lexSolve(); 1270 1338 /// Get continuous model 1271 inline ClpSimplex * getContinuousModel() const 1272 { return continuousModel_;} 1339 inline ClpSimplex *getContinuousModel() const 1340 { 1341 return continuousModel_; 1342 } 1273 1343 /// Set continuous model 1274 inline void setContinuousModel(ClpSimplex * model) 1275 { continuousModel_ = model;} 1276 //@} 1277 1344 inline void setContinuousModel(ClpSimplex *model) 1345 { 1346 continuousModel_ = model; 1347 } 1348 //@} 1349 1278 1350 protected: 1279 1351 /**@name Protected member data */ 1280 1352 //@{ 1281 1353 /// Clp model represented by this class instance 1282 mutable ClpSimplex * 1354 mutable ClpSimplex *modelPtr_; 1283 1355 //@} 1284 1356 /**@name Cached information derived from the OSL model */ 1285 1357 //@{ 1286 1358 /// Pointer to dense vector of row sense indicators 1287 mutable char 1288 1359 mutable char *rowsense_; 1360 1289 1361 /// Pointer to dense vector of row righthand side values 1290 mutable double 1291 1362 mutable double *rhs_; 1363 1292 1364 /** Pointer to dense vector of slack upper bounds for range 1293 1365 constraints (undefined for nonrange rows) 1294 1366 */ 1295 mutable double 1296 1367 mutable double *rowrange_; 1368 1297 1369 /** A pointer to the warmstart information to be used in the hotstarts. 1298 1370 This is NOT efficient and more thought should be given to it... */ 1299 mutable CoinWarmStartBasis *ws_;1371 mutable CoinWarmStartBasis *ws_; 1300 1372 /** also save row and column information for hot starts 1301 1373 only used in hotstarts so can be casual */ 1302 mutable double * 1303 mutable double * 1374 mutable double *rowActivity_; 1375 mutable double *columnActivity_; 1304 1376 /// Stuff for fast dual 1305 1377 ClpNodeStuff stuff_; … … 1307 1379 int numberSOS_; 1308 1380 /// SOS set info 1309 CoinSet * 1381 CoinSet *setInfo_; 1310 1382 /// Alternate model (hot starts)  but also could be permanent and used for crunch 1311 ClpSimplex * 1383 ClpSimplex *smallModel_; 1312 1384 /// factorization for hot starts 1313 ClpFactorization * 1385 ClpFactorization *factorization_; 1314 1386 /** Smallest allowed element in cut. 1315 1387 If smaller than this then ignored */ … … 1322 1394 double largestAway_; 1323 1395 /// Arrays for hot starts 1324 char * 1396 char *spareArrays_; 1325 1397 /** Warmstart information to be used in resolves. */ 1326 1398 CoinWarmStartBasis basis_; 1327 1399 /** The original iteration limit before hotstarts started. */ 1328 1400 int itlimOrig_; 1329 1401 1330 1402 /*! \brief Last algorithm used 1331 1403 … … 1339 1411 */ 1340 1412 mutable int lastAlgorithm_; 1341 1413 1342 1414 /// To say if destructor should delete underlying model 1343 1415 bool notOwned_; 1344 1416 1345 1417 /// Pointer to rowwise copy of problem matrix coefficients. 1346 mutable CoinPackedMatrix *matrixByRow_; 1347 1418 mutable CoinPackedMatrix *matrixByRow_; 1419 1348 1420 /// Pointer to rowwise copy of continuous problem matrix coefficients. 1349 CoinPackedMatrix *matrixByRowAtContinuous_; 1350 1421 CoinPackedMatrix *matrixByRowAtContinuous_; 1422 1351 1423 /// Pointer to integer information 1352 char * 1353 1424 char *integerInformation_; 1425 1354 1426 /** Pointer to variables for which we want range information 1355 1427 The number is in [0] 1356 1428 memory is not owned by OsiClp 1357 1429 */ 1358 int * 1430 int *whichRange_; 1359 1431 1360 1432 //std::map<OsiIntParam, ClpIntParam> intParamMap_; 1361 1433 //std::map<OsiDblParam, ClpDblParam> dblParamMap_; 1362 1434 //std::map<OsiStrParam, ClpStrParam> strParamMap_; 1363 1435 1364 1436 /*! \brief Faking min to get proper dual solution signs in simplex API */ 1365 mutable bool fakeMinInSimplex_ 1437 mutable bool fakeMinInSimplex_; 1366 1438 /*! \brief Linear objective 1367 1439 … … 1419 1491 mutable unsigned int specialOptions_; 1420 1492 /// Copy of model when option 131072 set 1421 ClpSimplex * 1493 ClpSimplex *baseModel_; 1422 1494 /// Number of rows when last "scaled" 1423 1495 int lastNumberRows_; 1424 1496 /// Continuous model 1425 ClpSimplex * 1497 ClpSimplex *continuousModel_; 1426 1498 /// Possible disaster handler 1427 OsiClpDisasterHandler * disasterHandler_;1499 OsiClpDisasterHandler *disasterHandler_; 1428 1500 /// Fake objective 1429 ClpLinearObjective * 1501 ClpLinearObjective *fakeObjective_; 1430 1502 /// Row scale factors (has inverse at end) 1431 CoinDoubleArrayWithLength rowScale_; 1503 CoinDoubleArrayWithLength rowScale_; 1432 1504 /// Column scale factors (has inverse at end) 1433 CoinDoubleArrayWithLength columnScale_; 1505 CoinDoubleArrayWithLength columnScale_; 1434 1506 //@} 1435 1507 }; 1436 1508 1437 1509 class OsiClpDisasterHandler : public ClpDisasterHandler { 1438 1510 public: … … 1443 1515 virtual void intoSimplex(); 1444 1516 /// Checks if disaster 1445 virtual bool check() const 1517 virtual bool check() const; 1446 1518 /// saves information for next attempt 1447 1519 virtual void saveInfo(); … … 1449 1521 virtual int typeOfDisaster(); 1450 1522 //@} 1451 1452 1523 1453 1524 /**@name Constructors, destructor */ 1454 1525 1455 1526 //@{ 1456 1527 /** Default constructor. */ 1457 OsiClpDisasterHandler(OsiClpSolverInterface * 1528 OsiClpDisasterHandler(OsiClpSolverInterface *model = NULL); 1458 1529 /** Destructor */ 1459 1530 virtual ~OsiClpDisasterHandler(); 1460 1531 // Copy 1461 OsiClpDisasterHandler(const OsiClpDisasterHandler &);1532 OsiClpDisasterHandler(const OsiClpDisasterHandler &); 1462 1533 // Assignment 1463 OsiClpDisasterHandler & operator=(const OsiClpDisasterHandler&);1534 OsiClpDisasterHandler &operator=(const OsiClpDisasterHandler &); 1464 1535 /// Clone 1465 virtual ClpDisasterHandler * 1466 1467 //@} 1468 1536 virtual ClpDisasterHandler *clone() const; 1537 1538 //@} 1539 1469 1540 /**@name Sets/gets */ 1470 1541 1471 1542 //@{ 1472 1543 /** set model. */ 1473 void setOsiModel(OsiClpSolverInterface * 1544 void setOsiModel(OsiClpSolverInterface *model); 1474 1545 /// Get model 1475 inline OsiClpSolverInterface * osiModel() const 1476 { return osiModel_;} 1546 inline OsiClpSolverInterface *osiModel() const 1547 { 1548 return osiModel_; 1549 } 1477 1550 /// Set where from 1478 1551 inline void setWhereFrom(int value) 1479 { whereFrom_=value;} 1552 { 1553 whereFrom_ = value; 1554 } 1480 1555 /// Get where from 1481 1556 inline int whereFrom() const 1482 { return whereFrom_;} 1483 /// Set phase 1557 { 1558 return whereFrom_; 1559 } 1560 /// Set phase 1484 1561 inline void setPhase(int value) 1485 { phase_=value;} 1486 /// Get phase 1562 { 1563 phase_ = value; 1564 } 1565 /// Get phase 1487 1566 inline int phase() const 1488 { return phase_;} 1567 { 1568 return phase_; 1569 } 1489 1570 /// are we in trouble 1490 1571 bool inTrouble() const; 1491 1492 //@} 1493 1494 1572 1573 //@} 1574 1495 1575 protected: 1496 1576 /**@name Data members … … 1498 1578 //@{ 1499 1579 /// Pointer to model 1500 OsiClpSolverInterface * 1580 OsiClpSolverInterface *osiModel_; 1501 1581 /** Where from 1502 1582 0 dual (resolve) … … 1523 1603 //############################################################################# 1524 1604 /** A function that tests the methods in the OsiClpSolverInterface class. */ 1525 void OsiClpSolverInterfaceUnitTest(const std::string & mpsDir, const std::string &netlibDir);1605 void OsiClpSolverInterfaceUnitTest(const std::string &mpsDir, const std::string &netlibDir); 1526 1606 #endif 1607 1608 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 1609 */
Note: See TracChangeset
for help on using the changeset viewer.