lagheu.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 #ifndef LAGHEU_H
00008 #define LAGHEU_H
00009 
00010 #include "standard.h"
00011 #include "problem.h"
00012 #include "relaxopt.h"
00013 #include "linrelax.h"
00014 #include "bcp.h"
00015 
00023 class LagHeu : public RelaxationSolver {
00024         private:
00027                 Pointer<MIPSolver> project_LP;
00030                 Pointer<SparseVector<double> > project_LP_obj;
00031 
00032                 list<const MIPSolver::RowItem*> project_LP_cuts;
00033 
00036                 int x_con_start;
00037 
00038                 Pointer<MIPSolver> lagheu_LP;
00039                 int z_start;
00040 
00041                 bool project_and_round_rek(dvector& x, map<int, double>& unfixed, int& switch_count);
00042 
00043                 int switch_count_limit;
00044 
00045         protected:
00046                 Pointer<MinlpNode> node;
00047 
00048                 vector<list<const MIPSolver::ColItem*> > lagheu_LP_columns;
00049 
00054                 void make_project_LP();
00057                 void update_project_LP();
00058 
00061                 void update_project_LP_x(const dvector& x);
00062 
00067                 MIPSolver::SolutionStatus solve_project_LP(dvector& sol);
00068                 MIPSolver::SolutionStatus solve_project_LP(double& val);
00069 
00070                 void project_LP_fix_variable(int i, double val);
00071                 void project_LP_unfix_variable(int i);
00072 
00078                 void make_lagheu_LP(double delta);
00079 
00080                 MIPSolver::SolutionStatus solve_lagheu_LP();
00081                 MIPSolver::SolutionStatus solve_lagheu_LP(dvector &z, dvector& x);
00082                 MIPSolver::SolutionStatus solve_lagheu_LP(vector<dvector> &z, dvector& x);
00083 
00084                 void lagheu_LP_fixblock(int k, const MIPSolver::ColItem* colitem);
00085                 void lagheu_LP_unfixblock(int k);
00086 
00089                 double couple_con_violation(const dvector& x);
00090 
00093                 double delta;
00094 
00099                 bool project_and_round(dvector& x);
00100 
00101         public:
00102                 LagHeu(Pointer<MinlpProblem> orig_prob_, Pointer<LinearRelax> linrelax_, bool is_gams_prob=false, double closeval_tol_=0., Pointer<dvector> diam_=NULL, Pointer<Param> param_=NULL, Pointer<ostream> out_solver_p_=out_out_p, Pointer<ostream> out_solver_log_p_=out_log_p)
00103                 : RelaxationSolver(orig_prob_, is_gams_prob, closeval_tol_, diam_, param_, out_solver_p_, out_solver_log_p_),
00104                   delta(param_->get_d("LagHeu penalty parameter", 10.)), switch_count_limit(2*orig_prob_->i_discr.size())
00105                 {       set_linear_relax(linrelax_);
00106                 }
00107 
00108                 void set_linear_relax(Pointer<LinearRelax> linrelax_) {
00109                         RelaxationSolver::set_linear_relax(linrelax_);
00110                         make_project_LP();
00111                 }
00112 
00113                 virtual int solve(Pointer<MinlpNode> node_)=0;
00114 
00115                 int solve() {
00116                         assert(node);
00117                         return solve(node);
00118                 }
00119 
00120                 using Solver::solve;
00121 };
00122 
00123 class LagHeu1 : public LagHeu {
00124 
00125         public:
00126                 LagHeu1(Pointer<MinlpProblem> orig_prob_, Pointer<LinearRelax> linrelax_, bool is_gams_prob=false, double closeval_tol_=0., Pointer<dvector> diam_=NULL, Pointer<Param> param_=NULL, Pointer<ostream> out_solver_p_=out_out_p, Pointer<ostream> out_solver_log_p_=out_log_p)
00127                 : LagHeu(orig_prob_, linrelax_, is_gams_prob, closeval_tol_, diam_, param_, out_solver_p_, out_solver_log_p_)
00128                 { }
00129 
00130                 int solve(Pointer<MinlpNode> node_);
00131 
00132                 using LagHeu::solve;
00133 };
00134 
00149 class LagHeu_SimAnnealing : public LagHeu {
00150         private:
00153                 vector<vector<list<ExtremePoint>::iterator> > Z;
00154 
00157                 vector<int> nonsingles;
00158 
00161                 int minor_iter_max;
00162 
00163                 enum { VIOLATION, DISTANCE } weight_type;
00164 
00165                 void get_Wz(dvector& Wz, const ivector& z);
00166 
00167                 double weight(const ivector& z, const dvector& Wz);
00168 
00175                 void walk(ivector& z, dvector& Wz, double& weight_z, double T, int max_iter);
00176 
00177         public:
00178                 LagHeu_SimAnnealing(Pointer<MinlpProblem> orig_prob_, Pointer<LinearRelax> linrelax_, bool is_gams_prob=false, double closeval_tol_=0., Pointer<dvector> diam_=NULL, Pointer<Param> param_=NULL, Pointer<ostream> out_solver_p_=out_out_p, Pointer<ostream> out_solver_log_p_=out_log_p);
00179 
00180                 int solve(Pointer<MinlpNode> node_);
00181 
00182                 using LagHeu::solve;
00183 };
00184 
00198 class LagHeu2 : public LagHeu {
00199         private:
00200                 dvector x;
00201 
00204                 map<pair<double, int>, multimap<double, list<ExtremePoint>::iterator> > W;
00205 
00206                 Pointer<MinlpPenaltyFunc> penalty;
00207 
00208                 map<double, dvector> candidates;
00209                 int max_candidates;
00210 
00211                 int max_ns;
00212 
00213                 double ns_done;
00214                 double ns_all;
00215                 int lastprint;
00216 
00217                 void search(map<pair<double, int>, multimap<double, list<ExtremePoint>::iterator> >::reverse_iterator it_k, double ns);
00218 
00223                 bool project(dvector& res);
00224 
00227                 double key(const dvector& x);
00228 
00229         public:
00230                 LagHeu2(Pointer<MinlpProblem> orig_prob_, Pointer<LinearRelax> linrelax_, bool is_gams_prob=false, double closeval_tol_=0., Pointer<dvector> diam_=NULL, Pointer<Param> param_=NULL, Pointer<ostream> out_solver_p_=out_out_p, Pointer<ostream> out_solver_log_p_=out_log_p);
00231 
00232                 int solve(Pointer<MinlpNode> node_);
00233 
00234                 void set_reform(Pointer<Reformulation> reform_);
00235 
00236                 using LagHeu::solve;
00237 };
00238 
00252 class LagHeu2b : public LagHeu {
00253         private:
00254                 dvector x;
00255                 vector<dvector> z;
00256 
00259                 map<pair<double, int>, multimap<double, list<ExtremePoint>::iterator> > W;
00260 
00261                 dvector W_val;
00262                 list<int> unfixed_blocks;
00263 
00264                 Pointer<MinlpPenaltyFunc> penalty;
00265 
00266                 multimap<double, dvector> candidates;
00267                 int max_candidates;
00268 
00269                 int max_ns;
00270 
00271                 double ns_done;
00272                 double ns_all;
00273                 int lastprint;
00274 
00275                 int block_value(double& val, int k);
00276 
00277                 void search(double ns);
00278 
00281                 double key();
00282 
00285                 bool project();
00286 
00287                 bool switch_binaries(double val, bool eq, map<int,double>& coeff);
00288                 void make_binaries_feasible();
00289 
00290                 void switch_binaries2(double val, bool eq, map<int,double>& coeff);
00291                 void switch_binaries2_rek(double val, bool eq, double& bestval, dvector& pt, map<int,double>::iterator coeff_it, map<int,double>& coeff);
00292                 void move_continuous(double& val, bool eq, map<int,double>& cont_coeff);                
00293         public:
00294                 LagHeu2b(Pointer<MinlpProblem> orig_prob_, Pointer<LinearRelax> linrelax_, bool is_gams_prob=false, double closeval_tol_=0., Pointer<dvector> diam_=NULL, Pointer<Param> param_=NULL, Pointer<ostream> out_solver_p_=out_out_p, Pointer<ostream> out_solver_log_p_=out_log_p);
00295 
00296                 int solve(Pointer<MinlpNode> node_);
00297 
00298                 void set_reform(Pointer<Reformulation> reform_);
00299 
00300                 using LagHeu::solve;
00301 };
00302 
00303 #endif

Generated on Wed Oct 22 03:12:39 2008 for LaGO by  doxygen 1.4.7