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,
00075 const CoinMessages * messages, bool doCrossover = true);
00085 void crossOver(int mode);
00087
00088
00094 inline double getStartingWeight() const {
00095 return mu_;
00096 }
00097 inline void setStartingWeight(double value) {
00098 mu_ = value;
00099 }
00102 inline double getWeightFactor() const {
00103 return muFactor_;
00104 }
00105 inline void setWeightFactor(double value) {
00106 muFactor_ = value;
00107 }
00111 inline double getFeasibilityTolerance() const {
00112 return smallInfeas_;
00113 }
00114 inline void setFeasibilityTolerance(double value) {
00115 smallInfeas_ = value;
00116 }
00120 inline double getReasonablyFeasible() const {
00121 return reasonableInfeas_;
00122 }
00123 inline void setReasonablyFeasible(double value) {
00124 reasonableInfeas_ = value;
00125 }
00128 inline double getExitInfeasibility() const {
00129 return exitFeasibility_;
00130 }
00131 inline void setExitInfeasibility(double value) {
00132 exitFeasibility_ = value;
00133 }
00136 inline int getMajorIterations() const {
00137 return majorIterations_;
00138 }
00139 inline void setMajorIterations(int value) {
00140 majorIterations_ = value;
00141 }
00148 inline int getMinorIterations() const {
00149 return maxIts2_;
00150 }
00151 inline void setMinorIterations(int value) {
00152 maxIts2_ = value;
00153 }
00154
00155 inline int getMinorIterations0() const {
00156 return maxIts_;
00157 }
00158 inline void setMinorIterations0(int value) {
00159 maxIts_ = value;
00160 }
00164 inline int getReduceIterations() const {
00165 return maxBigIts_;
00166 }
00167 inline void setReduceIterations(int value) {
00168 maxBigIts_ = value;
00169 }
00171 inline int getLogLevel() const {
00172 return logLevel_;
00173 }
00174 inline void setLogLevel(int value) {
00175 logLevel_ = value;
00176 }
00178 inline int getLightweight() const {
00179 return lightWeight_;
00180 }
00181 inline void setLightweight(int value) {
00182 lightWeight_ = value;
00183 }
00185 inline int getStrategy() const {
00186 return strategy_;
00187 }
00188 inline void setStrategy(int value) {
00189 strategy_ = value;
00190 }
00192 inline double getDropEnoughFeasibility() const {
00193 return dropEnoughFeasibility_;
00194 }
00195 inline void setDropEnoughFeasibility(double value) {
00196 dropEnoughFeasibility_ = value;
00197 }
00199 inline double getDropEnoughWeighted() const {
00200 return dropEnoughWeighted_;
00201 }
00202 inline void setDropEnoughWeighted(double value) {
00203 dropEnoughWeighted_ = value;
00204 }
00206
00207
00209 private:
00210
00212
00213 public:
00214 void solve2(CoinMessageHandler * handler, const CoinMessages *messages);
00215 private:
00216 IdiotResult IdiSolve(
00217 int nrows, int ncols, double * rowsol , double * colsol,
00218 double * pi, double * djs, const double * origcost ,
00219 double * rowlower,
00220 double * rowupper, const double * lower,
00221 const double * upper, const double * element,
00222 const int * row, const CoinBigIndex * colcc,
00223 const int * length, double * lambda,
00224 int maxIts, double mu, double drop,
00225 double maxmin, double offset,
00226 int strategy, double djTol, double djExit, double djFlag,
00227 CoinThreadRandom * randomNumberGenerator);
00228 int dropping(IdiotResult result,
00229 double tolerance,
00230 double small,
00231 int *nbad);
00232 IdiotResult objval(int nrows, int ncols, double * rowsol , double * colsol,
00233 double * pi, double * djs, const double * cost ,
00234 const double * rowlower,
00235 const double * rowupper, const double * lower,
00236 const double * upper, const double * elemnt,
00237 const int * row, const CoinBigIndex * columnStart,
00238 const int * length, int extraBlock, int * rowExtra,
00239 double * solExtra, double * elemExtra, double * upperExtra,
00240 double * costExtra, double weight);
00241
00242 int cleanIteration(int iteration, int ordinaryStart, int ordinaryEnd,
00243 double * colsol, const double * lower, const double * upper,
00244 const double * rowLower, const double * rowUpper,
00245 const double * cost, const double * element, double fixTolerance, double & objChange,
00246 double & infChange);
00247 private:
00249 OsiSolverInterface * model_;
00250
00251 double djTolerance_;
00252 double mu_;
00253 double drop_;
00254 double muFactor_;
00255 double stopMu_;
00256 double smallInfeas_;
00257 double reasonableInfeas_;
00258 double exitDrop_;
00259 double muAtExit_;
00260 double exitFeasibility_;
00261 double dropEnoughFeasibility_;
00262 double dropEnoughWeighted_;
00263 int * whenUsed_;
00264 int maxBigIts_;
00265 int maxIts_;
00266 int majorIterations_;
00267 int logLevel_;
00268 int logFreq_;
00269 int checkFrequency_;
00270 int lambdaIterations_;
00271 int maxIts2_;
00272 int strategy_;
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 int lightWeight_;
00285 };
00286 #endif