qsopt.h

Go to the documentation of this file.
00001 /****************************************************************************/
00002 /*                                                                          */
00003 /*  This file is part of QSopt_ex.                                          */
00004 /*                                                                          */
00005 /*  (c) Copyright 2006 by David Applegate, William Cook, Sanjeeb Dash,      */
00006 /*  and Daniel Espinoza                                                     */
00007 /*                                                                          */
00008 /*  Sanjeeb Dash ownership of copyright in QSopt_ex is derived from his     */
00009 /*  copyright in QSopt.                                                     */
00010 /*                                                                          */
00011 /*  This code may be used under the terms of the GNU General Public License */
00012 /*  (Version 2.1 or later) as published by the Free Software Foundation.    */
00013 /*                                                                          */
00014 /*  Alternatively, use is granted for research purposes only.               */
00015 /*                                                                          */
00016 /*  It is your choice of which of these two licenses you are operating      */
00017 /*  under.                                                                  */
00018 /*                                                                          */
00019 /*  We make no guarantees about the correctness or usefulness of this code. */
00020 /*                                                                          */
00021 /****************************************************************************/
00022 
00023 /*  $RCSfile: qsopt.h,v $ $Revision: 1.3 $ $Date: 2003/11/05 16:57:39 $" */
00024 #ifndef __QS_QSOPT_H
00025 #define __QS_QSOPT_H
00026 
00027 #include <stdio.h>
00028 #include "qs_config.h"
00029 
00030 #ifdef WIN32
00031 
00032 #ifdef QSLIB_EXPORTS
00033 #define QSLIB_INTERFACE __declspec(dllexport)
00034 #else
00035 #define QSLIB_INTERFACE __declspec(dllimport)
00036 #endif
00037 
00038 #else
00039 #define QSLIB_INTERFACE extern
00040 #endif
00041 
00042 #ifdef WIN32
00043 typedef struct QSLIB_INTERFACE qsdata *QSprob;
00044 typedef struct QSLIB_INTERFACE qsbasis *QSbas;
00045 #else
00046 typedef struct qsdata *QSprob;
00047 typedef struct qsbasis *QSbas;
00048 #endif
00049 
00050 /****************************************************************************/
00051 /*                                                                          */
00052 /*                 PARAMETERS TO SPECIFY OBJECTIVE SENSE                    */
00053 /*                                                                          */
00054 /****************************************************************************/
00055 #include "basicdefs.h"
00056 /*
00057 #define QS_LP_PRIMAL_FEASIBLE   11
00058 #define QS_LP_PRIMAL_INFEASIBLE 12
00059 #define QS_LP_PRIMAL_UNBOUNDED  13
00060 #define QS_LP_DUAL_FEASIBLE     14
00061 #define QS_LP_DUAL_INFEASIBLE   15
00062 #define QS_LP_DUAL_UNBOUNDED    16
00063 */
00064 
00065 /****************************************************************************/
00066 /*                                                                          */
00067 /*                      QSopt Library Functions                             */
00068 /*                                                                          */
00069 /****************************************************************************/
00070 #ifdef  __cplusplus
00071 extern "C"
00072 {
00073 #endif
00074 
00075 #ifdef WIN32
00076 /* 
00077  *  in WINDOWS we make 
00078  *     solver_main/reader_main part of DLL
00079  */
00080 QSLIB_INTERFACE int solver_main ( int argc, char **argv);
00081 QSLIB_INTERFACE int reader_main ( int argc, char **argv);
00082 #endif
00083 
00084 QSLIB_INTERFACE void QSfree ( void *ptr),
00085     QSfree_prob ( QSprob p),
00086     QSfree_basis ( QSbas B),
00087     QSset_precision ( const unsigned prec),/**< set the precision for floating 
00088                                                  point numbers to the given 
00089                                                  number of bits */
00090     QSstart ( void),/**< whe we use non native numbers, we need to make 
00091                          some initializations before operating with the
00092                          library */
00093     QSend ( void);  /**< just to free any internal static data needed by
00094                          the variable precision numbers */
00095 
00096 QSLIB_INTERFACE int QSopt_primal ( QSprob p, int *status),
00097     QSopt_dual ( QSprob p, int *status),
00098     QSopt_pivotin_col ( QSprob p, int ccnt, int *clist),
00099     QSopt_pivotin_row ( QSprob p, int rcnt, int *rlist),
00100     QSopt_strongbranch ( QSprob p, int ncand, int *candidatelist,
00101       EGlpNum_t * xlist, EGlpNum_t * down_vals, EGlpNum_t * up_vals,
00102       int iterations, EGlpNum_t objbound),
00103     QSchange_objsense ( QSprob p, int newsense),
00104     QSget_objsense ( QSprob p, int *newsense),
00105     QSnew_col ( QSprob p,const EGlpNum_t obj,const EGlpNum_t lower,const EGlpNum_t upper,
00106       const char *name),
00107     QSadd_cols ( QSprob p, int num, int *cmatcnt, int *cmatbeg, int *cmatind,
00108       EGlpNum_t * cmatval, EGlpNum_t * obj, EGlpNum_t * lower,
00109       EGlpNum_t * upper, const char **names),
00110     QSadd_col ( QSprob p, int cnt, int *cmatind, EGlpNum_t * cmatval,
00111       EGlpNum_t obj, EGlpNum_t lower, EGlpNum_t upper, const char *name),
00112     QSnew_row ( QSprob p,const EGlpNum_t rhs, int sense, const char *name),
00113     QSadd_ranged_rows ( QSprob p, int num, int *rmatcnt, int *rmatbeg, 
00114       int *rmatind,const EGlpNum_t * rmatval,const EGlpNum_t * rhs, char *sense,
00115       const EGlpNum_t* range, const char **names),
00116     QSadd_ranged_row ( QSprob p, int cnt, int *rmatind,const EGlpNum_t * rmatval,
00117       const EGlpNum_t * rhs, int sense,const EGlpNum_t * range, const char *name),
00118     QSadd_rows ( QSprob p, int num, int *rmatcnt, int *rmatbeg, int *rmatind,
00119       const EGlpNum_t * rmatval,const EGlpNum_t * rhs, char *sense, const char **names),
00120     QSadd_row ( QSprob p, int cnt, int *rmatind,const EGlpNum_t * rmatval,
00121       const EGlpNum_t * rhs, int sense, const char *name),
00122     QSdelete_rows ( QSprob p, int num, int *dellist),
00123     QSdelete_row ( QSprob p, int rowindex),
00124     QSdelete_setrows ( QSprob p, int *flags),
00125     QSdelete_named_row ( QSprob p, const char *rowname),
00126     QSdelete_named_rows_list ( QSprob p, int num, const char **rownames),
00127     QSdelete_cols ( QSprob p, int num, int *dellist),
00128     QSdelete_col ( QSprob p, int colindex),
00129     QSdelete_setcols ( QSprob p, int *flags),
00130     QSdelete_named_column ( QSprob p, const char *colname),
00131     QSdelete_named_columns_list ( QSprob p, int num, const char **colnames),
00132     QSchange_senses ( QSprob p, int num, int *rowlist, char *sense),
00133     QSchange_sense ( QSprob p, int rowindex, int sense),
00134     QSchange_coef ( QSprob p, int rowindex, int colindex, EGlpNum_t coef),
00135     QSchange_objcoef ( QSprob p, int indx, EGlpNum_t coef),
00136     QSchange_rhscoef ( QSprob p, int indx, EGlpNum_t coef),
00137     QSchange_range(QSprob p, int rowindex, EGlpNum_t range),
00138     QSchange_bounds ( QSprob p, int num, int *collist, char *lu, 
00139       const EGlpNum_t * bounds),
00140     QSchange_bound ( QSprob p, int indx, int lu,const EGlpNum_t bound),
00141     QSload_basis ( QSprob p, QSbas B),
00142     QSread_and_load_basis ( QSprob p, const char *filename),
00143     QSload_basis_array ( QSprob p, char *cstat, char *rstat),
00144     QSload_basis_and_row_norms_array ( QSprob p, char *cstat, char *rstat, 
00145       EGlpNum_t * rownorms),
00146     QSget_basis_array ( QSprob p, char *cstat, char *rstat),
00147     QSget_basis_and_row_norms_array ( QSprob p, char *cstat, char *rstat,
00148       EGlpNum_t * rownorms),
00149     QSget_binv_row ( QSprob p, int indx, EGlpNum_t * binvrow),
00150     QSget_tableau_row ( QSprob p, int indx, EGlpNum_t * tableaurow),
00151     QSget_basis_order ( QSprob p, int *basorder), 
00152     QSget_coef (QSprob p, int rowindex, int colindex, EGlpNum_t*coef),
00153     QSget_status ( QSprob p, int *status),
00154     QSget_solution ( QSprob p, EGlpNum_t * value, EGlpNum_t * x,
00155       EGlpNum_t * pi, EGlpNum_t * slack, EGlpNum_t * rc),
00156     QSget_objval ( QSprob p, EGlpNum_t * value),
00157     QSget_pi_array ( QSprob p, EGlpNum_t * pi),
00158     QSget_rc_array ( QSprob p, EGlpNum_t * rc),
00159     QSget_x_array ( QSprob p, EGlpNum_t * x),
00160     QSget_slack_array ( QSprob p, EGlpNum_t * slack),
00161     QSget_infeas_array ( QSprob p, EGlpNum_t * pi),
00162     QSget_colcount ( QSprob p),
00163     QSget_rowcount ( QSprob p),
00164     QSget_nzcount ( QSprob p),
00165     QSget_obj_list(QSprob p, int num, int*collist, EGlpNum_t*obj),
00166     QSget_obj ( QSprob p, EGlpNum_t * obj),
00167     QSget_rhs ( QSprob p, EGlpNum_t * rhs),
00168     QSget_ranged_rows_list ( QSprob p, int num, int *rowlist, int **rowcnt,
00169       int **rowbeg, int **rowind, EGlpNum_t ** rowval, EGlpNum_t ** rhs,
00170       char **sense, EGlpNum_t **range, char ***names),
00171     QSget_ranged_rows ( QSprob p, int **rowcnt, int **rowbeg, int **rowind,
00172       EGlpNum_t ** rowval, EGlpNum_t ** rhs, char **sense, 
00173       EGlpNum_t ** range, char ***names),
00174     QSget_senses ( QSprob p, char*senses),
00175     QSget_rows_list ( QSprob p, int num, int *rowlist, int **rowcnt,
00176       int **rowbeg, int **rowind, EGlpNum_t ** rowval, EGlpNum_t ** rhs,
00177       char **sense, char ***names),
00178     QSget_rows ( QSprob p, int **rowcnt, int **rowbeg, int **rowind,
00179       EGlpNum_t ** rowval, EGlpNum_t ** rhs, char **sense, char ***names),
00180     QSget_columns_list ( QSprob p, int num, int *collist, int **colcnt,
00181       int **colbeg, int **colind, EGlpNum_t ** colval, EGlpNum_t ** obj,
00182       EGlpNum_t ** lower, EGlpNum_t ** upper, char ***names),
00183     QSget_columns ( QSprob p, int **colcnt, int **colbeg, int **colind,
00184       EGlpNum_t ** colval, EGlpNum_t ** obj, EGlpNum_t ** lower,
00185       EGlpNum_t ** upper, char ***names),
00186     QSget_rownames ( QSprob p, char **rownames),
00187     QSget_colnames ( QSprob p, char **colnames),
00188     QSget_bound ( QSprob p, int colindex, int lu, EGlpNum_t * bound),
00189     QSget_bounds ( QSprob p, EGlpNum_t * lower, EGlpNum_t * upper),
00190     QSget_bounds_list(QSprob p, int num, int*collist, EGlpNum_t*lb,
00191       EGlpNum_t*ub),
00192     QSget_intflags ( QSprob p, int *intflags),
00193     QSget_intcount ( QSprob p, int *count),
00194     QSget_column_index ( QSprob p, const char *name, int *colindex),
00195     QSget_row_index ( QSprob p, const char *name, int *rowindex),
00196     QSget_named_x ( QSprob p, const char *colname, EGlpNum_t * val),
00197     QSget_named_rc ( QSprob p, const char *colname, EGlpNum_t * val),
00198     QSget_named_pi ( QSprob p, const char *rowname, EGlpNum_t * val),
00199     QSget_named_slack ( QSprob p, const char *rowname, EGlpNum_t * val),
00200     QScompute_row_norms ( QSprob p),
00201     QSwrite_prob ( QSprob p, const char *filename, const char *filetype),
00202     QSwrite_prob_file ( QSprob p, FILE * file, const char *filetype),
00203     QSwrite_basis ( QSprob p, QSbas B, const char *filename),
00204     QStest_row_norms ( QSprob p),
00205     QSget_itcnt(QSprob p, int *pI_iter, int *pII_iter, int *dI_iter,
00206       int *dII_iter, int *tot_iter),
00207     QSset_param ( QSprob p, int whichparam, int newvalue),
00208     QSset_param_EGlpNum ( QSprob p, int whichparam, EGlpNum_t newvalue),
00209     QSget_param ( QSprob p, int whichparam, int *value),
00210     QSget_param_EGlpNum ( QSprob p, int whichparam, EGlpNum_t * value); 
00211 
00212 QSLIB_INTERFACE char *QSget_probname ( QSprob p);
00213 QSLIB_INTERFACE char *QSget_objname ( QSprob p);
00214 QSLIB_INTERFACE char *QSversion ( void);
00215 
00216 QSLIB_INTERFACE QSprob QScreate_prob ( const char *name, int objsense),
00217     QSread_prob ( const char *filename, const char *filetype),
00218     QSload_prob ( const char *probname, int ncols, int nrows, int *cmatcnt,
00219       int *cmatbeg, int *cmatind, EGlpNum_t * cmatval, int objsense,
00220       EGlpNum_t * obj, EGlpNum_t * rhs, char *sense, EGlpNum_t * lower,
00221       EGlpNum_t * upper, const char **colnames, const char **rownames),
00222     QScopy_prob ( QSprob p, const char *newname);
00223 
00224 QSLIB_INTERFACE QSbas QSget_basis ( QSprob p),
00225     QSread_basis ( QSprob p, const char *filename);
00226 
00227 #ifdef  __cplusplus
00228 }
00229 #endif
00230 
00231 /****************************************************************************
00232  *
00233  * This is the undocumented part of the QSlib interface 
00234  *
00235  ****************************************************************************/
00236 /* 
00237  * functions to facilitate line by line reading from other sources than 
00238  * files from within MPS/LP parsers  
00239  * 
00240  * functions to facilitate the collection of error information instead of 
00241  * having the parsers print messages to stderr
00242  *                              by mps/lp format writers
00243  * 
00244  * a problem's reporter is used by the solver code to provide important 
00245  * feedback/progress information
00246  */
00247 
00248 #ifdef WIN32
00249 typedef struct QSLIB_INTERFACE qsline_reader *QSline_reader;
00250 typedef struct QSLIB_INTERFACE qsformat_error *QSformat_error;
00251 typedef struct QSLIB_INTERFACE qserror_collector *QSerror_collector;
00252 typedef struct QSLIB_INTERFACE qserror_memory *QSerror_memory;
00253 #else
00254 typedef struct qsline_reader *QSline_reader;
00255 typedef struct qsformat_error *QSformat_error;
00256 typedef struct qserror_collector *QSerror_collector;
00257 typedef struct qserror_memory *QSerror_memory;
00258 #endif
00259 
00260 #ifdef  __cplusplus
00261 extern "C"
00262 {
00263 #endif
00264   QSLIB_INTERFACE const char *QSformat_error_type_string (
00265   int tp);
00266 
00267   QSLIB_INTERFACE int QSerror_get_type (
00268   QSformat_error error);
00269   QSLIB_INTERFACE const char *QSerror_get_desc (
00270   QSformat_error error);
00271   QSLIB_INTERFACE int QSerror_get_line_number (
00272   QSformat_error error);
00273   QSLIB_INTERFACE int QSerror_get_pos (
00274   QSformat_error error);
00275   QSLIB_INTERFACE const char *QSerror_get_line (
00276   QSformat_error error);
00277   QSLIB_INTERFACE void QSerror_print (
00278   FILE * f,
00279   QSformat_error error);
00280 
00281   QSLIB_INTERFACE QSerror_collector QSerror_collector_new (
00282   void *fct,
00283   void *dest);
00284   QSLIB_INTERFACE QSerror_collector QSerror_memory_collector_new (
00285   QSerror_memory mem);
00286   QSLIB_INTERFACE void QSerror_collector_free (
00287   QSerror_collector c);
00288 
00289 /****************************************************************************
00290  * line reader 
00291  */
00292   QSLIB_INTERFACE QSline_reader QSline_reader_new (
00293   void *fct,
00294   void *data_src);
00295   /* reader->read_line_fct defaults to fgets */
00296 
00297   QSLIB_INTERFACE void QSline_reader_free (
00298   QSline_reader reader);
00299 
00300   QSLIB_INTERFACE void QSline_reader_set_error_collector (
00301   QSline_reader reader,
00302   QSerror_collector collector);
00303 
00304   QSLIB_INTERFACE char *QSline_reader_get (
00305   QSline_reader reader,
00306   char *s,
00307   int size);
00308 
00309   QSLIB_INTERFACE QSprob QSget_prob (
00310   QSline_reader reader,
00311   const char *probname,
00312   const char *filetype);
00313   /* the MPS and LP parsers uses the fct from reader 
00314    * to get to next input line */
00315 
00316 
00317 /****************************************************************************
00318  * error memory 
00319  */
00320   QSLIB_INTERFACE QSerror_memory QSerror_memory_create (
00321   int takeErrorLines);
00322   QSLIB_INTERFACE void QSerror_memory_free (
00323   QSerror_memory mem);
00324 
00325   QSLIB_INTERFACE int QSerror_memory_get_nof (
00326   QSerror_memory mem,
00327   int error_type);
00328   QSLIB_INTERFACE int QSerror_memory_get_nerrors (
00329   QSerror_memory mem);
00330 
00331   QSLIB_INTERFACE QSformat_error QSerror_memory_get_last_error (
00332   QSerror_memory mem);
00333   QSLIB_INTERFACE QSformat_error QSerror_memory_get_prev_error (
00334   QSformat_error e);
00335 
00336 /**************************************************************************** 
00337  * reporter for solver feedback 
00338  */
00339   QSLIB_INTERFACE void QSset_reporter (
00340   QSprob prob,
00341   int iterskip,
00342   void *fct,
00343   void *dest);
00344 
00345   QSLIB_INTERFACE int QSreport_prob (
00346   QSprob p,
00347   const char *filetype,
00348   QSerror_collector c);
00349 
00350 #ifdef  __cplusplus
00351 }
00352 #endif
00353 #endif                          /* __QS_QSOPT_H */

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