minlpopt.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 MINLPOPT_H
00008 #define MINLPOPT_H
00009 
00010 #include "standard.h"
00011 #include "MINLPData.h"
00012 #include "MINLP.h"
00013 #include "problem.h"
00014 #include "opt.h"
00015 
00016 #include "decomp.h"
00017 #include "relax.h"
00018 
00019 class MinlpOpt;
00020 #include "linrelax.h"
00021 
00025 class SolCandidate : public pair<double, dvector> {
00026         friend ostream& operator<<(ostream& out, const SolCandidate& s) {
00027                 out << s.first << ": " << s.second;
00028                 return out;
00029         }
00030 
00031         private:
00032                 double closeval_tol;
00033                 Pointer<dvector> diam;
00034 
00035         public:
00036 
00037                 SolCandidate(double val, const dvector& x, double closeval_tol_, Pointer<dvector> diam_)
00038                 : pair<double, dvector>(val, x), closeval_tol(closeval_tol_), diam(diam_)
00039                 { }
00040 
00041                 bool operator<(const SolCandidate& y) const {
00042                         if (first<y.first-closeval_tol*(fabs(first)+1)) return true;
00043                         if (first>y.first+closeval_tol*(fabs(first)+1)) return false;
00044                         for (int i=0; i<second.dim(); i++)
00045                                 if (fabs(second(i)-y.second(i))>(*diam)(i))
00046                                         return (second(i)<y.second(i));
00047                         return false;
00048                 }
00049 
00050 };
00051 
00054 class Reformulation {
00055         private:
00056                 MinlpOpt& opt;
00057 
00060                 void add_var(vector<vector<Pointer<BlockMatrix> > >& A, vector<vector<Pointer<SepQcFunc> > >& s, MinlpProblem& prob, int k, int index, double lower, double upper, Pointer<char> name=NULL);
00063                 void add_con(vector<vector<Pointer<BlockMatrix> > >& A, vector<vector<Pointer<SepQcFunc> > >& s, MinlpProblem& prob, int c, int k);
00064 
00065         public:
00066                 Pointer<MinlpProblem> ext_prob;
00067                 Pointer<MinlpProblem> ext_quad_prob;
00068                 Pointer<MinlpProblem> ext_convex_prob;
00069 
00074                 vector<int> related_t;
00075 
00076                 Reformulation(MinlpOpt& opt_)
00077                 : opt(opt_)
00078                 { }
00079 
00080                 void reformulate();
00081 
00082                 dvector get_short_vector(const dvector &x);
00083                 dvector get_long_vector(const dvector &x);
00084 
00085                 bool set_t_block(dvector& x, int k);
00086 
00087 };
00088 
00091 class LevelCutHandler {
00092         private:
00095                 list<pair<Pointer<MinlpProblem>, int> > problems_with_levelcut;
00096 
00097                 list<Pointer<LinearRelax> > linrelax_with_levelcut;
00098 
00099                 double val; // the value of the level cut
00100 
00101         public:
00102 
00103                 LevelCutHandler(double init_val=INFINITY)
00104                 : val(init_val)
00105                 {       }
00106                 
00107                 ~LevelCutHandler();
00108 
00109                 void add_problem(Pointer<MinlpProblem> prob);
00110                 void add_problem(Pointer<LinearRelax> linear_relax);
00111 
00112                 void update_level_cut(double newval);
00113 };
00114 
00198 class MinlpOpt : public Solver {
00199         friend class LinearRelax;
00200         friend class Reformulation;
00201         friend int main(int argc, char** argv);
00202         private:
00205                 Pointer<Param> param;
00206                 
00207                 Pointer<Timer> timer;
00208                 
00209                 Pointer<MINLPData> minlpdata;
00210 
00213                 bool is_gams_prob;
00214 
00217                 Pointer<MinlpProblem> orig_prob; // (P)
00218 
00221                 Pointer<MinlpProblem> split_prob; // (S)
00222 
00225                 Pointer<MinlpProblem> quad_prob; // (Q)
00226 
00229                 Pointer<MinlpProblem> convex_prob; // (C)
00230 
00233                 Pointer<Reformulation> reform;
00234 
00235                 vector<vector<double> > min_eigval, max_eigval;
00236 
00239                 bool prob_is_convex;
00240 
00243                 SparseVector<double> quad_obj_c_add;
00246                 vector<SparseVector<double> > quad_con_c_add;
00249                 SparseVector<double> conv_obj_c_add;
00252                 vector<SparseVector<double> > conv_con_c_add;
00253 
00254                 ivector ineq_index;
00255 
00258                 Pointer<LinearRelax> linear_relax;
00259 
00260                 Pointer<LevelCutHandler> levelcuts;
00261 
00262                 IntervalReduction intervalreduction;
00263 
00266                 void decompose(); // generates (S)
00267 
00270                 bool check_convex(MinlpProblem& prob);
00271 
00274                 void quad_relax();
00275 
00278                 void convex_relax();
00279 
00280                 bool init_called;
00283                 void init();
00286                 void init2();
00287 
00288                 double sol_cand_closeval_tol;
00289                 Pointer<dvector> sol_cand_diam;
00290 
00291                 enum { box_off, box_C, box_Cext, box_Pext } boxreduce_type;
00292                 int boxreduce_effort;
00293                 double boxreduce_time;
00294 
00297                 list<int> unbounded_var;
00298 
00301                 Pointer<MinlpProblem> get_convex_prob(Pointer<MinlpProblem> prob);
00304                 Pointer<MinlpProblem> get_convex_prob(Pointer<MinlpProblem> prob, Pointer<MinlpProblem> prob_curv_ref);
00305                 double print_box_reduce_quality(dvector& oldlow, dvector& oldup, Pointer<MinlpProblem> prob, const char* prefix);
00306 
00307         public:
00310                 set<SolCandidate> sol_cand;
00311 
00314                 Pointer<dvector> sol_Cext;
00315                 bool sol_Cext_is_solution;
00316 
00317                 double low_bound;
00318 
00319                 MinlpOpt(Pointer<MinlpProblem> prob, Pointer<Param> param_, bool is_gams_prob_=false, Pointer<ostream> out_solver_p=out_out_p, Pointer<ostream> out_solver_log_p=out_log_p);
00320 
00321                 void box_reduce0();
00322 
00326                 void box_reduce1();
00327 
00328                 double box_reduce2();
00329 
00330                 void box_reduce3();
00331 
00334                 int start_round_part_heu();
00335 
00338                 int start_bb();
00339 
00343                 void check_initial_point();
00344 
00347                 int solve();
00348 
00349                 using Solver::solve;
00350 };
00351 
00352 #endif

Generated on Mon Oct 20 03:12:06 2008 for LaGO by  doxygen 1.4.7