Changeset 1883


Ignore:
Timestamp:
Sep 26, 2012 8:08:20 AM (7 years ago)
Author:
forrest
Message:

allow setting of random seed

Location:
trunk/Clp/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/CbcOrClpParam.cpp

    r1878 r1883  
    55
    66#include "CoinPragma.hpp"
     7#include "CoinTime.hpp"
    78#include "CbcOrClpParam.hpp"
    89
     
    603604          case CLP_PARAM_INT_SPECIALOPTIONS:
    604605               model->setSpecialOptions(value);
     606               break;
     607          case CLP_PARAM_INT_RANDOMSEED:
     608            {
     609              if (value==0) {
     610                double time = fabs(CoinGetTimeOfDay());
     611                while (time>=COIN_INT_MAX)
     612                  time *= 0.5;
     613                value = static_cast<int>(time);
     614                sprintf(printArray, "using time of day %s was changed from %d to %d",
     615                  name_.c_str(), oldValue, value);
     616              }
     617              model->setRandomSeed(value);
     618            }
     619               break;
    605620#ifndef COIN_HAS_CBC
    606621#ifdef CBC_THREAD
     
    638653     case CLP_PARAM_INT_SPECIALOPTIONS:
    639654          value = model->specialOptions();
     655          break;
     656     case CLP_PARAM_INT_RANDOMSEED:
     657          value = model->randomNumberGenerator()->getSeed();
    640658          break;
    641659#ifndef COIN_HAS_CBC
     
    29502968#ifdef COIN_HAS_CBC
    29512969     parameters[numberParameters++] =
    2952           CbcOrClpParam("rand!omizedRounding", "Whether to try randomized rounding heuristic",
     2970          CbcOrClpParam("randomi!zedRounding", "Whether to try randomized rounding heuristic",
    29532971                        "off", CBC_PARAM_STR_RANDROUND);
    29542972     parameters[numberParameters-1].append("on");
     
    29592977          "stuff needed. \
    29602978Doh option does heuristic before preprocessing"     );
     2979#endif
     2980#ifdef COIN_HAS_CLP
     2981     parameters[numberParameters++] =
     2982          CbcOrClpParam("randomS!eed", "Random seed for Clp",
     2983                        0, COIN_INT_MAX, CLP_PARAM_INT_RANDOMSEED);
     2984     parameters[numberParameters-1].setLonghelp
     2985     (
     2986          "This sets a random seed for Clp \
     2987- 0 says use time of day."
     2988     );
     2989     parameters[numberParameters-1].setIntValue(1234567);
     2990#endif
     2991#ifdef COIN_HAS_CBC
    29612992     parameters[numberParameters++] =
    29622993          CbcOrClpParam("ratio!Gap", "Stop when gap between best possible and \
  • trunk/Clp/src/CbcOrClpParam.hpp

    r1878 r1883  
    101101     CLP_PARAM_INT_PROCESSTUNE,
    102102     CLP_PARAM_INT_USESOLUTION,
     103     CLP_PARAM_INT_RANDOMSEED,
    103104
    104105     CBC_PARAM_INT_STRONGBRANCHING = 151,
  • trunk/Clp/src/ClpModel.cpp

    r1826 r1883  
    718718          }
    719719     }
    720      randomNumberGenerator_.setSeed(1234567);
     720     //randomNumberGenerator_.setSeed(1234567);
    721721}
    722722// Assignment operator. This copies the data
Note: See TracChangeset for help on using the changeset viewer.