00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef Idiot_H
00011 #define Idiot_H
00012 #ifndef OSI_IDIOT
00013 #include "ClpSimplex.hpp"
00014 #define OsiSolverInterface ClpSimplex
00015 #else
00016 #include "OsiSolverInterface.hpp"
00017 typedef int CoinBigIndex;
00018 #endif
00019 class CoinMessageHandler;
00020 class CoinMessages;
00022 typedef struct {
00023 double infeas;
00024 double objval;
00025 double dropThis;
00026 double weighted;
00027 double sumSquared;
00028 double djAtBeginning;
00029 double djAtEnd;
00030 int iteration;
00031 } IdiotResult;
00048 class Idiot {
00049
00050 public:
00051
00056
00057 Idiot ( );
00059 Idiot ( OsiSolverInterface & model );
00060
00062 Idiot(const Idiot &);
00064 Idiot & operator=(const Idiot & rhs);
00066 ~Idiot ( );
00068
00069
00073
00074 void solve();
00076 void crash(int numberPass, CoinMessageHandler * handler,
00077 const CoinMessages * messages, bool doCrossover = true);
00087 void crossOver(int mode);
00089
00090
00096 inline double getStartingWeight() const {
00097 return mu_;
00098 }
00099 inline void setStartingWeight(double value) {
00100 mu_ = value;
00101 }
00104 inline double getWeightFactor() const {
00105 return muFactor_;
00106 }
00107 inline void setWeightFactor(double value) {
00108 muFactor_ = value;
00109 }
00113 inline double getFeasibilityTolerance() const {
00114 return smallInfeas_;
00115 }
00116 inline void setFeasibilityTolerance(double value) {
00117 smallInfeas_ = value;
00118 }
00122 inline double getReasonablyFeasible() const {
00123 return reasonableInfeas_;
00124 }
00125 inline void setReasonablyFeasible(double value) {
00126 reasonableInfeas_ = value;
00127 }
00130 inline double getExitInfeasibility() const {
00131 return exitFeasibility_;
00132 }
00133 inline void setExitInfeasibility(double value) {
00134 exitFeasibility_ = value;
00135 }
00138 inline int getMajorIterations() const {
00139 return majorIterations_;
00140 }
00141 inline void setMajorIterations(int value) {
00142 majorIterations_ = value;
00143 }
00150 inline int getMinorIterations() const {
00151 return maxIts2_;
00152 }
00153 inline void setMinorIterations(int value) {
00154 maxIts2_ = value;
00155 }
00156
00157 inline int getMinorIterations0() const {
00158 return maxIts_;
00159 }
00160 inline void setMinorIterations0(int value) {
00161 maxIts_ = value;
00162 }
00166 inline int getReduceIterations() const {
00167 return maxBigIts_;
00168 }
00169 inline void setReduceIterations(int value) {
00170 maxBigIts_ = value;
00171 }
00173 inline int getLogLevel() const {
00174 return logLevel_;
00175 }
00176 inline void setLogLevel(int value) {
00177 logLevel_ = value;
00178 }
00180 inline int getLightweight() const {
00181 return lightWeight_;
00182 }
00183 inline void setLightweight(int value) {
00184 lightWeight_ = value;
00185 }
00187 inline int getStrategy() const {
00188 return strategy_;
00189 }
00190 inline void setStrategy(int value) {
00191 strategy_ = value;
00192 }
00194 inline double getDropEnoughFeasibility() const {
00195 return dropEnoughFeasibility_;
00196 }
00197 inline void setDropEnoughFeasibility(double value) {
00198 dropEnoughFeasibility_ = value;
00199 }
00201 inline double getDropEnoughWeighted() const {
00202 return dropEnoughWeighted_;
00203 }
00204 inline void setDropEnoughWeighted(double value) {
00205 dropEnoughWeighted_ = value;
00206 }
00208 inline void setModel(OsiSolverInterface * model) {
00209 model_ = model;
00210 };
00212
00213
00215 private:
00216
00218
00219 public:
00220 void solve2(CoinMessageHandler * handler, const CoinMessages *messages);
00221 private:
00222 IdiotResult IdiSolve(
00223 int nrows, int ncols, double * rowsol , double * colsol,
00224 double * pi, double * djs, const double * origcost ,
00225 double * rowlower,
00226 double * rowupper, const double * lower,
00227 const double * upper, const double * element,
00228 const int * row, const CoinBigIndex * colcc,
00229 const int * length, double * lambda,
00230 int maxIts, double mu, double drop,
00231 double maxmin, double offset,
00232 int strategy, double djTol, double djExit, double djFlag,
00233 CoinThreadRandom * randomNumberGenerator);
00234 int dropping(IdiotResult result,
00235 double tolerance,
00236 double small,
00237 int *nbad);
00238 IdiotResult objval(int nrows, int ncols, double * rowsol , double * colsol,
00239 double * pi, double * djs, const double * cost ,
00240 const double * rowlower,
00241 const double * rowupper, const double * lower,
00242 const double * upper, const double * elemnt,
00243 const int * row, const CoinBigIndex * columnStart,
00244 const int * length, int extraBlock, int * rowExtra,
00245 double * solExtra, double * elemExtra, double * upperExtra,
00246 double * costExtra, double weight);
00247
00248 int cleanIteration(int iteration, int ordinaryStart, int ordinaryEnd,
00249 double * colsol, const double * lower, const double * upper,
00250 const double * rowLower, const double * rowUpper,
00251 const double * cost, const double * element, double fixTolerance, double & objChange,
00252 double & infChange, double & maxInfeasibility);
00253 private:
00255 OsiSolverInterface * model_;
00256
00257 double djTolerance_;
00258 double mu_;
00259 double drop_;
00260 double muFactor_;
00261 double stopMu_;
00262 double smallInfeas_;
00263 double reasonableInfeas_;
00264 double exitDrop_;
00265 double muAtExit_;
00266 double exitFeasibility_;
00267 double dropEnoughFeasibility_;
00268 double dropEnoughWeighted_;
00269 int * whenUsed_;
00270 int maxBigIts_;
00271 int maxIts_;
00272 int majorIterations_;
00273 int logLevel_;
00274 int logFreq_;
00275 int checkFrequency_;
00276 int lambdaIterations_;
00277 int maxIts2_;
00278 int strategy_;
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295 int lightWeight_;
00296 };
00297 #endif