00001
00002
00003
00004
00005
00006
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
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
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
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_;
00224 double drop_;
00225 double muFactor_;
00226 double stopMu_;
00227 double smallInfeas_;
00228 double reasonableInfeas_;
00229 double exitDrop_;
00230 double muAtExit_;
00231 double exitFeasibility_;
00232 double dropEnoughFeasibility_;
00233 double dropEnoughWeighted_;
00234 int * whenUsed_;
00235 int maxBigIts_;
00236 int maxIts_;
00237 int majorIterations_;
00238 int logLevel_;
00239 int logFreq_;
00240 int checkFrequency_;
00241 int lambdaIterations_;
00242 int maxIts2_;
00243 int strategy_;
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 int lightWeight_;
00256 };
00257 #endif