 Timestamp:
 Feb 10, 2011 11:36:02 AM (9 years ago)
 Location:
 trunk/Clp/src
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Clp/src/CbcOrClpParam.cpp
r1680 r1681 1548 1548 parameters[numberParameters1].append("on"); 1549 1549 parameters[numberParameters1].append("so!low_halim"); 1550 parameters[numberParameters1].append(" ha!lim_solow(JJF mods)");1550 parameters[numberParameters1].append("lots"); 1551 1551 // parameters[numberParameters1].append("4"); 1552 1552 // parameters[numberParameters1].append("5"); 
trunk/Clp/src/ClpMain.cpp
r1665 r1681 25 25 #include "CoinMpsIO.hpp" 26 26 #include "CoinFileIO.hpp" 27 #ifdef COIN_HAS_GLPK 28 #include "glpk.h" 29 extern glp_tran* cbc_glp_tran; 30 extern glp_prob* cbc_glp_prob; 31 #endif 27 32 28 33 #include "ClpFactorization.hpp" … … 647 652 ClpSolve::PresolveType presolveType; 648 653 ClpSimplex * model2 = models + iModel; 654 ClpSolve solveOptions; 655 if (dualize==4) { 656 solveOptions.setSpecialOption(4, 77); 657 dualize=0; 658 } 649 659 if (dualize) { 650 660 bool tryIt = true; … … 671 681 model2 = models + iModel; 672 682 dualize = 0; 673 683 } 674 684 } else { 675 685 dualize = 0; 676 686 } 677 687 } 678 ClpSolve solveOptions; 688 if (preSolveFile) 689 presolveOptions = 0x40000000; 679 690 solveOptions.setPresolveActions(presolveOptions); 680 691 solveOptions.setSubstitution(substitution); … … 722 733 } 723 734 solveOptions.setSolveType(method); 724 if (preSolveFile)725 presolveOptions = 0x40000000;726 solveOptions.setSpecialOption(4, presolveOptions);727 735 solveOptions.setSpecialOption(5, printOptions & 1); 728 736 if (doVector) { … … 961 969 if (absolutePath) { 962 970 fileName = field; 971 int length = field.size(); 972 int percent = field.find('%'); 973 if (percent < length && percent > 0) { 974 gmpl = 1; 975 fileName = field.substr(0, percent); 976 gmplData = field.substr(percent + 1); 977 if (percent < length  1) 978 gmpl = 2; // two files 979 printf("GMPL model file %s and data file %s\n", 980 fileName.c_str(), gmplData.c_str()); 981 } 963 982 } else if (field[0] == '~') { 964 983 char * environVar = getenv("HOME"); … … 1756 1775 break; 1757 1776 case CLP_PARAM_ACTION_SOLUTION: 1777 case CLP_PARAM_ACTION_GMPL_SOLUTION: 1758 1778 if (goodModels[iModel]) { 1759 1779 // get next field … … 1803 1823 } 1804 1824 if (fp) { 1825 // See if Glpk 1826 if (type == CLP_PARAM_ACTION_GMPL_SOLUTION) { 1827 int numberRows = models[iModel].getNumRows(); 1828 int numberColumns = models[iModel].getNumCols(); 1829 int numberGlpkRows=numberRows+1; 1830 if (cbc_glp_prob) { 1831 // from gmpl 1832 numberGlpkRows=glp_get_num_rows(cbc_glp_prob); 1833 if (numberGlpkRows!=numberRows) 1834 printf("Mismatch  cbc %d rows, glpk %d\n", 1835 numberRows,numberGlpkRows); 1836 } 1837 fprintf(fp,"%d %d\n",numberGlpkRows, 1838 numberColumns); 1839 int iStat = models[iModel].status(); 1840 int iStat2 = GLP_UNDEF; 1841 if (iStat == 0) { 1842 // optimal 1843 iStat2 = GLP_FEAS; 1844 } else if (iStat == 1) { 1845 // infeasible 1846 iStat2 = GLP_NOFEAS; 1847 } else if (iStat == 2) { 1848 // unbounded 1849 // leave as 1 1850 } else if (iStat >= 3 && iStat <= 5) { 1851 iStat2 = GLP_FEAS; 1852 } 1853 double objValue = models[iModel].getObjValue() 1854 * models[iModel].getObjSense(); 1855 fprintf(fp,"%d 2 %g\n",iStat2,objValue); 1856 if (numberGlpkRows > numberRows) { 1857 // objective as row 1858 fprintf(fp,"4 %g 1.0\n",objValue); 1859 } 1860 int lookup[6]= 1861 {4,1,3,2,4,5}; 1862 const double * primalRowSolution = 1863 models[iModel].primalRowSolution(); 1864 const double * dualRowSolution = 1865 models[iModel].dualRowSolution(); 1866 for (int i=0;i<numberRows;i++) { 1867 fprintf(fp,"%d %g %g\n",lookup[models[iModel].getRowStatus(i)], 1868 primalRowSolution[i],dualRowSolution[i]); 1869 } 1870 const double * primalColumnSolution = 1871 models[iModel].primalColumnSolution(); 1872 const double * dualColumnSolution = 1873 models[iModel].dualColumnSolution(); 1874 for (int i=0;i<numberColumns;i++) { 1875 fprintf(fp,"%d %g %g\n",lookup[models[iModel].getColumnStatus(i)], 1876 primalColumnSolution[i],dualColumnSolution[i]); 1877 } 1878 fclose(fp); 1879 #ifdef COIN_HAS_GLPK 1880 if (cbc_glp_prob) { 1881 glp_read_sol(cbc_glp_prob,fileName.c_str()); 1882 glp_mpl_postsolve(cbc_glp_tran, 1883 cbc_glp_prob, 1884 GLP_SOL); 1885 // free up as much as possible 1886 glp_free(cbc_glp_prob); 1887 glp_mpl_free_wksp(cbc_glp_tran); 1888 //gmp_free_mem(); 1889 /* check that no memory blocks are still allocated */ 1890 glp_free_env(); 1891 } 1892 #endif 1893 break; 1894 } 1805 1895 // Write solution header (suggested by Luigi Poderico) 1806 1896 double objValue = models[iModel].getObjValue() * models[iModel].getObjSense();
Note: See TracChangeset
for help on using the changeset viewer.