Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

Idiot.hpp

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;
00018 // for use internally
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;};
00141   inline int getReduceIterations() const
00142   { return maxBigIts_;};
00143   inline void setReduceIterations(int value)
00144   { maxBigIts_ = value;};
00146   inline int getLogLevel() const
00147   { return logLevel_;};
00148   inline void setLogLevel(int value)
00149   { logLevel_ = value;};
00151   inline int getLightweight() const
00152   { return lightWeight_;};
00153   inline void setLightweight(int value)
00154   { lightWeight_ = value;};
00156   inline int getStrategy() const
00157   { return strategy_;};
00158   inline void setStrategy(int value)
00159   { strategy_ = value;};
00161   inline double getDropEnoughFeasibility() const
00162   { return dropEnoughFeasibility_;};
00163   inline void setDropEnoughFeasibility(double value)
00164   { dropEnoughFeasibility_=value;};
00166   inline double getDropEnoughWeighted() const
00167   { return dropEnoughWeighted_;};
00168   inline void setDropEnoughWeighted(double value)
00169   { dropEnoughWeighted_=value;};
00171 
00172 
00174 private:
00175 
00177   void solve2(CoinMessageHandler * handler,const CoinMessages *messages);
00178 IdiotResult IdiSolve(
00179                      int nrows, int ncols, double * rowsol , double * colsol,
00180                      double * pi, double * djs, const double * origcost , 
00181                      const double * rowlower,
00182                      double * rowupper, const double * lower,
00183                      const double * upper, const double * element, 
00184                      const int * row, const CoinBigIndex * colcc,
00185                      const int * length, double * lambda,
00186                      int maxIts,double mu,double drop,
00187                      double maxmin, double offset,
00188                      int strategy,double djTol,double djExit,double djFlag);
00189 int dropping(IdiotResult result,
00190              double tolerance,
00191              double small,
00192              int *nbad);
00193 IdiotResult objval(int nrows, int ncols, double * rowsol , double * colsol,
00194                    double * pi, double * djs, const double * cost , 
00195                    const double * rowlower,
00196                    const double * rowupper, const double * lower,
00197                    const double * upper, const double * elemnt, 
00198                    const int * row, const CoinBigIndex * columnStart,
00199                    const int * length, int extraBlock, int * rowExtra,
00200                    double * solExtra, double * elemExtra, double * upperExtra,
00201                    double * costExtra,double weight);
00202 
00203 private:
00205   OsiSolverInterface * model_;
00206 
00207   double djTolerance_;
00208   double mu_;  /* starting mu */
00209   double drop_; /* exit if drop over 5 checks less than this */
00210   double muFactor_; /* reduce mu by this */
00211   double stopMu_; /* exit if mu gets smaller than this */
00212   double smallInfeas_; /* feasibility tolerance */
00213   double reasonableInfeas_; /* use lambdas if feasibility less than this */
00214   double exitDrop_; /* candidate for stopping after a major iteration */
00215   double muAtExit_; /* mu on exit */
00216   double exitFeasibility_; /* exit if infeasibility less than this */
00217   double dropEnoughFeasibility_; /* okay if feasibility drop this factor */
00218   double dropEnoughWeighted_; /* okay if weighted obj drop this factor */
00219   int * whenUsed_; /* array to say what was used */
00220   int maxBigIts_; /* always reduce mu after this */
00221   int maxIts_; /* do this many iterations on first go */
00222   int majorIterations_;
00223   int logLevel_;
00224   int logFreq_;
00225   int checkFrequency_; /* can exit after 5 * this iterations (on drop) */
00226   int lambdaIterations_; /* do at least this many lambda iterations */ 
00227   int maxIts2_; /* do this many iterations on subsequent goes */
00228   int strategy_;   /* 0 - default strategy
00229                      1 - do accelerator step but be cautious
00230                      2 - do not do accelerator step 
00231                      4 - drop, exitDrop and djTolerance all relative
00232                      8 - keep accelerator step to theta=10.0
00233 
00234                     32 - Scale
00235                    512 - crossover 
00236                   2048 - keep lambda across mu change
00237                   4096 - return best solution (not last found) */
00238   int lightWeight_; // 0 - normal, 1 lightweight
00239 };
00240 #endif

Generated on Wed Dec 3 14:37:36 2003 for CLP by doxygen 1.3.5