00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef CouenneSdpCuts_hpp
00012 #define CouenneSdpCuts_hpp
00013
00014 #include "CglConfig.h"
00015 #include "CglCutGenerator.hpp"
00016 #include "BonRegisteredOptions.hpp"
00017 #include "IpOptionsList.hpp"
00018 #include "CouenneJournalist.hpp"
00019
00020 namespace Couenne {
00021
00022 class CouenneProblem;
00023 class CouenneExprMatrix;
00024
00042
00043 class CouenneSdpCuts: public CglCutGenerator {
00044
00045 protected:
00046
00047 CouenneProblem *problem_;
00048
00049 bool doNotUse_;
00050
00051
00052
00053 std::vector <CouenneExprMatrix *> minors_;
00054
00055 int numEigVec_;
00056
00057 bool onlyNegEV_;
00058
00059 bool useSparsity_;
00060
00061 bool fillMissingTerms_;
00062
00063
00064
00065
00066 public:
00067
00068 CouenneSdpCuts (CouenneProblem *, JnlstPtr,
00069 const Ipopt::SmartPtr <Ipopt::OptionsList>);
00070
00071 ~CouenneSdpCuts ();
00072 CouenneSdpCuts &operator= (const CouenneSdpCuts &);
00073 CouenneSdpCuts (const CouenneSdpCuts &);
00074 virtual CglCutGenerator *clone () const;
00075
00076 const bool doNotUse () const {return doNotUse_;}
00077
00079 virtual void generateCuts (const OsiSolverInterface &,
00080 OsiCuts &,
00081 const CglTreeInfo = CglTreeInfo ())
00082 #if CGL_VERSION_MAJOR == 0 && CGL_VERSION_MINOR <= 57
00083 const
00084 #endif
00085 ;
00086
00088 static void registerOptions (Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions);
00089
00090
00091
00092 void updateSol();
00093
00094 private:
00095
00096 void genCutSingle (CouenneExprMatrix * const &,
00097 const OsiSolverInterface &, OsiCuts &,
00098 const CglTreeInfo = CglTreeInfo ()) const;
00099
00100 void compareSparsify (const OsiSolverInterface &si,
00101 int n, int m, const double *sol,
00102 double *z, double *w,FILE *out) const;
00103
00104
00105 void sparsify2 (const int n,
00106 const double *A, double **sparse_v_mat,
00107 int *card_v_mat, int min_nz, int *evdec_num) const;
00108
00109 void genSDPcut (const OsiSolverInterface &si,
00110 OsiCuts &cs,
00111 CouenneExprMatrix *XX,
00112 double *v1, double *v2,
00113 int **) const;
00114
00115 void additionalSDPcuts (const OsiSolverInterface &si,
00116 OsiCuts &cs,
00117 CouenneExprMatrix *minor,
00118 int np, const double *A,
00119 const double *vector, int **) const;
00120
00121 enum zero_type {POS_DELTA, SELECTED, VALID_DELTA};
00122
00123 void zero_comp (const int ind_i, const double delta,
00124 const int np, const int *selected,
00125 int *loc_selected,
00126 int *ploc_card_selected, int *ploc_card_new_selected,
00127 double *ploc_lhs,
00128 double *locmargin, double *locmat,
00129 double *locv,
00130 const int evidx, bool wise,
00131 int *evdec_num,
00132 double *recomp_gap,
00133 double *threshold) const;
00134
00135 void zero_unified (enum zero_type type,
00136 const int np, const int *order,
00137 const int * selected,
00138 const int min_card_new_selected,
00139 const double min_delta, const int start_point,
00140 const int curr_i,
00141 int *loc_selected,
00142 int *ploc_card_selected,
00143 int *ploc_card_new_selected,
00144 double *ploc_lhs,
00145 double *locmargin, double *locmat,
00146 int *pnchanged,
00147 double *locv,
00148 const int evidx, bool wise,double *recomp_gap, double *threshold,
00149 int *evdec_num) const;
00150
00151 void add_v_cut(const int np,
00152 const int *loc_selected,
00153 const int loc_card_selected,
00154 const double *locv,
00155 const int init_card_selected, int *has_init_vect,
00156 int *selected, int *pcard_selected,
00157 int *pnew_selected,
00158 double **sparse_v_mat,
00159 int *pcard_v_mat) const;
00160
00161 void update_sparsify_structures(const int np,
00162 double *v, double* margin,
00163 double *A, double *lhs, const int *zeroed,
00164 int evidx, bool decompose, int *evdec_num) const;
00165
00166 void sparsify (bool sparsify_new,
00167 const int evidx, const double eigen_val,
00168 const double *v, const int n,
00169 const double *sol, double **sparse_v_mat,
00170 int *card_v_mat,
00171 int *evdec_num) const;
00172 };
00173 }
00174
00175 #endif