Changeset 2428
 Timestamp:
 Nov 20, 2018 8:02:05 AM (8 months ago)
 Location:
 trunk/Cbc/src
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/Cbc_C_Interface.cpp
r2427 r2428 241 241 242 242 Cbc_Model * model = new Cbc_Model(); 243 OsiClpSolverInterface solver1; 244 model>solver_ = &solver1; 243 OsiClpSolverInterface solver1; // will be release at the end of the scope, CbcModel clones it 245 244 model>model_ = new CbcModel(solver1); 245 model>solver_ = dynamic_cast<OsiClpSolverInterface *>(model>model_>solver()); 246 246 CbcMain0(*model>model_); 247 247 model>handler_ = NULL; 248 model>relax_ = 0; 248 249 249 250 if (VERBOSE > 0) printf("%s return\n", prefix); … … 430 431 } 431 432 433 434 COINLIBAPI int COINLINKAGE 435 Cbc_getNumIntegers(Cbc_Model * model) 436 { 437 return model>model_>solver()>getNumIntegers(); 438 } 439 440 432 441 // Column starts in matrix 433 442 COINLIBAPI const CoinBigIndex * COINLINKAGE … … 551 560 } 552 561 562 COINLIBAPI void COINLINKAGE 563 Cbc_setSolveRelax(Cbc_Model * model, char solveOnlyRelax ) 564 { 565 model>relax_ = solveOnlyRelax; 566 } 553 567 554 568 COINLIBAPI int COINLINKAGE 555 569 Cbc_solve(Cbc_Model * model) 556 570 { 571 OsiSolverInterface *solver = model>solver_; 572 if ( solver>getNumIntegers() == 0  model>relax_ == 1 ) 573 { 574 if ( solver>basisIsAvailable() ) { 575 solver>resolve(); 576 } 577 else { 578 solver>initialSolve(); 579 } 580 581 if (solver>isProvenOptimal()) 582 return 0; 583 584 return 1; 585 } 586 557 587 const char prefix[] = "Cbc_C_Interface::Cbc_solve(): "; 558 588 int result = 0; … … 630 660 631 661 632 633 662 CbcGetProperty(int, getNumCols) 634 663 CbcGetProperty(int, getNumRows) 635 664 CbcGetProperty(int, getIterationCount) 636 CbcGetProperty(int, isAbandoned) 637 CbcGetProperty(int, isProvenOptimal) 638 CbcGetProperty(int, isProvenInfeasible) 665 666 /** Are there a numerical difficulties? */ 667 COINLIBAPI int COINLINKAGE 668 Cbc_isAbandoned(Cbc_Model * model) 669 { 670 if ( Cbc_getNumIntegers(model)==0  model>relax_==1 ) 671 return model>solver_>isAbandoned(); 672 else 673 return model>model_>isAbandoned(); 674 } 675 676 /** Is optimality proven? */ 677 COINLIBAPI int COINLINKAGE 678 Cbc_isProvenOptimal(Cbc_Model * model) 679 { 680 if ( Cbc_getNumIntegers(model)==0  model>relax_==1 ) 681 return model>solver_>isProvenOptimal(); 682 else 683 return model>model_>isProvenOptimal(); 684 } 685 686 COINLIBAPI int COINLINKAGE 687 Cbc_isProvenInfeasible(Cbc_Model * model) 688 { 689 if ( Cbc_getNumIntegers(model)==0  model>relax_==1 ) 690 return (model>solver_>isProvenDualInfeasible()  model>solver_>isProvenPrimalInfeasible()); 691 else 692 return model>model_>isProvenInfeasible(); 693 } 694 639 695 CbcGetProperty(int, isContinuousUnbounded) 640 696 CbcGetProperty(int, isNodeLimitReached) … … 669 725 CbcGetProperty(double, getObjValue) 670 726 CbcGetProperty(double, getBestPossibleObjValue) 727 728 COINLIBAPI double* COINLINKAGE 729 Cbc_bestSolution(Cbc_Model * model) 730 { 731 return model>model_>bestSolution(); 732 } 671 733 672 734 /* Print model */ … … 755 817 result>handler_ = NULL; 756 818 result>cmdargs_ = model>cmdargs_; 819 result>relax_ = model>relax_; 757 820 758 821 if (VERBOSE > 0) printf("%s return\n", prefix); 
trunk/Cbc/src/Cbc_C_Interface.h
r2427 r2428 82 82 Cbc_readMps(Cbc_Model * model, const char *filename) 83 83 ; 84 /** Read an lp file from the given filename */ 85 COINLIBAPI int COINLINKAGE 86 Cbc_readLp(Cbc_Model * model, const char *filename) 87 ; 84 88 /** Write an mps file from the given filename */ 85 89 COINLIBAPI void COINLINKAGE 86 90 Cbc_writeMps(Cbc_Model * model, const char *filename) 87 91 ; 88 /** Readan lp file from the given filename */89 COINLIBAPI intCOINLINKAGE90 Cbc_ readLp(Cbc_Model * model, const char *filename)92 /** Write an lp file from the given filename */ 93 COINLIBAPI void COINLINKAGE 94 Cbc_writeLp(Cbc_Model * model, const char *filename) 91 95 ; 92 96 /** Provide an initial feasible solution to accelerate branchandbound … … 152 156 COINLIBAPI int COINLINKAGE 153 157 Cbc_getNumCols(Cbc_Model * model) 158 ; 159 /** Number of integer variables in the model */ 160 COINLIBAPI int COINLINKAGE 161 Cbc_getNumIntegers(Cbc_Model * model) 154 162 ; 155 163 /** Direction of optimization (1  minimize, 1  maximize, 0  ignore) */ … … 354 362 COINLIBAPI double COINLINKAGE 355 363 Cbc_getBestPossibleObjValue(Cbc_Model * model) 364 ; 365 /** Best integer feasible solution or NULL if no integer feas sol found */ 366 COINLIBAPI double* COINLINKAGE 367 Cbc_bestSolution(Cbc_Model * model) 356 368 ; 357 369 /** Number of nodes explored in B&B tree */
Note: See TracChangeset
for help on using the changeset viewer.