Changeset 393 for trunk/ClpPresolve.cpp
 Timestamp:
 Jul 21, 2004 4:36:05 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/ClpPresolve.cpp
r378 r393 13 13 #include "CoinPackedMatrix.hpp" 14 14 #include "ClpSimplex.hpp" 15 #include "ClpQuadraticObjective.hpp" 15 16 16 17 #include "ClpPresolve.hpp" … … 215 216 } 216 217 // Now check solution 218 double offset; 217 219 memcpy(originalModel_>dualColumnSolution(), 218 originalModel_>objective(),ncols_*sizeof(double)); 220 originalModel_>objectiveAsObject()>gradient(originalModel_, 221 originalModel_>primalColumnSolution(), 222 offset,true),ncols_*sizeof(double)); 219 223 originalModel_>transposeTimes(1.0, 220 224 originalModel_>dualRowSolution(), … … 371 375 // later just do individually 372 376 bool doDualStuff = (presolvedModel_>integerInformation()==NULL); 377 if (prob>anyProhibited()) 378 doDualStuff=false; 373 379 374 380 #if CHECK_CONSISTENCY … … 862 868 ClpDisjointCopyN(si>getColLower(), ncols, clo_); 863 869 ClpDisjointCopyN(si>getColUpper(), ncols, cup_); 864 ClpDisjointCopyN(si>getObjCoefficients(), ncols, cost_); 870 //ClpDisjointCopyN(si>getObjCoefficients(), ncols, cost_); 871 double offset; 872 ClpDisjointCopyN(si>objectiveAsObject()>gradient(si,si>getColSolution(),offset,true), ncols, cost_); 865 873 ClpDisjointCopyN(si>getRowLower(), nrows, rlo_); 866 874 ClpDisjointCopyN(si>getRowUpper(), nrows, rup_); … … 991 999 } 992 1000 1001 #ifndef NO_RTTI 1002 ClpQuadraticObjective * quadraticObj = (dynamic_cast< ClpQuadraticObjective*>(si>objectiveAsObject())); 1003 #else 1004 ClpQuadraticObjective * quadraticObj = NULL; 1005 if (si>objectiveAsObject()>type()==2) 1006 quadraticObj = (static_cast< ClpQuadraticObjective*>(si>objectiveAsObject())); 1007 #endif 993 1008 // Set up prohibited bits if needed 994 1009 if (nonLinearValue) { … … 1008 1023 setColProhibited(icol); 1009 1024 } 1025 } else if (quadraticObj) { 1026 CoinPackedMatrix * quadratic = quadraticObj>quadraticObjective(); 1027 //const int * columnQuadratic = quadratic>getIndices(); 1028 //const CoinBigIndex * columnQuadraticStart = quadratic>getVectorStarts(); 1029 const int * columnQuadraticLength = quadratic>getVectorLengths(); 1030 //double * quadraticElement = quadratic>getMutableElements(); 1031 int numberColumns = quadratic>getNumCols(); 1032 anyProhibited_ = true; 1033 for (int iColumn=0;iColumn<numberColumns;iColumn++) { 1034 if (columnQuadraticLength[iColumn]) { 1035 setColProhibited(iColumn); 1036 //printf("%d prohib\n",iColumn); 1037 } 1038 } 1010 1039 } else { 1011 1040 anyProhibited_ = false; … … 1062 1091 si>loadProblem(ncols_, nrows_, mcstrt_, hrow_, colels_, hincol_, 1063 1092 clo_, cup_, cost_, rlo_, rup_); 1064 1065 1093 delete [] si>integerInformation(); 1066 1094 int numberIntegers=0; … … 1291 1319 1292 1320 // Do presolve 1293 1294 1321 paction_ = presolve(&prob); 1295 1322 … … 1351 1378 int ncolsNow = presolvedModel_>getNumCols(); 1352 1379 memcpy(originalColumn_,prob.originalColumn_,ncolsNow*sizeof(int)); 1380 #ifndef NO_RTTI 1381 ClpQuadraticObjective * quadraticObj = (dynamic_cast< ClpQuadraticObjective*>(originalModel>objectiveAsObject())); 1382 #else 1383 ClpQuadraticObjective * quadraticObj = NULL; 1384 if (originalModel>objectiveAsObject()>type()==2) 1385 quadraticObj = (static_cast< ClpQuadraticObjective*>(originalModel>objectiveAsObject())); 1386 #endif 1387 if (quadraticObj) { 1388 // set up for subset 1389 char * mark = new char [ncols_]; 1390 memset(mark,0,ncols_); 1391 CoinPackedMatrix * quadratic = quadraticObj>quadraticObjective(); 1392 //const int * columnQuadratic = quadratic>getIndices(); 1393 //const CoinBigIndex * columnQuadraticStart = quadratic>getVectorStarts(); 1394 const int * columnQuadraticLength = quadratic>getVectorLengths(); 1395 //double * quadraticElement = quadratic>getMutableElements(); 1396 int numberColumns = quadratic>getNumCols(); 1397 ClpQuadraticObjective * newObj = new ClpQuadraticObjective(*quadraticObj, 1398 ncolsNow, 1399 originalColumn_); 1400 // and modify linear and check 1401 double * linear = newObj>linearObjective(); 1402 memcpy(linear,presolvedModel_>objective(),ncolsNow*sizeof(double)); 1403 int iColumn; 1404 for ( iColumn=0;iColumn<numberColumns;iColumn++) { 1405 if (columnQuadraticLength[iColumn]) 1406 mark[iColumn]=1; 1407 } 1408 // and new 1409 quadratic = newObj>quadraticObjective(); 1410 columnQuadraticLength = quadratic>getVectorLengths(); 1411 int numberColumns2 = quadratic>getNumCols(); 1412 for ( iColumn=0;iColumn<numberColumns2;iColumn++) { 1413 if (columnQuadraticLength[iColumn]) 1414 mark[originalColumn_[iColumn]]=0; 1415 } 1416 presolvedModel_>setObjective(newObj); 1417 delete newObj; 1418 // final check 1419 for ( iColumn=0;iColumn<numberColumns;iColumn++) 1420 if (mark[iColumn]) 1421 printf("Quadratic column %d modified  may be okay\n",iColumn); 1422 delete [] mark; 1423 } 1353 1424 delete [] prob.originalColumn_; 1354 1425 prob.originalColumn_=NULL;
Note: See TracChangeset
for help on using the changeset viewer.