00001 #ifndef SCIL_ILP_PROBLEM_H
00002 #define SCIL_ILP_PROBLEM_H
00003
00004 #include<LEDA/tuple.h>
00005 #include<LEDA/list.h>
00006 #include<LEDA/map.h>
00007 #include<LEDA/d_array.h>
00008 #include<abacus/master.h>
00009 #include<abacus/sub.h>
00010 #include<abacus/row.h>
00011 #include<abacus/conbranchrule.h>
00012 #include<abacus/column.h>
00013
00014 #include<scil/cons.h>
00015 #include<scil/variable.h>
00016 #include<scil/solution.h>
00017
00018 namespace SCIL {
00019
00020 class primal_heuristic;
00021 class sym_constraint;
00022 class subproblem;
00023
00024 typedef LEDA::three_tuple<var, cons, double> Coefficient;
00025
00028 class ILP_Problem : public ABA_MASTER
00029 {
00030 friend class subproblem;
00031 friend class ABA_Constraint;
00032 friend class ABA_Variable;
00033
00034 private:
00035 solution Sol;
00036 int lpsolverset;
00037 LEDA::list<sym_constraint*> sym_constraints;
00038 LEDA::list<Coefficient> coeff_list;
00039 Optsense os;
00040 LEDA::d_array<LEDA::string, LEDA::string> ConfMap;
00041 int nvars;
00042 int nconss;
00043
00044 subproblem* myroot;
00045
00046 public:
00047
00051
00054 ILP_Problem(Optsense optSense, bool price=false);
00055
00056 virtual
00057 ~ILP_Problem();
00058
00059 virtual
00060 ABA_SUB *firstSub();
00061
00062 primal_heuristic* primal_heur;
00063
00064 void ChangeToCompiledLpSolver() {
00065 #ifdef ABACUS_LP_SOPLEX
00066 lpsolverset=ABA_MASTER::Soplex;
00067 #endif
00068 #ifdef ABACUS_LP_CPLEX
00069 lpsolverset=ABA_MASTER::Cplex;
00070 #endif
00071 };
00073
00077
00083 var add_variable(double obj, double lBound, double uBound, Vartype vt,
00084 Activation a=Static);
00085
00089 cons add_basic_constraint(cons_sense s, double r, Activation a=Static);
00090
00093 cons add_basic_constraint(cons_obj* c, Activation a=Static);
00094
00097 var add_variable(var_obj* v, Activation a=Static);
00098
00100 void add_sym_constraint(sym_constraint* c);
00101
00104 void set_coefficient(var v, cons i, double d);
00105
00107 void set_primal_heuristic(primal_heuristic* P);
00108
00110
00114
00116 int number_of_variables() {
00117 return nvars;
00118 }
00119
00121 int number_of_constraints() {
00122 return nconss;
00123 }
00124
00126
00130
00132 const
00133 LEDA::string& configuration(const LEDA::string&) const;
00134
00136 LEDA::string& configuration(const LEDA::string&);
00137
00139 void read_configuration_file(LEDA::string);
00140
00142
00146
00148 void optimize();
00149
00151
00155
00156 Optsense opt_sense() { return os; };
00157
00159 double get_solution(var v);
00160
00162 double get_solution(row& r);
00163
00165
00166 void set_silent() {
00167 outLevel(ILP_Problem::Silent);
00168 };
00169
00170 void save_solution(solution& S) {
00171 var v;
00172 double obj=0;
00173 forall_variables(v, *myroot) {
00174 obj+=S.value(v)*v.obj();
00175 };
00176
00177 if(betterPrimal(obj)) {
00178 updateBestSolution(S);
00179 primalBound(obj);
00180 }
00181 };
00182
00183 private:
00184 void updateBestSolution(solution&);
00185
00186 void initialize_Optimization();
00187
00188 virtual void initializeParameters();
00189
00190 };
00191
00192 }
00193
00194 #endif