Main Page   Class Hierarchy   Compound List   File List   Contact   Download   Symbolic Constraints   Examples  

ilp_problem.h

00001 #ifndef SCIL_ILP_PROBLEM_H
00002 #define SCIL_ILP_PROBLEM_H
00003 
00004 #include<tr1/tuple>
00005 #include<map>
00006 #include<abacus/master.h>
00007 #include<abacus/sub.h>
00008 #include<abacus/row.h>
00009 #include<abacus/conbranchrule.h>
00010 #include<abacus/column.h>
00011 
00012 #include<scil/cons.h>
00013 #include<scil/variable.h>
00014 #include<scil/solution.h>
00015 #include<scil/primal_heur.h>
00016 #include<scil/implicator.h>
00017 
00018 #include<vector>
00019 
00020 //FIXME
00021 #include<scil/row_constraint.h>
00022 
00023 namespace SCIL {
00024 
00025 class sym_constraint;
00026 class subproblem;
00027 class monomial;
00028 class polynomial;
00029 class pol_constraint;
00030 class monomial_inst;
00031 class bool_inst;
00032 class QuadRef;
00033 class mon_split_strategy;
00034 class bool_split_strategy;
00035 class boolfunction;
00036 
00037 typedef std::tr1::tuple<var, cons, double> Coefficient;
00038 
00041 class ILP_Problem : public ABA_MASTER // TODO make private
00042 {
00043   friend class subproblem;
00044   friend class ABA_Constraint;
00045   friend class ABA_Variable;
00046   
00047 private:
00048   solution Sol;
00049   std::list<sym_constraint*> sym_constraints;
00050   std::list<Coefficient> coeff_list;
00051   std::list<monomial> monomials;
00052   Optsense os;
00053   std::map<std::string, std::string> ConfMap;
00054   monomial_inst* monomialinstance;
00055   bool_inst* boolinstance;
00056   int nvars; 
00057   int nconss;
00058   bool objint;
00059   int numcon;
00060   bool spb;
00061   double pb;
00062   mon_split_strategy* mon_splitstrat;
00063   bool_split_strategy* bool_splitstrat;
00064   bool qr_on_separate;
00065   quadRefStatus qrType;
00066   std::list<boolfunction*> bf_list;
00067   std::list<boolfunction*> bf_toDelete;
00068   
00069 
00070 
00071 
00072   subproblem* myroot;
00073 
00074  public:
00075   primal_heuristic* primal_heur;
00076   implicator* implic;
00077   QuadRef* qr;
00078   virtual 
00079     ABA_SUB *firstSub();
00080   //FIXME
00081   //virtual int enumerationStrategy (const ABA_SUB *s1, const ABA_SUB *s2);
00082   
00086 
00089   ILP_Problem(Optsense optSense, bool price=false, int numcon=-1, const char* problemName = "none");
00090 
00091 virtual 
00092     ~ILP_Problem();
00093 
00094 
00095 
00096 
00097 
00101 
00108   var add_binary_variable(double obj, Activation a=Static);
00109 
00116   var add_variable(double obj, double lBound, double uBound, Vartype vt,
00117                    Activation a=Static);
00118 
00122   cons add_basic_constraint(cons_sense s, double r, Activation a=Static);
00123 
00126   cons add_basic_constraint(cons_obj* c, Activation a=Static, quadRefStatus qrStatus=CHECK);
00127 
00130   var add_variable(var_obj* v, Activation a=Static);
00131 
00133   row add_polynomial(polynomial p, bool update = true);
00135   row add_polynomial(monomial m, bool update = true);
00136   
00138   var add_boolfunction(boolfunction* bf, double c);
00139 
00145   void add_bool_constraint(std::list<boolfunction*>& bcl, bool_cons_type bct);
00146 
00150   void add_bool_constraint(boolfunction* bf, bool_cons_type bct);
00151 
00153   void add_sym_constraint(sym_constraint* c);
00154 
00156   void add_pol_constraint(pol_constraint c);
00157 
00160   void set_coefficient(var v, cons i, double d);
00161 
00163   void set_obj_coefficient(var v, double d);
00164 
00166   void set_primal_heuristic(primal_heuristic* P);
00167  
00169   void extendSolution(solution& S);
00170 
00171   void set_implicator(implicator* P);
00172 
00174   void set_monomial_split_strategy(mon_split_strategy* spst);
00175 
00177   void set_bool_split_strategy(bool_split_strategy* spst);
00178 
00180   void set_qr_on_separate(bool qr);
00181 
00183   void set_qrType(quadRefStatus qt);
00184 
00185 
00187 
00191 
00193   int number_of_variables() {
00194     return nvars;
00195   }
00196   
00198   int number_of_constraints() {
00199     return nconss;
00200   }
00201 
00203   double get_obj_coefficient(var v) const;
00204 
00206   quadRefStatus get_qrType();
00207 
00209   bool get_qr_on_separate();
00211 
00212 
00216 
00218   const
00219   std::string configuration(const std::string&) const;
00220 
00222   void configuration(const std::string&, const std::string&);
00223 
00225   void read_configuration_file(const char*);
00226 
00228 
00232 
00234   void optimize();
00235 
00237 
00241 
00242   Optsense opt_sense() { return os;  };
00243 
00245   double get_solution(var v);
00246 
00248   double get_solution(row& r);
00249 
00251   solution get_solution();
00252 
00254   double get_optimum();
00255   
00257 
00258   void set_silent() {
00259     outLevel(ILP_Problem::Silent);
00260   };
00261 
00262   void primal_bound(double b) {
00263      pb = b;
00264      spb = true;
00265   };
00266 
00267   bool save_solution(solution& S) {
00268     var v;
00269     double obj=0.;
00270     forall_variables(v, *myroot) {
00271       obj+=S.value(v)*v.obj();
00272      };
00273 
00274     if(betterPrimal(obj)) {
00275       updateBestSolution(S);
00276       primalBound(obj);
00277       return true;
00278     }
00279     return false;
00280   };
00281 
00282  private:
00283   void updateBestSolution(solution&);
00284 
00285   void initializeOptimization();
00286   
00287   virtual void initializeParameters();
00288 };
00289 
00290 };
00291 
00292 #endif
Generated on Mon Mar 28 22:03:48 2011 for SCIL by  doxygen 1.6.3