- Timestamp:
- Sep 29, 2009 11:42:05 AM (11 years ago)
- Location:
- trunk/Clp/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Clp/src/ClpPredictorCorrector.cpp
r1434 r1439 960 960 deleteWorkingData(); 961 961 #if KEEP_GOING_IF_FIXED<10 962 #if ndef NDEBUG962 #if 0 //ndef NDEBUG 963 963 { 964 964 static int kk=0; -
trunk/Clp/src/ClpSimplex.cpp
r1434 r1439 611 611 if (!numberBasic) { 612 612 //printf("no errors on basic - going to all slack - numberOut %d\n",numberOut); 613 #if 0 613 614 allSlackBasis(true); 614 615 CoinIotaN(pivotVariable_,numberRows_,numberColumns_); 616 #else 617 // allow 618 numberOut=0; 619 #endif 615 620 } 616 621 CoinSort_2(save, save + numberOut, sort); -
trunk/Clp/src/ClpSimplexNonlinear.cpp
r1370 r1439 51 51 // for moment only if no scaling 52 52 // May be faster if switched off - but can't see why 53 if (!quadraticObj->fullMatrix()&& !rowScale_&&objectiveScale_==1.0) {53 if (!quadraticObj->fullMatrix()&&(!rowScale_&&!scalingFlag_)&&objectiveScale_==1.0) { 54 54 saveObjective = objective_; 55 55 objective_=new ClpQuadraticObjective(*quadraticObj,1); -
trunk/Clp/src/ClpSolve.cpp
r1431 r1439 2214 2214 } 2215 2215 } 2216 if (method==ClpSolve::useBarrier ) {2216 if (method==ClpSolve::useBarrier||barrierStatus<0) { 2217 2217 if (maxIts&&barrierStatus<4&&!quadraticObj) { 2218 2218 //printf("***** crossover - needs more thought on difficult models\n"); -
trunk/Clp/src/Idiot.cpp
r1434 r1439 175 175 if (iCol>=0) { 176 176 // may want to carry on - because of cost? 177 while ( cost[iCol]<0&&rowValue<rowUpper[i]) {177 while (iCol>=0&&cost[iCol]<0&&rowValue<rowUpper[i]) { 178 178 // want to increase 179 179 double distance = rowUpper[i]-rowValue; … … 241 241 if (iCol>=0) { 242 242 // may want to carry on - because of cost? 243 while ( cost[iCol]<0&&rowValue>rowLower[i]) {243 while (iCol>=0&&cost[iCol]<0&&rowValue>rowLower[i]) { 244 244 // want to increase 245 245 double distance = -(rowLower[i]-rowValue); … … 1314 1314 int * negSlack = posSlack+nrows; 1315 1315 int * nextSlack = negSlack + nrows; 1316 #if 1 1317 // Array for sorting out slack values 1318 double * ratio = new double [ncols]; 1319 int * which = new int [ncols]; 1320 for (i=0;i<nrows;i++) { 1321 if (posSlack[i]>=0||negSlack[i]>=0) { 1322 int iCol; 1323 int nPlus=0; 1324 int nMinus=0; 1325 bool possible=true; 1326 // Get sum 1327 double sum=0.0; 1328 iCol =posSlack[i]; 1329 while (iCol>=0) { 1330 double value = element[columnStart[iCol]]; 1331 sum += value*colsol[iCol]; 1332 if (lower[iCol]) { 1333 possible=false; 1334 break; 1335 } else { 1336 nPlus++; 1337 } 1338 iCol=nextSlack[iCol]; 1339 } 1340 iCol =negSlack[i]; 1341 while (iCol>=0) { 1342 double value = -element[columnStart[iCol]]; 1343 sum -= value*colsol[iCol]; 1344 if (lower[iCol]) { 1345 possible=false; 1346 break; 1347 } else { 1348 nMinus++; 1349 } 1350 iCol=nextSlack[iCol]; 1351 } 1352 //printf("%d plus, %d minus",nPlus,nMinus); 1353 //printf("\n"); 1354 if ((rowsol[i]-rowlower[i]<1.0e-7|| 1355 rowupper[i]-rowsol[i]<1.0e-7)&& 1356 nPlus+nMinus<2) 1357 possible=false; 1358 if (possible) { 1359 // Amount contributed by other varaibles 1360 sum = rowsol[i]-sum; 1361 double lo = rowlower[i]; 1362 if (lo>-1.0e20) 1363 lo -=sum; 1364 double up = rowupper[i]; 1365 if (up<1.0e20) 1366 up -= sum; 1367 //printf("row bounds %g %g\n",lo,up); 1368 if (0) { 1369 double sum=0.0; 1370 double x=0.0; 1371 for (int k=0;k<ncols;k++) { 1372 CoinBigIndex j; 1373 double value=colsol[k]; 1374 x+=value*cost[k]; 1375 for (j=columnStart[k];j<columnStart[k]+columnLength[k];j++) { 1376 int irow=row[j]; 1377 if (irow==i) 1378 sum += element[j]*value; 1379 } 1380 } 1381 printf("Before sum %g <= %g <= %g cost %.18g\n", 1382 rowlower[i],sum,rowupper[i],x); 1383 } 1384 // set all to zero 1385 iCol =posSlack[i]; 1386 while (iCol>=0) { 1387 colsol[iCol]=0.0; 1388 iCol=nextSlack[iCol]; 1389 } 1390 iCol =negSlack[i]; 1391 while (iCol>=0) { 1392 colsol[iCol]=0.0; 1393 iCol=nextSlack[iCol]; 1394 } 1395 { 1396 int iCol; 1397 iCol =posSlack[i]; 1398 while (iCol>=0) { 1399 //printf("col %d el %g sol %g bounds %g %g cost %g\n", 1400 // iCol,element[columnStart[iCol]], 1401 // colsol[iCol],lower[iCol],upper[iCol],cost[iCol]); 1402 iCol = nextSlack[iCol]; 1403 } 1404 iCol =negSlack[i]; 1405 while (iCol>=0) { 1406 //printf("col %d el %g sol %g bounds %g %g cost %g\n", 1407 // iCol,element[columnStart[iCol]], 1408 // colsol[iCol],lower[iCol],upper[iCol],cost[iCol]); 1409 iCol = nextSlack[iCol]; 1410 } 1411 } 1412 //printf("now what?\n"); 1413 int n=0; 1414 bool basic=false; 1415 if (lo>0.0) { 1416 // Add in positive 1417 iCol =posSlack[i]; 1418 while (iCol>=0) { 1419 double value = element[columnStart[iCol]]; 1420 ratio[n]=cost[iCol]/value; 1421 which[n++]=iCol; 1422 iCol=nextSlack[iCol]; 1423 } 1424 CoinSort_2(ratio,ratio+n,which); 1425 for (int i=0;i<n;i++) { 1426 iCol=which[i]; 1427 double value=element[columnStart[iCol]]; 1428 if (lo>=upper[iCol]*value) { 1429 value *=upper[iCol]; 1430 sum+=value; 1431 lo-=value; 1432 colsol[iCol]=upper[iCol]; 1433 } else { 1434 value = lo/value; 1435 sum += lo; 1436 lo=0.0; 1437 colsol[iCol]=value; 1438 model_->setColumnStatus(iCol,ClpSimplex::basic); 1439 basic=true; 1440 } 1441 if (lo<1.0e-7) 1442 break; 1443 } 1444 } else if (up<0.0) { 1445 // Use lo so coding is more similar 1446 lo=-up; 1447 // Add in negative 1448 iCol =negSlack[i]; 1449 while (iCol>=0) { 1450 double value = -element[columnStart[iCol]]; 1451 ratio[n]=cost[iCol]/value; 1452 which[n++]=iCol; 1453 iCol=nextSlack[iCol]; 1454 } 1455 CoinSort_2(ratio,ratio+n,which); 1456 for (int i=0;i<n;i++) { 1457 iCol=which[i]; 1458 double value=-element[columnStart[iCol]]; 1459 if (lo>=upper[iCol]*value) { 1460 value *=upper[iCol]; 1461 sum+=value; 1462 lo-=value; 1463 colsol[iCol]=upper[iCol]; 1464 } else { 1465 value = lo/value; 1466 sum += lo; 1467 lo=0.0; 1468 colsol[iCol]=value; 1469 model_->setColumnStatus(iCol,ClpSimplex::basic); 1470 basic=true; 1471 } 1472 if (lo<1.0e-7) 1473 break; 1474 } 1475 } 1476 if (0) { 1477 double sum2=0.0; 1478 double x=0.0; 1479 for (int k=0;k<ncols;k++) { 1480 CoinBigIndex j; 1481 double value=colsol[k]; 1482 x+=value*cost[k]; 1483 for (j=columnStart[k];j<columnStart[k]+columnLength[k];j++) { 1484 int irow=row[j]; 1485 if (irow==i) 1486 sum2 += element[j]*value; 1487 } 1488 } 1489 printf("after sum %g <= %g <= %g cost %.18g (sum = %g)\n", 1490 rowlower[i],sum2,rowupper[i],x,sum); 1491 } 1492 rowsol[i]=sum; 1493 if (basic) { 1494 if (fabs(rowsol[i]-rowlower[i])<fabs(rowsol[i]-rowupper[i])) 1495 model_->setRowStatus(i,ClpSimplex::atLowerBound); 1496 else 1497 model_->setRowStatus(i,ClpSimplex::atUpperBound); 1498 } 1499 } else { 1500 int n=0; 1501 int iCol; 1502 iCol =posSlack[i]; 1503 while (iCol>=0) { 1504 if (colsol[iCol]>lower[iCol]+1.0e-8&& 1505 colsol[iCol]<upper[iCol]-1.0e-8) { 1506 model_->setColumnStatus(iCol,ClpSimplex::basic); 1507 n++; 1508 } 1509 iCol = nextSlack[iCol]; 1510 } 1511 iCol =negSlack[i]; 1512 while (iCol>=0) { 1513 if (colsol[iCol]>lower[iCol]+1.0e-8&& 1514 colsol[iCol]<upper[iCol]-1.0e-8) { 1515 model_->setColumnStatus(iCol,ClpSimplex::basic); 1516 n++; 1517 } 1518 iCol = nextSlack[iCol]; 1519 } 1520 if (n) { 1521 if (fabs(rowsol[i]-rowlower[i])<fabs(rowsol[i]-rowupper[i])) 1522 model_->setRowStatus(i,ClpSimplex::atLowerBound); 1523 else 1524 model_->setRowStatus(i,ClpSimplex::atUpperBound); 1525 #ifdef CLP_INVESTIGATE 1526 if (n>1) 1527 printf("%d basic on row %d!\n",n,i); 1528 #endif 1529 } 1530 } 1531 } 1532 } 1533 delete [] ratio; 1534 delete [] which; 1535 #else 1316 1536 for (i=0;i<nrows;i++) { 1317 1537 int n=0; 1318 1538 int iCol; 1319 1539 iCol =posSlack[i]; 1320 if(iCol>=0) {1540 while (iCol>=0) { 1321 1541 if (colsol[iCol]>lower[iCol]+1.0e-8&& 1322 1542 colsol[iCol]<upper[iCol]-1.0e-8) { … … 1324 1544 n++; 1325 1545 } 1326 while (nextSlack[iCol]>=0) { 1327 iCol = nextSlack[iCol]; 1328 if (colsol[iCol]>lower[iCol]+1.0e-8&& 1329 colsol[iCol]<upper[iCol]-1.0e-8) { 1330 model_->setColumnStatus(iCol,ClpSimplex::basic); 1331 n++; 1332 } 1333 } 1546 iCol = nextSlack[iCol]; 1334 1547 } 1335 1548 iCol =negSlack[i]; 1336 if(iCol>=0) {1549 while (iCol>=0) { 1337 1550 if (colsol[iCol]>lower[iCol]+1.0e-8&& 1338 1551 colsol[iCol]<upper[iCol]-1.0e-8) { … … 1340 1553 n++; 1341 1554 } 1342 while (nextSlack[iCol]>=0) { 1343 iCol = nextSlack[iCol]; 1344 if (colsol[iCol]>lower[iCol]+1.0e-8&& 1345 colsol[iCol]<upper[iCol]-1.0e-8) { 1346 model_->setColumnStatus(iCol,ClpSimplex::basic); 1347 n++; 1348 } 1349 } 1555 iCol = nextSlack[iCol]; 1350 1556 } 1351 1557 if (n) { … … 1354 1560 else 1355 1561 model_->setRowStatus(i,ClpSimplex::atUpperBound); 1562 #ifdef CLP_INVESTIGATE 1356 1563 if (n>1) 1357 1564 printf("%d basic on row %d!\n",n,i); 1358 } 1359 } 1565 #endif 1566 } 1567 } 1568 #endif 1360 1569 } 1361 1570 double maxmin;
Note: See TracChangeset
for help on using the changeset viewer.