Changeset 854 for stable/0.4


Ignore:
Timestamp:
Jun 8, 2012 11:30:44 AM (8 years ago)
Author:
stefan
Message:

merge r813 from trunk: activates catching ctrl+c when using CouenneBab?

Location:
stable/0.4/Couenne
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • stable/0.4/Couenne

  • stable/0.4/Couenne/src

  • stable/0.4/Couenne/src/bound_tightening

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • stable/0.4/Couenne/src/branch

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • stable/0.4/Couenne/src/expression/operators/exprGroup.cpp

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • stable/0.4/Couenne/src/heuristics/BonNlpHeuristic.cpp

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • stable/0.4/Couenne/src/interfaces/CouenneTNLP.hpp

    r713 r854  
    217217    CouenneSparseMatrix *optHessian_;
    218218
    219     /// flag to be set to save this solution's Lagrangian hessian in above structure
     219    /// Flag to be set to save this solution's Lagrangian Hessian in above structure
    220220    bool saveOptHessian_;
    221221  };
  • stable/0.4/Couenne/src/main/BonCouenne.cpp

    r844 r854  
    345345      lb = bb. model (). getBestPossibleObjValue ();
    346346
    347     if (cp -> getRecordBestSol ())              ub = cp -> getRecordBestSol () -> getVal ();
     347    if (cp -> getRecordBestSol () &&
     348        (ub > cp -> getRecordBestSol () -> getVal ())) ub = cp -> getRecordBestSol () -> getVal ();
     349
    348350    if ((fabs (lb) > COUENNE_INFINITY / 1e4) ||
    349         (lb > ub))                              lb = ub;
     351        (lb > ub))                                     lb = ub;
    350352
    351353    char
     
    374376                     bb.numNodes ());
    375377
    376     if (fabs (ub - bb. model (). getObjValue ()) > COUENNE_EPS * ub)
     378    if (fabs (ub - bb. model (). getObjValue ()) > COUENNE_EPS * fabs (ub))
    377379      jnlst -> Printf (J_ERROR, J_COUENNE,
    378380                       "Warning: upper bounds differ between Couenne and Cbc. Saving Couenne's (more reliable).\n");
  • stable/0.4/Couenne/src/main/BonCouenneSetup.cpp

    r764 r854  
    9797
    9898#ifdef COIN_HAS_ASL
    99   // free (aslfg_ -> asl); // triggers segfault
     99  // free (aslfg_ -> asl); // triggers segfault -- apparently freed in ancestor class
    100100#endif
    101101}
  • stable/0.4/Couenne/src/main/CouenneBab.cpp

    r853 r854  
    3636#define CUTOFF_TOL 1e-6
    3737
    38 // TODO: signal handler
    39 
    40 // // Code to enable user interuption
    41 // static CbcModel * currentBranchModel = NULL; //pointer to the main b&b
    42 // Bonmin::OACutGenerator2 * currentOA = NULL; //pointer to the OA generator
    43 // CbcModel * OAModel; // pointer to the submip if using Cbc
    44 // bool BonminAbortAll;
    45 
    46 // #define SIGNAL
    47 // #ifdef SIGNAL
    48 // #include "CoinSignal.hpp"
    49 
    50 // extern "C"
    51 // {
    52 
    53 //   static bool BonminInteruptedOnce =false;
    54 
    55 //   static void signal_handler(int whichSignal) {
    56 //     if (BonminInteruptedOnce) {
    57 //       std::cerr<<"User forced interuption"<<std::endl;
    58 //       exit(0);
    59 //     }
    60 //     if (currentBranchModel!=NULL)
    61 //       currentBranchModel->sayEventHappened(); // stop at next node
    62 //     if (OAModel!=NULL)
    63 //       OAModel->sayEventHappened(); // stop at next node
    64 //     if (currentOA!=NULL)
    65 //       currentOA->parameter().maxLocalSearchTime_ = 0.; // stop OA
    66 //     BonminAbortAll = true;
    67 //     BonminInteruptedOnce = true;
    68 //     return;
    69 //   }
    70 // }
    71 // #endif
     38// Code to enable user interruption
     39static CbcModel * currentBranchModel = NULL; //pointer to the main b&b
     40Bonmin::OACutGenerator2 * currentOA = NULL; //pointer to the OA generator
     41CbcModel * OAModel; // pointer to the submip if using Cbc
     42
     43#define SIGNAL
     44#ifdef SIGNAL
     45#include "CoinSignal.hpp"
     46
     47extern "C" {
     48
     49  static bool BonminInterruptedOnce = false;
     50
     51  static void couenne_signal_handler (int whichSignal) {
     52
     53    if (BonminInterruptedOnce) {
     54      //std::cerr<<"User-forced interruption"<<std::endl;
     55      exit(0);
     56    }
     57    if (currentBranchModel)       currentBranchModel->sayEventHappened(); // stop at next node
     58    if (OAModel)                  OAModel->sayEventHappened(); // stop at next node
     59    if (currentOA)                currentOA->parameter().maxLocalSearchTime_ = 0.; // stop OA
     60
     61    BonminInterruptedOnce = true;
     62  }
     63}
     64#endif
    7265
    7366using namespace Couenne;
     
    515508
    516509        OsiTMINLPInterface * tnlpSolver = dynamic_cast<OsiTMINLPInterface *>(model_.solver());
    517         // Primal dual point is not copied if one (supposedely a better one) has already been put into the solver.
     510        // Primal dual point is not copied if one (supposedly a better one) has already been put into the solver.
    518511        if(tnlpSolver->problem()->has_x_init() != 2){
    519512          model_.solver()->setColSolution(colsol);
     
    534527      }
    535528
    536 // #ifdef SIGNAL
    537 //     CoinSighandler_t saveSignal=SIG_DFL;
    538 //     // register signal handler
    539 //     if (!usingCouenne_)
    540 //       saveSignal = signal(SIGINT,signal_handler);
    541 //    currentBranchModel = &model_;
    542 // #endif
     529#ifdef SIGNAL
     530    CoinSighandler_t saveSignal = SIG_DFL;
     531    // register signal handler
     532    saveSignal = signal (SIGINT,couenne_signal_handler);
     533    currentBranchModel = &model_;
     534#endif
    543535
    544536
     
    601593  }
    602594
    603   // if (hasFailed && !usingCouenne_) {
    604   //    *model_.messageHandler()
    605   //   << "************************************************************" << CoinMessageEol
    606   //   << "WARNING : Optimization failed on an NLP during optimization"  << CoinMessageEol
    607   //   << "  (no optimal value found within tolerances)."  << CoinMessageEol
    608   //   << "  Optimization was not stopped because option"  << CoinMessageEol
    609   //   << "\"nlp_failure_behavior\" has been set to fathom but"  << CoinMessageEol
    610   //   << " beware that reported solution may not be optimal"  << CoinMessageEol
    611   //   << "************************************************************" << CoinMessageEol;
    612   // }
    613 
    614595  TMINLP::SolverReturn status = TMINLP::MINLP_ERROR;
    615596
Note: See TracChangeset for help on using the changeset viewer.