Ignore:
Timestamp:
Jun 24, 2013 6:13:05 AM (7 years ago)
Author:
fmargot
Message:

fix bug in checkNLP2 and handling of non-var objects in strong branching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Couenne/src/problem/checkNLP.cpp

    r940 r967  
    419419
    420420      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(" := ");
    428437      variables_ [i] -> Image () -> print (); printf ("\n");
    429438    }
     
    629638    for (int i=0; i<nOrigVars_ - ndefined_; i++)
    630639      printf ("%.12e ", solution [i]);
    631     printf ("\nCouenneProblem::checkNLP2(): Start checking computed_solution\n");
     640    printf ("\nCouenneProblem::checkNLP2(): Start checking recomputed_solution\n");
    632641  }
    633642
     
    642651
    643652  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);
    645654
    646655#ifdef CHECK
     
    659668  // install NL solution candidate and original bounds in evaluation structure
    660669  // bounds are important so that getAuxs below works properly
    661   domain_.push(nVars(), domain_.x(), getRecordBestSol()->getInitDomLb(),
     670  domain_.push(nVars(), solution, getRecordBestSol()->getInitDomLb(),
    662671               getRecordBestSol()->getInitDomUb(), false);
    663672
     
    678687    double maxDelta = 0;
    679688    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    }
    684707  }
    685708
     
    912935      // printf ("]\n");
    913936
    914       printf ("checkNLP2(): RETURN: selected solution is feasible (maxViol: %g)\n", maxViol);
     937      printf ("checkNLP2(): RETURN: feasible (maxViol: %g)\n", maxViol);
    915938    }
    916939    else {
    917       printf ("checkNLP2(): RETURN: modified_solution and solution are infeasible\n");
     940      printf ("checkNLP2(): RETURN: recomputed_solution and solution are infeasible\n");
    918941      if(!stopAtFirstViol) {
    919942        printf("(maxViol: %g)\n", maxViol);
Note: See TracChangeset for help on using the changeset viewer.