Changeset 1615 for stable/2.6/Cbc/src/CbcSolver.cpp
- Timestamp:
- Mar 21, 2011 11:48:47 PM (10 years ago)
- Location:
- stable/2.6
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable/2.6
- Property svn:mergeinfo changed
/trunk (added) merged: 1539-1540,1555-1558
- Property svn:mergeinfo changed
-
stable/2.6/Cbc
- Property svn:mergeinfo changed
/trunk/Cbc merged: 1539-1540,1555-1558
- Property svn:mergeinfo changed
-
stable/2.6/Cbc/src/CbcSolver.cpp
r1508 r1615 1621 1621 std::string field; 1622 1622 if (!noPrinting_) { 1623 sprintf(generalPrint, "Cbc version %s, build %s", 1624 CBC_VERSION, __DATE__); 1623 sprintf(generalPrint, 1624 "Welcome to the CBC MILP Solver \n"); 1625 if (strcmp(CBC_VERSION, "trunk")){ 1626 sprintf(generalPrint + strlen(generalPrint), 1627 "Version: %s \n", CBC_VERSION); 1628 }else{ 1629 sprintf(generalPrint + strlen(generalPrint), 1630 "Version: Trunk (unstable) \n"); 1631 } 1632 sprintf(generalPrint + strlen(generalPrint), 1633 "Build Date: %s \n", __DATE__); 1634 #ifdef CBC_SVN_REV 1635 sprintf(generalPrint + strlen(generalPrint), 1636 "Revision Number: %d \n", CBC_SVN_REV); 1637 #endif 1625 1638 generalMessageHandler->message(CLP_GENERAL, generalMessages) 1626 1639 << generalPrint … … 2644 2657 model_.setProblemStatus(iStatus); 2645 2658 model_.setSecondaryStatus(iStatus2); 2646 //assert (lpSolver==clpSolver->getModelPtr()); 2659 if ((iStatus == 2 || iStatus2 > 0) && 2660 !noPrinting_) { 2661 std::string statusName[] = {"", "Stopped on ", "Run abandoned", "", "", "User ctrl-c"}; 2662 std::string minor[] = {"Optimal solution found", "Linear relaxation infeasible", "Optimal solution found (within gap tolerance)", "node limit", "time limit", "user ctrl-c", "solution limit", "Linear relaxation unbounded", "Problem proven infeasible"}; 2663 sprintf(generalPrint, "\nResult - %s%s\n\n", 2664 statusName[iStatus].c_str(), 2665 minor[iStatus2].c_str()); 2666 sprintf(generalPrint + strlen(generalPrint), 2667 "Enumerated nodes: 0\n"); 2668 sprintf(generalPrint + strlen(generalPrint), 2669 "Total iterations: 0\n"); 2670 sprintf(generalPrint + strlen(generalPrint), 2671 "Time (seconds): %.2f\n", 2672 CoinCpuTime() - time0); 2673 generalMessageHandler->message(CLP_GENERAL, generalMessages) 2674 << generalPrint 2675 << CoinMessageEol; 2676 } 2677 //assert (lpSolver==clpSolver->getModelPtr()); 2647 2678 assert (clpSolver == model_.solver()); 2648 2679 clpSolver->setWarmStart(NULL); … … 5993 6024 #endif 5994 6025 delete [] bestSolution; 5995 std::string statusName[] = {"Finished", "Stopped on ", "Difficulties", 5996 "", "", "User ctrl-c" 5997 }; 5998 std::string minor[] = {"", "", "gap", "nodes", "time", "", "solutions", "user ctrl-c", "proven-infeasible"}; 6026 std::string statusName[] = {"", "Stopped on ", "Run abandoned", "", "", "User ctrl-c"}; 6027 std::string minor[] = {"Optimal solution found", "Linear relaxation infeasible", "Optimal solution found (within gap tolerance)", "node limit", "time limit", "user ctrl-c", "solution limit", "Linear relaxation unbounded", "Problem proven infeasible"}; 5999 6028 int iStat = babModel_->status(); 6000 6029 int iStat2 = babModel_->secondaryStatus(); … … 6011 6040 statistics_result = statusName[iStat];; 6012 6041 if (!noPrinting_) { 6013 sprintf(generalPrint, "Result - %s%s objective %.16g after %d nodes and %d iterations - took %.2f seconds (total time %.2f)", 6014 statusName[iStat].c_str(), minor[iStat2].c_str(), 6015 babModel_->getObjValue(), babModel_->getNodeCount(), 6016 babModel_->getIterationCount(), time2 - time1, time2 - time0); 6017 generalMessageHandler->message(CLP_GENERAL, generalMessages) 6018 << generalPrint 6019 << CoinMessageEol; 6042 sprintf(generalPrint, "\nResult - %s%s\n", 6043 statusName[iStat].c_str(), 6044 minor[iStat2].c_str()); 6045 generalMessageHandler->message(CLP_GENERAL, generalMessages) 6046 << generalPrint 6047 << CoinMessageEol; 6048 if (babModel_->bestSolution()){ 6049 sprintf(generalPrint, 6050 "Objective value: %.8f\n", 6051 babModel_->getObjValue()); 6052 }else{ 6053 sprintf(generalPrint, 6054 "No feasible solution found\n"); 6055 } 6056 if (iStat2 >= 2 && iStat2 <=6){ 6057 sprintf(generalPrint + strlen(generalPrint), 6058 "Lower bound: %.3f\n", 6059 babModel_->getBestPossibleObjValue()); 6060 if (babModel_->bestSolution()){ 6061 sprintf(generalPrint + strlen(generalPrint), 6062 "Gap: %.2f\n", 6063 (babModel_->getObjValue()-babModel_->getBestPossibleObjValue())/babModel_->getBestPossibleObjValue()); 6064 } 6065 } 6066 sprintf(generalPrint + strlen(generalPrint), 6067 "Enumerated nodes: %d\n", 6068 babModel_->getNodeCount()); 6069 sprintf(generalPrint + strlen(generalPrint), 6070 "Total iterations: %d\n", 6071 babModel_->getIterationCount()); 6072 sprintf(generalPrint + strlen(generalPrint), 6073 "Time (seconds): %.2f\n", 6074 time2 - time1); 6075 sprintf(generalPrint + strlen(generalPrint), 6076 "Total time: %.2f\n", 6077 time2 - time0); 6078 generalMessageHandler->message(CLP_GENERAL, generalMessages) 6079 << generalPrint 6080 << CoinMessageEol; 6020 6081 } 6021 6082 int returnCode = callBack(babModel_, 5); … … 7494 7555 double objValue = lpSolver->getObjValue() * lpSolver->getObjSense(); 7495 7556 int iStat = lpSolver->status(); 7496 if (integerStatus >= 0) 7557 int iStat2 = -1; 7558 if (integerStatus >= 0){ 7497 7559 iStat = integerStatus; 7560 iStat2 = babModel_->secondaryStatus(); 7561 } 7498 7562 if (iStat == 0) { 7499 7563 fprintf(fp, "Optimal" ); 7564 if (iStat2 == 2){ 7565 fprintf(fp, " (within gap tolerance)" ); 7566 } 7500 7567 } else if (iStat == 1) { 7501 7568 // infeasible … … 7505 7572 fprintf(fp, "Unbounded" ); 7506 7573 } else if (iStat >= 3 && iStat <= 5) { 7507 if (iStat == 3) 7508 fprintf(fp, "Stopped on iterations or time" ); 7509 else if (iStat == 4) 7510 fprintf(fp, "Stopped on difficulties" ); 7511 else 7512 fprintf(fp, "Stopped on ctrl-c" ); 7574 if (iStat == 3) { 7575 if (iStat2 == 4){ 7576 fprintf(fp, "Stopped on time" ); 7577 }else{ 7578 fprintf(fp, "Stopped on iterations" ); 7579 } 7580 } else if (iStat == 4){ 7581 fprintf(fp, "Stopped on difficulties" ); 7582 } else { 7583 fprintf(fp, "Stopped on ctrl-c" ); 7584 } 7513 7585 if (babModel_ && !babModel_->bestSolution()) 7514 7586 fprintf(fp, " (no integer solution - continuous used)"); 7515 7587 } else if (iStat == 6) { 7516 7517 7588 // bab infeasible 7589 fprintf(fp, "Integer infeasible" ); 7518 7590 } else { 7519 7520 } 7521 fprintf(fp, " - objective value % 15.8g\n", objValue);7591 fprintf(fp, "Status unknown" ); 7592 } 7593 fprintf(fp, " - objective value %.8f\n", objValue); 7522 7594 } 7523 7595 #endif … … 7906 7978 babModel_ = NULL; 7907 7979 model_.solver()->setWarmStart(NULL); 7908 sprintf(generalPrint, "Total time %.2f", CoinCpuTime() - time0);7909 generalMessageHandler->message(CLP_GENERAL, generalMessages)7910 << generalPrint7911 << CoinMessageEol;7980 //sprintf(generalPrint, "Total time %.2f", CoinCpuTime() - time0); 7981 //generalMessageHandler->message(CLP_GENERAL, generalMessages) 7982 //<< generalPrint 7983 //<< CoinMessageEol; 7912 7984 return 0; 7913 7985 }
Note: See TracChangeset
for help on using the changeset viewer.