Changeset 1301 for trunk/Clp/src/ClpSimplexDual.cpp
 Timestamp:
 Nov 4, 2008 10:09:25 AM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/ClpSimplexDual.cpp
r1294 r1301 311 311 // Can't get here if values pass 312 312 gutsOfSolution(NULL,NULL); 313 //if (numberDualInfeasibilities_) 314 //printf("ZZZ %d primal %d dual  cost %g\n", 315 // numberPrimalInfeasibilities_, 316 // numberDualInfeasibilities_,cost_[0]); 313 #ifdef COIN_DEVELOP 314 if (numberDualInfeasibilities_) 315 printf("ZZZ %d primal %d dual  cost %g\n", 316 numberPrimalInfeasibilities_, 317 numberDualInfeasibilities_,cost_[0]); 318 #endif 317 319 if (handler_>logLevel()>2) { 318 320 handler_>message(CLP_SIMPLEX_STATUS,messages_) … … 1612 1614 // If we have just factorized and infeasibility reasonable say infeas 1613 1615 if (((specialOptions_&4096)!=0bestPossiblePivot<1.0e11)&&dualBound_>1.0e8) { 1614 if (valueOut_>upperOut_+1.0e4valueOut_<lowerOut_1.0e4 1616 double testValue=1.0e4; 1617 if (!factorization_>pivots()&&numberPrimalInfeasibilities_==1) 1618 testValue=1.0e6; 1619 if (valueOut_>upperOut_+testValuevalueOut_<lowerOut_testValue 1615 1620  (specialOptions_&64)==0) { 1616 1621 // say infeasible … … 1790 1795 } else { 1791 1796 problemStatus_=0; 1792 // make it look OK 1793 numberPrimalInfeasibilities_=0; 1794 sumPrimalInfeasibilities_=0.0; 1795 numberDualInfeasibilities_=0; 1796 sumDualInfeasibilities_=0.0; 1797 // May be perturbed 1798 if (perturbation_==101numberChanged_) { 1799 perturbation_=102; // stop any perturbations 1800 //double changeCost; 1801 //changeBounds(1,NULL,changeCost); 1802 createRim4(false); 1803 // make sure duals are current 1804 computeDuals(givenDuals); 1805 checkDualSolution(); 1806 if (numberDualInfeasibilities_) { 1807 problemStatus_=10; // was 3; 1808 } else { 1797 #ifndef CLP_CHECK_NUMBER_PIVOTS 1798 #define CLP_CHECK_NUMBER_PIVOTS 10 1799 #endif 1800 #if CLP_CHECK_NUMBER_PIVOTS < 20 1801 if (numberPivots>CLP_CHECK_NUMBER_PIVOTS) { 1802 #ifndef NDEBUG 1803 int nTotal = numberRows_+numberColumns_; 1804 double * comp = CoinCopyOfArray(solution_,nTotal); 1805 #endif 1806 computePrimals(rowActivityWork_,columnActivityWork_); 1807 #ifndef NDEBUG 1808 double largest=1.0e5; 1809 int bad=1; 1810 for (int i=0;i<nTotal;i++) { 1811 double value = solution_[i]; 1812 double larger = CoinMax(fabs(value),fabs(comp[i])); 1813 double tol = 1.0e5+1.0e5*larger; 1814 double diff = fabs(valuecomp[i]); 1815 if (difftol>largest) { 1816 bad=i; 1817 largest = difftol; 1818 } 1819 } 1820 if (bad>=0) 1821 printf("bad %d old %g new %g\n",bad,comp[bad],solution_[bad]); 1822 #endif 1823 checkPrimalSolution(rowActivityWork_,columnActivityWork_); 1824 if (numberPrimalInfeasibilities_) { 1825 printf("XXX Infeas ? %d inf summing to %g\n",numberPrimalInfeasibilities_, 1826 sumPrimalInfeasibilities_); 1827 problemStatus_=1; 1828 returnCode=2; 1829 } 1830 #ifndef NDEBUG 1831 memcpy(solution_,comp,nTotal*sizeof(double)); 1832 delete [] comp; 1833 #endif 1834 } 1835 #endif 1836 if (!problemStatus_) { 1837 // make it look OK 1838 numberPrimalInfeasibilities_=0; 1839 sumPrimalInfeasibilities_=0.0; 1840 numberDualInfeasibilities_=0; 1841 sumDualInfeasibilities_=0.0; 1842 // May be perturbed 1843 if (perturbation_==101numberChanged_) { 1844 perturbation_=102; // stop any perturbations 1845 //double changeCost; 1846 //changeBounds(1,NULL,changeCost); 1847 createRim4(false); 1848 // make sure duals are current 1849 computeDuals(givenDuals); 1850 checkDualSolution(); 1851 if (numberDualInfeasibilities_) { 1852 problemStatus_=10; // was 3; 1853 } else { 1854 computeObjectiveValue(true); 1855 } 1856 } else if (numberPivots) { 1809 1857 computeObjectiveValue(true); 1858 } 1859 if (numberPivots<1000) { 1860 // objective may be wrong 1861 objectiveValue_ = innerProduct(cost_,numberColumns_+numberRows_,solution_); 1862 objectiveValue_ += objective_>nonlinearOffset(); 1863 objectiveValue_ /= (objectiveScale_*rhsScale_); 1864 if ((specialOptions_&16384)==0) { 1865 // and dual_ may be wrong (i.e. for fixed or basic) 1866 CoinIndexedVector * arrayVector = rowArray_[1]; 1867 arrayVector>clear(); 1868 int iRow; 1869 double * array = arrayVector>denseVector(); 1870 /* Use dual_ instead of array 1871 Even though dual_ is only numberRows_ long this is 1872 okay as gets permuted to longer rowArray_[2] 1873 */ 1874 arrayVector>setDenseVector(dual_); 1875 int * index = arrayVector>getIndices(); 1876 int number=0; 1877 for (iRow=0;iRow<numberRows_;iRow++) { 1878 int iPivot=pivotVariable_[iRow]; 1879 double value = cost_[iPivot]; 1880 dual_[iRow]=value; 1881 if (value) { 1882 index[number++]=iRow; 1883 } 1884 } 1885 arrayVector>setNumElements(number); 1886 // Extended duals before "updateTranspose" 1887 matrix_>dualExpanded(this,arrayVector,NULL,0); 1888 // Btran basic costs 1889 rowArray_[2]>clear(); 1890 factorization_>updateColumnTranspose(rowArray_[2],arrayVector); 1891 // and return vector 1892 arrayVector>setDenseVector(array); 1893 } 1810 1894 } 1811 } else if (numberPivots) { 1812 computeObjectiveValue(true); 1813 } 1814 if (numberPivots<1000) { 1815 // objective may be wrong 1816 objectiveValue_ = innerProduct(cost_,numberColumns_+numberRows_,solution_); 1817 objectiveValue_ += objective_>nonlinearOffset(); 1818 objectiveValue_ /= (objectiveScale_*rhsScale_); 1819 if ((specialOptions_&16384)==0) { 1820 // and dual_ may be wrong (i.e. for fixed or basic) 1821 CoinIndexedVector * arrayVector = rowArray_[1]; 1822 arrayVector>clear(); 1823 int iRow; 1824 double * array = arrayVector>denseVector(); 1825 /* Use dual_ instead of array 1826 Even though dual_ is only numberRows_ long this is 1827 okay as gets permuted to longer rowArray_[2] 1828 */ 1829 arrayVector>setDenseVector(dual_); 1830 int * index = arrayVector>getIndices(); 1831 int number=0; 1832 for (iRow=0;iRow<numberRows_;iRow++) { 1833 int iPivot=pivotVariable_[iRow]; 1834 double value = cost_[iPivot]; 1835 dual_[iRow]=value; 1836 if (value) { 1837 index[number++]=iRow; 1838 } 1839 } 1840 arrayVector>setNumElements(number); 1841 // Extended duals before "updateTranspose" 1842 matrix_>dualExpanded(this,arrayVector,NULL,0); 1843 // Btran basic costs 1844 rowArray_[2]>clear(); 1845 factorization_>updateColumnTranspose(rowArray_[2],arrayVector); 1846 // and return vector 1847 arrayVector>setDenseVector(array); 1848 } 1849 } 1850 sumPrimalInfeasibilities_=0.0; 1895 sumPrimalInfeasibilities_=0.0; 1896 } 1851 1897 if ((specialOptions_&(1024+16384))!=0&&!problemStatus_) { 1852 1898 CoinIndexedVector * arrayVector = rowArray_[1]; … … 2915 2961 double bestPossible=0.0; 2916 2962 double badFree=0.0; 2963 alpha_=0.0; 2917 2964 if (spareIntArray_[0]!=1) { 2918 2965 numberRemaining = dualColumn0(rowArray,columnArray,spareArray, … … 4072 4119 #endif 4073 4120 numberChanged_=1; // force something to happen 4121 lastCleaned=numberIterations_1; 4074 4122 #ifdef DUAL_TRY_FASTER 4075 4123 } else {
Note: See TracChangeset
for help on using the changeset viewer.