Changeset 2371 for trunk/Cbc


Ignore:
Timestamp:
Mar 31, 2018 1:17:28 PM (16 months ago)
Author:
forrest
Message:

finger trouble - out new multiple

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcModel.cpp

    r2370 r2371  
    27582758      }
    27592759      delete basis;
    2760       char general[200];
    2761       /*
    2762         1 - bit set - first come first served
    2763         2 - bit set - pass on cutoffs (not deterministic if 1 set)
    2764        */
    2765 #define MULTIPLE_TYPE 3
    2766 #if MULTIPLE_TYPE == 1 || MULTIPLE_TYPE == 3
    2767 #define FIRST_COME
    2768 #endif
    2769 #if MULTIPLE_TYPE == 2 || MULTIPLE_TYPE == 3
    2770 #define SET_CUTOFF
    2771 #endif
    2772 #ifndef MAX_HEURISTIC_TIMES
    2773 #define MAX_HEURISTIC_TIMES 16
    2774 #endif
    2775 #ifdef SET_CUTOFF
    2776       double bestCutoff = getCutoff();
    2777 #endif
    27782760#ifdef CBC_THREAD
    27792761      if (numberRootThreads==1) {
    27802762#endif
    27812763        for (int iModel=0;iModel<numberModels;iModel++) {
    2782           rootBundle bundle;
    2783           bundle.useCutoff=COIN_DBL_MAX;
    2784           bundle.model=rootModels[iModel];
    2785           bundle.switches=0;
    2786 #ifdef SET_CUTOFF
    2787           bundle.useCutoff=bestCutoff;
    2788           rootModels[iModel]->setCutoff(bestCutoff);
    2789 #endif
    2790           doRootCbcThread(&bundle);
    2791           sprintf(general,"Ending multiple root solver %d out of %d",
    2792                   iModel+1,numberModels);
    2793           messageHandler()->message(CBC_GENERAL,messages())
    2794             << general << CoinMessageEol ;
    2795 #ifdef SET_CUTOFF
    2796           if (rootModels[iModel]->getCutoff()<bestCutoff)
    2797             bestCutoff = rootModels[iModel]->getCutoff();
    2798 #endif
     2764          doRootCbcThread(rootModels[iModel]);
    27992765          // see if solved at root node
    28002766          if (rootModels[iModel]->getMaximumNodes()) {
     
    28052771#ifdef CBC_THREAD
    28062772      } else {
    2807         // redone so can use numberThreads_ threads more efficiently
    2808         // but then if changing cutoff - not deterministic
    2809         // BUT changing cutoff has a bug (what bug - debug)
    28102773        Coin_pthread_t * threadId = new Coin_pthread_t [numberRootThreads];
    2811         rootBundle * bundle = new rootBundle [numberRootThreads];
    2812         int numberDone=0;
    2813         int kModel=numberRootThreads;
    2814         for (int iModel=0;iModel<kModel;iModel++) {
    2815           threadId[iModel].status=1000+iModel;
    2816           bundle[iModel].useCutoff=COIN_DBL_MAX;
    2817           if (numberDone>=MAX_HEURISTIC_TIMES) {
    2818 #ifdef SET_CUTOFF
    2819             bundle[iModel].useCutoff=bestCutoff;
    2820             rootModels[iModel]->setCutoff(bestCutoff);
    2821 #endif
    2822             for (int i=0;i<rootModels[iModel]->numberHeuristics_;i++)
    2823               delete rootModels[iModel]->heuristic_[i];
    2824             delete [] rootModels[iModel]->heuristic_;
    2825             rootModels[iModel]->heuristic_=NULL;
    2826             numberHeuristics_=0;
     2774        for (int kModel=0;kModel<numberModels;kModel+=numberRootThreads) {
     2775          bool finished=false;
     2776          for (int iModel=kModel;iModel<CoinMin(numberModels,kModel+numberRootThreads);iModel++) {
     2777            pthread_create(&(threadId[iModel-kModel].thr), NULL,
     2778                           doRootCbcThread,
     2779                           rootModels[iModel]);
    28272780          }
    2828           bundle[iModel].model=rootModels[iModel];
    2829           bundle[iModel].switches=0;
    2830           pthread_create(&(threadId[iModel].thr), NULL,
    2831                          doRootCbcThread,
    2832                          bundle+iModel);
    2833         }
    2834         bool finished=false;
    2835         while (numberDone<numberModels) {
    2836 #ifdef FIRST_COME
    2837           usleep(100000);
    2838 #else
    2839           for (int iModel=0;iModel<numberRootThreads;iModel++) {
    2840             pthread_join(threadId[iModel].thr, NULL);
    2841 #ifdef SET_CUTOFF
    2842             int jModel = static_cast<int>(threadId[iModel].status-1000);
    2843             if (rootModels[jModel]->getCutoff()<bestCutoff)
    2844               bestCutoff = rootModels[jModel]->getCutoff();
    2845 #endif
     2781          // wait
     2782          for (int iModel=kModel;iModel<CoinMin(numberModels,kModel+numberRootThreads);iModel++) {
     2783            pthread_join(threadId[iModel-kModel].thr, NULL);
    28462784          }
    2847 #endif
    2848           for (int iModel=0;iModel<numberRootThreads;iModel++) {
    2849             if (threadId[iModel].status>0) {
    2850               int jModel = static_cast<int>(threadId[iModel].status-1000);
    2851               if (rootModels[jModel]->secondaryStatus()==123456789) {
    2852 #ifdef FIRST_COME
    2853                 pthread_join(threadId[iModel].thr, NULL);
    2854 #ifdef SET_CUTOFF
    2855                 if (rootModels[jModel]->getCutoff()<bestCutoff)
    2856                   bestCutoff = rootModels[jModel]->getCutoff();
    2857 #endif
    2858 #endif
    2859                 sprintf(general,"Ending multiple root solver %d (%d) out of %d",
    2860                         numberDone+1,jModel+1,numberModels);
    2861                 messageHandler()->message(CBC_GENERAL,messages())
    2862                   << general << CoinMessageEol ;
    2863                 if (rootModels[jModel]->getMaximumNodes()) {
    2864                   finished=true;
    2865                   numberDone += numberModels-kModel;
    2866                   kModel=numberModels;
    2867                 }
    2868                 numberDone++;
    2869                 if (kModel<numberModels) {
    2870                   bundle[iModel].useCutoff=COIN_DBL_MAX;
    2871                   bundle[iModel].model=rootModels[kModel];
    2872                   bundle[iModel].switches=0;
    2873 #ifdef SET_CUTOFF
    2874                   bundle[iModel].useCutoff=bestCutoff;
    2875 #endif
    2876                   if (numberDone>=MAX_HEURISTIC_TIMES) {
    2877                     for (int i=0;i<rootModels[kModel]->numberHeuristics_;i++)
    2878                       delete rootModels[kModel]->heuristic_[i];
    2879                     delete [] rootModels[kModel]->heuristic_;
    2880                     rootModels[kModel]->heuristic_=NULL;
    2881                     rootModels[kModel]->numberHeuristics_=0;
    2882                   }
    2883                   threadId[iModel].status=1000+kModel;
    2884                   pthread_create(&(threadId[iModel].thr), NULL,
    2885                                  doRootCbcThread,
    2886                                  bundle+iModel);
    2887                   kModel++;
    2888                 } else {
    2889                   threadId[iModel].status=-1;
    2890                 }
    2891               }
    2892             }
     2785          // see if solved at root node
     2786          for (int iModel=kModel;iModel<CoinMin(numberModels,kModel+numberRootThreads);iModel++) {
     2787            if (rootModels[iModel]->getMaximumNodes())
     2788              finished=true;
     2789          }
     2790          if (finished) {
     2791            feasible=false;
     2792            break;
    28932793          }
    28942794        }
    2895         // see if solved at root node
    2896         if (finished)
    2897           feasible=false;
    28982795        delete [] threadId;
    2899         delete [] bundle;
    29002796      }
    29012797#endif
     
    29112807        }
    29122808      }
     2809      char general[100];
    29132810      rootTimeCpu=CoinCpuTime()-rootTimeCpu;
    29142811      if (numberRootThreads==1)
     
    1930619203static void * doRootCbcThread(void * voidInfo)
    1930719204{
    19308     rootBundle * bundle = reinterpret_cast<rootBundle *>(voidInfo);
    19309     CbcModel * model = bundle->model;
    19310     if (bundle->useCutoff<model->getCutoff())
    19311       model->setCutoff(bundle->useCutoff);
     19205    CbcModel * model = reinterpret_cast<CbcModel *> (voidInfo);
    1931219206#ifdef COIN_HAS_CLP
    1931319207    OsiClpSolverInterface * clpSolver
Note: See TracChangeset for help on using the changeset viewer.