00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GAMSBCH_HPP_
00010 #define GAMSBCH_HPP_
00011
00012 #include "GAMSlinksConfig.h"
00013
00014 #include "CoinPragma.hpp"
00015
00016 #include <vector>
00017
00018 #include "GamsHandler.hpp"
00019 #include "GamsOptions.hpp"
00020 #include "GamsDictionary.hpp"
00021
00024 class GamsBCH {
00025 public:
00028 class Cut {
00029 public:
00031 double lb;
00033 double ub;
00035 int nnz;
00037 int* indices;
00039 double* coeff;
00040
00044 Cut();
00047 ~Cut();
00048 };
00049
00050 private:
00051 GamsHandler& gams;
00052
00053 struct dictRec* dict;
00054
00055
00056 double *node_x;
00057
00058 double *node_lb;
00059
00060 double *node_ub;
00061
00062 bool have_incumbent;
00063 bool new_incumbent;
00064 double incumbent_value;
00065
00066 double *incumbent;
00067
00068 double *global_lb;
00069
00070 double *global_ub;
00071
00072 bool userkeep;
00073
00074 int heurfreq;
00075 int heurinterval;
00076 int heurmult;
00077 int heurfirst;
00078 bool heurnewint;
00079 int heurobjfirst;
00080 char heurcall[1024];
00081
00082 char cutcall[1024];
00083 int cutfreq;
00084 int cutinterval;
00085 int cutmult;
00086 int cutfirst;
00087 bool cutnewint;
00088
00089 char incbcall[1024];
00090 char incbicall[1024];
00091
00092 char userjobid[1024];
00093
00094 char gdxname[1024];
00095 char gdxnameinc[1024];
00096 char usergdxin[1024];
00097
00098 int ncalls;
00099 int ncuts;
00100 int nsols;
00101
00102 int loglevel;
00103
00104 void init();
00105
00110 int reportIncumbent();
00111 public:
00117 GamsBCH(GamsHandler& gams_, GamsDictionary& gamsdict, GamsOptions& opt);
00123 GamsBCH(GamsHandler& gams_, GamsDictionary& gamsdict);
00124
00127 ~GamsBCH();
00128
00132 void setupParameters(GamsOptions& opt);
00133
00137 void set_userjobid(const char* userjobid);
00138 void set_usergdxname(const char* usergdxname, const char* usergdxprefix = NULL);
00139 void set_usergdxnameinc(const char* usergdxnameinc, const char* usergdxprefix = NULL);
00140 void set_usergdxin(const char* usergdxin_, const char* usergdxprefix = NULL);
00141 void set_userkeep(bool userkeep_) { userkeep = userkeep_; }
00142
00143 void set_usercutcall(const char* usercutcall);
00144 void set_usercutfreq(int usercutfreq) { cutfreq=usercutfreq; }
00145 void set_usercutinterval(int usercutinterval) { cutinterval=usercutinterval; }
00146 void set_usercutmult(int usercutmult) { cutmult=usercutmult; }
00147 void set_usercutfirst(int usercutfirst) { cutfirst=usercutfirst; }
00148 void set_usercutnewint(bool usercutnewint) { cutnewint=usercutnewint; }
00149
00150 void set_userheurcall(const char* userheurcall);
00151 void set_userheurfreq(int userheurfreq) { heurfreq=userheurfreq; }
00152 void set_userheurinterval(int userheurinterval) { heurinterval=userheurinterval; }
00153 void set_userheurmult(int userheurmult) { heurmult=userheurmult; }
00154 void set_userheurfirst(int userheurfirst) { heurfirst=userheurfirst; }
00155 void set_userheurnewint(bool userheurnewint) { heurnewint=userheurnewint; }
00156 void set_userheurobjfirst(int userheurobjfirst) { heurobjfirst=userheurobjfirst; }
00157
00158 void set_userincbcall(const char* userincbcall);
00159 void set_userincbicall(const char* userincbicall);
00160
00161 const char* get_usercutcall() { return cutcall; }
00162 bool get_usercutnewint() const { return cutnewint; }
00163
00164 const char* get_userheurcall() { return heurcall; }
00165 bool get_userheurnewint() const { return heurnewint; }
00166
00170 void setLogLevel(int loglevel_) { loglevel=loglevel_; }
00171
00174 int getNumCalls() const { return ncalls; }
00177 int getNumCuts() const { return ncuts; }
00180 int getNumSols() const { return nsols; }
00181
00185 int getNumCols() const { return gams.getColCount(); }
00186
00187 void printParameters() const;
00188
00191 void setGlobalBounds(const double* lb_, const double* ub_);
00192
00196 void setNodeSolution(const double* x_, double objval_, const double* lb_, const double* ub_);
00197
00204 bool setIncumbentSolution(const double* x_, double objval_);
00205
00209 bool doCuts();
00210
00216 bool generateCuts(std::vector<Cut>& cuts);
00217
00221 bool doHeuristic(double bestbnd, double curobj);
00222
00228 bool runHeuristic(double* x, double& objvalue);
00229 };
00230
00231 #endif