- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Alps-1.2.1/Clp/src/Idiot.hpp

Go to the documentation of this file.

    00001 /* $Id: Idiot.hpp 1525 2010-02-26 17:27:59Z mjs $ */
    00002 // Copyright (C) 2002, International Business Machines
    00003 // Corporation and others.  All Rights Reserved.
    00004 // "Idiot" as the name of this algorithm is copylefted.  If you want to change
    00005 // the name then it should be something equally stupid (but not "Stupid") or
    00006 // even better something witty.
    00007
    00008 #ifndef Idiot_H
    00009 #define Idiot_H
    00010 #ifndef OSI_IDIOT
    00011 #include "ClpSimplex.hpp"
    00012 #define OsiSolverInterface ClpSimplex
    00013 #else
    00014 #include "OsiSolverInterface.hpp"
    00015 typedef int CoinBigIndex;
    00016 #endif
    00017 class CoinMessageHandler;
    00018 class CoinMessages;
    00020 typedef struct {
    00021      double infeas;
    00022      double objval;
    00023      double dropThis;
    00024      double weighted;
    00025      double sumSquared;
    00026      double djAtBeginning;
    00027      double djAtEnd;
    00028      int iteration;
    00029 } IdiotResult;
    00046 class Idiot {
    00047
    00048 public:
    00049
    00054
    00055      Idiot (  );
    00057      Idiot ( OsiSolverInterface & model );
    00058
    00060      Idiot(const Idiot &);
    00062      Idiot & operator=(const Idiot & rhs);
    00064      ~Idiot (  );
    00066
    00067
    00071
    00072      void solve();
    00074      void crash(int numberPass, CoinMessageHandler * handler,
    00075                 const CoinMessages * messages, bool doCrossover = true);
    00085      void crossOver(int mode);
    00087
    00088
    00094      inline double getStartingWeight() const {
    00095           return mu_;
    00096      }
    00097      inline void setStartingWeight(double value) {
    00098           mu_ = value;
    00099      }
    00102      inline double getWeightFactor() const {
    00103           return muFactor_;
    00104      }
    00105      inline void setWeightFactor(double value) {
    00106           muFactor_ = value;
    00107      }
    00111      inline double getFeasibilityTolerance() const {
    00112           return smallInfeas_;
    00113      }
    00114      inline void setFeasibilityTolerance(double value) {
    00115           smallInfeas_ = value;
    00116      }
    00120      inline double getReasonablyFeasible() const {
    00121           return reasonableInfeas_;
    00122      }
    00123      inline void setReasonablyFeasible(double value) {
    00124           reasonableInfeas_ = value;
    00125      }
    00128      inline double getExitInfeasibility() const {
    00129           return exitFeasibility_;
    00130      }
    00131      inline void setExitInfeasibility(double value) {
    00132           exitFeasibility_ = value;
    00133      }
    00136      inline int getMajorIterations() const {
    00137           return majorIterations_;
    00138      }
    00139      inline void setMajorIterations(int value) {
    00140           majorIterations_ = value;
    00141      }
    00148      inline int getMinorIterations() const {
    00149           return maxIts2_;
    00150      }
    00151      inline void setMinorIterations(int value) {
    00152           maxIts2_ = value;
    00153      }
    00154      // minor iterations for first time
    00155      inline int getMinorIterations0() const {
    00156           return maxIts_;
    00157      }
    00158      inline void setMinorIterations0(int value) {
    00159           maxIts_ = value;
    00160      }
    00164      inline int getReduceIterations() const {
    00165           return maxBigIts_;
    00166      }
    00167      inline void setReduceIterations(int value) {
    00168           maxBigIts_ = value;
    00169      }
    00171      inline int getLogLevel() const {
    00172           return logLevel_;
    00173      }
    00174      inline void setLogLevel(int value) {
    00175           logLevel_ = value;
    00176      }
    00178      inline int getLightweight() const {
    00179           return lightWeight_;
    00180      }
    00181      inline void setLightweight(int value) {
    00182           lightWeight_ = value;
    00183      }
    00185      inline int getStrategy() const {
    00186           return strategy_;
    00187      }
    00188      inline void setStrategy(int value) {
    00189           strategy_ = value;
    00190      }
    00192      inline double getDropEnoughFeasibility() const {
    00193           return dropEnoughFeasibility_;
    00194      }
    00195      inline void setDropEnoughFeasibility(double value) {
    00196           dropEnoughFeasibility_ = value;
    00197      }
    00199      inline double getDropEnoughWeighted() const {
    00200           return dropEnoughWeighted_;
    00201      }
    00202      inline void setDropEnoughWeighted(double value) {
    00203           dropEnoughWeighted_ = value;
    00204      }
    00206
    00207
    00209 private:
    00210
    00212      // allow public!
    00213 public:
    00214      void solve2(CoinMessageHandler * handler, const CoinMessages *messages);
    00215 private:
    00216      IdiotResult IdiSolve(
    00217           int nrows, int ncols, double * rowsol , double * colsol,
    00218           double * pi, double * djs, const double * origcost ,
    00219           double * rowlower,
    00220           double * rowupper, const double * lower,
    00221           const double * upper, const double * element,
    00222           const int * row, const CoinBigIndex * colcc,
    00223           const int * length, double * lambda,
    00224           int maxIts, double mu, double drop,
    00225           double maxmin, double offset,
    00226           int strategy, double djTol, double djExit, double djFlag,
    00227           CoinThreadRandom * randomNumberGenerator);
    00228      int dropping(IdiotResult result,
    00229                   double tolerance,
    00230                   double small,
    00231                   int *nbad);
    00232      IdiotResult objval(int nrows, int ncols, double * rowsol , double * colsol,
    00233                         double * pi, double * djs, const double * cost ,
    00234                         const double * rowlower,
    00235                         const double * rowupper, const double * lower,
    00236                         const double * upper, const double * elemnt,
    00237                         const int * row, const CoinBigIndex * columnStart,
    00238                         const int * length, int extraBlock, int * rowExtra,
    00239                         double * solExtra, double * elemExtra, double * upperExtra,
    00240                         double * costExtra, double weight);
    00241      // Deals with whenUsed and slacks
    00242      int cleanIteration(int iteration, int ordinaryStart, int ordinaryEnd,
    00243                         double * colsol, const double * lower, const double * upper,
    00244                         const double * rowLower, const double * rowUpper,
    00245                         const double * cost, const double * element, double fixTolerance, double & objChange,
    00246                         double & infChange);
    00247 private:
    00249      OsiSolverInterface * model_;
    00250
    00251      double djTolerance_;
    00252      double mu_;  /* starting mu */
    00253      double drop_; /* exit if drop over 5 checks less than this */
    00254      double muFactor_; /* reduce mu by this */
    00255      double stopMu_; /* exit if mu gets smaller than this */
    00256      double smallInfeas_; /* feasibility tolerance */
    00257      double reasonableInfeas_; /* use lambdas if feasibility less than this */
    00258      double exitDrop_; /* candidate for stopping after a major iteration */
    00259      double muAtExit_; /* mu on exit */
    00260      double exitFeasibility_; /* exit if infeasibility less than this */
    00261      double dropEnoughFeasibility_; /* okay if feasibility drop this factor */
    00262      double dropEnoughWeighted_; /* okay if weighted obj drop this factor */
    00263      int * whenUsed_; /* array to say what was used */
    00264      int maxBigIts_; /* always reduce mu after this */
    00265      int maxIts_; /* do this many iterations on first go */
    00266      int majorIterations_;
    00267      int logLevel_;
    00268      int logFreq_;
    00269      int checkFrequency_; /* can exit after 5 * this iterations (on drop) */
    00270      int lambdaIterations_; /* do at least this many lambda iterations */
    00271      int maxIts2_; /* do this many iterations on subsequent goes */
    00272      int strategy_;   /* 0 - default strategy
    00273                      1 - do accelerator step but be cautious
    00274                      2 - do not do accelerator step
    00275                      4 - drop, exitDrop and djTolerance all relative
    00276                      8 - keep accelerator step to theta=10.0
    00277
    00278                     32 - Scale
    00279                    512 - crossover
    00280                   2048 - keep lambda across mu change
    00281                   4096 - return best solution (not last found)
    00282                   8192 - always do a presolve in crossover
    00283                  16384 - costed slacks found - so whenUsed_ longer */
    00284      int lightWeight_; // 0 - normal, 1 lightweight
    00285 };
    00286 #endif