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

subproblem.h

00001 #ifndef SCIL_SUBPROBLEM_H
00002 #define SCIL_SUBPROBLEM_H
00003 
00004 #include<abacus/sub.h>
00005 #include<scil/global.h>
00006 #include<abacus/lpsub.h>
00007 #include<scil/row.h>
00008 #include<scil/sym_constraint.h>
00009 
00010 namespace SCIL {
00011 
00012 class solution;
00013 class var;
00014 class sym_constraint;
00015 class cons;
00016 class cons_obj;
00017 class ABA_Variable;
00018 class ABA_Constraint;
00019 class ILP_Problem;
00020 
00021 #define forall_variables(x,S)\
00022 for(int loop_var = (S).first_variable_item();\
00023 x=(S).get_var(loop_var), x != nil; \
00024 loop_var=(S).next_variable_item(loop_var) )
00025 
00026 #define forall_basic_constraints(x,S)\
00027 for(int loop_var = (S).first_constraint_item();\
00028 x=(S).get_cons(loop_var), x != nil; \
00029 loop_var=(S).next_constraint_item(loop_var) )
00030   
00033 
00034 class subproblem : private ABA_SUB
00035 {
00036 
00037  public: //TODO remake private
00038   friend class ABA_Variable;
00039   friend class ABA_Constraint;
00040   friend class ILP_Problem;
00041 
00042   int t;
00043   ILP_Problem & GM;
00044   bool initpricing;
00045   ABA_BUFFER < ABA_VARIABLE * >*newvarbuffer;
00046   std::list < sym_constraint * >sym_constraints;
00047   int updateLP;
00048   bool check_LP ();
00049   double prio;
00050 
00051  protected:
00052   virtual void fixByLogImp(ABA_BUFFER<int>& variable, ABA_BUFFER<ABA_FSVARSTAT*>& status);
00053   virtual void setByLogImp(ABA_BUFFER<int>& variable, ABA_BUFFER<ABA_FSVARSTAT*>& status);
00054 
00055  private:
00056   // Some typedefs for iteration
00057   typedef std::list <sym_constraint*>::iterator sym_constraint_iterator;
00058   typedef std::list <sym_constraint*>::const_iterator sym_constraint_constiterator;
00059 
00060  public:
00061 
00062   ABA_LPSUB* get_lp() {
00063      return lp();
00064   }
00065 
00066   ABA_BRANCHRULE* get_branch_rule() {
00067      return branchRule();
00068   }
00069   
00073 
00077   var add_binary_variable (double obj, Activation a = Static);
00078 
00084   var add_variable (double obj, double lBound, double uBound, Vartype,
00085                     Activation a = Static);
00086 
00089   void add_variable (var, Activation a = Static);
00090 
00095   virtual
00096   cons add_basic_constraint (cons_sense, double, Activation a = Dynamic, Validity v = Global);
00097 
00101   virtual
00102   cons add_basic_constraint (cons_obj * c, Activation a = Dynamic, Validity v = Global);
00103 
00106   virtual
00107   cons _add_basic_constraint (cons_obj * c, Activation a = Dynamic, Validity v = Global);
00108 
00110   void add_sym_constraint (sym_constraint * c);
00111 
00114   void remove_variable (var V);
00115 
00118   void set_coefficient (var v, cons i, double d);
00119 
00121 
00125 
00126 
00127   Varstat get_varstat(var v);
00129   var get_var (int i);
00130 
00132   int nVar () const;
00133 
00135   double get_coeff (var v, cons i);
00136 
00138   int get_level() const {
00139 
00140      return level();
00141   }
00143   int first_variable_item() const { 
00144     return 0; }
00145 
00147   int next_variable_item(int i) const {
00148     return i+1;
00149   };
00150 
00151   int first_constraint_item() const { 
00152     return 0; }
00153 
00155   int next_constraint_item(int i) const {
00156     return i+1;
00157   };
00158 
00159   // TODO: possibility to iteratoe over sym_constraints. Maybe via
00162 
00164   cons get_cons (int i);
00165 
00166   int found_constraint() {
00167     return t>0;
00168   };
00169 
00171   int ncons ();
00172 
00174   virtual
00175   double value (var v);
00176 
00178   double value(row& r);
00179 
00181   double lower_bound (var v);
00182 
00184   double upper_bound (var v);
00185 
00191   double value (cons i, as_what as = as_is);
00192 
00194   double red_cost(var v);
00195 
00196   bool save_solution(solution& s);
00197 
00199 
00203 
00205   const
00206   std::string configuration(const std::string& s) const;
00207 
00209   void configuration(const std::string& s, const std::string& t);
00210 
00212 
00213   subproblem(ABA_MASTER * master);
00214 
00215   subproblem(ABA_MASTER * master, ABA_SUB * father, ABA_BRANCHRULE * branchRule);
00216 
00217   virtual ~ subproblem ();
00218 
00219   virtual bool feasible ();
00220 
00221   virtual bool feasible (subproblem &, solution&);
00222 
00223   void update_indices (); 
00224 
00225   virtual int separate ();
00226   
00227   virtual int separate (subproblem &); 
00228 
00229   void activate (subproblem & S);
00230 
00231   void activate ();
00232 
00233   void deactivate (subproblem & S);
00234 
00235   void deactivate ();
00236 
00237   double myvalue (int i);
00238 
00239   virtual int pricing ();
00240 
00241   virtual int pricing (subproblem &);
00242 
00243   virtual int mf_pricing (subproblem &); 
00244 
00245   virtual int improve (double&);
00246 
00247   double *MxVal ();
00248 
00249   virtual ABA_SUB * generateSon (ABA_BRANCHRULE * rule);
00250 
00251 };
00252 
00253 }
00254 #endif
Generated on Mon Mar 28 22:03:50 2011 for SCIL by  doxygen 1.6.3