- Timestamp:
- Jun 24, 2013 6:13:05 AM (6 years ago)
- Location:
- trunk/Couenne/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Couenne/src/branch/CouenneChooseStrong.cpp
r930 r967 99 99 100 100 /***********************************************************************/ 101 // returns 102 // 4 if not a variable object (deemed good) 103 // 3 if variable object and is good 104 // 2 if variable object and is not good (i.e. fixed variable) 105 // 1 if OsiSimpleBranchingObject and not good (deprecated) 101 106 int CouenneChooseStrong::goodCandidate(OsiSolverInterface *solver, 102 107 OsiBranchingInformation *info, … … 106 111 int vInd = object [iObject] -> columnNumber (); 107 112 108 if (vInd < 0) return 3; // not a variable object, so deem it good113 if (vInd < 0) return 4; // not a variable object, so deem it good 109 114 110 115 bool varIsInt = solver -> isInteger (vInd); … … 211 216 We can pick up a forced branch (can change bound) from whichForcedObject() and whichForcedWay() 212 217 If we have a solution then we can pick up from goodObjectiveValue() and goodSolution() 218 219 Note: Must not return 4 for a non variable object 213 220 */ 214 221 int CouenneChooseStrong::chooseVariable (OsiSolverInterface * solver, … … 255 262 256 263 if (isRoot) { 257 numberStrong = CoinMax(numberStrong_, numberStrongRoot_);264 numberStrong = numberStrongRoot_; 258 265 } 259 266 … … 272 279 273 280 results_.clear(); 274 int returnCode = 0; 281 282 // All look satisfied; 283 //useful if all objects considered for strong branching use pseudo costs 284 int returnCode = 1; 285 275 286 int returnCodeSB = 0; 276 287 bestObjectIndex_ = -1; … … 466 477 } 467 478 468 if((needBranch == 3) &&479 if((needBranch >= 3) && 469 480 saveBestCand(object, iObject, value, upEstimate, downEstimate, 470 481 bestTrustedVal1, … … 546 557 547 558 // store bad candidates in secondary best 548 if(needBranch !=3) {559 if(needBranch < 3) { 549 560 if(saveBestCand(object, iObject, value, 550 561 upEstimate, downEstimate, … … 566 577 bestTrustedVal1, 567 578 bestTrustedVal2, bestObjectIndex_, bestWhichWay_)) { 579 if(returnCode == 1) { // first saved object 580 // is using pseudo-cost 581 returnCode = 0; 582 } 583 568 584 returnCode = (returnCode ? 3 : 0); // if returnCode was 2 or 3 569 585 // it becomes 3 … … 582 598 bestWhichWay_ = bestWhichWay2; 583 599 bestTrustedVal1 = bestTrusted2Val1; 584 returnCode = 4; 600 if(goodCandidate(solver, info, object, 601 bestObjectIndex_, prec) != 4) { 602 returnCode = 4; 603 } 604 else { 605 returnCode = 3; 606 } 585 607 } 586 608 } … … 604 626 if(objectVarInd >= 0) { 605 627 double vUb = solver->getColUpper()[objectVarInd]; 606 double vLb = solver->getColLower()[objectVarInd]; 628 char strUb[400], strLb[400]; 629 if(vUb > 1e50) { 630 sprintf(strUb, "+inf"); 631 } 632 else { 633 sprintf(strUb, "%f", vUb); 634 } 635 double vLb = solver->getColLower()[objectVarInd]; 636 if(vLb < -1e50) { 637 sprintf(strLb, "-inf"); 638 } 639 else { 640 sprintf(strLb, "%f", vLb); 641 } 607 642 double vSolI = info->solution_[objectVarInd]; 608 643 double vSolS = solver->getColSolution()[objectVarInd]; 609 printf("Branch on object %d (var: %d): solInfo: %10.4f SolSolver: %10.4f low: %10.4f up: %10.4f\n", 610 bestObjectIndex_, objectVarInd, vSolI, vSolS, vLb, vUb); 644 printf("Branch on object %d (var: %d): solInfo: %10.4f SolSolver: %10.4f low: %s up: %s\n", 645 bestObjectIndex_, objectVarInd, vSolI, vSolS, strLb, strU 646 647 b); 611 648 } 612 649 else { … … 618 655 message(CHOSEN_VAR)<<bestObjectIndex_<<CoinMessageEol; 619 656 620 if (numberFixed==numberUnsatisfied_&&numberFixed) 621 returnCode=4; 657 if((numberFixed==numberUnsatisfied_&&numberFixed) && 658 (goodCandidate(solver, info, object, bestObjectIndex_, prec) != 4)) { 659 returnCode = 4; 660 } 622 661 623 662 if((returnCode == 2) || (returnCode == 3)) { 624 663 if((objectVarInd > -1) && 625 (goodCandidate(solver, info, object, bestObjectIndex_, prec) != 2)) {664 (goodCandidate(solver, info, object, bestObjectIndex_, prec) != 4)) { 626 665 // Can occur: two objects for same var, first scanned object 627 666 // has both branches feasible and is saved as bestObjectIndex_, … … 703 742 704 743 #ifdef TRACE_STRONG 744 printf("Start CouenneChooseStrong::setupList()\n"); 705 745 OsiObject ** object = info->solver_->objects(); 706 746 if(problem_->doPrint_) { … … 759 799 #ifdef TRACE_STRONG 760 800 if(problem_->doPrint_) { 761 printf("Strong list: (obj_ind var_ind priority useful )\n");801 printf("Strong list: (obj_ind var_ind priority useful viol)\n"); 762 802 printf("numberStrong: %d numberStrongRoot: %d retval: %d\n", 763 803 numberStrong_, numberStrongRoot_, retval); … … 769 809 // } 770 810 // else { 771 811 objectInd = object[list_[i]]->columnNumber(); 772 812 // } 773 printf(" (%d %d %d %6.4f)", list_[i], objectInd, 774 object[list_[i]]->priority(), useful_[i]); 775 } 776 printf("\n"); 777 } 813 814 int wayprint; 815 double violprint = object[list_[i]]->infeasibility(info, wayprint); 816 if(violprint < COIN_DBL_MAX / 100) { 817 printf(" (%d %d %d %6.4f %6.4f)", list_[i], objectInd, 818 object[list_[i]]->priority(), useful_[i], 819 violprint); 820 } 821 else { 822 printf(" (%d %d %d %6.4f +inf)", list_[i], objectInd, 823 object[list_[i]]->priority(), useful_[i]); 824 } 825 printf("\n"); 826 } 778 827 #endif 779 828 … … 785 834 jnlst_ -> Printf (J_ITERSUMMARY, J_BRANCHING, 786 835 "----------------- (strong) setup list done - %d infeasibilities\n", retval); 836 837 #if (defined TRACE_STRONG) 838 printf("Done CouenneChooseStrong::setupList()\n"); 839 #endif 787 840 788 841 problem_ -> domain () -> pop (); … … 876 929 } 877 930 printf("\nmaxViol: %g minPosViol: %g\n", maxViol, minPosViol); 878 879 931 } /* printObjViol */ 880 932 -
trunk/Couenne/src/problem/checkNLP.cpp
r940 r967 419 419 420 420 double 421 v = (*(variables_ [i])) (), 422 f = (*(variables_ [i] -> Image ())) (); 423 424 printf ("[%g,%g]\n", v, f); 425 426 printf ("checking aux -- %+.12e = %+.12e [%+.12e] ", v, f, v-f); 427 variables_ [i] -> print (); printf (" := "); 421 vdb = (*(variables_ [i])) (), 422 fdb = (*(variables_ [i] -> Image ())) (); 423 424 double 425 del = 426 ((v -> sign () == expression::AUX_GEQ) && (vdb >= fdb)) ? 0. : 427 ((v -> sign () == expression::AUX_LEQ) && (vdb <= fdb)) ? 0. : 428 fabs (vdb - fdb); 429 430 printf ("[%g,%g]\n", vdb, fdb); 431 432 printf ("checking aux -- %+.12e = %+.12e [%+.12e] ", vdb, fdb, del); 433 variables_ [i] -> print (); 434 if(v->sign()== expression::AUX_GEQ) printf(" >= "); 435 if(v->sign()== expression::AUX_LEQ) printf(" <= "); 436 if(v->sign()== expression::AUX_EQ) printf(" := "); 428 437 variables_ [i] -> Image () -> print (); printf ("\n"); 429 438 } … … 629 638 for (int i=0; i<nOrigVars_ - ndefined_; i++) 630 639 printf ("%.12e ", solution [i]); 631 printf ("\nCouenneProblem::checkNLP2(): Start checking computed_solution\n");640 printf ("\nCouenneProblem::checkNLP2(): Start checking recomputed_solution\n"); 632 641 } 633 642 … … 642 651 643 652 if (stopAtFirstViol && !isFeasRec && Jnlst () -> ProduceOutput (Ipopt::J_ALL, J_PROBLEM)) 644 printf("CouenneProblem::checkNLP2(): modified_solution is infeasible (some orig vars not integer feasible; violation: %12.10g)\n", maxViolRecSol);653 printf("CouenneProblem::checkNLP2(): recomputed_solution is infeasible (some orig vars not integer feasible; violation: %12.10g)\n", maxViolRecSol); 645 654 646 655 #ifdef CHECK … … 659 668 // install NL solution candidate and original bounds in evaluation structure 660 669 // bounds are important so that getAuxs below works properly 661 domain_.push(nVars(), domain_.x(), getRecordBestSol()->getInitDomLb(),670 domain_.push(nVars(), solution, getRecordBestSol()->getInitDomLb(), 662 671 getRecordBestSol()->getInitDomUb(), false); 663 672 … … 678 687 double maxDelta = 0; 679 688 for (int i=0; i<nVars (); i++) { 680 printf ("%4d %+e %+e [%+e %+e] %+e\n", i, solution[i], domain_.x (i), domain_.lb (i), domain_.ub (i), solution[i] - domain_.x (i)); 681 if (maxDelta < fabs(solution[i] - domain_.x(i))) maxDelta = fabs (solution[i] - domain_.x(i)); 682 } 683 printf ("maxDelta: %.12g\n", maxDelta); 689 exprVar *v = variables_ [i]; 690 if (v -> Multiplicity () <= 0) 691 continue; 692 if(i < nOrigVars_ - ndefined_) { 693 double soli = solution[i]; 694 double domi = domain_.x (i); 695 double domlbi = domain_.lb (i); 696 double domubi = domain_.ub (i); 697 printf ("%4d %+e %+e [%+e %+e] %+e\n", i, solution[i], domain_.x (i), domain_.lb (i), domain_.ub (i), solution[i] - domain_.x (i)); 698 if (maxDelta < fabs(solution[i] - domain_.x(i))) maxDelta = fabs (solution[i] - domain_.x(i)); 699 } 700 else { 701 if(v -> Type() == AUX) { 702 printf ("%4d ------ %+e [%+e %+e]\n", i, domain_.x (i), domain_.lb (i), domain_.ub (i)); 703 } 704 } 705 printf ("maxDelta: %.12g\n", maxDelta); 706 } 684 707 } 685 708 … … 912 935 // printf ("]\n"); 913 936 914 printf ("checkNLP2(): RETURN: selected solution isfeasible (maxViol: %g)\n", maxViol);937 printf ("checkNLP2(): RETURN: feasible (maxViol: %g)\n", maxViol); 915 938 } 916 939 else { 917 printf ("checkNLP2(): RETURN: modified_solution and solution are infeasible\n");940 printf ("checkNLP2(): RETURN: recomputed_solution and solution are infeasible\n"); 918 941 if(!stopAtFirstViol) { 919 942 printf("(maxViol: %g)\n", maxViol);
Note: See TracChangeset
for help on using the changeset viewer.