boxfind.h

Go to the documentation of this file.
00001 // Copyright (C) 2006 Ivo Nowak and Stefan Vigerske
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Author: Stefan Vigerske
00006 
00007 
00008 #ifndef BOXFIND_H
00009 #define BOXFIND_H
00010 
00011 #include "standard.h"
00012 #include "param.h"
00013 #include "problem.h"
00014 #include "opt.h"
00015 #include "relax.h"
00016 #include "graph.h"
00017 
00032 class BoundsFinder {
00033         private:
00036                 Pointer<Param> param;
00037 
00040                 int method;
00041 
00051                 double compute_bound(MinlpProblem& conv_prob, int& ret, int index, int block, bool low);
00052 
00053         public:
00054                 bool low, up, known;
00055 
00059                 BoundsFinder(Pointer<Param> param_=NULL);
00060                 
00067                 pair<int,int> compute_bounds(MinlpProblem& prob, vector<bool>& discr);
00068 
00076                 pair<int,int> compute_bounds_guess(MinlpProblem& prob);
00077 
00093                 pair<int,int> compute_bounds_expensive(MinlpProblem& conv_prob, dvector& lower, dvector& upper, vector<bool>& discr);
00094 
00103                 pair<int,int> compute_bounds_expensive2(MinlpProblem& conv_prob, dvector& lower, dvector& upper, vector<bool>& discr);
00104 
00109                 void compute_linbounds(MinlpProblem& prob);
00110 };
00111 
00114 class DualBounds {
00115         private:
00116                 Pointer<Param> param;
00117 
00118                 Pointer<MinlpProblem> S, C, R;
00119                 vector<Pointer<MinlpProblem> > lag_prob;
00120 
00124                 vector<list<int> > lin_con;
00127                 vector<bool> lin_con2;
00128 
00129                 int type;
00130 
00131                 double dual_bound(UserVector<double>& a);
00132 
00133         public:
00134                 DualBounds(Pointer<MinlpProblem> S_, Pointer<MinlpProblem> C_, Pointer<Param> param_, int type_=1);
00135         
00136                 int update_box(int n);
00137                 int update_box() { return update_box(S->dim()); }
00138         
00139                 double obj_bound();
00140 };
00141 
00142 
00143 class IntervalReduction {
00144         public:
00145                 typedef enum {LOWER, UPPER, WHATEVER} which_bound_type;
00146         private:
00147                 class NodeData {
00148                         friend ostream& operator<<(ostream& out, const NodeData& nd) {
00149                                 if (nd.block_nr>=0) out << nd.block_nr << ',' << nd.block_index;
00150                                 return out;
00151                         }
00152                         public:
00153                                 int block_nr, block_index;
00154 
00155                                 NodeData(int block_nr_=-1, int block_index_=-1)
00156                                 : block_nr(block_nr_), block_index(block_index_)
00157                                 { }
00158 
00159                                 NodeData& operator+=(const NodeData& nd) { return *this; }
00160                 };
00161 
00162                 class EdgeData {
00163                         friend ostream& operator<<(ostream& out, const EdgeData& ed);
00164                         public:
00165                                 which_bound_type which_bound;
00166                                 int con_nr;
00167                                 double coeff; // the coefficient before the linear variable, this edge is directed to
00168 
00169                                 EdgeData(int con_nr_, which_bound_type which_bound_, double coeff_)
00170                                 : con_nr(con_nr_), which_bound(which_bound_), coeff(coeff_)
00171                                 { }
00172 
00173                                 bool operator<(const EdgeData& ed) const { return con_nr<ed.con_nr; }
00174 
00175                                 const EdgeData& operator+=(const EdgeData& ed) const;
00176                 };
00177                 friend ostream& operator<<(ostream& out, const EdgeData& ed);
00178 
00179                 Pointer<MinlpProblem> prob;
00180 
00181                 typedef Graph<NodeData,EdgeData,true,true> DependencyGraph;
00182                 DependencyGraph dependency_graph;
00183 
00184                 void run(dvector& newlow, dvector& newup, const dvector& oldlow, const dvector& oldup, set<pair<const DependencyGraph::NodeType*, which_bound_type> >& nodeset);
00185 
00186         public:
00187                 bool do_print;
00188                 bool empty_boxes;
00189                 double min_impr;
00190                 int maxfunceval;
00191                 set<pair<int, int> > reduced_integer;
00192 
00195                 dvector reduction_by_block;
00196                 double reduction;
00197 
00198                 IntervalReduction(Pointer<MinlpProblem> prob_=NULL);
00199 
00200                 void set_problem(Pointer<MinlpProblem> prob_);
00201 
00202                 void compute(dvector& newlow, dvector& newup, const dvector& oldlow, const dvector& oldup);
00203                 void compute(dvector& newlow, dvector& newup, const dvector& oldlow, const dvector& oldup, set<pair<int, which_bound_type> >& startset);
00204 
00205                 void print_small_boxes(dvector& low, dvector& up);
00206 };
00207 
00208 
00211 class BoundsFinderLinear {
00212         private:
00213                 Pointer<Param> param;
00214 
00215                 Pointer<MinlpProblem> prob;
00216 
00217                 Pointer<MIPSolver> solver;
00218 
00219                 MIPSolver::SolutionStatus compute_bound(double& bound, int index, bool low);
00220 
00221         public:
00222                 bool low, up, known;
00223 
00224                 BoundsFinderLinear(Pointer<MinlpProblem> prob_, Pointer<Param> param_);
00225 
00226                 int compute(dvector& newlow, dvector& newup, set<pair<int, IntervalReduction::which_bound_type> >* changed_var=NULL, double min_impr=0.01);
00227 
00228 };
00229 
00230 #endif

Generated on Tue Oct 21 03:12:09 2008 for LaGO by  doxygen 1.4.7