• Main Page
  • Classes
  • Files
  • File List
  • File Members

/build/buildd/clp-1.11.1/Clp/src/Idiot.hpp

Go to the documentation of this file.
00001 /* $Id: Idiot.hpp 1458 2009-11-05 12:34:07Z forrest $ */
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 ,const CoinMessages * messages);
00084   void crossOver(int mode);
00086 
00087 
00093   inline double getStartingWeight() const
00094   { return mu_;}
00095   inline void setStartingWeight(double value)
00096   { mu_ = value;}
00099   inline double getWeightFactor() const
00100   { return muFactor_;}
00101   inline void setWeightFactor(double value)
00102   { muFactor_ = value;}
00106   inline double getFeasibilityTolerance() const
00107   { return smallInfeas_;}
00108   inline void setFeasibilityTolerance(double value)
00109   { smallInfeas_ = value;}
00113   inline double getReasonablyFeasible() const
00114   { return reasonableInfeas_;}
00115   inline void setReasonablyFeasible(double value)
00116   { reasonableInfeas_ = value;}
00119   inline double getExitInfeasibility() const
00120   { return exitFeasibility_;}
00121   inline void setExitInfeasibility(double value)
00122   { exitFeasibility_ = value;}
00125   inline int getMajorIterations() const
00126   { return majorIterations_;}
00127   inline void setMajorIterations(int value)
00128   { majorIterations_ = value;}
00135   inline int getMinorIterations() const
00136   { return maxIts2_;}
00137   inline void setMinorIterations(int value)
00138   { maxIts2_ = value;}
00139   // minor iterations for first time
00140   inline int getMinorIterations0() const
00141   { return maxIts_;}
00142   inline void setMinorIterations0(int value)
00143   { maxIts_ = value;}
00147   inline int getReduceIterations() const
00148   { return maxBigIts_;}
00149   inline void setReduceIterations(int value)
00150   { maxBigIts_ = value;}
00152   inline int getLogLevel() const
00153   { return logLevel_;}
00154   inline void setLogLevel(int value)
00155   { logLevel_ = value;}
00157   inline int getLightweight() const
00158   { return lightWeight_;}
00159   inline void setLightweight(int value)
00160   { lightWeight_ = value;}
00162   inline int getStrategy() const
00163   { return strategy_;}
00164   inline void setStrategy(int value)
00165   { strategy_ = value;}
00167   inline double getDropEnoughFeasibility() const
00168   { return dropEnoughFeasibility_;}
00169   inline void setDropEnoughFeasibility(double value)
00170   { dropEnoughFeasibility_=value;}
00172   inline double getDropEnoughWeighted() const
00173   { return dropEnoughWeighted_;}
00174   inline void setDropEnoughWeighted(double value)
00175   { dropEnoughWeighted_=value;}
00177 
00178 
00180 private:
00181 
00183   // allow public!
00184 public:
00185   void solve2(CoinMessageHandler * handler,const CoinMessages *messages);
00186 private:
00187 IdiotResult IdiSolve(
00188                      int nrows, int ncols, double * rowsol , double * colsol,
00189                      double * pi, double * djs, const double * origcost , 
00190                      double * rowlower,
00191                      double * rowupper, const double * lower,
00192                      const double * upper, const double * element, 
00193                      const int * row, const CoinBigIndex * colcc,
00194                      const int * length, double * lambda,
00195                      int maxIts,double mu,double drop,
00196                      double maxmin, double offset,
00197                      int strategy,double djTol,double djExit,double djFlag,
00198                      CoinThreadRandom * randomNumberGenerator);
00199 int dropping(IdiotResult result,
00200              double tolerance,
00201              double small,
00202              int *nbad);
00203 IdiotResult objval(int nrows, int ncols, double * rowsol , double * colsol,
00204                    double * pi, double * djs, const double * cost , 
00205                    const double * rowlower,
00206                    const double * rowupper, const double * lower,
00207                    const double * upper, const double * elemnt, 
00208                    const int * row, const CoinBigIndex * columnStart,
00209                    const int * length, int extraBlock, int * rowExtra,
00210                    double * solExtra, double * elemExtra, double * upperExtra,
00211                    double * costExtra,double weight);
00212   // Deals with whenUsed and slacks
00213   int cleanIteration(int iteration, int ordinaryStart, int ordinaryEnd,
00214                      double * colsol, const double * lower, const double * upper,
00215                      const double * rowLower, const double * rowUpper,
00216                      const double * cost, const double * element, double fixTolerance,double & objChange,
00217                      double & infChange);
00218 private:
00220   OsiSolverInterface * model_;
00221 
00222   double djTolerance_;
00223   double mu_;  /* starting mu */
00224   double drop_; /* exit if drop over 5 checks less than this */
00225   double muFactor_; /* reduce mu by this */
00226   double stopMu_; /* exit if mu gets smaller than this */
00227   double smallInfeas_; /* feasibility tolerance */
00228   double reasonableInfeas_; /* use lambdas if feasibility less than this */
00229   double exitDrop_; /* candidate for stopping after a major iteration */
00230   double muAtExit_; /* mu on exit */
00231   double exitFeasibility_; /* exit if infeasibility less than this */
00232   double dropEnoughFeasibility_; /* okay if feasibility drop this factor */
00233   double dropEnoughWeighted_; /* okay if weighted obj drop this factor */
00234   int * whenUsed_; /* array to say what was used */
00235   int maxBigIts_; /* always reduce mu after this */
00236   int maxIts_; /* do this many iterations on first go */
00237   int majorIterations_;
00238   int logLevel_;
00239   int logFreq_;
00240   int checkFrequency_; /* can exit after 5 * this iterations (on drop) */
00241   int lambdaIterations_; /* do at least this many lambda iterations */ 
00242   int maxIts2_; /* do this many iterations on subsequent goes */
00243   int strategy_;   /* 0 - default strategy
00244                      1 - do accelerator step but be cautious
00245                      2 - do not do accelerator step 
00246                      4 - drop, exitDrop and djTolerance all relative
00247                      8 - keep accelerator step to theta=10.0
00248 
00249                     32 - Scale
00250                    512 - crossover 
00251                   2048 - keep lambda across mu change
00252                   4096 - return best solution (not last found)
00253                   8192 - always do a presolve in crossover
00254                  16384 - costed slacks found - so whenUsed_ longer */
00255   int lightWeight_; // 0 - normal, 1 lightweight
00256 };
00257 #endif

Generated on Fri Aug 20 2010 06:29:29 by  doxygen 1.7.1