Changeset 1306 for stable/1.8
- Timestamp:
- Nov 12, 2008 9:45:46 AM (12 years ago)
- Location:
- stable/1.8/Clp/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable/1.8/Clp/src/ClpSimplexDual.cpp
r1296 r1306 308 308 // Can't get here if values pass 309 309 gutsOfSolution(NULL,NULL); 310 #ifdef COIN_DEVELOP 311 if (numberDualInfeasibilities_) 312 printf("ZZZ %d primal %d dual - cost %g\n", 313 numberPrimalInfeasibilities_, 314 numberDualInfeasibilities_,cost_[0]); 315 #endif 310 316 if (handler_->logLevel()>2) { 311 317 handler_->message(CLP_SIMPLEX_STATUS,messages_) … … 1565 1571 // If we have just factorized and infeasibility reasonable say infeas 1566 1572 if (((specialOptions_&4096)!=0||bestPossiblePivot<1.0e-11)&&dualBound_>1.0e8) { 1567 if (valueOut_>upperOut_+1.0e-3||valueOut_<lowerOut_-1.0e-3 1573 double testValue=1.0e-4; 1574 if (!factorization_->pivots()&&numberPrimalInfeasibilities_==1) 1575 testValue=1.0e-6; 1576 if (valueOut_>upperOut_+testValue||valueOut_<lowerOut_-testValue 1568 1577 || (specialOptions_&64)==0) { 1569 1578 // say infeasible … … 1739 1748 problemStatus_=-5; 1740 1749 } else { 1741 if (numberPivots) {1742 // objective may be wrong1743 objectiveValue_ = innerProduct(cost_,numberColumns_+numberRows_,solution_);1744 objectiveValue_ += objective_->nonlinearOffset();1745 objectiveValue_ /= (objectiveScale_*rhsScale_);1746 if ((specialOptions_&16384)==0) {1747 // and dual_ may be wrong (i.e. for fixed or basic)1748 CoinIndexedVector * arrayVector = rowArray_[1];1749 arrayVector->clear();1750 int iRow;1751 double * array = arrayVector->denseVector();1752 /* Use dual_ instead of array1753 Even though dual_ is only numberRows_ long this is1754 okay as gets permuted to longer rowArray_[2]1755 */1756 arrayVector->setDenseVector(dual_);1757 int * index = arrayVector->getIndices();1758 int number=0;1759 for (iRow=0;iRow<numberRows_;iRow++) {1760 int iPivot=pivotVariable_[iRow];1761 double value = cost_[iPivot];1762 dual_[iRow]=value;1763 if (value) {1764 index[number++]=iRow;1765 }1766 }1767 arrayVector->setNumElements(number);1768 // Extended duals before "updateTranspose"1769 matrix_->dualExpanded(this,arrayVector,NULL,0);1770 // Btran basic costs1771 rowArray_[2]->clear();1772 factorization_->updateColumnTranspose(rowArray_[2],arrayVector);1773 // and return vector1774 arrayVector->setDenseVector(array);1775 }1776 }1777 1750 problemStatus_=0; 1778 sumPrimalInfeasibilities_=0.0; 1751 #ifndef CLP_CHECK_NUMBER_PIVOTS 1752 #define CLP_CHECK_NUMBER_PIVOTS 10 1753 #endif 1754 #if CLP_CHECK_NUMBER_PIVOTS < 20 1755 if (numberPivots>CLP_CHECK_NUMBER_PIVOTS) { 1756 #ifndef NDEBUG 1757 int nTotal = numberRows_+numberColumns_; 1758 double * comp = CoinCopyOfArray(solution_,nTotal); 1759 #endif 1760 computePrimals(rowActivityWork_,columnActivityWork_); 1761 #ifndef NDEBUG 1762 double largest=1.0e-5; 1763 int bad=-1; 1764 for (int i=0;i<nTotal;i++) { 1765 double value = solution_[i]; 1766 double larger = CoinMax(fabs(value),fabs(comp[i])); 1767 double tol = 1.0e-5+1.0e-5*larger; 1768 double diff = fabs(value-comp[i]); 1769 if (diff-tol>largest) { 1770 bad=i; 1771 largest = diff-tol; 1772 } 1773 } 1774 if (bad>=0) 1775 printf("bad %d old %g new %g\n",bad,comp[bad],solution_[bad]); 1776 #endif 1777 checkPrimalSolution(rowActivityWork_,columnActivityWork_); 1778 if (numberPrimalInfeasibilities_) { 1779 printf("XXX Infeas ? %d inf summing to %g\n",numberPrimalInfeasibilities_, 1780 sumPrimalInfeasibilities_); 1781 problemStatus_=-1; 1782 returnCode=-2; 1783 } 1784 #ifndef NDEBUG 1785 memcpy(solution_,comp,nTotal*sizeof(double)); 1786 delete [] comp; 1787 #endif 1788 } 1789 #endif 1790 if (!problemStatus_) { 1791 // make it look OK 1792 numberPrimalInfeasibilities_=0; 1793 sumPrimalInfeasibilities_=0.0; 1794 numberDualInfeasibilities_=0; 1795 sumDualInfeasibilities_=0.0; 1796 // May be perturbed 1797 if (perturbation_==101||numberChanged_) { 1798 perturbation_=102; // stop any perturbations 1799 //double changeCost; 1800 //changeBounds(1,NULL,changeCost); 1801 createRim4(false); 1802 // make sure duals are current 1803 computeDuals(givenDuals); 1804 checkDualSolution(); 1805 if (numberDualInfeasibilities_) { 1806 problemStatus_=10; // was -3; 1807 } else { 1808 computeObjectiveValue(true); 1809 } 1810 } else if (numberPivots) { 1811 computeObjectiveValue(true); 1812 } 1813 if (numberPivots<-1000) { 1814 // objective may be wrong 1815 objectiveValue_ = innerProduct(cost_,numberColumns_+numberRows_,solution_); 1816 objectiveValue_ += objective_->nonlinearOffset(); 1817 objectiveValue_ /= (objectiveScale_*rhsScale_); 1818 if ((specialOptions_&16384)==0) { 1819 // and dual_ may be wrong (i.e. for fixed or basic) 1820 CoinIndexedVector * arrayVector = rowArray_[1]; 1821 arrayVector->clear(); 1822 int iRow; 1823 double * array = arrayVector->denseVector(); 1824 /* Use dual_ instead of array 1825 Even though dual_ is only numberRows_ long this is 1826 okay as gets permuted to longer rowArray_[2] 1827 */ 1828 arrayVector->setDenseVector(dual_); 1829 int * index = arrayVector->getIndices(); 1830 int number=0; 1831 for (iRow=0;iRow<numberRows_;iRow++) { 1832 int iPivot=pivotVariable_[iRow]; 1833 double value = cost_[iPivot]; 1834 dual_[iRow]=value; 1835 if (value) { 1836 index[number++]=iRow; 1837 } 1838 } 1839 arrayVector->setNumElements(number); 1840 // Extended duals before "updateTranspose" 1841 matrix_->dualExpanded(this,arrayVector,NULL,0); 1842 // Btran basic costs 1843 rowArray_[2]->clear(); 1844 factorization_->updateColumnTranspose(rowArray_[2],arrayVector); 1845 // and return vector 1846 arrayVector->setDenseVector(array); 1847 } 1848 } 1849 sumPrimalInfeasibilities_=0.0; 1850 } 1779 1851 if ((specialOptions_&(1024+16384))!=0) { 1780 1852 CoinIndexedVector * arrayVector = rowArray_[1]; … … 2767 2839 double bestPossible=0.0; 2768 2840 double badFree=0.0; 2841 alpha_=0.0; 2769 2842 if (spareIntArray_[0]!=-1) { 2770 2843 numberRemaining = dualColumn0(rowArray,columnArray,spareArray, … … 3896 3969 //if (numberDualInfeasibilities_) 3897 3970 numberChanged_=1; // force something to happen 3898 //else 3899 //computeObjectiveValue(); 3971 lastCleaned=numberIterations_-1; 3972 #ifdef DUAL_TRY_FASTER 3973 } else { 3974 //double value = objectiveValue_; 3975 computeObjectiveValue(true); 3976 //printf("old %g new %g\n",value,objectiveValue_); 3977 //numberChanged_=1; 3978 } 3979 #endif 3900 3980 } 3901 3981 if (lastCleaned<numberIterations_&&numberTimesOptimal_<4&& -
stable/1.8/Clp/src/ClpSimplexPrimal.cpp
r1218 r1306 1285 1285 } 1286 1286 } else { 1287 problemStatus_=0; // optimal 1287 if (!alwaysOptimal||!sumOfRelaxedPrimalInfeasibilities_) 1288 problemStatus_=0; // optimal 1289 else 1290 problemStatus_=1; // infeasible 1288 1291 } 1289 1292 }
Note: See TracChangeset
for help on using the changeset viewer.