Changeset 142


Ignore:
Timestamp:
Nov 29, 2006 3:54:55 PM (13 years ago)
Author:
andreasw
Message:

committed changes in curvature branching heuristic

Location:
branches/devel/Bonmin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Bonmin/configure

    r121 r142  
    27822782  fi
    27832783
     2784  # if PM doesn't want the warning messages, take them out
     2785  if test x"$coin_skip_warn_cflags" = xyes; then
     2786    coin_warn_cflags=
     2787  fi
     2788
    27842789  if test x${DBG_CFLAGS+set} != xset; then
    27852790    DBG_CFLAGS="$coin_dbg_cflags $coin_add_cflags $coin_warn_cflags"
     
    35673572  fi
    35683573
     3574  # if PM doesn't want the warning messages, take them out
     3575  if test x"$coin_skip_warn_cxxflags" = xyes; then
     3576    coin_warn_cxxflags=
     3577  fi
     3578
    35693579  if test x${DBG_CXXFLAGS+set} != xset; then
    35703580    DBG_CXXFLAGS="$coin_dbg_cxxflags $coin_add_cxxflags $coin_warn_cxxflags"
     
    47504760*-*-irix6*)
    47514761  # Find out which ABI we are using.
    4752   echo '#line 4752 "configure"' > conftest.$ac_ext
     4762  echo '#line 4762 "configure"' > conftest.$ac_ext
    47534763  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
    47544764  (eval $ac_compile) 2>&5
     
    58845894
    58855895# Provide some information about the compiler.
    5886 echo "$as_me:5886:" \
     5896echo "$as_me:5896:" \
    58875897     "checking for Fortran 77 compiler version" >&5
    58885898ac_compiler=`set X $ac_compile; echo $2`
     
    69516961   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    69526962   -e 's:$: $lt_compiler_flag:'`
    6953    (eval echo "\"\$as_me:6953: $lt_compile\"" >&5)
     6963   (eval echo "\"\$as_me:6963: $lt_compile\"" >&5)
    69546964   (eval "$lt_compile" 2>conftest.err)
    69556965   ac_status=$?
    69566966   cat conftest.err >&5
    6957    echo "$as_me:6957: \$? = $ac_status" >&5
     6967   echo "$as_me:6967: \$? = $ac_status" >&5
    69586968   if (exit $ac_status) && test -s "$ac_outfile"; then
    69596969     # The compiler can only warn and ignore the option if not recognized
     
    72197229   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    72207230   -e 's:$: $lt_compiler_flag:'`
    7221    (eval echo "\"\$as_me:7221: $lt_compile\"" >&5)
     7231   (eval echo "\"\$as_me:7231: $lt_compile\"" >&5)
    72227232   (eval "$lt_compile" 2>conftest.err)
    72237233   ac_status=$?
    72247234   cat conftest.err >&5
    7225    echo "$as_me:7225: \$? = $ac_status" >&5
     7235   echo "$as_me:7235: \$? = $ac_status" >&5
    72267236   if (exit $ac_status) && test -s "$ac_outfile"; then
    72277237     # The compiler can only warn and ignore the option if not recognized
     
    73237333   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    73247334   -e 's:$: $lt_compiler_flag:'`
    7325    (eval echo "\"\$as_me:7325: $lt_compile\"" >&5)
     7335   (eval echo "\"\$as_me:7335: $lt_compile\"" >&5)
    73267336   (eval "$lt_compile" 2>out/conftest.err)
    73277337   ac_status=$?
    73287338   cat out/conftest.err >&5
    7329    echo "$as_me:7329: \$? = $ac_status" >&5
     7339   echo "$as_me:7339: \$? = $ac_status" >&5
    73307340   if (exit $ac_status) && test -s out/conftest2.$ac_objext
    73317341   then
     
    96689678  lt_status=$lt_dlunknown
    96699679  cat > conftest.$ac_ext <<EOF
    9670 #line 9670 "configure"
     9680#line 9680 "configure"
    96719681#include "confdefs.h"
    96729682
     
    97689778  lt_status=$lt_dlunknown
    97699779  cat > conftest.$ac_ext <<EOF
    9770 #line 9770 "configure"
     9780#line 9780 "configure"
    97719781#include "confdefs.h"
    97729782
     
    1211212122   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    1211312123   -e 's:$: $lt_compiler_flag:'`
    12114    (eval echo "\"\$as_me:12114: $lt_compile\"" >&5)
     12124   (eval echo "\"\$as_me:12124: $lt_compile\"" >&5)
    1211512125   (eval "$lt_compile" 2>conftest.err)
    1211612126   ac_status=$?
    1211712127   cat conftest.err >&5
    12118    echo "$as_me:12118: \$? = $ac_status" >&5
     12128   echo "$as_me:12128: \$? = $ac_status" >&5
    1211912129   if (exit $ac_status) && test -s "$ac_outfile"; then
    1212012130     # The compiler can only warn and ignore the option if not recognized
     
    1221612226   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    1221712227   -e 's:$: $lt_compiler_flag:'`
    12218    (eval echo "\"\$as_me:12218: $lt_compile\"" >&5)
     12228   (eval echo "\"\$as_me:12228: $lt_compile\"" >&5)
    1221912229   (eval "$lt_compile" 2>out/conftest.err)
    1222012230   ac_status=$?
    1222112231   cat out/conftest.err >&5
    12222    echo "$as_me:12222: \$? = $ac_status" >&5
     12232   echo "$as_me:12232: \$? = $ac_status" >&5
    1222312233   if (exit $ac_status) && test -s out/conftest2.$ac_objext
    1222412234   then
     
    1378613796   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    1378713797   -e 's:$: $lt_compiler_flag:'`
    13788    (eval echo "\"\$as_me:13788: $lt_compile\"" >&5)
     13798   (eval echo "\"\$as_me:13798: $lt_compile\"" >&5)
    1378913799   (eval "$lt_compile" 2>conftest.err)
    1379013800   ac_status=$?
    1379113801   cat conftest.err >&5
    13792    echo "$as_me:13792: \$? = $ac_status" >&5
     13802   echo "$as_me:13802: \$? = $ac_status" >&5
    1379313803   if (exit $ac_status) && test -s "$ac_outfile"; then
    1379413804     # The compiler can only warn and ignore the option if not recognized
     
    1389013900   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    1389113901   -e 's:$: $lt_compiler_flag:'`
    13892    (eval echo "\"\$as_me:13892: $lt_compile\"" >&5)
     13902   (eval echo "\"\$as_me:13902: $lt_compile\"" >&5)
    1389313903   (eval "$lt_compile" 2>out/conftest.err)
    1389413904   ac_status=$?
    1389513905   cat out/conftest.err >&5
    13896    echo "$as_me:13896: \$? = $ac_status" >&5
     13906   echo "$as_me:13906: \$? = $ac_status" >&5
    1389713907   if (exit $ac_status) && test -s out/conftest2.$ac_objext
    1389813908   then
     
    1609716107   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    1609816108   -e 's:$: $lt_compiler_flag:'`
    16099    (eval echo "\"\$as_me:16099: $lt_compile\"" >&5)
     16109   (eval echo "\"\$as_me:16109: $lt_compile\"" >&5)
    1610016110   (eval "$lt_compile" 2>conftest.err)
    1610116111   ac_status=$?
    1610216112   cat conftest.err >&5
    16103    echo "$as_me:16103: \$? = $ac_status" >&5
     16113   echo "$as_me:16113: \$? = $ac_status" >&5
    1610416114   if (exit $ac_status) && test -s "$ac_outfile"; then
    1610516115     # The compiler can only warn and ignore the option if not recognized
     
    1636516375   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    1636616376   -e 's:$: $lt_compiler_flag:'`
    16367    (eval echo "\"\$as_me:16367: $lt_compile\"" >&5)
     16377   (eval echo "\"\$as_me:16377: $lt_compile\"" >&5)
    1636816378   (eval "$lt_compile" 2>conftest.err)
    1636916379   ac_status=$?
    1637016380   cat conftest.err >&5
    16371    echo "$as_me:16371: \$? = $ac_status" >&5
     16381   echo "$as_me:16381: \$? = $ac_status" >&5
    1637216382   if (exit $ac_status) && test -s "$ac_outfile"; then
    1637316383     # The compiler can only warn and ignore the option if not recognized
     
    1646916479   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    1647016480   -e 's:$: $lt_compiler_flag:'`
    16471    (eval echo "\"\$as_me:16471: $lt_compile\"" >&5)
     16481   (eval echo "\"\$as_me:16481: $lt_compile\"" >&5)
    1647216482   (eval "$lt_compile" 2>out/conftest.err)
    1647316483   ac_status=$?
    1647416484   cat out/conftest.err >&5
    16475    echo "$as_me:16475: \$? = $ac_status" >&5
     16485   echo "$as_me:16485: \$? = $ac_status" >&5
    1647616486   if (exit $ac_status) && test -s out/conftest2.$ac_objext
    1647716487   then
  • branches/devel/Bonmin/src/CbcBonmin/BonChooseVariable.cpp

    r98 r142  
    5050}
    5151
     52// For now there is no difference to what John has, so let's just use his
     53//#ifdef UseOurOwn
    5254// Initialize
    5355// PB: ToDo Check
     
    7375  int bestPriority=INT_MAX;
    7476  // pretend one strong even if none
    75   int maximumStrong= Min(numberStrong_ ? numberStrong_ : 1, numberObjects);
     77  int maximumStrong= numberStrong_ ? CoinMin(numberStrong_,numberObjects) : 1;
    7678  int putOther = numberObjects;
    7779  int i;
     
    147149    if (!numberStrong_)
    148150      numberOnList_=0;
    149   }
     151  }
     152  //  DELETEME
     153  for (int i=0; i<Min(numberUnsatisfied_,numberStrong_); i++)
     154    printf("list_[%5d] = %5d, usefull_[%5d] = %23.16e\n", i,list_[i],i,useful_[i]);
    150155  return numberUnsatisfied_;
    151156}
     157//#endif
    152158
    153159/* Choose a variable
     
    181187    const double * b_U = solver->getColUpper();
    182188
    183     int numberObjects = solver_->numberObjects();
    184     int numStrong = Min(numberObjects, numberStrong_);
     189    int numStrong = Min(numberUnsatisfied_, numberStrong_);
    185190    // space for storing the predicted changes in the objective
    186191    double * change_up = new double[numStrong];
     
    212217          numRows, lam, new_mults, orig_d, projected_d, gradLagTd, dTHLagd);
    213218      // ToDo
    214       assert(retval);
     219      if (!retval) {
     220        printf("Problem with curvature estimator for down up.\n");
     221      }
    215222      new_bounds = false;
    216223      new_x = false;
     
    219226      // Determine step size and predicted change
    220227      const double &curr_val = solution[col_number];
    221       if (retval) {
     228      if (retval && projected_d[col_number] != 0.) {
    222229        const double up_val = Min(b_U[col_number],ceil(curr_val));
    223230        double alpha = (up_val-curr_val)/projected_d[col_number];
     
    225232      }
    226233      else {
    227         change_up[i] = large_number;
     234        change_up[i] = -large_number;
    228235      }
    229236
     
    233240          new_bounds, numCols, solution, new_x, z_L, z_U,
    234241          numRows, lam, new_mults, orig_d, projected_d, gradLagTd, dTHLagd);
     242      // ToDo
     243      if (!retval) {
     244        printf("Problem with curvature estimator for down down.\n");
     245      }
    235246
    236247      // Determine step size and predicted change
     
    241252      }
    242253      else {
    243         change_down[i] = large_number;
     254        change_down[i] = -large_number;
    244255      }
    245256
     
    251262    // Determine most promising branching variable
    252263    int best_i = -1;
    253     double best_change = large_number;
     264    double best_change = -large_number;
    254265    for (int i=0; i<numStrong; i++) {
     266      //DELETEME
     267      printf("i = %d down = %e up = %e\n", i,change_down[i], change_up[i]);
    255268      // for now, we look for the best combined change
    256269      double change_min = Min(change_down[i], change_up[i]);
    257270      double change_max = Max(change_down[i], change_up[i]);
    258271      double change_comp = 2.*change_max + change_min;
    259       if (best_change > change_comp) {
     272      if (best_change < change_comp) {
    260273        best_change = change_comp;
    261274        best_i = i;
     
    267280
    268281    assert(best_i != -1);
     282
     283    //DELETEME
     284    printf("best_i = %d  best_change = %e\n", best_i, best_change);
    269285
    270286    bestObjectIndex_=list_[best_i];
  • branches/devel/Bonmin/src/CbcBonmin/BonChooseVariable.hpp

    r98 r142  
    4545  virtual ~BonChooseVariable ();
    4646
     47  //#ifdef UseOurOwn
    4748  /** Sets up strong list and clears all if initialize is true.
    4849      Returns number of infeasibilities. */
    4950  virtual int setupList ( OsiBranchingInformation *info, bool initialize);
     51  //#endif
    5052  /** Choose a variable
    5153      Returns -
  • branches/devel/Bonmin/src/Interfaces/BonCurvatureEstimator.cpp

    r99 r142  
    270270      new_mults = true;
    271271    }
     272    //DELETEME
     273    new_bounds = true;
    272274
    273275    DBG_ASSERT(n == n_);
     
    294296      new_activities = true;
    295297      active_x_.clear();
    296       const Number zTol = 1e-4; // ToDo: make this more elaborate
     298      const Number zTol = 1e300; //1e-2; // ToDo: make this more elaborate
    297299      jnlst_->Printf(J_MOREDETAILED, J_NLP,
    298300                     "List of variables considered fixed (with z_L and z_U)\n");
    299301      for (Index i=0; i<n; i++) {
    300302        if(z_L[i] > zTol || z_U[i] > zTol) {
    301           active_x_.push_back(i+1);
     303          if (z_L[i] > z_U[i]) {
     304            active_x_.push_back(-(i+1));
     305            DBG_ASSERT(x_l_[i] > -1e19);
     306          }
     307          else {
     308            active_x_.push_back(i+1);
     309            DBG_ASSERT(x_u_[i] < 1e19);
     310          }
    302311          jnlst_->Printf(J_MOREDETAILED, J_NLP,
    303312                         "x[%5d] (%e,%e)\n", i, z_L[i], z_U[i]);
     313          DBG_ASSERT(orig_d[i] == 0.);
    304314        }
    305315      }
     
    312322      IpBlasDcopy(m, &zero, 0, jacTd, 1);
    313323      for (Index i=0; i<nnz_jac_; i++) {
    314         const Index &irow = irows_jac_[i];
    315         const Index &jcol = jcols_jac_[i];
     324        const Index& irow = irows_jac_[i];
     325        const Index& jcol = jcols_jac_[i];
    316326        jacTd[irow] += jac_vals_[i]*orig_d[jcol];
    317327      }
     
    323333        if (g_l_[j] < g_u_[j] && fabs(lam[j]) > lamTol) {
    324334          if (lam[j]*jacTd[j] > 0) {
    325             active_g_.push_back(j+1);
     335            if (lam[j] < 0.) {
     336              active_g_.push_back(-(j+1));
     337              DBG_ASSERT(g_l_[j] > -1e19);
     338            }
     339            else {
     340              active_g_.push_back(j+1);
     341              DBG_ASSERT(g_u_[j] < 1e19);
     342            }
     343            //      active_g_.push_back(j+1);
    326344            jnlst_->Printf(J_MOREDETAILED, J_NLP,
    327345                           "g[%5d] (%e,%e)\n", j, lam[j], jacTd[j]);
     
    349367        return false;
    350368      }
     369#ifdef lambdas
    351370      if (!SolveSystem(grad_f_, NULL, NULL, lambda_)) {
    352371        return false;
    353372      }
    354373      IpBlasDscal(m_, -1., lambda_, 1);
     374      if (jnlst_->ProduceOutput(J_MOREVECTOR, J_NLP)) {
     375        jnlst_->Printf(J_MOREVECTOR, J_NLP,
     376                       "Curvature Estimator: least square multiplier:\n");
     377        for (Index i=0; i<m_; i++) {
     378          jnlst_->Printf(J_MOREVECTOR, J_NLP, "lambda[%5d] = %23.16e\n",
     379                         i, lambda_[i]);
     380        }
     381      }
    355382      new_lambda = true;
     383#endif
    356384    }
    357385
     
    361389    }
    362390
    363     // Compute the product with the gradient of the Lagrangian
    364     gradLagTd = IpBlasDdot(n, projected_d, 1, grad_f_, 1);
     391    // Sanity check to see if the thing is indeed in the null space
     392    // (if the constraint gradients are rank-deficient, the solver
     393    // might not have done a good job)
     394    Number* trash = new Number[m_];
     395    for (Index j=0; j<m_; j++) {
     396      trash[j] = 0.;
     397    }
    365398    for (Index i=0; i<nnz_jac_; i++) {
    366399      const Index &irow = irows_jac_[i];
    367400      const Index &jcol = jcols_jac_[i];
    368       gradLagTd += lambda_[irow]*jac_vals_[i]*projected_d[jcol];
     401      if (x_free_map_[jcol] >= 0 && g_fixed_map_[irow] >= 0) {
     402        trash[irow] += jac_vals_[i]*projected_d[jcol];
     403      }
     404    }
     405    if (jnlst_->ProduceOutput(J_MOREVECTOR, J_NLP)) {   
     406      for (Index j=0; j<m_; j++) {
     407        jnlst_->Printf(J_MOREVECTOR, J_NLP,
     408                       "nullspacevector[%5d] = %e\n", j, trash[j]);
     409      }
     410    }
     411    Index imax = IpBlasIdamax(m_, trash, 1);
     412    Number max_trash = trash[imax];
     413    delete [] trash;
     414    const Number max_trash_tol = 1e-6;
     415    if (max_trash > max_trash_tol) {
     416      return false;
     417    }
     418
     419    if (jnlst_->ProduceOutput(J_MOREVECTOR, J_NLP)) {
     420      jnlst_->Printf(J_MOREVECTOR, J_NLP,
     421                     "Curvature Estimator: original and projected directions are:\n");
     422      for (Index i=0; i<n_; i++) {
     423        jnlst_->Printf(J_MOREVECTOR, J_NLP,
     424                       "orig_d[%5d] = %23.16e proj_d[%5d] = %23.16e\n",
     425                       i, orig_d[i], i, projected_d[i]);
     426      }
     427    }
     428
     429    // Compute the product with the gradient of the Lagrangian
     430    if (true) {
     431      gradLagTd = 0.;
     432    }
     433    else {
     434      gradLagTd = IpBlasDdot(n, projected_d, 1, grad_f_, 1);
     435      for (Index i=0; i<nnz_jac_; i++) {
     436        const Index &irow = irows_jac_[i];
     437        const Index &jcol = jcols_jac_[i];
     438        gradLagTd += lambda_[irow]*jac_vals_[i]*projected_d[jcol];
     439      }
    369440    }
    370441
    371442    // Compute the product with the Hessian of the Lagrangian
    372     if (!Compute_dTHLagd(projected_d, x, new_x, lambda_, new_lambda, dTHLagd)) {
     443    //    if (!Compute_dTHLagd(projected_d, x, new_x, lambda_, new_lambda, dTHLagd)) {
     444    if (!Compute_dTHLagd(projected_d, x, new_x, lam, new_lambda, dTHLagd)) {
    373445      return false;
    374446    }
     
    395467        else {
    396468          x_free_map_[(*i)-1] = -1;
    397           DBG_ASSERT(x_u_[(-*i)-1] < 1e19);
     469          DBG_ASSERT(x_u_[(*i)-1] < 1e19);
    398470        }
    399471      }
     
    510582        }
    511583      }
    512       comp_proj_matrix_->Print(*jnlst_,J_WARNING,J_MAIN,"compmat");
     584      //DELETEME
     585      // comp_proj_matrix_->Print(*jnlst_,J_WARNING,J_MAIN,"compmat");
    513586      DBG_ASSERT(inz == tjac->Nonzeros());
    514587
     
    561634    ESymSolverStatus solver_retval =
    562635      tsymlinearsolver_->Solve(*comp_proj_matrix_, *rhs, *sol, false, 0);
     636    // For now we try, if the system is reported to be singular, to
     637    // still get a solution; ToDo
     638    if (solver_retval == SYMSOLVER_SINGULAR) {
     639      jnlst_->Printf(J_DETAILED, J_NLP,
     640                     "Projection matrix reported to be singular, but we try to obtain a solution anyway.\n");
     641      solver_retval =
     642        tsymlinearsolver_->Solve(*comp_proj_matrix_, *rhs, *sol, false, 0);
     643    }
     644
    563645    if (solver_retval != SYMSOLVER_SUCCESS) {
     646      // DELETEME
     647      printf("Return code from Solver is %d\n", solver_retval);
    564648      return false;
    565649    }
     
    603687  {
    604688    if (new_x || new_lambda || !hess_vals_) {
    605       hess_vals_ = new Number[nnz_hess_];
     689      if (!hess_vals_) {
     690        hess_vals_ = new Number[nnz_hess_];
     691      }
    606692      if (!tnlp_->eval_h(n_, x, new_x, 1., m_, lambda, new_lambda, nnz_hess_,
    607693                         NULL, NULL, hess_vals_)) {
  • branches/devel/Bonmin/src/Interfaces/BonOsiTMINLPInterface.cpp

    r123 r142  
    630630    throw SimpleError("Don't know how to copy an empty IpoptInterface.",
    631631        "copy constructor");
    632   }
    633 
    634   if(source.obj_) {
    635     obj_ = new double[source.getNumCols()];
    636     CoinCopyN(source.obj_, source.getNumCols(), obj_);
    637632  }
    638633
Note: See TracChangeset for help on using the changeset viewer.