Changeset 1539
- Timestamp:
- Nov 28, 2010 12:15:22 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cbc/src/CbcSolver.cpp
r1508 r1539 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 sprintf(generalPrint, 6049 "Objective value: %.3f\n", 6050 babModel_->getObjValue()); 6051 if (iStat2 >= 2 && iStat2 <=6){ 6052 sprintf(generalPrint + strlen(generalPrint), 6053 "Lower bound: %.3f\n", 6054 babModel_->getBestPossibleObjValue()); 6055 sprintf(generalPrint + strlen(generalPrint), 6056 "Gap: %.2f\n", 6057 (babModel_->getObjValue()-babModel_->getBestPossibleObjValue())/babModel_->getBestPossibleObjValue()); 6058 } 6059 sprintf(generalPrint + strlen(generalPrint), 6060 "Enumerated nodes: %d\n", 6061 babModel_->getNodeCount()); 6062 sprintf(generalPrint + strlen(generalPrint), 6063 "Total iterations: %d\n", 6064 babModel_->getIterationCount()); 6065 sprintf(generalPrint + strlen(generalPrint), 6066 "Time (seconds): %.2f\n", 6067 time2 - time1); 6068 sprintf(generalPrint + strlen(generalPrint), 6069 "Total time: %.2f\n", 6070 time2 - time0); 6071 generalMessageHandler->message(CLP_GENERAL, generalMessages) 6072 << generalPrint 6073 << CoinMessageEol; 6020 6074 } 6021 6075 int returnCode = callBack(babModel_, 5); … … 7494 7548 double objValue = lpSolver->getObjValue() * lpSolver->getObjSense(); 7495 7549 int iStat = lpSolver->status(); 7496 if (integerStatus >= 0) 7550 int iStat2 = -1; 7551 if (integerStatus >= 0){ 7497 7552 iStat = integerStatus; 7553 iStat2 = babModel_->secondaryStatus(); 7554 } 7498 7555 if (iStat == 0) { 7499 7556 fprintf(fp, "Optimal" ); 7557 if (iStat2 == 2){ 7558 fprintf(fp, " (within gap tolerance)" ); 7559 } 7500 7560 } else if (iStat == 1) { 7501 7561 // infeasible … … 7505 7565 fprintf(fp, "Unbounded" ); 7506 7566 } 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" ); 7567 if (iStat == 3) { 7568 if (iStat2 == 4){ 7569 fprintf(fp, "Stopped on time" ); 7570 }else{ 7571 fprintf(fp, "Stopped on iterations" ); 7572 } 7573 } else if (iStat == 4){ 7574 fprintf(fp, "Stopped on difficulties" ); 7575 } else { 7576 fprintf(fp, "Stopped on ctrl-c" ); 7577 } 7513 7578 if (babModel_ && !babModel_->bestSolution()) 7514 7579 fprintf(fp, " (no integer solution - continuous used)"); 7515 7580 } else if (iStat == 6) { 7516 7517 7581 // bab infeasible 7582 fprintf(fp, "Integer infeasible" ); 7518 7583 } else { 7519 7584 fprintf(fp, "Status unknown" ); 7520 7585 } 7521 7586 fprintf(fp, " - objective value %15.8g\n", objValue); … … 7906 7971 babModel_ = NULL; 7907 7972 model_.solver()->setWarmStart(NULL); 7908 sprintf(generalPrint, "Total time %.2f", CoinCpuTime() - time0);7909 generalMessageHandler->message(CLP_GENERAL, generalMessages)7910 << generalPrint7911 << CoinMessageEol;7973 //sprintf(generalPrint, "Total time %.2f", CoinCpuTime() - time0); 7974 //generalMessageHandler->message(CLP_GENERAL, generalMessages) 7975 //<< generalPrint 7976 //<< CoinMessageEol; 7912 7977 return 0; 7913 7978 }
Note: See TracChangeset
for help on using the changeset viewer.