Changeset 1798 for trunk/Cbc/src
 Timestamp:
 Oct 21, 2012 9:34:48 AM (9 years ago)
 Location:
 trunk/Cbc/src
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/src/CbcModel.cpp
r1791 r1798 1607 1607 dblParam_[CbcLargestChange] = 0.0; 1608 1608 intParam_[CbcNumberBranches] = 0; 1609 // Double check optimization directions line up 1610 dblParam_[CbcOptimizationDirection] = solver_>getObjSense(); 1609 // Force minimization !!!! 1610 bool flipObjective = (solver_>getObjSense()<0.0); 1611 if (flipObjective) 1612 flipModel(); 1613 dblParam_[CbcOptimizationDirection] = 1.0; // was solver_>getObjSense(); 1611 1614 strongInfo_[0] = 0; 1612 1615 strongInfo_[1] = 0; … … 1635 1638 CbcDisasterHandler handler(this); 1636 1639 clpSolver>passInDisasterHandler(&handler); 1637 // Initialise solvers seed 1638 clpSolver>getModelPtr()>setRandomSeed(1234567); 1640 // Initialise solvers seed (unless users says not) 1641 if ((specialOptions_&4194304)==0) 1642 clpSolver>getModelPtr()>setRandomSeed(1234567); 1639 1643 #ifdef JJF_ZERO 1640 1644 // reduce factorization frequency … … 1673 1677 secondaryStatus_ = 1; 1674 1678 originalContinuousObjective_ = COIN_DBL_MAX; 1679 if (flipObjective) 1680 flipModel(); 1675 1681 return ; 1676 1682 } else if (numberObjects_ && object_) { … … 2022 2028 originalContinuousObjective_ = COIN_DBL_MAX; 2023 2029 solverCharacteristics_ = NULL; 2030 if (flipObjective) 2031 flipModel(); 2024 2032 return ; 2025 2033 } else if (!numberObjects_ && (!strategy_  strategy_>preProcessState() <= 0)) { 2026 2034 // nothing to do 2035 if (flipObjective) 2036 flipModel(); 2027 2037 solverCharacteristics_ = NULL; 2028 2038 bestObjective_ = solver_>getObjValue() * solver_>getObjSense(); … … 2789 2799 delete [] upperBefore; 2790 2800 delete saveSolver; 2801 if (flipObjective) 2802 flipModel(); 2791 2803 return; 2792 2804 } … … 4332 4344 } 4333 4345 } 4346 if (flipObjective) 4347 flipModel(); 4334 4348 #ifdef COIN_HAS_CLP 4335 4349 { … … 15644 15658 specialOptions_ = setFlag; 15645 15659 } 15660 static void flipSolver(OsiSolverInterface * solver, double newCutoff) 15661 { 15662 if (solver) { 15663 double objValue = solver>getObjValue(); 15664 double objectiveOffset; 15665 solver>setObjSense(solver>getObjSense()); 15666 solver>getDblParam(OsiObjOffset,objectiveOffset); 15667 solver>setDblParam(OsiObjOffset,objectiveOffset); 15668 int numberColumns = solver>getNumCols(); 15669 double * array = CoinCopyOfArray(solver>getObjCoefficients(),numberColumns); 15670 for (int i=0;i<numberColumns;i++) 15671 array[i] =  array[i]; 15672 solver>setObjective(array); 15673 delete [] array; 15674 solver>setDblParam(OsiDualObjectiveLimit,newCutoff); 15675 #ifdef COIN_HAS_CLP 15676 OsiClpSolverInterface * clpSolver 15677 = dynamic_cast<OsiClpSolverInterface *> (solver); 15678 if (clpSolver) { 15679 double * dj = clpSolver>getModelPtr()>dualColumnSolution(); 15680 for (int i=0;i<numberColumns;i++) 15681 dj[i] =  dj[i]; 15682 int numberRows=clpSolver>getNumRows(); 15683 double * pi = clpSolver>getModelPtr()>dualRowSolution(); 15684 for (int i=0;i<numberRows;i++) 15685 pi[i] =  pi[i]; 15686 clpSolver>getModelPtr()>setObjectiveValue(objValue); 15687 } else { 15688 #endif 15689 // update values 15690 solver>resolve(); 15691 #ifdef COIN_HAS_CLP 15692 } 15693 #endif 15694 } 15695 } 15696 /* 15697 Flip direction of optimization on all models 15698 */ 15699 void 15700 CbcModel::flipModel() 15701 { 15702 if (parentModel_) 15703 return; 15704 // I think cutoff is always minimization 15705 double cutoff=getCutoff(); 15706 flipSolver(referenceSolver_,cutoff); 15707 flipSolver(continuousSolver_,cutoff); 15708 flipSolver(solver_,cutoff); 15709 } 15646 15710 #ifdef CBC_KEEP_DEPRECATED 15647 15711 /* preProcess problem  replacing solver 
trunk/Cbc/src/CbcModel.hpp
r1794 r1798 439 439 */ 440 440 void saveModel(OsiSolverInterface * saveSolver, double * checkCutoffForRestart, bool * feasible); 441 /** 442 Flip direction of optimization on all models 443 */ 444 void flipModel(); 441 445 442 446 //@} … … 1729 1733 19 bit (524288)  recipient CbcModel 1730 1734 20 bit (1048576)  waiting for sub model to return 1735 22 bit (4194304)  do not initialize random seed in solver (user has) 1731 1736 */ 1732 1737 inline void setSpecialOptions(int value) {
Note: See TracChangeset
for help on using the changeset viewer.