/home/coin/SVN-release/CoinAll-1.1.0/Clp/src/Idiot.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2002, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 // "Idiot" as the name of this algorithm is copylefted.  If you want to change
00004 // the name then it should be something equally stupid (but not "Stupid") or
00005 // even better something witty.
00006 
00007 #ifndef Idiot_H
00008 #define Idiot_H
00009 #ifndef OSI_IDIOT
00010 #include "ClpSimplex.hpp"
00011 #define OsiSolverInterface ClpSimplex
00012 #else
00013 #include "OsiSolverInterface.hpp"
00014 typedef int CoinBigIndex;
00015 #endif
00016 class CoinMessageHandler;
00017 class CoinMessages;
00019 typedef struct {
00020   double infeas;
00021   double objval;
00022   double dropThis;
00023   double weighted;
00024   double sumSquared;
00025   double djAtBeginning;
00026   double djAtEnd;
00027   int iteration;
00028 } IdiotResult;
00045 class Idiot {
00046 
00047 public:
00048 
00053 
00054     Idiot (  );
00056     Idiot ( OsiSolverInterface & model );
00057 
00059     Idiot(const Idiot &);
00061     Idiot & operator=(const Idiot & rhs);
00063     ~Idiot (  );
00065 
00066 
00070 
00071   void solve();
00073   void crash(int numberPass,CoinMessageHandler * handler ,const CoinMessages * messages);
00083   void crossOver(int mode);
00085 
00086 
00092   inline double getStartingWeight() const
00093   { return mu_;}
00094   inline void setStartingWeight(double value)
00095   { mu_ = value;}
00098   inline double getWeightFactor() const
00099   { return muFactor_;}
00100   inline void setWeightFactor(double value)
00101   { muFactor_ = value;}
00105   inline double getFeasibilityTolerance() const
00106   { return smallInfeas_;}
00107   inline void setFeasibilityTolerance(double value)
00108   { smallInfeas_ = value;}
00112   inline double getReasonablyFeasible() const
00113   { return reasonableInfeas_;}
00114   inline void setReasonablyFeasible(double value)
00115   { reasonableInfeas_ = value;}
00118   inline double getExitInfeasibility() const
00119   { return exitFeasibility_;}
00120   inline void setExitInfeasibility(double value)
00121   { exitFeasibility_ = value;}
00124   inline int getMajorIterations() const
00125   { return majorIterations_;}
00126   inline void setMajorIterations(int value)
00127   { majorIterations_ = value;}
00134   inline int getMinorIterations() const
00135   { return maxIts2_;}
00136   inline void setMinorIterations(int value)
00137   { maxIts2_ = value;}
00138   // minor iterations for first time
00139   inline int getMinorIterations0() const
00140   { return maxIts_;}
00141   inline void setMinorIterations0(int value)
00142   { maxIts_ = value;}
00146   inline int getReduceIterations() const
00147   { return maxBigIts_;}
00148   inline void setReduceIterations(int value)
00149   { maxBigIts_ = value;}
00151   inline int getLogLevel() const
00152   { return logLevel_;}
00153   inline void setLogLevel(int value)
00154   { logLevel_ = value;}
00156   inline int getLightweight() const
00157   { return lightWeight_;}
00158   inline void setLightweight(int value)
00159   { lightWeight_ = value;}
00161   inline int getStrategy() const
00162   { return strategy_;}
00163   inline void setStrategy(int value)
00164   { strategy_ = value;}
00166   inline double getDropEnoughFeasibility() const
00167   { return dropEnoughFeasibility_;}
00168   inline void setDropEnoughFeasibility(double value)
00169   { dropEnoughFeasibility_=value;}
00171   inline double getDropEnoughWeighted() const
00172   { return dropEnoughWeighted_;}
00173   inline void setDropEnoughWeighted(double value)
00174   { dropEnoughWeighted_=value;}
00176 
00177 
00179 private:
00180 
00182   // allow public!
00183 public:
00184   void solve2(CoinMessageHandler * handler,const CoinMessages *messages);
00185 private:
00186 IdiotResult IdiSolve(
00187                      int nrows, int ncols, double * rowsol , double * colsol,
00188                      double * pi, double * djs, const double * origcost , 
00189                      double * rowlower,
00190                      double * rowupper, const double * lower,
00191                      const double * upper, const double * element, 
00192                      const int * row, const CoinBigIndex * colcc,
00193                      const int * length, double * lambda,
00194                      int maxIts,double mu,double drop,
00195                      double maxmin, double offset,
00196                      int strategy,double djTol,double djExit,double djFlag,
00197                      CoinThreadRandom * randomNumberGenerator);
00198 int dropping(IdiotResult result,
00199              double tolerance,
00200              double small,
00201              int *nbad);
00202 IdiotResult objval(int nrows, int ncols, double * rowsol , double * colsol,
00203                    double * pi, double * djs, const double * cost , 
00204                    const double * rowlower,
00205                    const double * rowupper, const double * lower,
00206                    const double * upper, const double * elemnt, 
00207                    const int * row, const CoinBigIndex * columnStart,
00208                    const int * length, int extraBlock, int * rowExtra,
00209                    double * solExtra, double * elemExtra, double * upperExtra,
00210                    double * costExtra,double weight);
00211   // Deals with whenUsed and slacks
00212   int cleanIteration(int iteration, int ordinaryStart, int ordinaryEnd,
00213                      double * colsol, const double * lower, const double * upper,
00214                      const double * rowLower, const double * rowUpper,
00215                      const double * cost, const double * element, double fixTolerance,double & objChange,
00216                      double & infChange);
00217 private:
00219   OsiSolverInterface * model_;
00220 
00221   double djTolerance_;
00222   double mu_;  /* starting mu */
00223   double drop_; /* exit if drop over 5 checks less than this */
00224   double muFactor_; /* reduce mu by this */
00225   double stopMu_; /* exit if mu gets smaller than this */
00226   double smallInfeas_; /* feasibility tolerance */
00227   double reasonableInfeas_; /* use lambdas if feasibility less than this */
00228   double exitDrop_; /* candidate for stopping after a major iteration */
00229   double muAtExit_; /* mu on exit */
00230   double exitFeasibility_; /* exit if infeasibility less than this */
00231   double dropEnoughFeasibility_; /* okay if feasibility drop this factor */
00232   double dropEnoughWeighted_; /* okay if weighted obj drop this factor */
00233   int * whenUsed_; /* array to say what was used */
00234   int maxBigIts_; /* always reduce mu after this */
00235   int maxIts_; /* do this many iterations on first go */
00236   int majorIterations_;
00237   int logLevel_;
00238   int logFreq_;
00239   int checkFrequency_; /* can exit after 5 * this iterations (on drop) */
00240   int lambdaIterations_; /* do at least this many lambda iterations */ 
00241   int maxIts2_; /* do this many iterations on subsequent goes */
00242   int strategy_;   /* 0 - default strategy
00243                      1 - do accelerator step but be cautious
00244                      2 - do not do accelerator step 
00245                      4 - drop, exitDrop and djTolerance all relative
00246                      8 - keep accelerator step to theta=10.0
00247 
00248                     32 - Scale
00249                    512 - crossover 
00250                   2048 - keep lambda across mu change
00251                   4096 - return best solution (not last found)
00252                   8192 - always do a presolve in crossover
00253                  16384 - costed slacks found - so whenUsed_ longer */
00254   int lightWeight_; // 0 - normal, 1 lightweight
00255 };
00256 #endif

Generated on Sun Nov 14 14:06:32 2010 for Coin-All by  doxygen 1.4.7