dbl_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: dbl_qsopt.h,v $ $Revision: 1.3 $ $Date: 2003/11/05 16:57:39 $" */
00024 #ifndef dbl___QS_QSOPT_H
00025 #define dbl___QS_QSOPT_H
00026 
00027 #include <stdio.h>
00028 #include "qs_config.h"
00029 
00030 #ifdef WIN32
00031 
00032 #ifdef QSLIB_EXPORTS
00033 #define dbl_QSLIB_INTERFACE __declspec(dllexport)
00034 #else
00035 #define dbl_QSLIB_INTERFACE __declspec(dllimport)
00036 #endif
00037 
00038 #else
00039 #define dbl_QSLIB_INTERFACE extern
00040 #endif
00041 
00042 #ifdef WIN32
00043 typedef struct dbl_QSLIB_INTERFACE dbl_qsdata *dbl_QSprob;
00044 typedef struct dbl_QSLIB_INTERFACE qsbasis *dbl_QSbas;
00045 #else
00046 typedef struct dbl_qsdata *dbl_QSprob;
00047 typedef struct qsbasis *dbl_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  *     dbl_solver_main/dbl_reader_main part of DLL
00079  */
00080 dbl_QSLIB_INTERFACE int dbl_solver_main ( int argc, char **argv);
00081 dbl_QSLIB_INTERFACE int dbl_reader_main ( int argc, char **argv);
00082 #endif
00083 
00084 dbl_QSLIB_INTERFACE void dbl_QSfree ( void *ptr),
00085     dbl_QSfree_prob ( dbl_QSprob p),
00086     dbl_QSfree_basis ( dbl_QSbas B),
00087     dbl_QSset_precision ( const unsigned prec),/**< set the dbl_precision for floating 
00088                                                  point numbers to the given 
00089                                                  number of bits */
00090     dbl_QSstart ( void),/**< whe we use non native numbers, we need to make 
00091                          some initializations before operating with the
00092                          library */
00093     dbl_QSend ( void);  /**< just to free any internal static data needed by
00094                          the variable dbl_precision numbers */
00095 
00096 dbl_QSLIB_INTERFACE int dbl_QSopt_primal ( dbl_QSprob p, int *status),
00097     dbl_QSopt_dual ( dbl_QSprob p, int *status),
00098     dbl_QSopt_pivotin_col ( dbl_QSprob p, int ccnt, int *clist),
00099     dbl_QSopt_pivotin_row ( dbl_QSprob p, int rcnt, int *rlist),
00100     dbl_QSopt_strongbranch ( dbl_QSprob p, int ncand, int *candidatelist,
00101       double * xlist, double * down_vals, double * up_vals,
00102       int iterations, double objbound),
00103     dbl_QSchange_objsense ( dbl_QSprob p, int newsense),
00104     dbl_QSget_objsense ( dbl_QSprob p, int *newsense),
00105     dbl_QSnew_col ( dbl_QSprob p,const double obj,const double lower,const double upper,
00106       const char *name),
00107     dbl_QSadd_cols ( dbl_QSprob p, int num, int *cmatcnt, int *cmatbeg, int *cmatind,
00108       double * cmatval, double * obj, double * lower,
00109       double * upper, const char **names),
00110     dbl_QSadd_col ( dbl_QSprob p, int cnt, int *cmatind, double * cmatval,
00111       double obj, double lower, double upper, const char *name),
00112     dbl_QSnew_row ( dbl_QSprob p,const double rhs, int sense, const char *name),
00113     dbl_QSadd_ranged_rows ( dbl_QSprob p, int num, int *rmatcnt, int *rmatbeg, 
00114       int *rmatind,const double * rmatval,const double * rhs, char *sense,
00115       const double* range, const char **names),
00116     dbl_QSadd_ranged_row ( dbl_QSprob p, int cnt, int *rmatind,const double * rmatval,
00117       const double * rhs, int sense,const double * range, const char *name),
00118     dbl_QSadd_rows ( dbl_QSprob p, int num, int *rmatcnt, int *rmatbeg, int *rmatind,
00119       const double * rmatval,const double * rhs, char *sense, const char **names),
00120     dbl_QSadd_row ( dbl_QSprob p, int cnt, int *rmatind,const double * rmatval,
00121       const double * rhs, int sense, const char *name),
00122     dbl_QSdelete_rows ( dbl_QSprob p, int num, int *dellist),
00123     dbl_QSdelete_row ( dbl_QSprob p, int rowindex),
00124     dbl_QSdelete_setrows ( dbl_QSprob p, int *flags),
00125     dbl_QSdelete_named_row ( dbl_QSprob p, const char *rowname),
00126     dbl_QSdelete_named_rows_list ( dbl_QSprob p, int num, const char **rownames),
00127     dbl_QSdelete_cols ( dbl_QSprob p, int num, int *dellist),
00128     dbl_QSdelete_col ( dbl_QSprob p, int colindex),
00129     dbl_QSdelete_setcols ( dbl_QSprob p, int *flags),
00130     dbl_QSdelete_named_column ( dbl_QSprob p, const char *colname),
00131     dbl_QSdelete_named_columns_list ( dbl_QSprob p, int num, const char **colnames),
00132     dbl_QSchange_senses ( dbl_QSprob p, int num, int *rowlist, char *sense),
00133     dbl_QSchange_sense ( dbl_QSprob p, int rowindex, int sense),
00134     dbl_QSchange_coef ( dbl_QSprob p, int rowindex, int colindex, double coef),
00135     dbl_QSchange_objcoef ( dbl_QSprob p, int indx, double coef),
00136     dbl_QSchange_rhscoef ( dbl_QSprob p, int indx, double coef),
00137     dbl_QSchange_range(dbl_QSprob p, int rowindex, double range),
00138     dbl_QSchange_bounds ( dbl_QSprob p, int num, int *collist, char *lu, 
00139       const double * bounds),
00140     dbl_QSchange_bound ( dbl_QSprob p, int indx, int lu,const double bound),
00141     dbl_QSload_basis ( dbl_QSprob p, dbl_QSbas B),
00142     dbl_QSread_and_load_basis ( dbl_QSprob p, const char *filename),
00143     dbl_QSload_basis_array ( dbl_QSprob p, char *cstat, char *rstat),
00144     dbl_QSload_basis_and_row_norms_array ( dbl_QSprob p, char *cstat, char *rstat, 
00145       double * rownorms),
00146     dbl_QSget_basis_array ( dbl_QSprob p, char *cstat, char *rstat),
00147     dbl_QSget_basis_and_row_norms_array ( dbl_QSprob p, char *cstat, char *rstat,
00148       double * rownorms),
00149     dbl_QSget_binv_row ( dbl_QSprob p, int indx, double * binvrow),
00150     dbl_QSget_tableau_row ( dbl_QSprob p, int indx, double * tableaurow),
00151     dbl_QSget_basis_order ( dbl_QSprob p, int *basorder), 
00152     dbl_QSget_coef (dbl_QSprob p, int rowindex, int colindex, double*coef),
00153     dbl_QSget_status ( dbl_QSprob p, int *status),
00154     dbl_QSget_solution ( dbl_QSprob p, double * value, double * x,
00155       double * pi, double * slack, double * rc),
00156     dbl_QSget_objval ( dbl_QSprob p, double * value),
00157     dbl_QSget_pi_array ( dbl_QSprob p, double * pi),
00158     dbl_QSget_rc_array ( dbl_QSprob p, double * rc),
00159     dbl_QSget_x_array ( dbl_QSprob p, double * x),
00160     dbl_QSget_slack_array ( dbl_QSprob p, double * slack),
00161     dbl_QSget_infeas_array ( dbl_QSprob p, double * pi),
00162     dbl_QSget_colcount ( dbl_QSprob p),
00163     dbl_QSget_rowcount ( dbl_QSprob p),
00164     dbl_QSget_nzcount ( dbl_QSprob p),
00165     dbl_QSget_obj_list(dbl_QSprob p, int num, int*collist, double*obj),
00166     dbl_QSget_obj ( dbl_QSprob p, double * obj),
00167     dbl_QSget_rhs ( dbl_QSprob p, double * rhs),
00168     dbl_QSget_ranged_rows_list ( dbl_QSprob p, int num, int *rowlist, int **rowcnt,
00169       int **rowbeg, int **rowind, double ** rowval, double ** rhs,
00170       char **sense, double **range, char ***names),
00171     dbl_QSget_ranged_rows ( dbl_QSprob p, int **rowcnt, int **rowbeg, int **rowind,
00172       double ** rowval, double ** rhs, char **sense, 
00173       double ** range, char ***names),
00174     dbl_QSget_senses ( dbl_QSprob p, char*senses),
00175     dbl_QSget_rows_list ( dbl_QSprob p, int num, int *rowlist, int **rowcnt,
00176       int **rowbeg, int **rowind, double ** rowval, double ** rhs,
00177       char **sense, char ***names),
00178     dbl_QSget_rows ( dbl_QSprob p, int **rowcnt, int **rowbeg, int **rowind,
00179       double ** rowval, double ** rhs, char **sense, char ***names),
00180     dbl_QSget_columns_list ( dbl_QSprob p, int num, int *collist, int **colcnt,
00181       int **colbeg, int **colind, double ** colval, double ** obj,
00182       double ** lower, double ** upper, char ***names),
00183     dbl_QSget_columns ( dbl_QSprob p, int **colcnt, int **colbeg, int **colind,
00184       double ** colval, double ** obj, double ** lower,
00185       double ** upper, char ***names),
00186     dbl_QSget_rownames ( dbl_QSprob p, char **rownames),
00187     dbl_QSget_colnames ( dbl_QSprob p, char **colnames),
00188     dbl_QSget_bound ( dbl_QSprob p, int colindex, int lu, double * bound),
00189     dbl_QSget_bounds ( dbl_QSprob p, double * lower, double * upper),
00190     dbl_QSget_bounds_list(dbl_QSprob p, int num, int*collist, double*lb,
00191       double*ub),
00192     dbl_QSget_intflags ( dbl_QSprob p, int *intflags),
00193     dbl_QSget_intcount ( dbl_QSprob p, int *count),
00194     dbl_QSget_column_index ( dbl_QSprob p, const char *name, int *colindex),
00195     dbl_QSget_row_index ( dbl_QSprob p, const char *name, int *rowindex),
00196     dbl_QSget_named_x ( dbl_QSprob p, const char *colname, double * val),
00197     dbl_QSget_named_rc ( dbl_QSprob p, const char *colname, double * val),
00198     dbl_QSget_named_pi ( dbl_QSprob p, const char *rowname, double * val),
00199     dbl_QSget_named_slack ( dbl_QSprob p, const char *rowname, double * val),
00200     dbl_QScompute_row_norms ( dbl_QSprob p),
00201     dbl_QSwrite_prob ( dbl_QSprob p, const char *filename, const char *filetype),
00202     dbl_QSwrite_prob_file ( dbl_QSprob p, FILE * file, const char *filetype),
00203     dbl_QSwrite_basis ( dbl_QSprob p, dbl_QSbas B, const char *filename),
00204     dbl_QStest_row_norms ( dbl_QSprob p),
00205     dbl_QSget_itcnt(dbl_QSprob p, int *pI_iter, int *pII_iter, int *dI_iter,
00206       int *dII_iter, int *tot_iter),
00207     dbl_QSset_param ( dbl_QSprob p, int whichparam, int newvalue),
00208     dbl_QSset_param_EGlpNum ( dbl_QSprob p, int whichparam, double newvalue),
00209     dbl_QSget_param ( dbl_QSprob p, int whichparam, int *value),
00210     dbl_QSget_param_EGlpNum ( dbl_QSprob p, int whichparam, double * value); 
00211 
00212 dbl_QSLIB_INTERFACE char *dbl_QSget_probname ( dbl_QSprob p);
00213 dbl_QSLIB_INTERFACE char *dbl_QSget_objname ( dbl_QSprob p);
00214 dbl_QSLIB_INTERFACE char *dbl_QSversion ( void);
00215 
00216 dbl_QSLIB_INTERFACE dbl_QSprob dbl_QScreate_prob ( const char *name, int objsense),
00217     dbl_QSread_prob ( const char *filename, const char *filetype),
00218     dbl_QSload_prob ( const char *probname, int ncols, int nrows, int *cmatcnt,
00219       int *cmatbeg, int *cmatind, double * cmatval, int objsense,
00220       double * obj, double * rhs, char *sense, double * lower,
00221       double * upper, const char **colnames, const char **rownames),
00222     dbl_QScopy_prob ( dbl_QSprob p, const char *newname);
00223 
00224 dbl_QSLIB_INTERFACE dbl_QSbas dbl_QSget_basis ( dbl_QSprob p),
00225     dbl_QSread_basis ( dbl_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  * dbl_feedback/progress information
00246  */
00247 
00248 #ifdef WIN32
00249 typedef struct dbl_QSLIB_INTERFACE dbl_qsline_reader *dbl_QSline_reader;
00250 typedef struct dbl_QSLIB_INTERFACE dbl_qsformat_error *dbl_QSformat_error;
00251 typedef struct dbl_QSLIB_INTERFACE dbl_qserror_collector *dbl_QSerror_collector;
00252 typedef struct dbl_QSLIB_INTERFACE dbl_qserror_memory *dbl_QSerror_memory;
00253 #else
00254 typedef struct dbl_qsline_reader *dbl_QSline_reader;
00255 typedef struct dbl_qsformat_error *dbl_QSformat_error;
00256 typedef struct dbl_qserror_collector *dbl_QSerror_collector;
00257 typedef struct dbl_qserror_memory *dbl_QSerror_memory;
00258 #endif
00259 
00260 #ifdef  __cplusplus
00261 extern "C"
00262 {
00263 #endif
00264   dbl_QSLIB_INTERFACE const char *dbl_QSformat_error_type_string (
00265   int tp);
00266 
00267   dbl_QSLIB_INTERFACE int dbl_QSerror_get_type (
00268   dbl_QSformat_error error);
00269   dbl_QSLIB_INTERFACE const char *dbl_QSerror_get_desc (
00270   dbl_QSformat_error error);
00271   dbl_QSLIB_INTERFACE int dbl_QSerror_get_line_number (
00272   dbl_QSformat_error error);
00273   dbl_QSLIB_INTERFACE int dbl_QSerror_get_pos (
00274   dbl_QSformat_error error);
00275   dbl_QSLIB_INTERFACE const char *dbl_QSerror_get_line (
00276   dbl_QSformat_error error);
00277   dbl_QSLIB_INTERFACE void dbl_QSerror_print (
00278   FILE * f,
00279   dbl_QSformat_error error);
00280 
00281   dbl_QSLIB_INTERFACE dbl_QSerror_collector dbl_QSerror_collector_new (
00282   void *fct,
00283   void *dest);
00284   dbl_QSLIB_INTERFACE dbl_QSerror_collector dbl_QSerror_memory_collector_new (
00285   dbl_QSerror_memory mem);
00286   dbl_QSLIB_INTERFACE void dbl_QSerror_collector_free (
00287   dbl_QSerror_collector c);
00288 
00289 /****************************************************************************
00290  * line reader 
00291  */
00292   dbl_QSLIB_INTERFACE dbl_QSline_reader dbl_QSline_reader_new (
00293   void *fct,
00294   void *data_src);
00295   /* reader->read_line_fct defaults to fgets */
00296 
00297   dbl_QSLIB_INTERFACE void dbl_QSline_reader_free (
00298   dbl_QSline_reader reader);
00299 
00300   dbl_QSLIB_INTERFACE void dbl_QSline_reader_set_error_collector (
00301   dbl_QSline_reader reader,
00302   dbl_QSerror_collector collector);
00303 
00304   dbl_QSLIB_INTERFACE char *dbl_QSline_reader_get (
00305   dbl_QSline_reader reader,
00306   char *s,
00307   int size);
00308 
00309   dbl_QSLIB_INTERFACE dbl_QSprob dbl_QSget_prob (
00310   dbl_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   dbl_QSLIB_INTERFACE dbl_QSerror_memory dbl_QSerror_memory_create (
00321   int takeErrorLines);
00322   dbl_QSLIB_INTERFACE void dbl_QSerror_memory_free (
00323   dbl_QSerror_memory mem);
00324 
00325   dbl_QSLIB_INTERFACE int dbl_QSerror_memory_get_nof (
00326   dbl_QSerror_memory mem,
00327   int error_type);
00328   dbl_QSLIB_INTERFACE int dbl_QSerror_memory_get_nerrors (
00329   dbl_QSerror_memory mem);
00330 
00331   dbl_QSLIB_INTERFACE dbl_QSformat_error dbl_QSerror_memory_get_last_error (
00332   dbl_QSerror_memory mem);
00333   dbl_QSLIB_INTERFACE dbl_QSformat_error dbl_QSerror_memory_get_prev_error (
00334   dbl_QSformat_error e);
00335 
00336 /**************************************************************************** 
00337  * reporter for solver dbl_feedback 
00338  */
00339   dbl_QSLIB_INTERFACE void dbl_QSset_reporter (
00340   dbl_QSprob prob,
00341   int iterskip,
00342   void *fct,
00343   void *dest);
00344 
00345   dbl_QSLIB_INTERFACE int dbl_QSreport_prob (
00346   dbl_QSprob p,
00347   const char *filetype,
00348   dbl_QSerror_collector c);
00349 
00350 #ifdef  __cplusplus
00351 }
00352 #endif
00353 #endif                          /* dbl___QS_QSOPT_H */

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