Ignore:
Timestamp:
Oct 9, 2006 4:19:31 PM (13 years ago)
Author:
forrest
Message:

for local tree search and feasibility pump

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/devel/Cbc/src/CoinSolve.cpp

    r439 r441  
    9191static bool maskMatches(const int * starts, char ** masks,
    9292                        std::string & check);
    93 static void generateCode(const char * fileName,int type,int preProcess);
     93static void generateCode(CbcModel * model, const char * fileName,int type,int preProcess);
    9494#ifdef NDEBUG
    9595#undef NDEBUG
     
    20642064                heuristic4.setMaximumPasses(parameters[whichParam(FPUMPITS,numberParameters,parameters)].intValue());
    20652065                int pumpTune=parameters[whichParam(FPUMPTUNE,numberParameters,parameters)].intValue();
    2066                 if (pumpTune>10) {
     2066                if (pumpTune>0) {
    20672067                  /*
    2068                     >=1000 use index+2 as number of large loops, if >4 decrement by 5 and clean used array
     2068                    >=1000000 use as accumulate switch
     2069                    >=1000 use index+2 as number of large loops
    20692070                    >=100 use 0.05 objvalue as increment
    20702071                    >=10 use +0.1 objvalue for cutoff (add)
    20712072                    1 == fix ints at bounds, 2 fix all integral ints, 3 and continuous at bounds
     2073                    4 and static continuous, 5 as 3 but no internal integers
    20722074                  */
    2073                   if (pumpTune) {
    2074                     double value = babModel->solver()->getObjSense()*babModel->solver()->getObjValue();
    2075                     int w = pumpTune/10;
    2076                     int c = w % 10;
    2077                     w /= 10;
    2078                     int i = w % 10;
    2079                     w /= 10;
    2080                     int r = w%10;
    2081                     // fake cutoff
    2082                     if (c) {
    2083                       double cutoff;
    2084                       babModel->solver()->getDblParam(OsiDualObjectiveLimit,cutoff);
    2085                       cutoff = CoinMin(cutoff,value + 0.1*fabs(value)*c);
    2086                       heuristic4.setFakeCutoff(cutoff);
    2087                     }
    2088                     if (i||r) {
    2089                       // also set increment
    2090                       heuristic4.setAbsoluteIncrement((0.01*i+0.005)*(fabs(value)+1.0e-12));
    2091                       if (r>4) {
    2092                         r -=5;
    2093                         heuristic4.setMaximumRetries(-r-2);
    2094                       } else {
    2095                         heuristic4.setMaximumRetries(r+2);
    2096                       }
    2097                     }
    2098                     pumpTune = pumpTune%100;
    2099                     heuristic4.setWhen(pumpTune+10);
     2075                  double value = babModel->solver()->getObjSense()*babModel->solver()->getObjValue();
     2076                  int w = pumpTune/10;
     2077                  int c = w % 10;
     2078                  w /= 10;
     2079                  int i = w % 10;
     2080                  w /= 10;
     2081                  int r = w;
     2082                  int accumulate = r/1000;
     2083                  r -= 1000*accumulate;
     2084                  // fake cutoff
     2085                  printf("Setting ");
     2086                  if (c) {
     2087                    double cutoff;
     2088                    babModel->solver()->getDblParam(OsiDualObjectiveLimit,cutoff);
     2089                    cutoff = CoinMin(cutoff,value + 0.1*fabs(value)*c);
     2090                    heuristic4.setFakeCutoff(cutoff);
     2091                    printf("fake cutoff of %g ",cutoff);
    21002092                  }
     2093                  if (i||r) {
     2094                    // also set increment
     2095                    heuristic4.setAbsoluteIncrement((0.01*i+0.005)*(fabs(value)+1.0e-12));
     2096                    heuristic4.setAccumulate(accumulate);
     2097                    heuristic4.setMaximumRetries(r+2);
     2098                    if (i)
     2099                      printf("increment of %g ",heuristic4.absoluteIncrement());
     2100                    if (accumulate)
     2101                      printf("accumulate of %d ",accumulate);
     2102                    printf("%d retries ",r+2);
     2103                  }
     2104                  pumpTune = pumpTune%100;
     2105                  printf("and setting when to %d\n",pumpTune+10);
     2106                  heuristic4.setWhen(pumpTune+10);
    21012107                }
    21022108                babModel->addHeuristic(&heuristic4);
     
    22152221                  iLevel = -iLevel;
    22162222                }
    2217                 babModel->messageHandler()->setLogLevel(parameters[log].intValue());
     2223                babModel->messageHandler()->setLogLevel(iLevel);
    22182224                if (babModel->getNumCols()>2000||babModel->getNumRows()>1500||
    22192225                    babModel->messageHandler()->logLevel()>1)
     
    25592565                    fclose(fp);
    25602566                    // now call generate code
    2561                     generateCode("user_driver.cpp",cppValue,prepro);
     2567                    generateCode(babModel,"user_driver.cpp",cppValue,prepro);
    25622568                  } else {
    25632569                    std::cout<<"Unable to open file user_driver.cpp"<<std::endl;
     
    44964502  *put='\0';
    44974503}
    4498 static void generateCode(const char * fileName,int type,int preProcess)
     4504static void generateCode(CbcModel * model, const char * fileName,int type,int preProcess)
    44994505{
    45004506  // options on code generation
     
    45214527  if (preProcess>0)
    45224528    strcpy(line[numberLines++],"0#include \"CglProbing.hpp\""); // possibly redundant
    4523   while (fgets(line[numberLines],MAXONELINE,fp)) {
    4524     assert (numberLines<MAXLINES);
    4525     clean(line[numberLines]);
    4526     numberLines++;
    4527   }
    4528   fclose(fp);
    4529   strcpy(line[numberLines++],"0\nint main (int argc, const char *argv[])\n{");
    4530   strcpy(line[numberLines++],"0  OsiClpSolverInterface solver1;");
    4531   strcpy(line[numberLines++],"0  int status=1;");
    4532   strcpy(line[numberLines++],"0  if (argc<2)");
    4533   strcpy(line[numberLines++],"0    std::cout<<\"Please give file name\"<<std::endl;");
    4534   strcpy(line[numberLines++],"0  else");
    4535   strcpy(line[numberLines++],"0    status=solver1.readMps(argv[1],\"\");");
    4536   strcpy(line[numberLines++],"0  if (status) {");
    4537   strcpy(line[numberLines++],"0    std::cout<<\"Bad readMps \"<<argv[1]<<std::endl;");
    4538   strcpy(line[numberLines++],"0    exit(1);");
    4539   strcpy(line[numberLines++],"0  }\n");
    4540   strcpy(line[numberLines++],"0  double time1 = CoinCpuTime();");
    4541   strcpy(line[numberLines++],"0  CbcModel model(solver1);");
    4542   strcpy(line[numberLines++],"0  // Now do requested saves and modifications");
    4543   strcpy(line[numberLines++],"0  CbcModel * cbcModel = & model;");
    4544   strcpy(line[numberLines++],"0  OsiSolverInterface * osiModel = model.solver();");
    4545   strcpy(line[numberLines++],"0  OsiClpSolverInterface * osiclpModel = dynamic_cast< OsiClpSolverInterface*> (osiModel);");
    4546   strcpy(line[numberLines++],"0  ClpSimplex * clpModel = osiclpModel->getModelPtr();");
    4547   // add in comments about messages
    4548   strcpy(line[numberLines++],"3  // You can save some time by switching off message building");
    4549   strcpy(line[numberLines++],"3  // clpModel->messagesPointer()->setDetailMessages(100,10000,(int *) NULL);");
     4529  // To allow generated 5's to be just before branchAndBound - do rest here
    45504530  strcpy(line[numberLines++],"5  cbcModel->initialSolve();");
    45514531  strcpy(line[numberLines++],"5  if (clpModel->tightenPrimalBounds()!=0) {");
     
    46134593    strcpy(line[numberLines++],"5  cbcModel->initialSolve();");
    46144594  }
     4595  while (fgets(line[numberLines],MAXONELINE,fp)) {
     4596    assert (numberLines<MAXLINES);
     4597    clean(line[numberLines]);
     4598    numberLines++;
     4599  }
     4600  fclose(fp);
     4601  strcpy(line[numberLines++],"0\nint main (int argc, const char *argv[])\n{");
     4602  strcpy(line[numberLines++],"0  OsiClpSolverInterface solver1;");
     4603  strcpy(line[numberLines++],"0  int status=1;");
     4604  strcpy(line[numberLines++],"0  if (argc<2)");
     4605  strcpy(line[numberLines++],"0    std::cout<<\"Please give file name\"<<std::endl;");
     4606  strcpy(line[numberLines++],"0  else");
     4607  strcpy(line[numberLines++],"0    status=solver1.readMps(argv[1],\"\");");
     4608  strcpy(line[numberLines++],"0  if (status) {");
     4609  strcpy(line[numberLines++],"0    std::cout<<\"Bad readMps \"<<argv[1]<<std::endl;");
     4610  strcpy(line[numberLines++],"0    exit(1);");
     4611  strcpy(line[numberLines++],"0  }\n");
     4612  strcpy(line[numberLines++],"0  double time1 = CoinCpuTime();");
     4613  strcpy(line[numberLines++],"0  CbcModel model(solver1);");
     4614  strcpy(line[numberLines++],"0  // Now do requested saves and modifications");
     4615  strcpy(line[numberLines++],"0  CbcModel * cbcModel = & model;");
     4616  strcpy(line[numberLines++],"0  OsiSolverInterface * osiModel = model.solver();");
     4617  strcpy(line[numberLines++],"0  OsiClpSolverInterface * osiclpModel = dynamic_cast< OsiClpSolverInterface*> (osiModel);");
     4618  strcpy(line[numberLines++],"0  ClpSimplex * clpModel = osiclpModel->getModelPtr();");
     4619  // add in comments about messages
     4620  strcpy(line[numberLines++],"3  // You can save some time by switching off message building");
     4621  strcpy(line[numberLines++],"3  // clpModel->messagesPointer()->setDetailMessages(100,10000,(int *) NULL);");
    46154622  // add in actual solve
    46164623  strcpy(line[numberLines++],"5  cbcModel->branchAndBound();");
Note: See TracChangeset for help on using the changeset viewer.