GamsBCH.hpp

Go to the documentation of this file.
00001 // Copyright (C) GAMS Development 2007-2008
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // $Id: GamsBCH.hpp 510 2008-08-16 19:31:27Z stefan $
00006 //
00007 // Author: Stefan Vigerske
00008 
00009 #ifndef GAMSBCH_HPP_
00010 #define GAMSBCH_HPP_
00011 
00012 #include "GAMSlinksConfig.h"
00013 // from CoinUtils
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         /* storage of size iolib.ncols for node relaxation solution */
00056   double    *node_x;
00057         /* storage of size iolib.ncols for node lower bound */
00058   double    *node_lb;
00059         /* storage of size iolib.ncols for node upper bound */
00060   double    *node_ub;
00061 
00062   bool      have_incumbent;
00063   bool      new_incumbent;
00064   double    incumbent_value; /* objective function value of incumbent */
00065         /* storage of size iolib.ncols for incumbent solution */
00066   double    *incumbent;
00067         /* storage of size iolib.ncols for global lower bounds */
00068   double    *global_lb;
00069         /* storage of size iolib.ncols for global upper bounds */
00070   double    *global_ub;
00071   
00072   bool       userkeep;       /* indicator for running gamskeep */
00073 
00074   int       heurfreq;       /* heuristic frequency */
00075   int       heurinterval;
00076   int       heurmult;
00077   int       heurfirst;      /* heuristic at first nodes */
00078   bool      heurnewint;     /* heuristic if new incumbent */
00079   int       heurobjfirst;   /* heurisitc at first nodes if node obj is good */
00080   char      heurcall[1024];      /* command line minus gams for the heuristic */
00081 
00082   char      cutcall[1024];       /* command line minus gams for the cut generation */
00083   int       cutfreq;        /* cut frequency */
00084   int       cutinterval;
00085   int       cutmult;
00086   int       cutfirst;       /* cuts at first nodes */
00087   bool      cutnewint;      /* cuts if new incumbent */
00088 
00089   char      incbcall[1024];      /* command line minus gams for the incumbent checking callback */
00090   char      incbicall[1024];     /* command line minus gams for the incumbent reporting callback */
00091 
00092   char      userjobid[1024];     /* jobid added to gdxname, gdxnameinc, usergdxin, adds --userjobid to the calls and o and lf */
00093 
00094   char      gdxname[1024];       /* GDX file name for solution read by the GAMS models */
00095   char      gdxnameinc[1024];    /* GDX file name for incumbent read by the GAMS models */
00096   char      usergdxin[1024];     /* GDX file name for reading stuff back */
00097         
00098         int       ncalls; /* number of BCH calls performed */
00099         int       ncuts;  /* number of cuts received */
00100         int       nsols;  /* number of primal solutions received */
00101         
00102         int       loglevel; /* amount of output printed by GamsBCH class */
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 /*GAMSBCH_HPP_*/

Generated on Tue Dec 30 03:01:24 2008 for GAMSlinks by  doxygen 1.4.7