misc_util.hpp

Go to the documentation of this file.
00001 /* $Id: misc_util.hpp 507 2011-02-15 20:53:18Z pbelotti $
00002  *
00003  * Name:    misc_util.hpp
00004  * Author:  Andrea Qualizza
00005  * Purpose: utilities for sdpcuts
00006  *
00007  * This file is licensed under the Eclipse Public License (EPL)
00008  */
00009 
00010 #ifndef MISCUTIL_HPP
00011 #define MISCUTIL_HPP
00012 
00013 #include <stdio.h>
00014 #include <stdlib.h>
00015 #include "OsiXxxSolverInterface.hpp"
00016 #include "OsiSolverInterface.hpp"
00017 
00018 #define indexQ(i,j,n) ((n) + (i) * (2*(n)-1-(i)) / 2 + (j))
00019 
00020 class Stat {
00021         public: 
00022 
00023                 Stat();
00024                 Stat(const double *vector,int n);
00025                 Stat(const int *vector,int n);
00026                 void addEntry(double value);
00027                 int numEntries() const;
00028                 int numNZEntries() const;
00029                 double mean() const;
00030                 double stdDev() const;
00031                 double sum() const;
00032                 double min() const;
00033                 double max() const;
00034                 int minIndex() const;
00035                 int maxIndex() const;
00036                 void reset();
00037         private:
00038                 int _n;
00039                 int _nz_entries;
00040                 double _sum;
00041                 double _sum_squares;
00042                 double _min;
00043                 double _max;
00044                 int _minIndex;
00045                 int _maxIndex;
00046 };
00047 
00048 class Timer {
00049         public:
00050                 Timer();
00051                 ~Timer();
00052                 void start();
00053                 void pause();
00054                 void restore();
00055                 double time();
00056         private:
00057                 double _starttime;
00058                 Timer *_pausetimer;
00059                 bool _pause;
00060                 double starttime();
00061 };
00062 
00063 extern void cpp_fprintvecINT(FILE *, char const *, const int *, int, 
00064                              const int);
00065 extern void cpp_fprintvecINT(FILE *, char const *, const int *, int);
00066 extern void cpp_printvecINT(char const *, const int *, int);
00067 
00068 extern void cpp_printmatINT(char const *, const int **, int, int);
00069 extern void cpp_printmatINT(char const *, int **, int, int);
00070 
00071 extern void cpp_fprintmatINT(FILE *, char const *, const int **, int, int);
00072 extern void cpp_fprintmatINT(FILE *, char const *, int **, int, int);
00073 
00074 extern void cpp_printvecCHAR(char const *, const char *, int);
00075 extern void cpp_printvecCHAR(char const *, char *, int);
00076 extern void cpp_fprintvecCHAR(FILE *, char const *, const char *, int);
00077 extern void cpp_fprintvecCHAR(FILE *, char const *, char *, int);
00078 
00079 extern void cpp_fprintvecDBL(FILE *, char const *, const double *, 
00080                              const int, const int, char const *);
00081 extern void cpp_fprintvecDBL(FILE *, char const *, const double *, 
00082                              const int, const int, const int, const int);
00083 extern void cpp_fprintvecDBLg(FILE *, char const *, const double *, 
00084                               const int, const int, const int, const int);
00085 extern void cpp_fprintvecDBL(FILE *, char const *, const double *, const int);
00086 extern void cpp_printvecDBL(char const *, const double *, const int);
00087 extern void cpp_printmatDBL(char const *, const double **, int, int);
00088 extern void cpp_printmatDBL(char const *, double **, int, int);
00089 
00090 extern void cpp_fprintvecDBL(FILE *, char const *, const double *, 
00091                              char const *);
00092 extern void cpp_fprintvecDBL(FILE *, char const *, double *, int);
00093 extern void cpp_fprintvecDBLg(FILE *, char const *, const double *, 
00094                               const int, const int, const int);
00095 extern void cpp_fprintmatDBL(FILE *, char const *, const double **, int, int);
00096 extern void cpp_fprintmatDBL(FILE *, char const *, double **, int, int);
00097 
00098 extern void cpp_myfree_and_null(char **);
00099 
00100 extern double cpp_genalea(int *);
00101 
00102 extern void cpp_quicksort_dec(int, int, int *, double *);
00103 extern void cpp_quicksortINT_dec(int, int, int *, int *);
00104 extern void cpp_quicksort_inc(int, int, int *, double *);
00105 extern void cpp_quicksortINT_inc(int, int, int *, int *);
00106 
00107 
00108 extern void print_barQ(FILE *f, char *header,
00109                 double **Q, const double *b, const int n);
00110 
00111 extern void get_vec_from_matbar(double **mat, const int dim, double *v,
00112                          const int include_entry_00);
00113 
00114 extern void get_mat_from_vec(const double *v, const int n, const double entry_00,
00115                       double **mat);
00116 
00117 extern void print_mat_from_vec(FILE *f, char *header,
00118                         const double *v, const int n, const double entry_00);
00119 
00120 extern void get_LPsol_vec_from_vvT(const double *v, const int n, double *vec,
00121                             const int include_entry_00);
00122 
00123 extern void get_mat_from_vvT(const double *v, const int n, double **mat);
00124 
00125 extern void print_mat_from_vvT(FILE *f, char *header,
00126                         const double *v, const int n);
00127 
00128 extern void fprintvecmat(FILE *f, char *header, const double *v, const int n,
00129                   const double entry_00);
00130 
00131 extern void check_prod_row_barQ(double **Q, const double *b, const int n,
00132                          const OsiSolverInterface *si,
00133                          const int from);
00134 
00135 // heuristic solution from eigenvextors of Q for positive eigenvalue
00136 extern void heur_sol_eigenv_Q(const int n, double *b, double **Q, 
00137                        double *heur_sol, double *heur_sol_val);
00138 
00139 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 19 Dec 2013 for Couenne by  doxygen 1.6.1