Ignore:
Timestamp:
Jan 6, 2019 2:43:06 PM (4 months ago)
Author:
unxusr
Message:

formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/Idiot.hpp

    r2144 r2385  
    2121/// for use internally
    2222typedef struct {
    23      double infeas;
    24      double objval;
    25      double dropThis;
    26      double weighted;
    27      double sumSquared;
    28      double djAtBeginning;
    29      double djAtEnd;
    30      int iteration;
     23  double infeas;
     24  double objval;
     25  double dropThis;
     26  double weighted;
     27  double sumSquared;
     28  double djAtBeginning;
     29  double djAtEnd;
     30  int iteration;
    3131} IdiotResult;
    3232/** This class implements a very silly algorithm.  It has no merit
     
    4949
    5050public:
    51 
    52      /**@name Constructors and destructor
     51  /**@name Constructors and destructor
    5352        Just a pointer to model is kept
    5453      */
    55      //@{
    56      /// Default constructor
    57      Idiot (  );
    58      /// Constructor with model
    59      Idiot ( OsiSolverInterface & model );
    60 
    61      /// Copy constructor.
    62      Idiot(const Idiot &);
    63      /// Assignment operator. This copies the data
    64      Idiot & operator=(const Idiot & rhs);
    65      /// Destructor
    66      ~Idiot (  );
    67      //@}
    68 
    69 
    70      /**@name Algorithmic calls
     54  //@{
     55  /// Default constructor
     56  Idiot();
     57  /// Constructor with model
     58  Idiot(OsiSolverInterface &model);
     59
     60  /// Copy constructor.
     61  Idiot(const Idiot &);
     62  /// Assignment operator. This copies the data
     63  Idiot &operator=(const Idiot &rhs);
     64  /// Destructor
     65  ~Idiot();
     66  //@}
     67
     68  /**@name Algorithmic calls
    7169      */
    72      //@{
    73      /// Get an approximate solution with the idiot code
    74      void solve();
    75      /// Lightweight "crash"
    76      void crash(int numberPass, CoinMessageHandler * handler,
    77                 const CoinMessages * messages, bool doCrossover = true);
    78      /** Use simplex to get an optimal solution
     70  //@{
     71  /// Get an approximate solution with the idiot code
     72  void solve();
     73  /// Lightweight "crash"
     74  void crash(int numberPass, CoinMessageHandler *handler,
     75    const CoinMessages *messages, bool doCrossover = true);
     76  /** Use simplex to get an optimal solution
    7977         mode is how many steps the simplex crossover should take to
    8078         arrive to an extreme point:
     
    8583         + 16 do presolves
    8684     */
    87      void crossOver(int mode);
    88      //@}
    89 
    90 
    91      /**@name Gets and sets of most useful data
     85  void crossOver(int mode);
     86  //@}
     87
     88  /**@name Gets and sets of most useful data
    9289      */
    93      //@{
    94      /** Starting weight - small emphasizes feasibility,
     90  //@{
     91  /** Starting weight - small emphasizes feasibility,
    9592         default 1.0e-4 */
    96      inline double getStartingWeight() const {
    97           return mu_;
    98      }
    99      inline void setStartingWeight(double value) {
    100           mu_ = value;
    101      }
    102      /** Weight factor - weight multiplied by this when changes,
     93  inline double getStartingWeight() const
     94  {
     95    return mu_;
     96  }
     97  inline void setStartingWeight(double value)
     98  {
     99    mu_ = value;
     100  }
     101  /** Weight factor - weight multiplied by this when changes,
    103102         default 0.333 */
    104      inline double getWeightFactor() const {
    105           return muFactor_;
    106      }
    107      inline void setWeightFactor(double value) {
    108           muFactor_ = value;
    109      }
    110      /** Feasibility tolerance - problem essentially feasible if
     103  inline double getWeightFactor() const
     104  {
     105    return muFactor_;
     106  }
     107  inline void setWeightFactor(double value)
     108  {
     109    muFactor_ = value;
     110  }
     111  /** Feasibility tolerance - problem essentially feasible if
    111112         individual infeasibilities less than this.
    112113         default 0.1 */
    113      inline double getFeasibilityTolerance() const {
    114           return smallInfeas_;
    115      }
    116      inline void setFeasibilityTolerance(double value) {
    117           smallInfeas_ = value;
    118      }
    119      /** Reasonably feasible.  Dubious method concentrates more on
     114  inline double getFeasibilityTolerance() const
     115  {
     116    return smallInfeas_;
     117  }
     118  inline void setFeasibilityTolerance(double value)
     119  {
     120    smallInfeas_ = value;
     121  }
     122  /** Reasonably feasible.  Dubious method concentrates more on
    120123         objective when sum of infeasibilities less than this.
    121124         Very dubious default value of (Number of rows)/20 */
    122      inline double getReasonablyFeasible() const {
    123           return reasonableInfeas_;
    124      }
    125      inline void setReasonablyFeasible(double value) {
    126           reasonableInfeas_ = value;
    127      }
    128      /** Exit infeasibility - exit if sum of infeasibilities less than this.
     125  inline double getReasonablyFeasible() const
     126  {
     127    return reasonableInfeas_;
     128  }
     129  inline void setReasonablyFeasible(double value)
     130  {
     131    reasonableInfeas_ = value;
     132  }
     133  /** Exit infeasibility - exit if sum of infeasibilities less than this.
    129134         Default -1.0 (i.e. switched off) */
    130      inline double getExitInfeasibility() const {
    131           return exitFeasibility_;
    132      }
    133      inline void setExitInfeasibility(double value) {
    134           exitFeasibility_ = value;
    135      }
    136      /** Major iterations.  stop after this number.
     135  inline double getExitInfeasibility() const
     136  {
     137    return exitFeasibility_;
     138  }
     139  inline void setExitInfeasibility(double value)
     140  {
     141    exitFeasibility_ = value;
     142  }
     143  /** Major iterations.  stop after this number.
    137144         Default 30.  Use 2-5 for "crash" 50-100 for serious crunching */
    138      inline int getMajorIterations() const {
    139           return majorIterations_;
    140      }
    141      inline void setMajorIterations(int value) {
    142           majorIterations_ = value;
    143      }
    144      /** Minor iterations.  Do this number of tiny steps before
     145  inline int getMajorIterations() const
     146  {
     147    return majorIterations_;
     148  }
     149  inline void setMajorIterations(int value)
     150  {
     151    majorIterations_ = value;
     152  }
     153  /** Minor iterations.  Do this number of tiny steps before
    145154         deciding whether to change weights etc.
    146155         Default - dubious sqrt(Number of Rows).
     
    148157         idiot is not trying to be clever which it may do every 10 minor
    149158         iterations) */
    150      inline int getMinorIterations() const {
    151           return maxIts2_;
    152      }
    153      inline void setMinorIterations(int value) {
    154           maxIts2_ = value;
    155      }
    156      // minor iterations for first time
    157      inline int getMinorIterations0() const {
    158           return maxIts_;
    159      }
    160      inline void setMinorIterations0(int value) {
    161           maxIts_ = value;
    162      }
    163      /** Reduce weight after this many major iterations.  It may
     159  inline int getMinorIterations() const
     160  {
     161    return maxIts2_;
     162  }
     163  inline void setMinorIterations(int value)
     164  {
     165    maxIts2_ = value;
     166  }
     167  // minor iterations for first time
     168  inline int getMinorIterations0() const
     169  {
     170    return maxIts_;
     171  }
     172  inline void setMinorIterations0(int value)
     173  {
     174    maxIts_ = value;
     175  }
     176  /** Reduce weight after this many major iterations.  It may
    164177         get reduced before this but this is a maximum.
    165178         Default 3.  3-10 plausible. */
    166      inline int getReduceIterations() const {
    167           return maxBigIts_;
    168      }
    169      inline void setReduceIterations(int value) {
    170           maxBigIts_ = value;
    171      }
    172      /// Amount of information - default of 1 should be okay
    173      inline int getLogLevel() const {
    174           return logLevel_;
    175      }
    176      inline void setLogLevel(int value) {
    177           logLevel_ = value;
    178      }
    179      /// How lightweight - 0 not, 1 yes, 2 very lightweight
    180      inline int getLightweight() const {
    181           return lightWeight_;
    182      }
    183      inline void setLightweight(int value) {
    184           lightWeight_ = value;
    185      }
    186      /// strategy
    187      inline int getStrategy() const {
    188           return strategy_;
    189      }
    190      inline void setStrategy(int value) {
    191           strategy_ = value;
    192      }
    193      /// Fine tuning - okay if feasibility drop this factor
    194      inline double getDropEnoughFeasibility() const {
    195           return dropEnoughFeasibility_;
    196      }
    197      inline void setDropEnoughFeasibility(double value) {
    198           dropEnoughFeasibility_ = value;
    199      }
    200      /// Fine tuning - okay if weighted obj drop this factor
    201      inline double getDropEnoughWeighted() const {
    202           return dropEnoughWeighted_;
    203      }
    204      inline void setDropEnoughWeighted(double value) {
    205           dropEnoughWeighted_ = value;
    206      }
    207      /// Set model
    208      inline void setModel(OsiSolverInterface * model) {
    209        model_ = model;
    210      };
    211      //@}
    212 
    213 
    214 /// Stuff for internal use
     179  inline int getReduceIterations() const
     180  {
     181    return maxBigIts_;
     182  }
     183  inline void setReduceIterations(int value)
     184  {
     185    maxBigIts_ = value;
     186  }
     187  /// Amount of information - default of 1 should be okay
     188  inline int getLogLevel() const
     189  {
     190    return logLevel_;
     191  }
     192  inline void setLogLevel(int value)
     193  {
     194    logLevel_ = value;
     195  }
     196  /// How lightweight - 0 not, 1 yes, 2 very lightweight
     197  inline int getLightweight() const
     198  {
     199    return lightWeight_;
     200  }
     201  inline void setLightweight(int value)
     202  {
     203    lightWeight_ = value;
     204  }
     205  /// strategy
     206  inline int getStrategy() const
     207  {
     208    return strategy_;
     209  }
     210  inline void setStrategy(int value)
     211  {
     212    strategy_ = value;
     213  }
     214  /// Fine tuning - okay if feasibility drop this factor
     215  inline double getDropEnoughFeasibility() const
     216  {
     217    return dropEnoughFeasibility_;
     218  }
     219  inline void setDropEnoughFeasibility(double value)
     220  {
     221    dropEnoughFeasibility_ = value;
     222  }
     223  /// Fine tuning - okay if weighted obj drop this factor
     224  inline double getDropEnoughWeighted() const
     225  {
     226    return dropEnoughWeighted_;
     227  }
     228  inline void setDropEnoughWeighted(double value)
     229  {
     230    dropEnoughWeighted_ = value;
     231  }
     232  /// Set model
     233  inline void setModel(OsiSolverInterface *model)
     234  {
     235    model_ = model;
     236  };
     237  //@}
     238
     239  /// Stuff for internal use
    215240private:
    216 
    217      /// Does actual work
    218      // allow public!
     241  /// Does actual work
     242  // allow public!
    219243public:
    220      void solve2(CoinMessageHandler * handler, const CoinMessages *messages);
     244  void solve2(CoinMessageHandler *handler, const CoinMessages *messages);
     245
    221246private:
    222      IdiotResult IdiSolve(
    223           int nrows, int ncols, double * rowsol , double * colsol,
    224           double * pi, double * djs, const double * origcost ,
    225           double * rowlower,
    226           double * rowupper, const double * lower,
    227           const double * upper, const double * element,
    228           const int * row, const CoinBigIndex * colcc,
    229           const int * length, double * lambda,
    230           int maxIts, double mu, double drop,
    231           double maxmin, double offset,
    232           int strategy, double djTol, double djExit, double djFlag,
    233           CoinThreadRandom * randomNumberGenerator);
    234      int dropping(IdiotResult result,
    235                   double tolerance,
    236                   double small,
    237                   int *nbad);
    238      IdiotResult objval(int nrows, int ncols, double * rowsol , double * colsol,
    239                         double * pi, double * djs, const double * cost ,
    240                         const double * rowlower,
    241                         const double * rowupper, const double * lower,
    242                         const double * upper, const double * elemnt,
    243                         const int * row, const CoinBigIndex * columnStart,
    244                         const int * length, int extraBlock, int * rowExtra,
    245                         double * solExtra, double * elemExtra, double * upperExtra,
    246                         double * costExtra, double weight);
    247      // Deals with whenUsed and slacks
    248      int cleanIteration(int iteration, int ordinaryStart, int ordinaryEnd,
    249                         double * colsol, const double * lower, const double * upper,
    250                         const double * rowLower, const double * rowUpper,
    251                         const double * cost, const double * element, double fixTolerance, double & objChange,
    252                         double & infChange, double & maxInfeasibility);
     247  IdiotResult IdiSolve(
     248    int nrows, int ncols, double *rowsol, double *colsol,
     249    double *pi, double *djs, const double *origcost,
     250    double *rowlower,
     251    double *rowupper, const double *lower,
     252    const double *upper, const double *element,
     253    const int *row, const CoinBigIndex *colcc,
     254    const int *length, double *lambda,
     255    int maxIts, double mu, double drop,
     256    double maxmin, double offset,
     257    int strategy, double djTol, double djExit, double djFlag,
     258    CoinThreadRandom *randomNumberGenerator);
     259  int dropping(IdiotResult result,
     260    double tolerance,
     261    double small,
     262    int *nbad);
     263  IdiotResult objval(int nrows, int ncols, double *rowsol, double *colsol,
     264    double *pi, double *djs, const double *cost,
     265    const double *rowlower,
     266    const double *rowupper, const double *lower,
     267    const double *upper, const double *elemnt,
     268    const int *row, const CoinBigIndex *columnStart,
     269    const int *length, int extraBlock, int *rowExtra,
     270    double *solExtra, double *elemExtra, double *upperExtra,
     271    double *costExtra, double weight);
     272  // Deals with whenUsed and slacks
     273  int cleanIteration(int iteration, int ordinaryStart, int ordinaryEnd,
     274    double *colsol, const double *lower, const double *upper,
     275    const double *rowLower, const double *rowUpper,
     276    const double *cost, const double *element, double fixTolerance, double &objChange,
     277    double &infChange, double &maxInfeasibility);
     278
    253279private:
    254      /// Underlying model
    255      OsiSolverInterface * model_;
    256 
    257      double djTolerance_;
    258      double mu_; /* starting mu */
    259      double drop_; /* exit if drop over 5 checks less than this */
    260      double muFactor_; /* reduce mu by this */
    261      double stopMu_; /* exit if mu gets smaller than this */
    262      double smallInfeas_; /* feasibility tolerance */
    263      double reasonableInfeas_; /* use lambdas if feasibility less than this */
    264      double exitDrop_; /* candidate for stopping after a major iteration */
    265      double muAtExit_; /* mu on exit */
    266      double exitFeasibility_; /* exit if infeasibility less than this */
    267      double dropEnoughFeasibility_; /* okay if feasibility drop this factor */
    268      double dropEnoughWeighted_; /* okay if weighted obj drop this factor */
    269      int * whenUsed_; /* array to say what was used */
    270      int maxBigIts_; /* always reduce mu after this */
    271      int maxIts_; /* do this many iterations on first go */
    272      int majorIterations_;
    273      int logLevel_;
    274      int logFreq_;
    275      int checkFrequency_; /* can exit after 5 * this iterations (on drop) */
    276      int lambdaIterations_; /* do at least this many lambda iterations */
    277      int maxIts2_; /* do this many iterations on subsequent goes */
    278      int strategy_;  /* 0 - default strategy
     280  /// Underlying model
     281  OsiSolverInterface *model_;
     282
     283  double djTolerance_;
     284  double mu_; /* starting mu */
     285  double drop_; /* exit if drop over 5 checks less than this */
     286  double muFactor_; /* reduce mu by this */
     287  double stopMu_; /* exit if mu gets smaller than this */
     288  double smallInfeas_; /* feasibility tolerance */
     289  double reasonableInfeas_; /* use lambdas if feasibility less than this */
     290  double exitDrop_; /* candidate for stopping after a major iteration */
     291  double muAtExit_; /* mu on exit */
     292  double exitFeasibility_; /* exit if infeasibility less than this */
     293  double dropEnoughFeasibility_; /* okay if feasibility drop this factor */
     294  double dropEnoughWeighted_; /* okay if weighted obj drop this factor */
     295  int *whenUsed_; /* array to say what was used */
     296  int maxBigIts_; /* always reduce mu after this */
     297  int maxIts_; /* do this many iterations on first go */
     298  int majorIterations_;
     299  int logLevel_;
     300  int logFreq_;
     301  int checkFrequency_; /* can exit after 5 * this iterations (on drop) */
     302  int lambdaIterations_; /* do at least this many lambda iterations */
     303  int maxIts2_; /* do this many iterations on subsequent goes */
     304  int strategy_; /* 0 - default strategy
    279305                     1 - do accelerator step but be cautious
    280306                     2 - do not do accelerator step
     
    293319                 262144 - just values pass etc
    294320                 524288 - don't treat structural slacks as slacks */
    295                  
    296      int lightWeight_; // 0 - normal, 1 lightweight
     321
     322  int lightWeight_; // 0 - normal, 1 lightweight
    297323};
    298324#endif
     325
     326/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
     327*/
Note: See TracChangeset for help on using the changeset viewer.