mpq_qsopt.h

Go to the documentation of this file.
00001 #include "qs_config.h"
00002 #ifdef HAVE_LIBGMP
00003 #if HAVE_LIBGMP
00004 /****************************************************************************/
00005 /*                                                                          */
00006 /*  This file is part of QSopt_ex.                                          */
00007 /*                                                                          */
00008 /*  (c) Copyright 2006 by David Applegate, William Cook, Sanjeeb Dash,      */
00009 /*  and Daniel Espinoza                                                     */
00010 /*                                                                          */
00011 /*  Sanjeeb Dash ownership of copyright in QSopt_ex is derived from his     */
00012 /*  copyright in QSopt.                                                     */
00013 /*                                                                          */
00014 /*  This code may be used under the terms of the GNU General Public License */
00015 /*  (Version 2.1 or later) as published by the Free Software Foundation.    */
00016 /*                                                                          */
00017 /*  Alternatively, use is granted for research purposes only.               */
00018 /*                                                                          */
00019 /*  It is your choice of which of these two licenses you are operating      */
00020 /*  under.                                                                  */
00021 /*                                                                          */
00022 /*  We make no guarantees about the correctness or usefulness of this code. */
00023 /*                                                                          */
00024 /****************************************************************************/
00025 
00026 /*  $RCSfile: mpq_qsopt.h,v $ $Revision: 1.3 $ $Date: 2003/11/05 16:57:39 $" */
00027 #ifndef mpq___QS_QSOPT_H
00028 #define mpq___QS_QSOPT_H
00029 
00030 #include <stdio.h>
00031 #include "qs_config.h"
00032 
00033 #ifdef WIN32
00034 
00035 #ifdef QSLIB_EXPORTS
00036 #define mpq_QSLIB_INTERFACE __declspec(dllexport)
00037 #else
00038 #define mpq_QSLIB_INTERFACE __declspec(dllimport)
00039 #endif
00040 
00041 #else
00042 #define mpq_QSLIB_INTERFACE extern
00043 #endif
00044 
00045 #ifdef WIN32
00046 typedef struct mpq_QSLIB_INTERFACE mpq_qsdata *mpq_QSprob;
00047 typedef struct mpq_QSLIB_INTERFACE qsbasis *mpq_QSbas;
00048 #else
00049 typedef struct mpq_qsdata *mpq_QSprob;
00050 typedef struct qsbasis *mpq_QSbas;
00051 #endif
00052 
00053 /****************************************************************************/
00054 /*                                                                          */
00055 /*                 PARAMETERS TO SPECIFY OBJECTIVE SENSE                    */
00056 /*                                                                          */
00057 /****************************************************************************/
00058 #include "basicdefs.h"
00059 /*
00060 #define QS_LP_PRIMAL_FEASIBLE   11
00061 #define QS_LP_PRIMAL_INFEASIBLE 12
00062 #define QS_LP_PRIMAL_UNBOUNDED  13
00063 #define QS_LP_DUAL_FEASIBLE     14
00064 #define QS_LP_DUAL_INFEASIBLE   15
00065 #define QS_LP_DUAL_UNBOUNDED    16
00066 */
00067 
00068 /****************************************************************************/
00069 /*                                                                          */
00070 /*                      QSopt Library Functions                             */
00071 /*                                                                          */
00072 /****************************************************************************/
00073 #ifdef  __cplusplus
00074 extern "C"
00075 {
00076 #endif
00077 
00078 #ifdef WIN32
00079 /* 
00080  *  in WINDOWS we make 
00081  *     mpq_solver_main/mpq_reader_main part of DLL
00082  */
00083 mpq_QSLIB_INTERFACE int mpq_solver_main ( int argc, char **argv);
00084 mpq_QSLIB_INTERFACE int mpq_reader_main ( int argc, char **argv);
00085 #endif
00086 
00087 mpq_QSLIB_INTERFACE void mpq_QSfree ( void *ptr),
00088     mpq_QSfree_prob ( mpq_QSprob p),
00089     mpq_QSfree_basis ( mpq_QSbas B),
00090     mpq_QSset_precision ( const unsigned prec),/**< set the mpq_precision for floating 
00091                                                  point numbers to the given 
00092                                                  number of bits */
00093     mpq_QSstart ( void),/**< whe we use non native numbers, we need to make 
00094                          some initializations before operating with the
00095                          library */
00096     mpq_QSend ( void);  /**< just to free any internal static data needed by
00097                          the variable mpq_precision numbers */
00098 
00099 mpq_QSLIB_INTERFACE int mpq_QSopt_primal ( mpq_QSprob p, int *status),
00100     mpq_QSopt_dual ( mpq_QSprob p, int *status),
00101     mpq_QSopt_pivotin_col ( mpq_QSprob p, int ccnt, int *clist),
00102     mpq_QSopt_pivotin_row ( mpq_QSprob p, int rcnt, int *rlist),
00103     mpq_QSopt_strongbranch ( mpq_QSprob p, int ncand, int *candidatelist,
00104       mpq_t * xlist, mpq_t * down_vals, mpq_t * up_vals,
00105       int iterations, mpq_t objbound),
00106     mpq_QSchange_objsense ( mpq_QSprob p, int newsense),
00107     mpq_QSget_objsense ( mpq_QSprob p, int *newsense),
00108     mpq_QSnew_col ( mpq_QSprob p,const mpq_t obj,const mpq_t lower,const mpq_t upper,
00109       const char *name),
00110     mpq_QSadd_cols ( mpq_QSprob p, int num, int *cmatcnt, int *cmatbeg, int *cmatind,
00111       mpq_t * cmatval, mpq_t * obj, mpq_t * lower,
00112       mpq_t * upper, const char **names),
00113     mpq_QSadd_col ( mpq_QSprob p, int cnt, int *cmatind, mpq_t * cmatval,
00114       mpq_t obj, mpq_t lower, mpq_t upper, const char *name),
00115     mpq_QSnew_row ( mpq_QSprob p,const mpq_t rhs, int sense, const char *name),
00116     mpq_QSadd_ranged_rows ( mpq_QSprob p, int num, int *rmatcnt, int *rmatbeg, 
00117       int *rmatind,const mpq_t * rmatval,const mpq_t * rhs, char *sense,
00118       const mpq_t* range, const char **names),
00119     mpq_QSadd_ranged_row ( mpq_QSprob p, int cnt, int *rmatind,const mpq_t * rmatval,
00120       const mpq_t * rhs, int sense,const mpq_t * range, const char *name),
00121     mpq_QSadd_rows ( mpq_QSprob p, int num, int *rmatcnt, int *rmatbeg, int *rmatind,
00122       const mpq_t * rmatval,const mpq_t * rhs, char *sense, const char **names),
00123     mpq_QSadd_row ( mpq_QSprob p, int cnt, int *rmatind,const mpq_t * rmatval,
00124       const mpq_t * rhs, int sense, const char *name),
00125     mpq_QSdelete_rows ( mpq_QSprob p, int num, int *dellist),
00126     mpq_QSdelete_row ( mpq_QSprob p, int rowindex),
00127     mpq_QSdelete_setrows ( mpq_QSprob p, int *flags),
00128     mpq_QSdelete_named_row ( mpq_QSprob p, const char *rowname),
00129     mpq_QSdelete_named_rows_list ( mpq_QSprob p, int num, const char **rownames),
00130     mpq_QSdelete_cols ( mpq_QSprob p, int num, int *dellist),
00131     mpq_QSdelete_col ( mpq_QSprob p, int colindex),
00132     mpq_QSdelete_setcols ( mpq_QSprob p, int *flags),
00133     mpq_QSdelete_named_column ( mpq_QSprob p, const char *colname),
00134     mpq_QSdelete_named_columns_list ( mpq_QSprob p, int num, const char **colnames),
00135     mpq_QSchange_senses ( mpq_QSprob p, int num, int *rowlist, char *sense),
00136     mpq_QSchange_sense ( mpq_QSprob p, int rowindex, int sense),
00137     mpq_QSchange_coef ( mpq_QSprob p, int rowindex, int colindex, mpq_t coef),
00138     mpq_QSchange_objcoef ( mpq_QSprob p, int indx, mpq_t coef),
00139     mpq_QSchange_rhscoef ( mpq_QSprob p, int indx, mpq_t coef),
00140     mpq_QSchange_range(mpq_QSprob p, int rowindex, mpq_t range),
00141     mpq_QSchange_bounds ( mpq_QSprob p, int num, int *collist, char *lu, 
00142       const mpq_t * bounds),
00143     mpq_QSchange_bound ( mpq_QSprob p, int indx, int lu,const mpq_t bound),
00144     mpq_QSload_basis ( mpq_QSprob p, mpq_QSbas B),
00145     mpq_QSread_and_load_basis ( mpq_QSprob p, const char *filename),
00146     mpq_QSload_basis_array ( mpq_QSprob p, char *cstat, char *rstat),
00147     mpq_QSload_basis_and_row_norms_array ( mpq_QSprob p, char *cstat, char *rstat, 
00148       mpq_t * rownorms),
00149     mpq_QSget_basis_array ( mpq_QSprob p, char *cstat, char *rstat),
00150     mpq_QSget_basis_and_row_norms_array ( mpq_QSprob p, char *cstat, char *rstat,
00151       mpq_t * rownorms),
00152     mpq_QSget_binv_row ( mpq_QSprob p, int indx, mpq_t * binvrow),
00153     mpq_QSget_tableau_row ( mpq_QSprob p, int indx, mpq_t * tableaurow),
00154     mpq_QSget_basis_order ( mpq_QSprob p, int *basorder), 
00155     mpq_QSget_coef (mpq_QSprob p, int rowindex, int colindex, mpq_t*coef),
00156     mpq_QSget_status ( mpq_QSprob p, int *status),
00157     mpq_QSget_solution ( mpq_QSprob p, mpq_t * value, mpq_t * x,
00158       mpq_t * pi, mpq_t * slack, mpq_t * rc),
00159     mpq_QSget_objval ( mpq_QSprob p, mpq_t * value),
00160     mpq_QSget_pi_array ( mpq_QSprob p, mpq_t * pi),
00161     mpq_QSget_rc_array ( mpq_QSprob p, mpq_t * rc),
00162     mpq_QSget_x_array ( mpq_QSprob p, mpq_t * x),
00163     mpq_QSget_slack_array ( mpq_QSprob p, mpq_t * slack),
00164     mpq_QSget_infeas_array ( mpq_QSprob p, mpq_t * pi),
00165     mpq_QSget_colcount ( mpq_QSprob p),
00166     mpq_QSget_rowcount ( mpq_QSprob p),
00167     mpq_QSget_nzcount ( mpq_QSprob p),
00168     mpq_QSget_obj_list(mpq_QSprob p, int num, int*collist, mpq_t*obj),
00169     mpq_QSget_obj ( mpq_QSprob p, mpq_t * obj),
00170     mpq_QSget_rhs ( mpq_QSprob p, mpq_t * rhs),
00171     mpq_QSget_ranged_rows_list ( mpq_QSprob p, int num, int *rowlist, int **rowcnt,
00172       int **rowbeg, int **rowind, mpq_t ** rowval, mpq_t ** rhs,
00173       char **sense, mpq_t **range, char ***names),
00174     mpq_QSget_ranged_rows ( mpq_QSprob p, int **rowcnt, int **rowbeg, int **rowind,
00175       mpq_t ** rowval, mpq_t ** rhs, char **sense, 
00176       mpq_t ** range, char ***names),
00177     mpq_QSget_senses ( mpq_QSprob p, char*senses),
00178     mpq_QSget_rows_list ( mpq_QSprob p, int num, int *rowlist, int **rowcnt,
00179       int **rowbeg, int **rowind, mpq_t ** rowval, mpq_t ** rhs,
00180       char **sense, char ***names),
00181     mpq_QSget_rows ( mpq_QSprob p, int **rowcnt, int **rowbeg, int **rowind,
00182       mpq_t ** rowval, mpq_t ** rhs, char **sense, char ***names),
00183     mpq_QSget_columns_list ( mpq_QSprob p, int num, int *collist, int **colcnt,
00184       int **colbeg, int **colind, mpq_t ** colval, mpq_t ** obj,
00185       mpq_t ** lower, mpq_t ** upper, char ***names),
00186     mpq_QSget_columns ( mpq_QSprob p, int **colcnt, int **colbeg, int **colind,
00187       mpq_t ** colval, mpq_t ** obj, mpq_t ** lower,
00188       mpq_t ** upper, char ***names),
00189     mpq_QSget_rownames ( mpq_QSprob p, char **rownames),
00190     mpq_QSget_colnames ( mpq_QSprob p, char **colnames),
00191     mpq_QSget_bound ( mpq_QSprob p, int colindex, int lu, mpq_t * bound),
00192     mpq_QSget_bounds ( mpq_QSprob p, mpq_t * lower, mpq_t * upper),
00193     mpq_QSget_bounds_list(mpq_QSprob p, int num, int*collist, mpq_t*lb,
00194       mpq_t*ub),
00195     mpq_QSget_intflags ( mpq_QSprob p, int *intflags),
00196     mpq_QSget_intcount ( mpq_QSprob p, int *count),
00197     mpq_QSget_column_index ( mpq_QSprob p, const char *name, int *colindex),
00198     mpq_QSget_row_index ( mpq_QSprob p, const char *name, int *rowindex),
00199     mpq_QSget_named_x ( mpq_QSprob p, const char *colname, mpq_t * val),
00200     mpq_QSget_named_rc ( mpq_QSprob p, const char *colname, mpq_t * val),
00201     mpq_QSget_named_pi ( mpq_QSprob p, const char *rowname, mpq_t * val),
00202     mpq_QSget_named_slack ( mpq_QSprob p, const char *rowname, mpq_t * val),
00203     mpq_QScompute_row_norms ( mpq_QSprob p),
00204     mpq_QSwrite_prob ( mpq_QSprob p, const char *filename, const char *filetype),
00205     mpq_QSwrite_prob_file ( mpq_QSprob p, FILE * file, const char *filetype),
00206     mpq_QSwrite_basis ( mpq_QSprob p, mpq_QSbas B, const char *filename),
00207     mpq_QStest_row_norms ( mpq_QSprob p),
00208     mpq_QSget_itcnt(mpq_QSprob p, int *pI_iter, int *pII_iter, int *dI_iter,
00209       int *dII_iter, int *tot_iter),
00210     mpq_QSset_param ( mpq_QSprob p, int whichparam, int newvalue),
00211     mpq_QSset_param_EGlpNum ( mpq_QSprob p, int whichparam, mpq_t newvalue),
00212     mpq_QSget_param ( mpq_QSprob p, int whichparam, int *value),
00213     mpq_QSget_param_EGlpNum ( mpq_QSprob p, int whichparam, mpq_t * value); 
00214 
00215 mpq_QSLIB_INTERFACE char *mpq_QSget_probname ( mpq_QSprob p);
00216 mpq_QSLIB_INTERFACE char *mpq_QSget_objname ( mpq_QSprob p);
00217 mpq_QSLIB_INTERFACE char *mpq_QSversion ( void);
00218 
00219 mpq_QSLIB_INTERFACE mpq_QSprob mpq_QScreate_prob ( const char *name, int objsense),
00220     mpq_QSread_prob ( const char *filename, const char *filetype),
00221     mpq_QSload_prob ( const char *probname, int ncols, int nrows, int *cmatcnt,
00222       int *cmatbeg, int *cmatind, mpq_t * cmatval, int objsense,
00223       mpq_t * obj, mpq_t * rhs, char *sense, mpq_t * lower,
00224       mpq_t * upper, const char **colnames, const char **rownames),
00225     mpq_QScopy_prob ( mpq_QSprob p, const char *newname);
00226 
00227 mpq_QSLIB_INTERFACE mpq_QSbas mpq_QSget_basis ( mpq_QSprob p),
00228     mpq_QSread_basis ( mpq_QSprob p, const char *filename);
00229 
00230 #ifdef  __cplusplus
00231 }
00232 #endif
00233 
00234 /****************************************************************************
00235  *
00236  * This is the undocumented part of the QSlib interface 
00237  *
00238  ****************************************************************************/
00239 /* 
00240  * functions to facilitate line by line reading from other sources than 
00241  * files from within MPS/LP parsers  
00242  * 
00243  * functions to facilitate the collection of error information instead of 
00244  * having the parsers print messages to stderr
00245  *                              by mps/lp format writers
00246  * 
00247  * a problem's reporter is used by the solver code to provide important 
00248  * mpq_feedback/progress information
00249  */
00250 
00251 #ifdef WIN32
00252 typedef struct mpq_QSLIB_INTERFACE mpq_qsline_reader *mpq_QSline_reader;
00253 typedef struct mpq_QSLIB_INTERFACE mpq_qsformat_error *mpq_QSformat_error;
00254 typedef struct mpq_QSLIB_INTERFACE mpq_qserror_collector *mpq_QSerror_collector;
00255 typedef struct mpq_QSLIB_INTERFACE mpq_qserror_memory *mpq_QSerror_memory;
00256 #else
00257 typedef struct mpq_qsline_reader *mpq_QSline_reader;
00258 typedef struct mpq_qsformat_error *mpq_QSformat_error;
00259 typedef struct mpq_qserror_collector *mpq_QSerror_collector;
00260 typedef struct mpq_qserror_memory *mpq_QSerror_memory;
00261 #endif
00262 
00263 #ifdef  __cplusplus
00264 extern "C"
00265 {
00266 #endif
00267   mpq_QSLIB_INTERFACE const char *mpq_QSformat_error_type_string (
00268   int tp);
00269 
00270   mpq_QSLIB_INTERFACE int mpq_QSerror_get_type (
00271   mpq_QSformat_error error);
00272   mpq_QSLIB_INTERFACE const char *mpq_QSerror_get_desc (
00273   mpq_QSformat_error error);
00274   mpq_QSLIB_INTERFACE int mpq_QSerror_get_line_number (
00275   mpq_QSformat_error error);
00276   mpq_QSLIB_INTERFACE int mpq_QSerror_get_pos (
00277   mpq_QSformat_error error);
00278   mpq_QSLIB_INTERFACE const char *mpq_QSerror_get_line (
00279   mpq_QSformat_error error);
00280   mpq_QSLIB_INTERFACE void mpq_QSerror_print (
00281   FILE * f,
00282   mpq_QSformat_error error);
00283 
00284   mpq_QSLIB_INTERFACE mpq_QSerror_collector mpq_QSerror_collector_new (
00285   void *fct,
00286   void *dest);
00287   mpq_QSLIB_INTERFACE mpq_QSerror_collector mpq_QSerror_memory_collector_new (
00288   mpq_QSerror_memory mem);
00289   mpq_QSLIB_INTERFACE void mpq_QSerror_collector_free (
00290   mpq_QSerror_collector c);
00291 
00292 /****************************************************************************
00293  * line reader 
00294  */
00295   mpq_QSLIB_INTERFACE mpq_QSline_reader mpq_QSline_reader_new (
00296   void *fct,
00297   void *data_src);
00298   /* reader->read_line_fct defaults to fgets */
00299 
00300   mpq_QSLIB_INTERFACE void mpq_QSline_reader_free (
00301   mpq_QSline_reader reader);
00302 
00303   mpq_QSLIB_INTERFACE void mpq_QSline_reader_set_error_collector (
00304   mpq_QSline_reader reader,
00305   mpq_QSerror_collector collector);
00306 
00307   mpq_QSLIB_INTERFACE char *mpq_QSline_reader_get (
00308   mpq_QSline_reader reader,
00309   char *s,
00310   int size);
00311 
00312   mpq_QSLIB_INTERFACE mpq_QSprob mpq_QSget_prob (
00313   mpq_QSline_reader reader,
00314   const char *probname,
00315   const char *filetype);
00316   /* the MPS and LP parsers uses the fct from reader 
00317    * to get to next input line */
00318 
00319 
00320 /****************************************************************************
00321  * error memory 
00322  */
00323   mpq_QSLIB_INTERFACE mpq_QSerror_memory mpq_QSerror_memory_create (
00324   int takeErrorLines);
00325   mpq_QSLIB_INTERFACE void mpq_QSerror_memory_free (
00326   mpq_QSerror_memory mem);
00327 
00328   mpq_QSLIB_INTERFACE int mpq_QSerror_memory_get_nof (
00329   mpq_QSerror_memory mem,
00330   int error_type);
00331   mpq_QSLIB_INTERFACE int mpq_QSerror_memory_get_nerrors (
00332   mpq_QSerror_memory mem);
00333 
00334   mpq_QSLIB_INTERFACE mpq_QSformat_error mpq_QSerror_memory_get_last_error (
00335   mpq_QSerror_memory mem);
00336   mpq_QSLIB_INTERFACE mpq_QSformat_error mpq_QSerror_memory_get_prev_error (
00337   mpq_QSformat_error e);
00338 
00339 /**************************************************************************** 
00340  * reporter for solver mpq_feedback 
00341  */
00342   mpq_QSLIB_INTERFACE void mpq_QSset_reporter (
00343   mpq_QSprob prob,
00344   int iterskip,
00345   void *fct,
00346   void *dest);
00347 
00348   mpq_QSLIB_INTERFACE int mpq_QSreport_prob (
00349   mpq_QSprob p,
00350   const char *filetype,
00351   mpq_QSerror_collector c);
00352 
00353 #ifdef  __cplusplus
00354 }
00355 #endif
00356 #endif                          /* mpq___QS_QSOPT_H */
00357 #endif
00358 #endif

Generated on Thu Mar 29 09:32:32 2012 for QSopt_ex by  doxygen 1.4.7